draw3DTrianglecolor won't work

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
dehseth
Posts: 130
Joined: Wed Dec 09, 2009 11:05 am
Contact:

draw3DTrianglecolor won't work

Post by dehseth »

Hi everybody,
I would like to draw a 3d rectangle, so I created a class

Code: Select all

class CQuadrangleSceneNode : public scene::ISceneNode
and this is the render function:

Code: Select all

void CQuadrangleSceneNode::render()
{
    video::IVideoDriver* driver = SceneManager->getVideoDriver();
 
    driver->setMaterial(getMaterial(0));
        driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
    driver->draw3DTriangle(m_triangles[0], SColor(200,0,52,250));
    driver->draw3DTriangle(m_triangles[1], SColor(200,200,5,50));
}
I tried to remove material, set some material, texture and bla bla but I just cannot make draw3DTriangle function to make it draw the triangles by given SColor. Any idea :idea: what am I doing wrong? And I would like to use alpha too.. Thanks! :?
Marthog
Posts: 31
Joined: Sun Oct 03, 2010 8:33 pm
Contact:

Re: draw3DTrianglecolor won't work

Post by Marthog »

Look at the class CBillboardSceneNode in the Irrlicht source. It draws a squad which turns automatically to the viewer.
Just copy the code and remove the tranformation update.
Rust fanboy
dehseth
Posts: 130
Joined: Wed Dec 09, 2009 11:05 am
Contact:

Re: draw3DTrianglecolor won't work

Post by dehseth »

no use of CBillboardSceneNode. so nobody knows why colorful triangles wont work?
Mel
Competition winner
Posts: 2293
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: draw3DTrianglecolor won't work

Post by Mel »

There are better ways to draw a rectangle than using 2 draw3Dtriangle calls. Using a single drawVertexPrimitiveList is twice faster because it draws 2 triangles in a single call. Instead of 2 triangles, it is better to use 4 vertices and 6 indices
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
dehseth
Posts: 130
Joined: Wed Dec 09, 2009 11:05 am
Contact:

Re: draw3DTrianglecolor won't work

Post by dehseth »

Hi Mel,
you seem to misunderstood the question. It's not about performance, it is about drawing 3d triangle function color does not work. Anyways I solved the problem yesterday this is what I needed to set as material during render function:

Code: Select all

 
video::IVideoDriver* driver = SceneManager->getVideoDriver();
 
SMaterial m;
m.ColorMaterial = ECM_AMBIENT;
driver->setMaterial(m);
 
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
driver->draw3DTriangle(m_triangles[0], color1);
driver->draw3DTriangle(m_triangles[1], color2);
 
Post Reply