Specific matrix question
Well I am going to be very specific. I am probably having trouble due to me not understanding OpenGl correctly. But here I go.
I have a model. Its position and rotation in world coordinate system are represented by 4 vectors
vector Position
vector Dof
vector up
vector side
I can use this to create a rotationTranslation matrix and this works great. What I want to is to make a new object go from a point on the model and forward into space into a direction. The point is in model coordinates.
vector extrude
vector object direction
So how do I do this.
I'm not sure I understand this:
Do you want to extrude an object? What's the vector "object direction"? Is the vector extrude the direction and scale you want to use for the extrusion?
To begin with, you can apply your matrix to the point to get it in world coordinates.
Um.. Well, before I continue I'd like confirmation that extrusion of an object is what you want [wink]
Quote:What I want to is to make a new object go from a point on the model and forward into space into a direction. The point is in model coordinates.
vector extrude
vector object direction
Do you want to extrude an object? What's the vector "object direction"? Is the vector extrude the direction and scale you want to use for the extrusion?
To begin with, you can apply your matrix to the point to get it in world coordinates.
Um.. Well, before I continue I'd like confirmation that extrusion of an object is what you want [wink]
Sorry wrong word for it ... I want to the smaller object to fly "out" from a point on first model.
The vector extrude, is the point where the smaller object starts
The vector extrude, is the point where the smaller object starts
not sure what your asking here but you can nest matrix ops, perhaps what you need
pushmatrix // for base object
loadidentity
postion
rotation
pushmatrix // for object 2 (smaller one i guess)
loadidentity
position(extrude + movement)
rotation
popmatrix
popmatrix
pushmatrix // for base object
loadidentity
postion
rotation
pushmatrix // for object 2 (smaller one i guess)
loadidentity
position(extrude + movement)
rotation
popmatrix
popmatrix
Quote:Original post by middy
Sorry wrong word for it ... I want to the smaller object to fly "out" from a point on first model.
The vector extrude, is the point where the smaller object starts
So the smaller object should start at point A, and fly in direction B over time ? Well, that would be:
P(t) = A + B * t
where P is the new position at time t. Then you just multiply P(t) by the same matrix you use to transform your model with, and you'll get it in world space.
Is it this what you meant ?
Well the movement part I have sorted out. My problem is rendering the damn thing.
The smaller object is a bullet stream, coming from a gun. When I rotate the gun the bullets (even though they have left the gun) rotates with it.
So I figured I constructed the bullet rotationTranslation matrix wrong. Or had misunderstood something
I included a picture
The smaller object is a bullet stream, coming from a gun. When I rotate the gun the bullets (even though they have left the gun) rotates with it.
So I figured I constructed the bullet rotationTranslation matrix wrong. Or had misunderstood something
I included a picture
Ok, if you do something like this:
* When a shot is fired, make a copy of the "rotationTranslation matrix" of the ship. Each bullet should have it's own copy.
* To render a bullet you should start with a clean modelview matrix (i.e. the ships transformation should not be on there.) Apply the bullet's rotationTranslation matrix to it.
* Calculate the bullet's position as Yann showed. Then draw the bullet at that position. The bullet should now be transformed to the correct position in space.
An alternative would be to transform starting position and direction to world space directly when a bullet is fired.
* When a shot is fired, make a copy of the "rotationTranslation matrix" of the ship. Each bullet should have it's own copy.
* To render a bullet you should start with a clean modelview matrix (i.e. the ships transformation should not be on there.) Apply the bullet's rotationTranslation matrix to it.
* Calculate the bullet's position as Yann showed. Then draw the bullet at that position. The bullet should now be transformed to the correct position in space.
An alternative would be to transform starting position and direction to world space directly when a bullet is fired.
So something like this?
//copy matrix
glPushMatrix();
glMultMatrix(matrix);
//render bullet
glPopMatrix();
How would I translate starting position and direction on ship to world coordinates?
//copy matrix
glPushMatrix();
glMultMatrix(matrix);
//render bullet
glPopMatrix();
How would I translate starting position and direction on ship to world coordinates?
Why don't you just give the bullet object 2 vector properties:position and velocity.When you fire a bullet,you initially set its position using the extrude or whatever,and set also the initial velocity from the direction of the gun.After that,you just calculate the orbit of the bullet using any physics equations you desire,and draw the bullet by just translating using the "bullet.position" vector.
Quote:Original post by middy
So something like this?
//copy matrix
glPushMatrix();
glMultMatrix(matrix);
//render bullet
glPopMatrix();
Yes, something like that, but with lots of code between "copy matrix" and glPushMatrix()... :)
Quote:How would I translate starting position and direction on ship to world coordinates?
Using the matrix you've copied..!
Say, why don't you post the code you have now and we'll try to tell you how to change it so it works?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement