how to draw the line with setted width

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
liusa80
Posts: 17
Joined: Tue Apr 06, 2010 3:24 am

how to draw the line with setted width

Post by liusa80 »

i try to draw the line with setted width,but i could look for the setting parameter.does anybody know how? thank u
Escen
Competition winner
Posts: 167
Joined: Sun Jul 19, 2009 11:27 am
Location: the Netherlands
Contact:

Post by Escen »

Did you try material settings?

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{......
   
Note that d3d does not support line thickness.
liusa80
Posts: 17
Joined: Tue Apr 06, 2010 3:24 am

Post by liusa80 »

thanks for your help.but it doesn't work
liusa80
Posts: 17
Joined: Tue Apr 06, 2010 3:24 am

Post by liusa80 »

anybody know how?
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Re: how to draw the line with setted width

Post by greenya »

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

Post by hybrid »

I think the question is regarding line thickness. Escen's solution is correct, and includes the mentioning of the d3d limitation. Nothing more to say, probably.
Bate
Posts: 364
Joined: Sun Nov 01, 2009 11:39 pm
Location: Germany

Post by Bate »

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.
liusa80
Posts: 17
Joined: Tue Apr 06, 2010 3:24 am

Post by liusa80 »

thank u,it works,but anothor question,when i set the value parameter"Thickness",it looks like cannot draw very big width,set 8.0f and 20.0f the effort like the same width.
liusa80
Posts: 17
Joined: Tue Apr 06, 2010 3:24 am

Post by liusa80 »

and set the width only works in opengl mode,really?
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Yes, only OpenGL and the sw renderers. And there's a maximum width that your gfx card supports, yes.
kvakvs
Posts: 30
Joined: Wed Oct 14, 2009 1:50 am
Location: Sweden
Contact:

Post by kvakvs »

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.
Last edited by kvakvs on Wed Aug 18, 2010 8:55 am, edited 1 time in total.
liusa80
Posts: 17
Joined: Tue Apr 06, 2010 3:24 am

Post by liusa80 »

how to settle the problem ?
liusa80
Posts: 17
Joined: Tue Apr 06, 2010 3:24 am

Post by liusa80 »

i'll try kvakvs's method , wish to be settled
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

This is a known limitation, there is a feature request/bug ticket filed, and this issue will be fixed in one of the next releases.
Post Reply