[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.

[Solved]3Dline are visible only under certain angle

Postby RVM » Sun May 06, 2012 2:11 pm

Hello,

I draw a 3D line with this code in a 3D environment with a skybox, some 3D mesh and a FPSCamera :
cpp Code: Select all
 
VideoDriver->draw3DLine(irr::core::vector3df(0,50,0),irr::core::vector3df(0,-500,0));
 


Before I do :
cpp 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
User avatar
RVM
 
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France

Re: 3Dline are visible only under certain angle

Postby hybrid » Sun May 06, 2012 7:23 pm

You have to set the transformation matrix as well. Please read the API docs again.
hybrid
Admin
 
Posts: 13942
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Re: 3Dline are visible only under certain angle

Postby RVM » Sun May 06, 2012 11:54 pm

I have set the transformation matrix as in the doc :
cpp 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
User avatar
RVM
 
Posts: 13
Joined: Sun Mar 27, 2011 6:14 pm
Location: France

Re: 3Dline are visible only under certain angle

Postby smso » Mon May 07, 2012 2:34 am

Try either:

cpp 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:
cpp Code: Select all
        camera->setFarValue(40000.0f);
        camera->setNearValue(0.1f);
 


Regards
smso
smso
 
Posts: 214
Joined: Fri Jun 04, 2010 3:28 pm
Location: Hong Kong

Re: 3Dline are visible only under certain angle

Postby hybrid » Mon May 07, 2012 7:52 am

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.
hybrid
Admin
 
Posts: 13942
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Re: 3Dline are visible only under certain angle

Postby RVM » Mon May 07, 2012 8:56 am

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

Re: 3Dline are visible only under certain angle

Postby hybrid » Mon May 07, 2012 11:49 am

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.
hybrid
Admin
 
Posts: 13942
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany

Re: 3Dline are visible only under certain angle

Postby RVM » Mon May 07, 2012 12:23 pm

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


Return to Beginners Help

Who is online

Users browsing this forum: No registered users and 1 guest