Seams where objects meet
Seams where objects meet
Hello,
I am working on a project where i'm trying to make a world out of cubes. I have the cubes spawned in with collision working fine, but where the edges of the cubes meet, no matter if they are barely touching, overlapping, or at the exact distance, there are still these ugly lines where they meet. Can somebody help me figure out how to make the lines go away? Oh, and these are simple 3d models of cubes, not cube scene nodes. I couldn't figure out how to texture individual sides of cube scene nodes, so I am using models of cubes. This issue of lines does not occur with cube scene nodes, so if anybody knows how to texture sides of a cubescenenode, I would also take that as an answer. If you need a pic, i can take one, just post if you need one.
Thanks in advance
-Evanias
Professional Timelord
I am working on a project where i'm trying to make a world out of cubes. I have the cubes spawned in with collision working fine, but where the edges of the cubes meet, no matter if they are barely touching, overlapping, or at the exact distance, there are still these ugly lines where they meet. Can somebody help me figure out how to make the lines go away? Oh, and these are simple 3d models of cubes, not cube scene nodes. I couldn't figure out how to texture individual sides of cube scene nodes, so I am using models of cubes. This issue of lines does not occur with cube scene nodes, so if anybody knows how to texture sides of a cubescenenode, I would also take that as an answer. If you need a pic, i can take one, just post if you need one.
Thanks in advance
-Evanias
Professional Timelord
Re: Seams where objects meet
I saw there used to be a few similar questions about the same problem. You might want to search the forum.
Maybe also shows picture about the problem. It is a bit long to read a long paragraph .
Maybe also shows picture about the problem. It is a bit long to read a long paragraph .
-
- Posts: 18
- Joined: Fri Jun 20, 2014 12:12 pm
Re: Seams where objects meet
I believe this is what he means, it is happening to me too right now and i also have no clue what is this caused by...
Oh and i am using a custom scene node (drawing the cube using vertex and indices) btw...
The lines are relative to the camera position, if i move around the camera i can even get to see no lines at all...
Re: Seams where objects meet
That's called Z-fighting. Don't draw two surfaces a the exact same position.
-
- Posts: 18
- Joined: Fri Jun 20, 2014 12:12 pm
Re: Seams where objects meet
Could you be more specific?hendu wrote:That's called Z-fighting. Don't draw two surfaces a the exact same position.
This is the method i use to draw:
Code: Select all
Vertices[0] = S3DVertex(0,0,0, -1,-1,-1, color, 0, 1);
Vertices[1] = S3DVertex(10,0,0, 1,-1,-1, color, 1, 1);
Vertices[2] = S3DVertex(10,10,0, 1,1,-1, color, 1, 0);
Vertices[3] = S3DVertex(0,10,0, -1,1,-1, color, 0, 0);
Vertices[4] = S3DVertex(10,0,10, -1,1,-1, color, 0, 1);
Vertices[5] = S3DVertex(10,10,10, 1,1,1, color, 0, 0);
Vertices[6] = S3DVertex(0,10,10, -1,1,1, color, 1, 0);
Vertices[7] = S3DVertex(0,0,10, -1,-1,1, color, 1, 1);
Vertices[8] = S3DVertex(0,10,10, -1,1,1, color, 0, 1);
Vertices[9] = S3DVertex(0,10,0, -1,1,-1, color, 1, 1);
Vertices[10] = S3DVertex(10,0,10, 1,-1,1, color, 1, 0);
Vertices[11] = S3DVertex(10,0,0, 1,-1,-1, color, 0, 0);
Code: Select all
u16 indices[36] = {0,2,1, 0,3,2, 1,5,4, 1,2,5, 4,6,7, 4,5,6, 7,3,0, 7,6,3, 9,5,2, 9,8,5, 0,11,10, 0,10,7 };
Or do you mean there is a problem with how i position the cubes? (maybe they overlap?) i dont think so, here is how i position them:
Code: Select all
for (int i = 1; i<300; i++)
{
cube[i] = new Cube(smgr->getRootSceneNode(),smgr,0,0,50);
cube[i]->setPosition(cube[i-1]->getPosition() + vector3df(10,0,0));
}
Re: Seams where objects meet
Nothing to do with your cube but your pillar.
Your pillar's frontside is in the same space as the cube's frontside. So of course they conflict.
Your pillar's frontside is in the same space as the cube's frontside. So of course they conflict.
-
- Posts: 18
- Joined: Fri Jun 20, 2014 12:12 pm
Re: Seams where objects meet
Er.. there are no pillars in this. I dont know what you mean by pillar
-
- Posts: 18
- Joined: Fri Jun 20, 2014 12:12 pm
Re: Seams where objects meet
I did not code anything to show a pillar. There are supposed to be only cubes, what you highlighted on that pic is a glitch that i am trying to get rid of.
Perhaps im a complete dumb and you are telling me something that i dont get.
Perhaps im a complete dumb and you are telling me something that i dont get.
-
- Posts: 18
- Joined: Fri Jun 20, 2014 12:12 pm
Re: Seams where objects meet
Using
instead of
the cube has no glitches.
Weird thing is that if i draw the cube using buffer it looks ok with drawVertexPrimitiveList()...
I dont know what i am doing wrong, i even tried to use only 8 vertices (instead of 12) but the glitch is still there.
Problem solved i guess but still.. i would know what was wrong. xD
Code: Select all
driver->drawIndexedTriangleList(&Vertices[0], 12, &indices[0], 12);
Code: Select all
driver->drawVertexPrimitiveList(&Vertices[0], 12, &indices[0], 36, EVT_STANDARD, EPT_TRIANGLES, EIT_16BIT);
Weird thing is that if i draw the cube using buffer it looks ok with drawVertexPrimitiveList()...
I dont know what i am doing wrong, i even tried to use only 8 vertices (instead of 12) but the glitch is still there.
Problem solved i guess but still.. i would know what was wrong. xD
Re: Seams where objects meet
Just a thought, but these 'seams' your seeing is probably how light is casting onto the objects.
Dream Big Or Go Home.
Help Me Help You.
Help Me Help You.
Re: Seams where objects meet
Looking at the code,
does not convert to
It converts to
Also, the second '12' is not the count of vertices, but the count of triangles. I don't know how the vertices are used to create the triangles but mathematics tells me that it must always be less than 12.
Code: Select all
driver->drawIndexedTriangleList(&Vertices[0], 12, &indices[0], 12);
Code: Select all
driver->drawVertexPrimitiveList(&Vertices[0], 12, &indices[0], 36, EVT_STANDARD, EPT_TRIANGLES, EIT_16BIT);
Code: Select all
driver->drawVertexPrimitiveList(&Vertices[0], 12, &indices[0], 12, EVT_STANDARD, EPT_TRIANGLES, EIT_16BIT);
-
- Posts: 18
- Joined: Fri Jun 20, 2014 12:12 pm
Re: Seams where objects meet
Yeah that was the error, i put the lenght of the indices array (36) but all that parameter asks for is the number of primitives (12). I knew it was an error on my part but i was sure that line was ok. (because im bad)
Thank you very much mongoose!
Btw The triangles need to be 12, you count 2 per face right? A cube has 6 faces so 6*2 = 12
EDIT: oh nvm you were talking about vertices. Yeah i could draw it using 8 vertices but there something i didnt quite understand about texturing (it needs 12 vertex to be textured correctly)
Thank you very much mongoose!
Btw The triangles need to be 12, you count 2 per face right? A cube has 6 faces so 6*2 = 12
EDIT: oh nvm you were talking about vertices. Yeah i could draw it using 8 vertices but there something i didnt quite understand about texturing (it needs 12 vertex to be textured correctly)
Re: Seams where objects meet
I may have got ahead of myself. Yes, there are 12 triangles. I suppose you could use 12 vertices but with lighting you need 24 for the normals.