• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
JustJim

Calculating Relative Height and Angle

4 posts in this topic

Hey there. I'm new here, but already need help with XNA/Monogame (well it's more Math and Phyics in fact).

 

Im writing a little game for fun and came to some problems regarding calculations.

 

First a little overview:

The Game is like a little Flight Simulator, with one significant change: The Planet should be a Sphere.

For Pitch and Roll I used Quaternion-Calc (through tutorial, because I'm not that much into Quaternions),

so the ship can Roll and Pitch around its own axis.

 

I wanted to add some physics into the game, namly upforce and downforce.

For that I want to calculate the relative height first to make the downforce and upforce decrease when going higher till zero.

 

Question A:

How do I determine the relative Height to the surface?

The Planet is just a Sphere in this state, and I want to make the height over Sea-Level, so there

won't be a Problem when adding Terrain.

 

My thoughts for a Solution to A:

Could I just calculate the Distance of the Ship to every point of the Planet and pick the one with the

smallest distance? Or would that be a waste of time?

Another approach was to just calc the distance from Point(0,0,0) and subtract the radius of the planet.

Would be much easier then, I think.

 

I'll go on:

The upforce should not be affected by Roll-Angle but by the Pitch-Angle.

If the Ship goes up on 90° the downforce would be zero, so to say.

 

Question B:

How do I determine the relative Pitch to Surface?

As I'm not used to Quaternions I just tried out.

When using rotation (quaternion) there is no matter what (rotation.X, rotation.Y, rotation.Z, rotation.Y),

it won't give me the right Angle.

As the Rotation is calculated by pitch-angle (rad) and roll-angle (rad) i tried to use the cos(pitch-angle)

which will work fine as long as the surface is not a sphere and the ship wont roll.

 

My thoghts for a Solution to B:

My theoretical approach was to use the radius of the planet and building a Tangent on the Sphere on the 

nearest position of the ship to the surface in the direction the ship is flying ( or is nearest to when flying upwards).

So to say, the Tangent has the direction that is 90° off to the direction the Wing-Tip goes to.

With this Tangent I could calculate the angle between it and the ships direction.

 

Question C:

How can I manage it to let the Plane fall to the surface if Downforce is higher than Upforce and both are not Zero?

 

My thoughts for a Solution on C:

Maybe I could use the Vector between the nearest point on the Sphere to the Ship, normalize it and devide it by a

value that depends on the downforce in regarde of height. Meaning the Normalized Vector will be "unnormalized"

so it gets bigger when getting nearer to the surface.

I won't use air-Resistance as a variable to determine the falling speed so this won't be a Problem.

then i could cange the Position-Vector of the ship to get closer to the surface by the rate of the calculated Vector.

 

I would appreaciate if anyone has a better solution to this problems or would comment on my approaches so I can

learn from it!

 

Thank you!

 

Edit:

Ah I forgot a point in regards of Gravitation:

I don't want to have this hard Physics in the game so I decided to

make a radius in where the Gravitation starts to play.

So to say: if the ship collides with the atmosphere, the gravitation starts to go up.

This makes it a lot easier when having more than 1 planet.

Edited by JustJim
0

Share this post


Link to post
Share on other sites

For question A -- distance to surface:

I'd probably just do distance between plane and center of the planet it flies around. Then subtract the radius of the planet.

0

Share this post


Link to post
Share on other sites
A) distance to surface = distance to center - radius (as Lactose! said).
B) Compute the dot product of the vector from center to craft and the forward vector and convert to an angle using the inverse cosine function, then take Pi/2 - that angle.
C) You don't need to do anything special: Compute gravity, lift, drag, thrust and any other forces acting on the plane, add them together to compute the total force and let integration do the work.

As a general comment, it looks like your math skills might not be up to snuff. Perhaps you could reduce the scope of the project? Have you tried to make a flight simulator where the land is a rectangle? That might be a good stepping stone between where you are and where you want to be.
1

Share this post


Link to post
Share on other sites

Ah well, actually I study computer-science and have a avarage math-background.

I just got confused about the Quaternion-Calc (and never made that more on Vector-Algebra than needed since XNA/Monogame - Start)

 

You just valdidated Point A.

 

Your Answer to point C is what I thought of. Just wanted to see if I could calc the Downforce-Vector like that to add it to the rest, so it would move appropiate.

 

Well on Point C, I'll try your approach. Just came up with the tangent as an work around.

0

Share this post


Link to post
Share on other sites

 

Could I just calculate the Distance of the Ship to every point of the Planet and pick the one with the

If you consider the planet to be round and not influence the vessel in vacuum space, then yes, you will exhibit only against gravitational atraction, safe from molecular reactions. for sure

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0