Hello
I made a little project with a car moving around on a hill. The idea is to have the car angle adapt to the angle of the terrain. It was working great until I introduced the Z axis rotation. The rotation works and everything, but the car doesn't go forward anymore like it should.
I've been looking at the car->getRotation().Y and it seems to be going all crazy. When my car rotates the Y takes these values :
I have no idea why :O, is there a way I can calculate the Y rotation like it use to be before the Z rotation was added? :
movement + rotation?
-
- Posts: 91
- Joined: Sun Oct 19, 2008 5:29 pm
- Location: Valencia (Spain)
- Contact:
I think I understood what you want make.
You want the vehicle to follow a specified address, forgetting the overall position.
For move:
For turn:
With this code could achieve an effect of driving.
PD: For more realism, use any physics engine.
You want the vehicle to follow a specified address, forgetting the overall position.
For move:
Code: Select all
vector3df move(x,y,z);
matrix4 matrix;
matrix = car->getRelativeTransformation();
matrix.transformVect(move);
car->setPosition(move);
Code: Select all
car->setRotation(vector3df(x,y,z) + car->getRotation());
PD: For more realism, use any physics engine.
-
- Posts: 9
- Joined: Tue Jan 05, 2010 3:06 pm
- Location: Brazil
Hello guys!
I'm having a very similar problem.
I'm trying to make my node movements this way
(Inspired by Resident Evil 4 Camera Style):
1 - Left and Right keys rotate my character node;
2 - Up and Down move my character node in the direction it's looking at.
My problem:
How am I suposed to get the direction
vector my character node is looking at?
I've tried some things, but I had no sucess.
Please, anyone help me...
I'm having a very similar problem.
I'm trying to make my node movements this way
(Inspired by Resident Evil 4 Camera Style):
1 - Left and Right keys rotate my character node;
2 - Up and Down move my character node in the direction it's looking at.
My problem:
How am I suposed to get the direction
vector my character node is looking at?
I've tried some things, but I had no sucess.
Please, anyone help me...
Erick
my trick is to have 2 bone that is align so it always face where the node facing.ericklima.comp wrote:Hello guys!
I'm having a very similar problem.
I'm trying to make my node movements this way
(Inspired by Resident Evil 4 Camera Style):
1 - Left and Right keys rotate my character node;
2 - Up and Down move my character node in the direction it's looking at.
My problem:
How am I suposed to get the direction
vector my character node is looking at?
I've tried some things, but I had no sucess.
Please, anyone help me...
when i want to get the direction i just get the absolute position of each bone and subtract it, then normalized the vector.
-
- Posts: 9
- Joined: Tue Jan 05, 2010 3:06 pm
- Location: Brazil
yes, it should, so the dir will always point to node directionericklima.comp wrote:Hello again!
I'll try something like that!
But i think I'm gonna use a dummy scene node.
If it works, I'll let you know!!!
One more question:
These scene nodes must be parent and child of each other?
Anyway,
Thanks a lot for answering, mataanjin!!!
-
- Posts: 9
- Joined: Tue Jan 05, 2010 3:06 pm
- Location: Brazil
Hello guys!!! Your support helped me a lot!!!
After my last post, I suceeded to code the camera the way wanted. \o/
I created the camera as a child of my character node.
Then I added a new Scene Node to get the direction.
So I used the FPSCamera as an example to make all the movement stuff.
For now, it's in my classes layout, but I'm thinking about
code an animator for it when I'm done with this project,
to help other people.
Special thanks to mataanjin!!!
After my last post, I suceeded to code the camera the way wanted. \o/
I created the camera as a child of my character node.
Then I added a new Scene Node to get the direction.
So I used the FPSCamera as an example to make all the movement stuff.
For now, it's in my classes layout, but I'm thinking about
code an animator for it when I'm done with this project,
to help other people.
Special thanks to mataanjin!!!
Erick