[Solved]3Dline are visible only under certain angle

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
RVM
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France
Contact:

[Solved]3Dline are visible only under certain angle

Post by RVM »

Hello,

I draw a 3D line with this code in a 3D environment with a skybox, some 3D mesh and a FPSCamera :

Code: Select all

 
VideoDriver->draw3DLine(irr::core::vector3df(0,50,0),irr::core::vector3df(0,-500,0));
 
Before I do :

Code: Select all

 
irr::video::SMaterial m;
    m.Lighting = false;
    VideoDriver->setMaterial(m);
 
But I see this line under few angle and not all the time...
Any reason ?

Thanks you for enlightening me,
RVM
Last edited by RVM on Mon May 07, 2012 3:22 pm, edited 1 time in total.
//When I wrote this, only God and I understood what I was doing
//Now, God only knows
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: 3Dline are visible only under certain angle

Post by hybrid »

You have to set the transformation matrix as well. Please read the API docs again.
RVM
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France
Contact:

Re: 3Dline are visible only under certain angle

Post by RVM »

I have set the transformation matrix as in the doc :

Code: Select all

VideoDriver->setTransform(irr::video::ETS_WORLD, irr::core::IdentityMatrix);
But don't help.. (http://youtu.be/2D5VSOqHgo0)
I have some orientation error too, the ray start at vector3df(10,10,10) and end at start + vector3df(0,-100,0).

RVM
//When I wrote this, only God and I understood what I was doing
//Now, God only knows
smso
Posts: 246
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: 3Dline are visible only under certain angle

Post by smso »

Try either:

Code: Select all

        video::SMaterial lineMaterial;
        lineMaterial.Lighting = false;
        lineMaterial.Thickness = 3.0f;
        lineMaterial.FrontfaceCulling = false;
        lineMaterial.BackfaceCulling = false;
        lineMaterial.MaterialType = video::EMT_SOLID;
        
        driver->setMaterial(lineMaterial);
 

or:

Code: Select all

        camera->setFarValue(40000.0f);
        camera->setNearValue(0.1f);
 
Regards
smso
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: 3Dline are visible only under certain angle

Post by hybrid »

Could be that it's just too near to the ground and covered by the terrain due to zbuffer imprecision. near/far value change could already help. Otherwise just disable zbuffer such that the line is not culled. We also support the depth bias in material, but IIRC only starting with Irrlicht 1.8. So might be worth a test, but could take some timeuntil it's available in the stable versions.
RVM
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France
Contact:

Re: 3Dline are visible only under certain angle

Post by RVM »

Hi,

@smso : I have test with your code but don't resolve this problem.

@hybrid : I have set zbuffer to false, and now, the line go black when I am near.

I have search about my orientation problem and why I have 2 line.
I think it's because I have rotate all world mesh by -90,180,0. And now the Y and Z axis are reversed.
If a take my world bounding box (http://sd-5.archive-host.com/membres/im ... -52-40.png) :
Normally X and Z must be large and Y small but I have for bounding box : Min X: -12.886924, Max X: 13.214664, Min Y: -12.512041, Max Y: 13.214664, Min Z: -0.586996, Max Z: 1.306891
I see also a bug with my bounding box : http://sd-5.archive-host.com/membres/im ... -39-69.png

RVM
PS : I use .X file
PS2 : my main : http://pastebin.com/Tx7ZJEc7 (line 192 for ray) and my word loading code : http://pastebin.com/crNs506m
//When I wrote this, only God and I understood what I was doing
//Now, God only knows
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Re: 3Dline are visible only under certain angle

Post by hybrid »

Well, you seem to have misunderstood both the API docs and our suggestions. You have to call setMaterial and setTransformation directly before the draw3DLine call. In each render cycle.
RVM
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France
Contact:

Re: 3Dline are visible only under certain angle

Post by RVM »

hybrid wrote:Well, you seem to have misunderstood both the API docs and our suggestions. You have to call setMaterial and setTransformation directly before the draw3DLine call. In each render cycle.
Sorry but I didn't know that I must call setMaterial and setTransformation every time before draww3dline in each render cycle...
For me to "set up material before drawing the line", is to set up one time at "setting" of engine (specify one time until the end).

Many thanks, the ray problem is solved :D ,

RVM
//When I wrote this, only God and I understood what I was doing
//Now, God only knows
Post Reply