[gameprogrammer] RES: Re: DirectX Line and Triangle

  • From: "Edilson Vasconcelos de Melo Junior" <dirso@xxxxxxxxxxxxxxxxxx>
  • To: <gameprogrammer@xxxxxxxxxxxxx>
  • Date: Mon, 14 Jul 2008 18:19:32 -0300

Hi,

 

I'm in 3d. can you help me a little more?

 

Thank you very much for your help,

Dirso

 

De: gameprogrammer-bounce@xxxxxxxxxxxxx
[mailto:gameprogrammer-bounce@xxxxxxxxxxxxx] Em nome de Alan Wolfe
Enviada em: segunda-feira, 14 de julho de 2008 17:38
Para: gameprogrammer@xxxxxxxxxxxxx
Assunto: [gameprogrammer] Re: DirectX Line and Triangle

 

Hey Dirso,

 

Here's a plan of attack (assuming you are in 2d)

 

Calculate the normal of the line segment to get a normalized vector
perpendicular to the line, this will be useful to figure out the vertices
for the flat back side of the triangle.  Call this NX and NY.

 

Calculate the normalized vector of the line, call this LX and LY.

 

Find the midpoint of the line call this MX and MY.

 

Figure out how wide and how tall you want the triangle to be, call this
TWidth and THeight.

 

If you do the above, here's how to find each of the 3 vertices for the
triangle for each line:

 

Vertex 1:

*start at the midpoint

*subtract LX,LY multiplied by TWidth/2

*add NX,NY * THeight/2

 

Vertex 2:

*start at the midpoint

*add LX,LY * TWidth/2

 

Vertex 3:

*start at the midpoint

*subtract LX,LY multiplied by TWidth/2

*subtract NX,NY * THeight/2

 

That will give you the vertices in a clockwise order, so watch out for back
face culling if you have clockwise culled (:


 

On 7/14/08, Edilson Vasconcelos de Melo Junior <dirso@xxxxxxxxxxxxxxxxxx>
wrote: 

Hi,

 

I have a CustomVertex.PositionColored[] object that represents a line and I
use the DrawUserPrimitives(PrimitiveType.LineStrip, this.linePoints.Length -
1, this.linePoints); to draw it on screen

Now I need to draw a small triangle aligned to each line segment and one of
each vertex must "pointy" to the finish point of the segment. How can I do
that?

Something like the attached picture, but not that ugly.

 

Thanks,

Dirso.




 

No virus found in this incoming message.
Checked by AVG - http://www.avg.com
Version: 8.0.138 / Virus Database: 270.4.10/1551 - Release Date: 14/7/2008
06:49

Other related posts: