Skip to main content
GameDev.net gamedev.net
🔒 Locked 🎮 Unity

Transforming lines..

Started by ArchangelMorph Jul 16, 2008 at 7:04 AM 0 replies 1.1k views
Original Post
ArchangelMorph
ArchangelMorph
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 ); } ... }
Mike nl
Mike nl
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,...) ).
Million-to-one chances occur nine times out of ten!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.