Sign in to follow this  
VISQI

Mesh Not drawn properly

Recommended Posts

VISQI    113
Hey guys,


So i was building a room mesh but the thing wouldn't just work, so i went to PIX and here is what i got.
[url="http://imageshack.us/photo/my-images/17/stuffek.jpg/"]Code[/url]

Apparently, the vertex is incrementing per float not per object, and the texture coordinates are being mapped incorrectly, as you can see.

The WorldVertex structure is just two D3DXVECTOR3's, one for Position, one for normals, and one D3DXVECTOR2 for Tex coordinates.

SetTexCoord() basically takes the second and third argument as the u and v, respectively.

Any suggestion will help, thanks people

Share this post


Link to post
Share on other sites
DanielDoyle    102
The main problem is see, is some of the walls positions are set in clockwise order, other walls points are counter-clockwise, that would most likely be your main problem, try creating the so they are all in clockwise order and it should work :)

Share this post


Link to post
Share on other sites
Zern    138
While GreaseMonkey is likely correct (I don't have the time to look at your source, sorry) you can add one simple line of code to validate their response.



Turn culling off before you draw your mesh. If it shows up properly you will know your ordering of your vertices are incorrect.




//: pd3dDevice is assumed to be a pointer to your Direct 3D Device
pd3dDevice->SetRenderState( D3DRS_CULLMODE , D3DCULL_NONE );

Share this post


Link to post
Share on other sites
VISQI    113
[quote name='GreaseMonkey' timestamp='1307837586' post='4822222']
The main problem is see, is some of the walls positions are set in clockwise order, other walls points are counter-clockwise, that would most likely be your main problem, try creating the so they are all in clockwise order and it should work :)
[/quote]
I am not drawing it in the order that it is shown. I am using an index buffer and it is working in clock-wise order, i thought that was implied.
The index buffer is working per quad like this : 0, 1, 2, 0, 2, 3

[quote name='Zern' timestamp='1307838203' post='4822223']
While GreaseMonkey is likely correct (I don't have the time to look at your source, sorry) you can add one simple line of code to validate their response.



Turn culling off before you draw your mesh. If it shows up properly you will know your ordering of your vertices are incorrect.




//: pd3dDevice is assumed to be a pointer to your Direct 3D Device
pd3dDevice->SetRenderState( D3DRS_CULLMODE , D3DCULL_NONE );
[/quote]

I did do that. The problem is still persistent. The problem is not with culling. The problem is that i am trying to render a full room(walls, columns, ceiling, ...) and all i am getting are unparalleled lines that don't make any sense. So, The most obvious solution is the index buffer, but i have checked that one multiple times, and till now i don't see any problems with the vertex, index, attribute buffer.
The problem is that the vertices are not iterating properly(check the PIX capture from the image).

Share this post


Link to post
Share on other sites
DanielDoyle    102
[quote name='VISQI' timestamp='1307849284' post='4822271']
[quote name='GreaseMonkey' timestamp='1307837586' post='4822222']
The main problem is see, is some of the walls positions are set in clockwise order, other walls points are counter-clockwise, that would most likely be your main problem, try creating the so they are all in clockwise order and it should work :)
[/quote]
I am not drawing it in the order that it is shown. I am using an index buffer and it is working in clock-wise order, i thought that was implied.
The index buffer is working per quad like this : 0, 1, 2, 0, 2, 3
[/quote]
That is correct for the first set in verticies, but drawing out the second set draws them counter clockwise (it would be clockwise is you were facing another direction)

Share this post


Link to post
Share on other sites
VISQI    113
Got it. I had the normals on D3DXVECTOR2 instead on D3DXVECTOR3, that is why it was skipping a step. The room mesh is drawn correctly.
Thanks for the help people

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this