Jump to content

  • Log In with Google      Sign In   
  • Create Account

Tapped

Member Since 29 Jan 2011
Offline Last Active Feb 03 2014 01:40 PM

#5100977 How to create a physics engine

Posted by Tapped on 13 October 2013 - 04:12 AM

If you want to make a physic engine, that may be used in a real project, you should hardware accelerate your physic engine for the GPU, by OpenCL or just by OpenGL shaders( a lot harder though, and more hackish...). That's what makes PhysX and Havoks performance so good. 

As people have pointed out, the method and algorithm used in a physic engine is common across the engines. And as L. Spiro said, Real-Time Collision Detection and Game Physics Engine Development are very good books(I have both). So it is up to you, how you gonna implement the engine, however you should have a decent understanding of geometry and physic laws, that you may recall from high-school. Another thing, it takes time to create a physic engine, so it should only be made for learning purposes or as part of your CV.




#5094262 Opengl ES on Desktop

Posted by Tapped on 15 September 2013 - 11:47 AM

Yeah, you can use OpenGL ES on desktop computers. However it is both platform and GPU dependent approaches for this to work. If you are using linux, just download the mesa-gles drivers, or even better find the vendor specific drivers for GLES.

I suggest to use the SDK from the GPU vendor on windows, which is http://developer.amd.com/tools-and-sdks/graphics-development/amd-opengl-es-sdk/ for AMD and https://developer.nvidia.com/tegra-resources for Nvidia.
Look here for installation instructions for Nvidia emulator: http://developer.download.nvidia.com/tegra/docs/win_es2emu_pack_v100.pdf

 

You may also look at http://www.imgtec.com/powervr/insider/sdkdownloads/index.asp for a platform independent solution.

 

Good luck, and remember I have yet not found a 100 % stable solution for my hardware setup, so don't expect to much, and happy debugging ;) 




#5067297 C++/SDL Game Design Guidance

Posted by Tapped on 04 June 2013 - 03:00 AM

Why not use the existing tile system as a grid?
Here is a snippet that maybe useful:

void DrawTilesWithinFrustum(Vec2f worldPos, int windowWidth, int windowHeight)
{
    Vec2f minIndex = worldPos / Vec2f(TILE_SIZE_X, TILE_SIZE_Y);
    Vec2f maxIndex = (worldPos + Vec2f((float)windowWidth, (float)windowHeight)) / Vec2f(TILE_SIZE_X, TILE_SIZE_Y);
    
    // We want to be sure that we draw the tiles that are slightly in the frustum.
    maxIndex.x += 1;
    maxIndex.y += 1;

    int numColumns = (maxIndex.x - minIndex.x) + 1;
    int numRows = (maxIndex.y - minIndex.y) + 1;

    for(int row = 0;row < numRows;++row)
    {
    	for(int column = 0;column < numColumns;++column)
    	{
    		int index = (unsigned int)(minIndex.x + row) + (unsigned int)(minIndex.y + column) * TILE_SIZE_X;
    		Tiles[index]->Draw();
    	}
    }
}

worldPos is the position of the camera. This approach would run a lot faster than bruteforcing each tile. It will only loop through the tiles that you want to draw. 

Beware that this code snippet is not tested, so it may include type errors etc.

 

Good luck.




#5066874 what the mechanics behind this ?

Posted by Tapped on 02 June 2013 - 07:53 AM

I would have solved this problem with simple classic physics. Look at your problem as a composite system. Your character got a force which makes it move. Futhermore the character would have a force, which makes it jump. It may also have a drag force, and lastly a gravity force.

 

By using D'Alembert's principle, you would calculate the final force, which is acting on the object. It implies that, if we have a set of forces acting on an object, we can replace all those forces with a single force, which is done by just summing the forces together. 

 

So I would have calculated the forces, the acceleration, the velocity and the position of you character, by using vector math. Then i would just do a simple bounding box test between the character and the obstacle, to check if the character is inside.

Here is a link for a simple tutorial, which explains what i have mentioned. 
http://ianqvist.blogspot.no/2009/09/2d-physics-engine-tutorial-part-3.html




#5063487 Events and Entity Component Systems

Posted by Tapped on 21 May 2013 - 06:04 AM

This is one of the biggest problem with component systems, how the components communicate when they don't know about each other.

This problem is often resolved with an internal message system. Unfortunately it does not work well for all cases.

 

A solution for the health problem, can be that all objects that wants collision information sends a reference to a collision data structure, which is part of the entity, to the physic system.
Then the physic system, fill collision data for entities with collision data.

Now you can just check this collision information in each update, and call the sound and health system.
The problem with this solution, is that some entities may want more information about the collision than others, so unused information may be stored.
Hence, this breaks the idea of component based design. 

 

