rotation matix from two vectors?
Ok it''s like this i need to create a rotation matrix from two vectors, the first vector is aimed "forward"(if i would use it on a polygon it would be the normal of that polygon).
The second vector is aimed towards a point in 3d space(from the object''s centre).
It would be used for thing''s like billboarding and aiming object''s towards other object''s.
Does anyone have any idea on how to do this?(without using the model view matrix), im'' totaly lost on this problem.
---------------------------------
For an overdose of l33tness, flashbang.nu
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
look at this code I posted a while ago.. it has a matrix class in it, and there is a lookAt() function in there.. it''s used in the demo too.. there is a big rotationg cube, and off to one side of it is a little cube, and attached to the little cube is a wee sphere that always points in the direction of a light thats buzzing around the scene...
| - Project-X - | - adDeath - | - my windows XP theme - | - email me - |
| - Project-X - | - adDeath - | - my windows XP theme - | - email me - |
Thanks RipTorn. I''ve been looking for code for a LookAt function for some time.
Thanx dude, im pretty shure that could work.
---------------------------------
For an overdose of l33tness, flashbang.nu
---------------------------------
For an overdose of l33tness, flashbang.nu
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
np.
if you understand exactly what a matrix is mathematically, then it''s not all that hard to understand how it works..
the 3x3 portion of a matrix is effectivly just 3 vectors, up, forward and right. So, if you have two (which a lookAt function will require) then you can generate the third by a cross product (as the result of a cross product will always be at right angles to both the vectors in the cross product) - In the lookAt code in there I do:
upVector=f.cross(upVector).cross(f);
where f was the vector direction your looking in.. what this does, if you think about it, makes sure that the upVector is at right angles to f.
the rest is all pretty simple, but I admit I named the vectors very badly
f,s and u were very poor choices in names on my part...
if you understand exactly what a matrix is mathematically, then it''s not all that hard to understand how it works..
the 3x3 portion of a matrix is effectivly just 3 vectors, up, forward and right. So, if you have two (which a lookAt function will require) then you can generate the third by a cross product (as the result of a cross product will always be at right angles to both the vectors in the cross product) - In the lookAt code in there I do:
upVector=f.cross(upVector).cross(f);
where f was the vector direction your looking in.. what this does, if you think about it, makes sure that the upVector is at right angles to f.
the rest is all pretty simple, but I admit I named the vectors very badly

Yea, it work's now.
Here is a screenshot of the working billboarding.

The scene has over 6000 stencil shadowed polygons with two light's and around 5000 billboarded particles.
And it's chugging along at 15 fps.
(I got a GFFX5600 and a AMD XP 1800+).
---------------------------------
For an overdose of l33tness, flashbang.nu
[edited by - lc_overlord on December 27, 2003 11:58:48 AM]
Here is a screenshot of the working billboarding.

The scene has over 6000 stencil shadowed polygons with two light's and around 5000 billboarded particles.
And it's chugging along at 15 fps.
(I got a GFFX5600 and a AMD XP 1800+).
---------------------------------
For an overdose of l33tness, flashbang.nu
[edited by - lc_overlord on December 27, 2003 11:58:48 AM]
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
Yea aren''t they great. =)
Now there s just about a ton of other thing''s to do.
Realistic perpixel lightning.
Unified lighting system.
making it so that my caracter dosn''t fall trough the floor.
world map format(CFWO) with zoned rendering.
Finnish the CFMD format.
Skeletal animations.
Other shit.
Blah.
Blah.
Blah.
Blah...
Let''s just say that i have my work cut out for me.
---------------------------------
For an overdose of l33tness, flashbang.nu
Now there s just about a ton of other thing''s to do.
Realistic perpixel lightning.
Unified lighting system.
making it so that my caracter dosn''t fall trough the floor.
world map format(CFWO) with zoned rendering.
Finnish the CFMD format.
Skeletal animations.
Other shit.
Blah.
Blah.
Blah.
Blah...
Let''s just say that i have my work cut out for me.
---------------------------------
For an overdose of l33tness, flashbang.nu
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement