how to draw the line with setted width
how to draw the line with setted width
i try to draw the line with setted width,but i could look for the setting parameter.does anybody know how? thank u
-
- Competition winner
- Posts: 167
- Joined: Sun Jul 19, 2009 11:27 am
- Location: the Netherlands
- Contact:
Did you try material settings?
Note that d3d does not support line thickness.
Code: Select all
//set material
SMaterial mat;
mat.Thickness = 5;
mat.AntiAliasing=true
mat.AmbientColor = mat.DiffuseColor = mat.EmissiveColor = irr::video::SColor(255,0,0,255);
Driver->setMaterial(mat)
//draw lines.....
Driver->draw3DLine{......
Re: how to draw the line with setted width
With setted width ?liusa80 wrote:i try to draw the line with setted width,but i could look for the setting parameter.does anybody know how? thank u
Not sure if i understand you, but:
#1
The line can be drawn using IVideoDriver::draw3DLine(...)
You need start point (vector3df -- 3 floats) and end point (the same as start).
So line in 3 dimensional space can be defined by 6 floats -- this is common definition and Irrlicht draw this data into line on the display with 1 call (draw3DLine() as i said above),
#2
BUT indeed, line can be defined also by:
- start point (vector3df)
- direction (vector 3df) // "start point" and "direction" already defines a ray
- width (1 float) // this will limit out ray to ending line.
If you need to draw line with #2nd type of data set, you need to make some vector calculations to get end point coordinates and draw the line in the same way as for #1.
Just in case: You have to draw the line in your main loop between beginScene and endScene.
Code: Select all
driver->beginScene(true, true, SColor(0,0,0,0));
SMaterial mat;
mat.Thickness = 5;
mat.AntiAliasing = true
mat.EmissiveColor = irr::video::SColor(255,0,0,255);
driver->setMaterial(mat)
driver->draw3DLine(...);
driver->endScene();
Never take advice from someone who likes to give advice, so take my advice and don't take it.
Modern video cards hardware can only draw simple Bresenham lines, no thick lines. Thick lines are simulated with 3D geometry (triangles and triangle strips).
So if you want full control over line rendering, with antialiasing, texturing, lighting, whatever you wish to control...
1. Build 2 points around your line start (half width left, and half width right), and then 2 points around your line end (again half width left, and half width right). Left and right are calculated using perpendicular vector to your line, there is easy algorithm on the internets, how to calculate a perpendicular.
2. Render the resulting quad with the color and quality settings you wish.
3. ????
4. Calculate profits.
So if you want full control over line rendering, with antialiasing, texturing, lighting, whatever you wish to control...
1. Build 2 points around your line start (half width left, and half width right), and then 2 points around your line end (again half width left, and half width right). Left and right are calculated using perpendicular vector to your line, there is easy algorithm on the internets, how to calculate a perpendicular.
2. Render the resulting quad with the color and quality settings you wish.
3. ????
4. Calculate profits.
Last edited by kvakvs on Wed Aug 18, 2010 8:55 am, edited 1 time in total.
/* my homesite */