Another solution is to make a query based physic system. Where entities can query for collision information. You can then solve the problem with unused information by creating different types of queries. The query system can also be used for ray tracing etc.

 

Both solutions require update functions, so if you want a very strict implementation of ECS these solutions is not appropriate.




#5063466 Moddable but not open source?

Posted by Tapped on 21 May 2013 - 04:06 AM

There are two approaches you can choose between. Both of them needs to be done in the design phase of your project.

 

The first one is to make a plugin based system, using DLL's(dynamic link library) on Windows, or shared libraries on UNIX platform.
You start of creating an executable core, with the engine and other things you don't want a modder to have access to.

However keep in mind what you want the modder to have access to, and export these functions.
Now you can choose to make the game as a mod, or create the game explicit in the executable.
The first approach is the easiest way, and used by Valve for example.

 

The second approach is to give the modder a scripting language, which is linked with some of the functions in your game.

This can easily be done with Python, or Lua. Most games made to day have scripting support, used during the development cycle.
Unreal Tournament uses this approach for example.

When it comes to assets, you need to have a copyright license. The copyright license must be there even if you don't make the game moddable.
However most games use compiled assets, which often are hard to edit or use. This way the modders can only use your assets in your game, but can't edit them.
You should also ship the tools used for compiling assets, so that the modders can create their own assets.




#5062349 Visual Studio 2010 C++ | Folder structures

Posted by Tapped on 16 May 2013 - 12:58 PM

I will show you how i do it.

  • First create a project, where "Create directory for solution" is ticked. 
  • Then remove the project from the solution, by right clicking in the Solution Explorer on the project.(It will not delete the project, only lose reference to it)
  • Now create a new directory for the project file, and call it what you want.
  • Copy the project files from the directory storing the project into your new folder.
  • Back in Visual Studio, add the existing project to the solution file, by File->Add->Existing Project.
  • Now you probably want to define the binary output folder.
  • This is done in the project properties. General tab->Output Directory. Remember to set both Debug and Release.
  • Also, set the path for your source folder, when you create new source files. This is done with the Location property in the add file window.
  • Git got a handy setting file called .gitignore. Use this file to ignore binaries, objects, and other temporary data generated by visual studio.
  • I often use the following ignore file, with some customization for Visual Studio: https://github.com/github/gitignore/blob/master/VisualStudio.gitignore

 

That's it, customize as much as you want :)




#5039633 Level data organisation advice?

Posted by Tapped on 05 March 2013 - 12:51 PM

Why not make an event structure like following:





public struct Event_t
{
char eventType;//Byte alignment error, for more memory efficient storage, should this byte be the last element of the struct!
int eventDuration;
short eventSize;
}

Event duration is the time from this event to next event. The event duration can be zero, which means that the event would be processed simultaneously with the next event. The event size are the number of bytes of the event(can be discarded if the size of the types of events are static). From here you can make different Event types. For example:





public struct EventMessage_t
{
int nMessageLength;
string szMessage;
}

After you have loaded the level. You can derive the event structs from a base event struct. Then you can make an array of base event structs, which you can easily process, by casting the base struct to the right event type structure.




#4980446 Marching Cube Holes

Posted by Tapped on 15 September 2012 - 12:19 PM

Now i have implemented the information i got from: http://gamedev.stack...le-perlin-noise
Even if i did that, i still had cracks, but then after a lot of testing of different sample types, i finally got it work. It worked when i used this sampler:
__constant sampler_t randomVolumeSampler = CLK_NORMALIZED_COORDS_TRUE | CLK_ADDRESS_MIRRORED_REPEAT | CLK_FILTER_LINEAR;


float4 realGridPos;
realGridPos.x = gridPos.x * voxelSize;
realGridPos.y = gridPos.y * voxelSize;
realGridPos.z = gridPos.z * voxelSize;

density.x += read_imagef(randomVolume, randomVolumeSampler, realGridPos).x * 0.8f;

realGridPos is the same as the local position in terms of a block, which in this case range from [0.0, 2.0] for each block.
Here is the result:

http://imageshack.us...383/itworks.png
Thanks for the help! Posted Image


#4851528 Bounding Sphere from OBB

Posted by Tapped on 20 August 2011 - 02:26 AM

Problem with a sphere is that it only haves 1 degree of freedom. You can only xhoose one size for every axe. So if one bounding box axe is slightly bigger the sphere would have more free space because the biggest axe would make the sphere. But on the picture is looks like the box is not in centre of sphere, that's maybe the problem.
And also you are generatimg the sphere wrong. The radius is the biggest axe extent.


PARTNERS