Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Irlan

Member Since 08 May 2012
Offline Last Active Yesterday, 06:39 PM

#5227609 Physics engine for a simracing game. Where to begin?

Posted by Irlan on 06 May 2015 - 06:14 PM


I've been reading the "Game Physics Engine Development by Ian Millington" book as I've been recommended to (not ended yet) but still quite lost about how to start with the development, don't really know where to begin...

 

This book is a good introduction, but is outdated. Forget about it.

 

I recommend all Erin Catto GDC slides, here: https://code.google.com/p/box2d/downloads/list. All slides on this website are pure gold, so do the references.

 

Take a look into sequential impulses LCP solver.

 

The most basic dynamics simulation should have rigid bodies and ball-socket joints.

 

You will also need collision detection, which increases exponentially the time needed to create an physics engine.

 

Creating a physics engine from scratch without a solid math background such vector calculus is hard. Especifically, to learn about constrained dynamics, which naturally comes from the robotics/mechanics literature. But is not impossible. Is actually a very good experience, IMHO.




#5225551 3D SAT Problem

Posted by Irlan on 25 April 2015 - 06:42 PM

All the computations are in world space.

 

I made a video testing the solver, with 10 iterations at 60Hz:

 

 

As you see, this is not very stable. One thing I've changed was calculate tangents for each contact point (not per manifold, as the normal). Even this way it seems to not converge. The points are kind of blinking because the one shot manifold generation way, so, since that there is some hidden problem, it will compute different ones each step. 

 

Disabling the angular impulses looks more correct:

 

 

According with Erin Iterative Dynamics this doesn't looks correct. At 10 iterations this should be stable, shouldn't it? 

 

Looks like I need to use the old sphere-plane test, and step through this cool.png . 




#5224894 Unsure about how to handle interactions between my classes

Posted by Irlan on 22 April 2015 - 12:44 PM


Is -> short hand for "contains a pointer to"? If that is the case I think I understand what you are saying. Thinking about it, this actually seems like a good solution since it is so general. Right now I'm trying to come up with a method of sharing something specific between classes, like the Player's hitbox shared with the class Enemy. In the future, if I ever wanted to add more complex AI behavior like, maybe having the Enemy respond in a certain way of the Player is moving, I would have to then share Player's velocity vector. Simply giving every entity a pointer to every other entity seems like it is the most general thing to do.
 
That being said, is there any reason this is a bad practice?

 

No. Is a shortcut for "inherits from" I did. All objects came from a base class called CEntity. This is abstraction.  I wouldn't share a pointer between unkown entities in this case. Since the player knows about the enemy just share a pointer. Always keep it simple.




#5224878 Unsure about how to handle interactions between my classes

Posted by Irlan on 22 April 2015 - 11:24 AM

You're lucky that your problem is a high-level one; that is, it sits at the game level (not the engine level). In this case it's actually doesn't matter your architecture (you don't have a scripting system). So you will code game logic, and players will need to know about the enemies anyway.

 

For game logic, there are some fast solutions. State machines can be a fast tool to model A.I. (did several times on the past). Your CollisionHandler is not directly related with the physics library. It depends of the physics library, but the logic settles inside the game level. 

 

IMHO instead of digging into more (general) solutions such component systems, continue with your simple entity hierarchy and just code game logic on the classes. In the case of the player-enemy, there is a game in between, and doesn't make sense abstract this.

 

A simple hierarchy which I used a lot on the past is:

 

CEntity

CActor->CEntity

CCamera->CEntity (or CActor)

CVehicle->CActor

CTank->CEntity (or CVeichle)

CPlayer->CActor

CEnemy

 

etc.

 

So a player can have a pointer to the enemy and a pointer to the camera. The game state is a collection of cameras for each side of the map and has a list of players and enemies, which will be used to check game logic, transit between game states, apply scores, monetization, etc. Actually, there is some kind of abstraction in between here:

 

CEntity

CActor->CEntity

CCamera->CEntity (or CActor)

 

In this case they are related to a scene (in game-object-pattern words, you can think of this as the GameObjectManager or EntityManager). But his applies only if you're  building an engine from scratch.




#5223793 Rate my Game Loop

Posted by Irlan on 16 April 2015 - 03:25 PM

Use the timer class as described here to avoid floating point precision issues. Then, one frame is just

