Space Flight Demo

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Space Flight Demo

Post by arras »

I decided to make small demo in order to learn and familize with Irrlicht. Here is progress so far:

Image
Image

You can download demo on my page:
http://members.lycos.co.uk/arras1
I was spliting download so you dont need to download Irrlicht.dll and d3dx8d.dll if you have them. Just copy them to demo directory.

There are only few features implemented untill now including one active, player controled object, static camera, skysphere and some dynamic lights.
You can control ship via
a-d w-s q-e keys for movement
1-2-3...-9 for speed
SPACE for stop

I have few questions you can help me with:
1. hove to change text font/size/colour?
2. is there limit in placing dynamic lights?
3. is there function to normalize matrix4?
4. for free flight movement I use matrix4 class to get proper movement of ship. However I got problem with matrix4::setRotationDegrees(...), matrix4::getRotationDegrees() and node->setRotation(...) functions.
In certain situations ship don't rotate corectly. here is code:

Code: Select all

void playerObject::rotate(vector3df rp) //rp is angle to turn, pitch or roll
{
   vector3df r = node->getRotation(); //get current rotation (euler)

   matrix4 m;
   matrix4 mp;
   m.setRotationDegrees(r); //set matrix to current rotation
   mp.setRotationDegrees(rp); //set second matrix to rotation to add
   m *= mp; //multipy them

   r = m.getRotationDegrees(); //get rotation vector from matrix (euler)
   node->setRotation(r); //rotate node
}
where vector3df rp is rotation needs to be added ...0,2,0 for turning right or -2,0,0 for pitching down for example.

When Y rotation of node (player object) is 0 or 180 pitch and roll don't work corectly. I made small workaround to prevent this but its not realy solution:

Code: Select all

   if(r.Y == 0.0f)
      r.Y = 0.001f;
   if(r.Y == 180.0f)
      r.Y = 180.001f;
Does somebody know hove to correct it or does somebody know diferent way howe to get turn, pitch and roll work properly (for example using quaternion class)?

.
jl0206
Posts: 55
Joined: Mon Jun 07, 2004 4:56 am

Post by jl0206 »

the url can't download
warui
Posts: 232
Joined: Wed Apr 14, 2004 12:06 pm
Location: Lodz, Poland
Contact:

Post by warui »

> the url can't download
Works fine for me.
Tomasz Nowakowski
Openoko - www.openoko.pl
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

jl0206>> Downloads seem's to work correctly. Try it again may be.
DarkWhoppy
Posts: 386
Joined: Thu Sep 25, 2003 12:43 pm
Contact:

Post by DarkWhoppy »

Next time could ya include the Dev-C++ DLL? (The MSVC++ version DLL wouldn't work :wink: )
Programmer of the Irrlicht Scene Editor:
Homepage - Forum Thread
Version 2 on its way!!
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

DarkWhoppy>> It is included, you just have to download it separately in SFd_dlls.zip ;)
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

@arras: your rotation problem probably comes from a bug in getRotationDegrees(). Here's the fix:

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2234

There's also a little bug in the matrix mutiplication (it's effect seems not that noticable though):

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2458

jox
Unarekin
Posts: 60
Joined: Thu Apr 22, 2004 11:02 pm

Post by Unarekin »

arras wrote:DarkWhoppy>> It is included you just have to download it separately in SFd_dlls.zip ;)
My brain hurts. :(
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

jox>> I found that treats already earlier and was recompiling Irrlicht.dll with your and neojzs code but it did not solved that problem.

I thought normalization could help but cant find Irrlicht function for normalization of matrix4.

I also tried to convert matrix to quaternion and back but that gave wery strange results.

Here is test code but it don't work like it should (or I misunderstant function descriptions in Irr. doc.)

Code: Select all

void playerObject::rotate(vector3df rp)
{
   vector3df r = node->getRotation();
   r = r + rp;
   
   quaternion q(r.X, r.Y, r.Z);
   q.normalize();
   q.makeInverse();
     
   matrix4 m = q.getMatrix();

   r = m.getRotationDegrees();
   node->setRotation(r);
}
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

Well, quaternion.h also has a bug

http://irrlicht.sourceforge.net/phpBB2/ ... php?t=2203

but I guess you know that already... :)
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

:) yes I know that ..I was already recompiling with that code ..but thanks a lot for trying to help jox.

...was ever somebody coding something similar in Irrlicht? Free movement in all three axis???
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

:lol: ...I was building my rotation code on that article!!!
jox
Bug Slayer
Posts: 726
Joined: Thu Apr 22, 2004 6:55 pm
Location: Germany

Post by jox »

uhm ok... :roll:

can you discribe in what manner "pitch and roll don't work correctly"? Is it like arbitrarily or does it follow any kind of rule?
arras
Posts: 1622
Joined: Mon Apr 05, 2004 8:35 am
Location: Slovakia
Contact:

Post by arras »

Sure and thanks a lot for trying to help once more:

...let say original Yrotation is 0 (vector3df r = (0,0,0) from code at the begining of this post ...one that use matrix4)
if I try to roll (vector3df rp = (0, 0, 0.4f) for example ) I get final rotation like (0,0, -179.6) ...should be (0,0, 0.4f)

If I try to pitch instead:
original rotation is -vector3df r = (0,0,0) I try to pitch up vector3df rp = (-0.4f, 0, 0) I get final rotation (0,0,180) ...should be (-0.4, 0 ,0) of course.

...similar if Yrot is 180 ...also some angles on X and Z axis but I cant track them.

If Y rotation is bit difrent let say 0.05 than code works fine...

You can look at it yourself if you can spare some time downloading -I made test program out of demo:
-use save as to download-
http://members.lycos.co.uk/arras1/download/SFtest.zip
use s/w to pitch q/e to roll and a/d to turn ship
Post Reply