Axis Widget

Blitz3D Forums/Blitz3D Beginners Area/Axis Widget

Eric(Posted 2011) [#1]
I'm trying to visualize the local Axes, like 3 lines or something pointing from the center of an entity in each of the 3 axes.

I am having problems controlling a mesh from the cameras perspective and I'm hoping that if I can put axes on my Entitys I will better understand what the heck is going on.


Depending on my orientation things get all messed up. I'm using the TFormVector Commands and all seems good until certain camera and Entity rotations happen.

I am using Xors3D and the physics functions... I am flying a "Missle" from the launcher... My camera follows the Missle from various vantage points.

I use my mouse to steer and as the missle arcs over all of my controls get screwy. I know it has to do with TForming my controls from Camera Space to World Space and then using those to control my missle.


Thanks,
Eric


Kryzon(Posted 2011) [#2]
Can you mock a simple example? I haven't realized how you want to control the missile.


Eric(Posted 2011) [#3]
Ok forget the missle.

I have a cone shape... and a first person Camera that follows the Cone... The cone is like a Moon Lander... Vertical thrust is the -Y Direction.

I use my Mouse to control X and Z rotation to tip the Cone forwards and Backwards, Left and right.

As the Cone moves the camera tracks and follows. The camera can therefore view the Cone from any Angle in a 360 degree sphere.

What I want is no matter what angle the camera is viewing the Cone... I want left/Right/forward/ Backward to be relative to the camera view.
Even if I am right above the cone.

Keep in mind that this is not like a car. The cone is Rolling and Pitching. Also keep in mind that that the yaw is free floating and can change.

I'm using Xors3d and BMax.

I had this working at one point but what I really need is to completely understand what is at work here so I don't have to keep asking.

Did this make sense?

I thought that if there was a way to visualize the actual Angles I would have a chance at understanding this.

Thanks,
Eric

Last edited 2011

Last edited 2011

Last edited 2011


Kryzon(Posted 2011) [#4]
Easy Way:
Parent the cone to the camera, then use TurnEntity(X,Y,Z,True) so the rotation is applied in relation to the camera's current orientation, and not the world.

Hard Way:
You need a way to retrieve the objects' matrices. I think xGetEntityMatrix() does that, but it returns an integer - I'm guessing this is a pointer to a matrix structure.
You need the camera's matrix and your cone's matrix.

Anyway, after some testing I think this is correct. What you want is this:
ConeMatrix.rotation = (RotationMatrix * CameraMatrix).rotation
ConeMatrix -> Your cone's matrix.
RotationMatrix -> The rotation you wish to apply to the cone. This is a rotation value in the form of a matrix.

Every frame you need to:
• Retrieve the current camera's matrix.
• Retrieve the current cone's matrix.
• Build the matrix 'RotationMatrix' from an Euler or Quaternion value.
• Overwrite the cone's matrix rotation part with the result from the above expression. The "rotation part" is the section of the matrix that stores rotation values.

You should know how much rotation you wish to apply to the cone based on the movement of the mouse (MouseXSpeed() and MouseYSpeed()).