UINT64 ui64CurTime = m_tRenderTime.Update();
while ( ui64CurTime - m_tLogicTime.CurTime() > FIXED_TIME_STEP ) {
        m_tLogicTime.UpdateBy( FIXED_TIME_STEP );
        //Update the logical-side of the game.
}
Render();



#5223725 Rigid Body Physics - Inertia Tensor Space

Posted by Irlan on 16 April 2015 - 10:57 AM

You can check the derivation Dirk described here or at David Eberly Game Physics book.

 

The integrals for simple shapes (such blocks and spheres) are given in tables. Based on the volume, density, mass of the object you can get the correct local inertia.




#5221673 Factory, managers, interfaces for noobs?

Posted by Irlan on 06 April 2015 - 12:52 PM


I have been looking through some source code of 'simple' game projects and I keep seeing these words pop up:
 

The main advices I have from the top of my head are:

  • #1 Single Responsability Principle (SRP)
  • #2 Components over inheritance

#1 is mandatory.

#2 means good code maintence.

 


For instance are they to do with OOP, or a general software engine architectural pattern?
 

On event based applications, a lot of design patterns applies correctly to it, but a game simulation it is different because it is run-time application. IMHO, the state pattern is used a lot in games.

 


something Manager e.g. GameManager

 

Do not create a class called Manager and another SomethingManager class extending it. Use the the SomethingManager class directly. In this case is the same thing of creating a class called CClass and extending it. Not every class is an interface; review your needs. To help you defining what are the classes that needs interfaces, use #1.




#5221207 Need help choosing a language

Posted by Irlan on 03 April 2015 - 03:50 PM

There are thousands of reasons why C++ can be considered the game industry standard language, not only on the game industry, but in the computer science field too.

 

I would like to reiterate:

 

C++ is a language for scientists.

 

Most of the mathematics/computer graphics/real-time physics simulations softwares uses C++. Game development is math by nature, so it fits inside the category.

 

I believe most universities out there starts with C and jump to C++ at some point (maybe start with languages such Python) to implement basics data structures algorithms or explain computer architetures, operational systems design, etc.

 

In my unv., for example, the sequence is C-->C++-->Java. The reason is that Java approaches to a web-development environment, such database transactions, etc. that has a lot of existing libraries that makes the life of the programmer easy in comparison to C++. Java is made for administrative companies. It has a lot of good specifications. Unfortunately you can't really "see how it works" internally. I'm not saying that Java is only-for high-level systems such the ones I've mentioned, but you just can't implement something on it knowing every part of the application transparently. Minecraft is on Java, I believe. 

 

C++ being a very used language doesn't means that has the best libraries to make your life easier. Java, being a high-level language, means that people can learn without much trouble, which means that they can invest their time in libraries to make the work easier.  

 

I wouldn't say: "pick the language you like". For most that looks a logical advice, it is a broad term to use.

 

I would say "review your needs".




#5221088 Need help choosing a language

Posted by Irlan on 03 April 2015 - 05:37 AM

While learning C++ you'll find topics such memory & cache management, OOP, etc. in more detail. It worth to learn.

 

One of the things that we usually don't find on a C++ is multithreading (even the basics). I know that you're starting, but keep in mind that for this type of topic you'll need to get another type of books. 

 

Most of the APIs out there have a well defined documentation for C++ (such DirectX e OpenGL); easy to read.

 

C/C++ are not easy. Takes time to understand because is a low-level language compared to Java.

 

C++ is the standard industry language.




#5219684 Distance between OBB's

Posted by Irlan on 27 March 2015 - 01:10 PM

From my experience:

 

SAT works well as a single-shot contact points generator;

GJK + single contact point for collision resolution only works well if you implement a contact point cache;

 

I haven't implemented SAT. So, I can say only about GJK and EPA method.

 

The GJK-SAT is a alternative version that exits more quickly if there is an SA bewteen the polyhedras. It is the simplest thing to implement. Molly Rocket's GJK implementation is a good start. 

 

IMHO while looking for implementing a collision detection system we should care about the contact information fist rather than the method itself. In this case, even with a fully-working GJK + EPA method, I think that it more time we should invest in robust one-shot methods such SAT rather than aproximating things more than they're.




#5219200 Game Development Advice Along with Course Help

Posted by Irlan on 25 March 2015 - 07:02 PM

Go to For Beginners and don't look back!




#5218675 Tips for reading mathematic formulae?

Posted by Irlan on 23 March 2015 - 08:58 PM

In Linear Algebra, I think the most used symbols:

 

