Page 1 of 1

Irrlich + Bullet - Draw 3D Line problem

Posted: Sun Aug 18, 2013 9:28 pm
by Nsty
Hello everyone,
I've been trying to integrate irrlicht with bullet when I encountered a problem with Bullet Debug Draw.
It requires to implement a DrawLine method which I didn't manage to do so far. I've tried to use pure OpenGL with GLUT as:

Code: Select all

    glBegin(GL_LINES);
    glColor3f(fromColor.getX(), fromColor.getY(), fromColor.getZ());
    glVertex3d(from.getX(), from.getY(), from.getZ());
    glColor3f(toColor.getX(), toColor.getY(), toColor.getZ());
    glVertex3d(to.getX(), to.getY(), to.getZ());
    glEnd();
 
But when i run this code inside the: driver->beginScene(); and driver->endScene(); nothing gets drawn.
Then I found the driver->draw3DLine() function but there seems to be a problem with coordinates. Objects gets drawn but it looks like they are flat (Y dimension of each object is close to 0) and they are 'missplaced'. Aditionally no mather what I pass as SColor all lines are always black.

I'd be greatfull for any advice :)

Re: Irrlich + Bullet - Draw 3D Line problem

Posted: Sun Aug 18, 2013 9:40 pm
by Isomorphix
If you want to display a line as if your monitor was a paper that you just drew on,

then this

Code: Select all

 
glBegin(GL_LINES);
    glColor3f(fromColor.getX(), fromColor.getY(), fromColor.getZ());
    glVertex3d(from.getX(), from.getY(), from.getZ());
    glColor3f(toColor.getX(), toColor.getY(), toColor.getZ());
    glVertex3d(to.getX(), to.getY(), to.getZ());
glEnd();
 
should be this

Code: Select all

 
glBegin(GL_LINES);
    glColor3f(fromColor.getX(), fromColor.getY(), fromColor.getZ());
    glVertex3d(from.getX(), from.getY(), 0.0f);
    glColor3f(toColor.getX(), toColor.getY(), toColor.getZ());
    glVertex3d(to.getX(), to.getY(), 0.0f);
glEnd();
 
By the way, glColor3f is in RGB ... not XYZ, your code might confuse others :wink:

Re: Irrlich + Bullet - Draw 3D Line problem

Posted: Sun Aug 18, 2013 9:46 pm
by randomMesh
Look here

Re: Irrlich + Bullet - Draw 3D Line problem

Posted: Sun Aug 18, 2013 11:52 pm
by Nsty
thx for the fast replay. That just solved my problem. Somehow I didnt manage to find that linked topic with search.
I've been missing:
driver->setTransform(irr::video::ETS_WORLD, irr::core::IdentityMatrix);
and tha black color was the lightning issue :)