PeCreateGround() //need to create ground to prevent our object keep falling PeInitPhysics() //initialize physics engine PeShutdown() // the engine to terminate and good bye.
If (objcount = 20000) // at 20000th frame we will end our physics lession!!
If (counter = 155) // at 155th frame we will drop the bullet!! Static void MainLoop() // this function use for check frame progress and what we want to do PeSimulationStep(0) // if you want to pause simulation send 1 here. Static void stepSim( int n) //use for step our simulation ahead If (j = 14+1-k*1) // the higher of row have less column Y axis will be static so just leave it -6.0įor (j=1 j<=15+1 j++) // we want to create 15 column of domino tower. we want to create domino and set position related to i,k values. If (i <= a) // the higher of row have less column If (i = 15 + 1 - k * 1) // the higher of row have less column this for "|" shape of dominosįor (i=1 i<=15+1 i++) // we want to create 15 column of domino tower same as aboveįor (k=1 k<=7+1 k++) // we want to create 7 row of domino tower. Int x //this is optional this variable for receive value returning from engine it useful for debuging. this function will call when initialize our scene Static void CreateTower() //Create domino tower. Objcount += 1 //we just created it so we will add 1 to our object counter X = peAddForce(objcount, -100.0f, 0.1f, -100.0f) // tell engine that we want to add force to which object in this case we add to bullet(lastly added) and vector X,Y,Z of force we want object to move(in which direction) more force cause more directional velocity to the subject. X = peCreateObjEx(1) // now we create object here we tell engine what object type(shape) we want to create 0=box, 1 = sphere, 2 = capsule X = peSetDensity(2.0f) //is it heavy? o.5 is default value 2.0(bullet) mean 4 time heavier than 0.5(domino) if the volume is equal X = peSetObjSize(0.5f, 0.5f, 0.5f) // how big of object relate to X,Y,Z axis X = peSetObjRot(Random.Next(), Random.Next(), Random.Next(), Random.Next() * 360) //tell engine how much angle of object we want to rotate before create it at X,Y,Z and how much angle value as radiant X = peSetObjPos(10.1f, -6.0f, 10.5f) //tell engine which position we want to create object in word space at X,Y,Z axis Int x //this is optional this variable for receive value returning from engine it useful for debuging
Random Random = new Random() //create new instance of ramdom class use for generate randomize number Static void drop_object() //this function for droping object to user scene current we use it to shoot the bullet Static int objcount // this will counter how much object we created so we can tell engine which the last object we just create Static int counter //We will use it to count rendered frame for adding some liner interactive We will create a little dominoes tower and hit it with a bullet.
This example shows how to create a 3D physics simulation and how easy it is to use PeaceEngine. PeaceEngine has a standard API for use with various computer programming languages, currently supporting PYTHON, VB.NET and C#. It has built-in physics (in the development stage) and integrated 3D graphics with hardware accelerator using OpenGL. PeaceEngine is written in C++ to optimize speed and performance.
You can write an application faster, because you can focus on the things specific to your application, rather than every tiny detail about how it's rendered, the physics. So you can write your application without implementing the low-level stuff yourself. The idea for using 3D or a Physics engine is to reduce the amount of time and lines of code.