MP3D problem with local rotation

Advanced game related topics
banban73
User
User
Posts: 21
Joined: Sun Jul 18, 2004 12:03 pm
Location: Bergerac - France

MP3D problem with local rotation

Post by banban73 »

Hi,

Does anyone around know how to make a rotation of a MP3D entity according to its local axis ? The function MP_EntityGetPitch() has a trigger to get local or global angle but I did not found the same for rotation functions, neither for the move function, which always refer to global axis.
I found and translated a DarkBasic piece of code about rotation using vectors (axis align and so on) but it relies on determining direction vector of the object by moving it slightly "forward", "up" and "left" along its local axis and calculating the delta in x,y and z. After that, it is only vector maths.
Unfortunately, since move functions in MP3D seem to refer only to global axis, this does not work at all and I am totally stuck.
As MP3D is still Alpha (but what a complete one) it may be logic that not all the features are already implemented or it may come that I fail to find the right command.

In fact, what I want is to make a 3d plane fly around a 3d earth (spherical) following great circle routes between two airports. I already display earth(!), great circle route by positioning spheres along the route and am rather happy with the airport selection system. All I need is to make this damn plane keep normal to earth radius all flight long.

If someone has a clue (about command or how to achieve local rotation by any other means), thank you by advance.

Best regards

Alban
User avatar
IceSoft
Addict
Addict
Posts: 1683
Joined: Thu Jun 24, 2004 8:51 am
Location: Germany

Re: MP3D problem with local rotation

Post by IceSoft »

Not sure what you realy want but have a look on this MP3D functions

Code: Select all

MP_TurnEntity(Entity, pitch.f, yaw.f, roll.f) 
MP_MeshSetParent(Entity, Parent) 
Belive! C++ version of Puzzle of Mystralia
<Wrapper>4PB, PB<game>, =QONK=, PetriDish, Movie2Image, PictureManager,...
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D problem with local rotation

Post by mpz »

Hi banban73,

For the global system you use MP_RotateEntity(Entity, pitch.f, yaw.f, roll.f), these are the absolute coord system (like the universe)
For the local system (your Mesh system) you use MP_TurnEntity(Entity, pitch.f, yaw.f, roll.f), these are the relative coord system (your airplane)

Please look on the MP_Terrain.pb Example. Here you see the movement of a camera in his local system...

With the Parent - Kid system it will be more complikate, because you have three coord systems and the kid local system moves with the parent system. But i think this was not the question 8)

Greetings Michael
Working on - MP3D Library - PB 5.73 version ready for download
banban73
User
User
Posts: 21
Joined: Sun Jul 18, 2004 12:03 pm
Location: Bergerac - France

Re: MP3D problem with local rotation

Post by banban73 »

Hello,

Thank you very much for your answers.

I tried MP_Turnentity() before posting but this did not work : in the way I use it, it seemed to rotate around global axis.

I also tried a MP_entitylookat() on the plane towards earth center (0,0,0) and that works in a incomplete way : the bottom of plane points towards earth center but nose points always to the West (that may be normal) and when I try to turn entity with MP_Turnentity() around its up axis to put it on the right heading, it turns around global axis and makes tail,nose or wings to bank in an inappropriate way.

Anyway, I have just uploaded an archive with plane and code as it may be clearer. You can find it here :
http://dl.free.fr/gXqU8d95S

Keys as following :
F1 earth cam : global view
F2 plane cam :zoom view centered on plane

SPACE : keep pressed for selection mode (make grey sphere collide with any green sphere (airports) and left click for departure select, right click for destination select)

ESC to quit

Thanks in advance for any clue you may find !
And many thanks MPZ for that great 3d engine.

Best regards
Alban
banban73
User
User
Posts: 21
Joined: Sun Jul 18, 2004 12:03 pm
Location: Bergerac - France

Re: MP3D problem with local rotation

Post by banban73 »

Sorry, just a precision to download the archive, click on "télécharger le fichier". I did not realize the free web page was only in french.

Regards

Alban
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D problem with local rotation

Post by mpz »

Hi Banban73,

nice peace of code. I have seen two problemes an i think it is my part to find a solution. The MP_EntityLookAt(Plane,0,0,0) command change the 3D matrix of the Plane, but do not actualice the global and individual angles of the plane. If you change the angle the MP_EntityLookAt matrix will be overwriten and lost and the palne move wrong. This is my part, i will check it and find a solution. The second problem ist the plane look not good. The plane has 4 Surface and i must check if the load of a mesh with some Surfaces works correctly. Perhaps ist is better to edit the mesh and make a easier model with one surface of it ...

Greetings
Michael
Working on - MP3D Library - PB 5.73 version ready for download
banban73
User
User
Posts: 21
Joined: Sun Jul 18, 2004 12:03 pm
Location: Bergerac - France

Re: MP3D problem with local rotation

Post by banban73 »

Hi,

Many thanks, MPZ, for taking a look on the source and answering.
I will try to get a simpler plane model with only one texture and see what happens.

I am really sorry for any additional work needed and I hope the matrix actualisation will not be too hard to implement.
Speaking of relative/absolute things, does the MP_moveEntity() refers to object orientation or to absolute axis ? (in the second case, could you add a trigger absolute/relative in the function parameter in one of the next releases ?)

Anyway, thanks again for your answer. I am looking forward to the next release !

Best regards

Alban
mpz
Enthusiast
Enthusiast
Posts: 497
Joined: Sat Oct 11, 2008 9:07 pm
Location: Germany, Berlin > member German forum

Re: MP3D problem with local rotation

Post by mpz »

Hi banban73,

i have good news. A german customer helps me with the lookat matrix. Now i have the correct angles and it is posible to move the Mesh in the correct way after using the lookat function.Netx good news, your Airplane was not fault it was my loadmesh command. I have solved this problem too. The debugged version will come soon. It will be the version alpha mp3d 28 version..

Nice Day Michael
Working on - MP3D Library - PB 5.73 version ready for download
Post Reply