Rn -> Rm(map from dimension n to m; used a lot in composition of linear transformations (that is; matrix multiplication) )

 

Rand R2 (three-dimensional and two)

 

y = Ax (A is the referred matrix; x is the independent var.; y is the problem solved; both are vectors);

 

Inverses, transposes, domains, images, etc. You should look at some mathematics symbols. I personally think that it is much beauty than art biggrin.png .

 

Calculus:

 

y = mx + b (passes through b; m is the slope);

 

dy/dx = f(y, x) = ODEs (mostly are initial value problems (IVPs); finding the integral of a curve given a initial condition).

 

The most important here is when hearing the word "derivative" immediatly think as its representation being the slope of a tangent line (m). In physics, you use the propagation of derivatives to understand better. Eg.: velocity = dx/dt (x = position); acceleration = dv/dt (v = velocity), etc. 

 

Well, I'll stop here...happy.png You asked about notation, not mathematics (before someone writes a book here).

 

Since you mentioned Prof. G.S., I recommend that you take a look at his MIT free courses that can be found here




#5216474 How do game programmers visualize the Maths on their game?

Posted by Irlan on 14 March 2015 - 12:36 PM


How did the programmer know if he is going to use Sin or Cos? I tried replacing it with cos still the same effects.
Sin and cos and tan will be on trigonometry part of math but where will you visualize it on screen? Even If i think that the screen is made up of many triangles or two triangles like this

 

He is using sin only to generate a simple oscilation in function of the time (independent variable). It could be generated with a cos evaluation in the same way, basically.

 
Both sin and cos (that are trig functions; transcendental) are used to help modeling some sword of phenomena in mathematics and help solving a wide range of problems that are related to circunferences. While there are a big concept behind it, this is called mathematical modeling. 
 
But in games there's no rule to follow in this simple specific case (UI). Certain areas such graphics, physics needs to follow a more mature mathematical approach.
 
How do a programmer visualize math?
 
What makes a ball oscilates it is the code that is behind the big picture. 
 
Graphics programmers recognizes certain type of lighting model because they know how to apply these models and of course knows the results it generates.
 
Physics programmers can recognize if a game is using a physics engine to simulate the objects behaviour in function of time because they do physics. 
 
I think your question is: How to a programmer applies certain behaviour to a game using mathematics? The answer is simple: using what mathematics supplies for you (applying the mathematics), most of the time using mathematical functions.
 
The game programmer then look at the x and y values of the cartesian coordinate space and he see that he want to generate a smooth behaviour of something. Then he sees that such simple tasks could be generated using such trig functions or related for its simplicity. Then he passes a value to the function uses that value to position/orient/ something on the screen.



#5216038 Saving old gamestates

Posted by Irlan on 12 March 2015 - 05:51 AM

The title you've posted doesn't match up with what you're asking. Please tell the moderator to change to: "Multi-threading the game engine".

 
Only one of the benefits of this system is easier multithreading for non-essential subsystems. My question was about whether this kind of system is feasible to begin with; not whether it's an ideal method of multithreading.

IMHO "Saving game states" is more appropriate for saving the game in files.


#5215977 Weird problems inside and outside visual studio (Component based engine)

Posted by Irlan on 11 March 2015 - 10:39 PM

thanks Irlan! :) , this are my classes headers in conflict:
 
MeshRenderer.h

class ColorMaterial;
class MeshRenderer : public Component
{

private:
	ColorMaterial* m_material;

//...
ColorMaterial.h
class MeshRenderer;
class ColorShader;

class ColorMaterial
{
	
private:
	ColorShader* m_ColorShader;
	MeshRenderer* m_MeshRenderer;

//...
ColorShader.h
class ColorMaterial;

class ColorShader
{
private:
	ColorMaterial* m_material;	
The rest of the code (.h and .cpp) i believe is fine. I have been following the tutorials from rastertek.(http://www.rastertek.com/tutdx11.html) :rolleyes:
I have used forward declarations in these classes to communicate between classes, is this the right way?

Yes. Forward declarations reduces dependencies and increases compile time; but there are compile time and run-time, and obviously the problem it is not with compilation because it wouldn't even compile if it was.

Check if you're assigning the addresses to pointers. A NULL pointer can't acess anything.

Try debugging your application using break points and the call stack. On MVS both stays on the bottom right corner of the windows. Once you've figured out which part, post here.




PARTNERS