Recommended Posts

Alright I'm having an issue with indices and freaking drawing a simple cube. Either me or the indices are being retarded about this. Its probably me. I think maybe I got the addition for coordinates messed up.

Share this post

Link to post

Share on other sites

So, what result are you getting. I'm guessing that only some parts of it are showing up? It looks to me like your winding order isn't consistent.It may help to draw out the cube on paper and number the verts, so you can have it in front of you, and can trace out the tris/sides to help you get the vert order correct.

0

Share this post

Link to post

Share on other sites

So, what result are you getting. I'm guessing that only some parts of it are showing up? It looks to me like your winding order isn't consistent.It may help to draw out the cube on paper and number the verts, so you can have it in front of you, and can trace out the tris/sides to help you get the vert order correct.

I tried drawing it out on paper. No luck. Infact that was the first thing I tried.

0

Share this post

Link to post

Share on other sites

Alright I'm having an issue with indices and freaking drawing a simple cube. Either me or the indices are being retarded about this. Its probably me. I think maybe I got the addition for coordinates messed up.

//front face
i[0] = 0;
i[1] = 1;
i[2] = 3;
i[3] = 2;

i[4] = 0xffffffff; //start new strip

//right face
i[5] = 1;
i[6] = 2;
i[7] = 5;
i[8] = 6;

i[9] = 0xffffffff;

//left face
i[10] = 0;
i[11] = 4;
i[12] = 3;
i[13] = 7;

i[14] = 0xffffffff;

//back face
i[15] = 7;
i[16] = 6;
i[17] = 4;
i[18] = 5;

i[19] = 0xffffffff;

//top face
i[20] = 0;
i[21] = 4;
i[22] = 1;
i[23] = 5;

i[24] = 0xffffffff;

//bottom face
i[25] = 6;
i[26] = 2;
i[27] = 3;
i[28] = 7;

pIndexBuffer->Unmap();

Changed a couple indices, try it with these.

edit: I am fairly sure some of your groups for faces were incorrect, but my order inside those groups might also be incorrect.

From the picture, it looks like his normals are flipped for most of the sides, which is why I reversed their winding order. Also, the yellow/green face looks mis-indexed, but it doesn't look like it should be from the code. It would help if each vertex had a unique color instead of having two vertices share a color.

0

Share this post

Link to post

Share on other sites

In addition to ordering the strips, remember to allocate the right buffers, 8 vertices in the vertex buffer and 29 in the index buffer (24 + 5). Your numVertices = 24 might mess some things up. Also winding order and culling mode can matter.

Another alternative for the strips, if Y+ is up and Z+ is further in, and you have clockwise frontfaces that should be on the outside of the cube.
0, 1, 2, 3, // front
0xffffffff,
5, 4, 7, 6, // back
0xffffffff,
4, 0, 6, 2, // left
0xffffffff,
1, 5, 3, 7, // right
0xffffffff,
4, 5, 0, 1, // top
0xffffffff,
2, 3, 6, 7 // bottom

From the picture, it looks like his normals are flipped for most of the sides, which is why I reversed their winding order. Also, the yellow/green face looks mis-indexed, but it doesn't look like it should be from the code. It would help if each vertex had a unique color instead of having two vertices share a color.
[/quote]

Share this post

Link to post

Share on other sites

The coordinates look correct to me. As I said before, it would be easier if each vertex were uniquely colored. That way you identifying which face is which would be easier in the graphic, and you could fix the faces one at a time. I'd just send two faces (after changing to unique vertex colors), and ensure theyre correct before adding a third, and so on. I recommend starting with two so you can easily tell if the normals are flipled.

Share this post

Link to post

Share on other sites

I've beginning to notice that the major issue is with the left face, no matter what, one point is always connected to vertex 4.

Here's one suggestion. Try drawing it using only one strip. You should be able to do a whole cube with only one strip, so try 0,1,2,3,7,1,5,0,4,2,6,7,4,5. I think that's right without breaking the strip.

Issue is far from my code, I'm beginning to think either my computer is racist towards cubes, or I messed up something earlier on in the code.
[/quote]

I highly doubt the issue is far from your code. I can tell you that your indices in your original post were not correct; even though my original correction was wrong. I'd anticipate it has something to do either with your indices or the way you are starting a new strip. Probably something akin to your new strip not actually being a new strip.

Share this post

Link to post

Share on other sites

Well, I ran into another issue after moving over to a mesh format and implementing lighting. I had this issue before and I fixed it but I can't remember how. However the issue now is that it draws (correctly from what I can see) but its only drawing part of it.

If I move my camera around it sort of cuts off everything past a certain distance and for some reason that distance is about an inch from the camera.

0

Share this post

Link to post

Share on other sites

Well, I ran into another issue after moving over to a mesh format and implementing lighting. I had this issue before and I fixed it but I can't remember how. However the issue now is that it draws (correctly from what I can see) but its only drawing part of it.

If I move my camera around it sort of cuts off everything past a certain distance and for some reason that distance is about an inch from the camera.

What's your camera's far distance? The problem is probably there.

0

Share this post

Link to post

Share on other sites

That's what the near and far plane do, clip things too near or far of the camera. Try adjusting those values and see what it does. As for the lightning problem, make sure that you're normals are correct and to enable lighting in the first place. Why don't you use a 3d modeler?? There's no way you're gonna make more complex shapes than basic primitives by writing vertices one by one anyway, and they will be errors free.

EDIT: if you're drawing a cube with an index array, it might look weird because triangles of different faces use the same normal value instead of there own. You could try averaging them, but im not sure if it will look good on a cube, but that's how you make models look smoother. The problem with the cube is that the angles are too steep.

Share this post

Link to post

Share on other sites

The thing is that near and far plane are set to 1 and 1000 respectively. Its not the far and near plane. Last time I had this issue it had to do with my world and projection matrix and I mixed them up or something. Can't remember how I fixed it though.

Once again I fixed the issue through some really odd tinkering. This time I changed when I used my matrix projectionMatrix and it worked... Also, my mesh cube is more... diamond shaped than cube.
[/quote]
Might be sheering. That is to say, your World matrix might be concating in a way that sheers the matrix. This is usually the result of concating them in the wrong order. If I have it right, it's Scale * Rotation * Position; Matrices concat in reverse order.