Jump to content
  • Advertisement
Sign in to follow this  
ArchangelMorph

Transforming lines..

This topic is 3631 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a unitY length line (setup up so that the origin sits dead at the centre of it..) I want to render.. I'm trying to setup a method which will allow me to specify a start vector & end vector & the LineRenderer object will setup a transformation matrix to pass to the draw function to get my line oriented & scaled into the correct place.. I've tried a few different algorithms but the vector math is frying my brain so I was wondering if someone could help me..? Something like this: class LineRenderer { ... public void Draw(Vector3 start, Vector3 end, Matrix viewproj) { // setup transform matrix Matrix mat = ... ; // draw with transform matrix DrawLine( mat ); } ... }

Share this post


Link to post
Share on other sites
Advertisement
Well, if you want it done your way, I guess you need to find the angle between (end - start) and (0,1,0), create a rotation matrix, then scale with (end - start).length() and translate to start.

Or, you know, you just create two vertices at start and end and render a line primitive with those (e.g with DrawPrimitiveUP(D3DPT_LINELIST,...) ).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!