trying to draw cylinder

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Alucard344
Posts: 21
Joined: Wed May 20, 2009 8:17 pm
Location: Qc, Canada

trying to draw cylinder

Post by Alucard344 »

Hi,
I am having a strange problem.
What i am trying to do is to draw a lot of cylinder. Those cylinder have a small radius (they represent drill hole).

All my cylinder are batched into a mesh.
The problem is, when I zoom out or zoom in, the cylinders start flicking. Some disseapear while some other reappear. The cylinder that appear or disseaper are completely random. Its like if the triangle were too small for the engine to detect if they should be drawn or not.

If i draw them in wireframe, then no more problem. everything is drawn perfectly and i can zoom in or out and everything is fine.

When i am really near the cylinder, they are all fine.

if i draw my cylinder with a bigger radius, i have to zoom out more for the flicking to begin. but it still happen at some point.

Also, i am using an orthogonal camera.

Does anyone have an idea of what i could do to fix this problem ?

And sorry for my english, it is not my primary language.

Thanks
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Sounds as if your model contains duplicated triangles at the cylinder borders. This would incur zbuffer fighting, where background and foreground can arbitrarily switch.
Alucard344
Posts: 21
Joined: Wed May 20, 2009 8:17 pm
Location: Qc, Canada

Post by Alucard344 »

Thanks for your fast answer,
I have made some test, generating only one triangle per cylinder but the problem remain.
the problem seems to happen only in orthogonal view.


here is screenshot of what i see. only 1 triangle per cylinder to be as simple as possible.

this is what it is supposed to look like. this is in wireframe. each line are in fact a triangle that you could see when zooming in.

Image

Now this is an orthogonal view shaded mode. a lot of them as disseapeared and are flicking randomly when zooming in or out
Image


And finally this is an oblique view, shaded again. all cylinder are there but they look like dotted line
Image


are the triangle too small to be displayed correctly ? what could be the problem ?


Thanks
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

I'd still say this is a z-fighting problem because of the apparently thin cylinders. It could happen that because of this, front- and backfacing verts fight and when the backface "wins", the cylinder is (partly) self-culled.
Just a guess.
beer->setMotivationCallback(this);
Alucard344
Posts: 21
Joined: Wed May 20, 2009 8:17 pm
Location: Qc, Canada

Post by Alucard344 »

and what can i do if it is frontface backface culling fighting ?
i have tried this but it doesnt change anything

Code: Select all

material.BackfaceCulling = false;
material.FrontfaceCulling = false;
polylux
Posts: 267
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Post by polylux »

Basically, I'd say your approach is kinda not-the-best. I would just replace the cylinders with Lines when the distance camera-object exceeds a certain threshold. Besides getting rid of the z-fighting this would also speed up the vis when having lots of objects.
beer->setMotivationCallback(this);
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Which parameters do you use for the orthogonal setup?
Alucard344
Posts: 21
Joined: Wed May 20, 2009 8:17 pm
Location: Qc, Canada

Post by Alucard344 »

Code: Select all


static const long CAMERA_FAR_VALUE = 1000000;
static const long CAMERA_NEAR_VALUE = 1;

irr::core::matrix4 matrix;
matrix.buildProjectionMatrixOrthoLH(width, height,CAMERA_NEAR_VALUE, CAMERA_FAR_VALUE); 
m_smgr->getActiveCamera()->setProjectionMatrix(matrix,true);
i know i can use some workaround as polylux proposed. but im still wondering if it is possible to do what i am trying to do with only mesh.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Use a far value of 10000
Alucard344
Posts: 21
Joined: Wed May 20, 2009 8:17 pm
Location: Qc, Canada

Post by Alucard344 »

it doesnt change anything..
Post Reply