Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Choosing a 3d (space) movement system

Author
Message
Devonps
15
Years of Service
User Offline
Joined: 5th Nov 2009
Location: Nottingham
Posted: 26th Feb 2010 19:34
I would like to create a single player 3D based space shoot-em up and was unsure of which of movement system to use for the players ship, for example: Free flight or Euler based.

Can people comment on which will be easier for me to code?

I would rate my game coding skills as a beginner.

I\'d prefer links to articles so I can learn the answers for myself - but explanations are just as good.

Thanks in advance,
Steve.

Marriage is a circle of rings....
Engagement ring, Wedding ring, Suffering!
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 27th Feb 2010 18:47 Edited at: 27th Feb 2010 18:48
I've gone back and forth between just using the 0 to 360 degree angles that DBPro functions give you, and the results that EZRotate gives you for about 3 years now.

I've actually settled on using the values that DBPro gives you. EZRotate has some good uses, but it's easy to get things turned around in the wrong direction.

If you aren't planning on limiting the users movement in some way on at least one axis, then your biggest hurdle will be overcoming gimbal lock. Aside from that it's just simple rotation using degrees.

Gimbal Lock on Wikipedia.org
http://en.wikipedia.org/wiki/Gimbal_lock

This math site has potential to help if you really want to get into the deep dark depths of the math.
http://www.euclideanspace.com/maths/geometry/transform/index.htm

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 27th Feb 2010 19:35
The thing about DBPro's rotation system is that it's unrealistic in a space scenario. As you probably know, there is no "up" in space, but with DBPro's rotation there is, because all Y rotations are done on the global Y axis. However, not all the rotations are global. X rotations are done on the local X axis.

Free flight is probably best in this case. You won't end up with any gimbal lock doing so anyway. However, it will be problematic to read off angles from the ship, to know in which direction to shoot missiles etc. In this case some matrix math would be really useful, and I've never used DBPro's matrix math commands.

"everyone forgets a semi-colon sometimes." - Phaelax
Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 27th Feb 2010 23:06
Quote: "The thing about DBPro's rotation system is that it's unrealistic in a space scenario. As you probably know, there is no "up" in space, but with DBPro's rotation there is, because all Y rotations are done on the global Y axis. However, not all the rotations are global. X rotations are done on the local X axis."


Could you explain that please? I don't understand the difference between a local axis and a global axis.

Windows Vista 32-Bit Home Premium Intel Pentium Dual-Core @ 1.46Ghz 2038mb RAM
Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Feb 2010 12:13
Well a global axis doesn't change with the rotation of any object, it always stays the same. A local axis does change though, so, for instance, if you're in a car, 'up' for you is always going to be the direction that the ground is facing, even if you end up upside-down somehow.

A local axis changes with your orientation, which is what space is like. If you're in space, it doesn't matter how you rotate your ship - 'up' is always going to be the direction that the top of your head points to.

Gettit?

"everyone forgets a semi-colon sometimes." - Phaelax
Devonps
15
Years of Service
User Offline
Joined: 5th Nov 2009
Location: Nottingham
Posted: 28th Feb 2010 12:51
@Kistech - thanks for the links, the Screw Theory made sense!

@Zotaster - thanks for the extra information.

So far I've managed to rotate my model in 3D with the following code



My next step is to simulate the movement through space and around a 2nd object.

Regards,

Steve.

Marriage is a circle of rings....
Engagement ring, Wedding ring, Suffering!
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 28th Feb 2010 17:33
That code will work, but as Zotoaster mentioned, your turns on the Y axis will be on the Global Y. That's where some of that extra math might come in handy. If turning on the Global Y is acceptable for your purposes then you're all set. (I'm doing that for my game too. It's just easier, and the players are less likely to get disoriented.)

Quote: "However, it will be problematic to read off angles from the ship"


The object angle commands just return the global angles of the ship. So no matter what methods you're using to achieve the rotations you want, the object angle commands will give you the proper global angles of the object.

Zotoaster
19
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 28th Feb 2010 18:46
Ah, yes, you are correct. My bad.

"everyone forgets a semi-colon sometimes." - Phaelax
Devonps
15
Years of Service
User Offline
Joined: 5th Nov 2009
Location: Nottingham
Posted: 2nd Mar 2010 21:10 Edited at: 2nd Mar 2010 23:12
Thanks for the help guys, I've managed to move my spaceship based on the direction it's facing

I've posted my updated code for others to maybe learn from

I've added extra keys to control the ships velocity (increase/decrease) and a key to bring the ship to a dead stop.


What I need to do next is add some code to restrict the ship rotation in all 3 angles.

Edited: As I noticed I had the keystates & angles the wrong way round - doh!

Marriage is a circle of rings....
Engagement ring, Wedding ring, Suffering!
feiting shadow
18
Years of Service
User Offline
Joined: 12th Sep 2006
Location:
Posted: 19th Mar 2010 08:26
zotoaster, you can avoid matrix math using DBP's built-in commands.

Set object to object orientation.
Move object.

And likewise with the camera. Then you simply initiate the movement.

If you wish to do free flight of the missiles without using move object, only use move object initially to find the displacement.

Eg.
Get X,Y,Z
Move object 10
get x y z
Move object back (-10)
Set object x velocity to (New X minus old X)
Do same for Y and Z
Store the X,Y,and Z velocities in a separate variable.

In your main game loop, add an update() that alters the physics to those specifications.

I avoided using sin and cos and made realistic flight doing this, but my HD crashed before I posted.

You can always reference my code under WIP to see how I handle objects. Remember there's a tutorial on using my already-made engine. (3d space engine dbp)

I got bored before adding collisions, so it is not complete for this, but still workable.

Also, I rarely come here (until school ends at least), so don't rely on me returning anytime soon. Sorry.

fs

Signed
------

Login to post a reply

Server time is: 2024-11-24 17:23:07
Your offset time is: 2024-11-24 17:23:07