Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Ozzuary

DirectX8.1 SDK : Vertex: D3DFVF_XYZ - Flag

This topic is 6113 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Situation: I have Direct3d wrapped up in classes, and ran into some problems. Problem: When using the D3DFVF_XYZ flag when creating a custom vertex type my type will not be rendered to the screen. There is very little difference between D3DFVF_XYZ and D3DFVF_XYZRHW, but namely the transformation. You cannot apply a matrice to D3DFVF_XYZRHW as far as I know. I cant even seem to render a triangle using D3DFVF_XYZ flag thats wrapped up in my class, but I can easily create a triangle with the D3DFVF_XYZRHW flag. Theres only a few lins of difference between the two types, why would this happen? VidCard: Geforce3 TI200 SDK: DirectX8.1 This is a simplistic vertex structure.. // Structure for our custom vertex type struct CUSTOMVERTEX { FLOAT x, y, z; DWORD color; }; // Custom FVF #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE) The Alternate structure RHW: // Structure for our custom vertex type struct CUSTOMVERTEX { FLOAT x, y, z, rhw; DWORD color; }; // Custom FVF #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE) The only main code difference applies when you fill your vertices, because you have an extra param for the RHW- Whats messed up is that XYZRHW type works for me, and XYZ does not. Anyone know why? Anyon have a DirectX8 Graphics wrapper class(s)? that wraps up vertex types? -Ozz

Share this post


Link to post
Share on other sites
Advertisement
Try using the the D3DLVERTEX struct instead of your own custom vertex.

I must admit though everything looks cool. You sure there''s nothing else in the code producing problems?

Share this post


Link to post
Share on other sites
Ozzuary,

That is not quite correct. The is a big difference in your actaully data for example for {x,y,z} coordinates must (for the most part) be between -1.0f and 1.0f for the D3DFVF_XYZ. Whereas, the D3DFVF_XYZRHW option the {x,y,z} coordinates should be screen coordinates with probably a z values >= 0.

Can you post your data points?

You could also have your camera wrong for D3DFVF_XYZ, whereas I don''t think the is possible for D3DFVF_XYZRHW since they are screen coordinates.

I think this is all correct, but I reserve the right to be wrong.

Thanks

Share this post


Link to post
Share on other sites
Just to be sure - it''s XYZ that''s not working, right?

Assuming that''s true, then it''s probably your view and/or projection matrices.

the "-1.0f to 1.0f" suggestion is false. You could have points anywhere in the world. For instance, you could have the point (1000.0, 2000.0, -3000.0) and it would be visible as long as your view and projection matrices made sense (and your clipping planes were set correctly).

Share this post


Link to post
Share on other sites
CrazedGenius,

I will take your word for it, but I have had a lot of problems with data points outside the -1.0f to 1.0f range. It is likley that I could have modifed the view and projection matrices.

Thanks

Share this post


Link to post
Share on other sites
Hmm... I''m guessing that you have had good luck with points that fall within the default frustum setup by the default matrices. Look into the D3DXMatrixLookAtLH and D3DXMatrixPerspectiveFovLH functions. For example, if you set your eye position to some point 50 units from the origin and your FOV to something decent (PI / 4), you should be able to see objects that are sitting on the origin with vertices far outside the -1 to 1 range.

Does that make sense in terms of your situation and/or a solution?

Share this post


Link to post
Share on other sites
CrazedGenius,

Pretty sure that is my case. Can you take a look at my post on CreateDevice entitled "Help: IDirect3D8::CreateDevice and D3DCREATE_PUREDEVICE"? I am thinking that you may be able to help me.

Thanks

Share this post


Link to post
Share on other sites
I''ve got the same problem as Ozz here

My Setup

Windowed X8R8G8B8 (D16)
Default Adapter HAL SWVP
Z Enabled

World Matrix Identity;
View Matrix Eye:<0,0,-50> LookAt: <0,0,0> Up <0,1,0>
Projection Matrix FOV:D3DX_PI/4 Aspect4.0f/3.0f) Zn:1.0 Zf:100.0

Material
Diffuse & Ambient R 1.0 G 1.0 B 1.0 A 1.0

Light 0 Enabled (D3DRS_LIGHTING enabled too)
Directional Direction: <0,0,1> Diffuse <1.0,1.0,1.0>

Backbuffer Cleared To R1.0 G0.0 B0.0 Z1.0
D3DRS_CULLMODE=D3DCULL_NONE
D3DRS_AMBIENT = R1.0 G1.0 B1.0


Drawing 1 Triangle (D3DFVF_XYZ|D3DFVF_NORMAL)
<0,50,0>, <50,-50,0>, <-50,-50,0>
Normals <0,0,-1.0>


I can''t find anything wrong with this....you?

Share this post


Link to post
Share on other sites
Just home from work.

Hell this is weird...

It is D3DFVF_XYZ that isnt working, correct.

What bothers me is that I finally bit the bullet and used some DirectX sample code, from the Matrices tutorial.


I just replaced all my data with DirectX sample code, Matrices Tutorial, Direct3d. It still does nothing.. which leads me to believe its something else.. The code is identical and nada.

I have the code wrapped in a function class, but it is identical.
If I comment out the XYZ related code and use XYZRHW related code, I see a ''triangle'', vice versa, I see nothing.

I just changed my code to reflect the vertex information from tutorials Vertex and Matrix, Direct3d Tutorials. - For code reference. The matrices are identical, the vertex information is identical. (I simply used the Matrice Tutorial code)

Are there some kind of limitations?


As long as the lpD3DDevice->SetTransform( D3DTS_VIEW, &matView );
Are set correctly for world, view, and projection using the device, does anyone else need to know anything?

Im guessing I somehow wrapped them in a manner that conflicts.. because the tutorial code works. How would you wrap them appropriately?

I just wanted to display a triangle with a custom vertex using XYZ, and wrap them in an OOP manner using classes and functions.. the pain.

Thanks,


-Ozz

Even without using a Matrice at all, XYZ still does not display anything.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!