EM2012 @ 7dfps

Share with us how are you using the powerrrr of the force

Moderator: Alain

EM2012 @ 7dfps

Postby Marc » Tue Jun 12, 2012 8:08 pm

Hi !

I'm participating in 7dfps (http://www.7dfps.org) using Newton Game Dynamics and Ogre3D. My game can be downloaded here: http://7dfps.org/?projects=2926

Instead of guns, you shoot a soccer ball in this first person shooter :)

I use the CustomPlayerController for the men. The ball is a sphere and the soccer field including the goal is a triangle mesh. Besides simulating the physics, I also use newton's scene management for spatial queries needed by the game logic/ai.

Image Image

Marc
Last edited by Marc on Mon Jun 18, 2012 10:38 am, edited 3 times in total.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: EM2012 @ 7dfps

Postby Julio Jerez » Wed Jun 13, 2012 1:02 pm

Marc wrote:Besides simulating the physics, I also use newton's scene management for spatial queries needed by the game logic/ai.
Marc


really? how you do that? :mrgreen:
you are ahead of my them because One of et hpalne for core 300, si a genral Scene querie manager, for and streamming and tuff liek acclision.
but that is a long term project.

is this core 300?
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: EM2012 @ 7dfps

Postby Marc » Thu Jun 14, 2012 1:52 pm

No it's not core300. I tried that approximately 2 months ago but I wasn't able to get the customplayercontroller working with core300. So this is still 2xx.

For the spatial queries for the logic, I generate a body with volume I'm interested in on demand, set a special material, do NewtonCollisionUpdate(nWorld), collect the info from the collisioncallback and destroy the body. This is probably not very efficient, but it's easy. Especially for this project it is fast enough - there are only 23 moving objects and maybe 10 static.

Besides that, I differentiate between complex-ai-steps and simple-ai-steps. I always do a complex ai step and then a simple one. During the complex steps, I do these spatial queries and during the simple ones, the units just continue doing what they planed the last complex step. That way I don't have to calculate the complex ai every iteration. The player hardly notices that because I do 60 steps per second, so the worst case is 120ms or so delay until the complex ai notices important changes.

Here is some code that shows the general idea of my spatial queries right now. Whenever I need to get all objects inside a sphere, I call QuerySphere3() in the logic code (during a complex ai step).

Code: Select all
   static void CallbackProcess(const NewtonJoint* contact, dFloat timestep, int threadIndex)
   {
      NewtonBody * body0 = NewtonJointGetBody0(contact);

      MSpatialNewton3E < TYPE > * t = (MSpatialNewton3E < TYPE > *)NewtonWorldGetUserData(NewtonBodyGetWorld(body0));

      int body0group = NewtonBodyGetMaterialGroupID(body0);
      TYPE v;
      if (body0group == t->materialgroup0)
      {
         v = (TYPE)NewtonBodyGetUserData(body0);
      }
      else
      {
         NewtonBody * body1 = NewtonJointGetBody1(contact);
         v = (TYPE)NewtonBodyGetUserData(body1);
      }
      t->queryresult->o[v] = 1;      // add this object to the result hashmap
   }

   
   QueryResult * QuerySphere3(const float x, const float y, const float z, const float rx, const float ry, const float rz)
   {
      NewtonCollision * col = NewtonCreateSphere(nWorld, rx, ry, rz, 0, 0);
      NewtonCollisionSetAsTriggerVolume(col, 1);

      float p[16];
      int i;
      for (i = 0; i < 16; ++i)
      {
         p[i] = 0;
      }
      p[0] = 1;
      p[5] = 1;
      p[10] = 1;
      p[15] = 1;
      p[12] = x;
      p[13] = y;
      p[14] = z;

      NewtonBody * body = NewtonCreateBody(nWorld, col);
      NewtonReleaseCollision(nWorld, col);
      NewtonBodySetMassMatrix(body, 1.0f, 1.0f/6.0f, 1.0f/6.0f, 1.0f/6.0f);
      NewtonBodySetUserData(body, 0);
      NewtonBodySetMatrix(body, p);
      NewtonBodySetMaterialGroupID(body, materialgroup1);

      queryresult = new QueryResult();
      NewtonCollisionUpdate(nWorld);

      NewtonDestroyBody(nWorld, body);

      return queryresult;
   }


P.S.: The current version has several enhancements. I updated the link in the project page on 7dfps in the first post http://7dfps.org/?projects=2926
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany

Re: EM2012 @ 7dfps

Postby Julio Jerez » Thu Jun 14, 2012 5:03 pm

Marc wrote: I tried that approximately 2 months ago but I wasn't able to get the customplayercontroller working with core300

Ha yes I still have no gotten around to fix it.

Marc wrote:For the spatial queries for the logic, I generate a body with volume I'm interested in on demand, set a special material, do NewtonCollisionUpdate(nWorld), collect the info from the collisioncallback and destroy the body. This is probably not very efficient, but it's easy. Especially for this project it is fast enough - there are only 23 moving objects and maybe 10 static.

One of the cool feature for core 300 is the unification of the collision and the rigid bode in the collision broad phase.
In core 200 and still in core 200 the representative of a body in the prophase is appetite to the body itself, with the new collision proxy, the entry of a body in eth collision phase will be a pointer to it collision instance.
This will allow for the introduction of new type of objects.
Stuff like Goth, Particle emitters, soft bodies, and other stuff that not necessarily have to be rigid bodies.
There will be not need for an extra Collision only update, you can query the state of a single body any time similar to the way is done for rigid bodies now.

for example any applicacation will be able to place graphic only objects in the broaphase by apending them the user data to the collison instance and adding the to the broaphase. This is what some engine call a kynematic body.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: EM2012 @ 7dfps

Postby Marc » Mon Jun 18, 2012 10:39 am

Sounds good. ;)

The contest is finished. I updated my initial post with the current screenshots.
Millenium Project Enterprises - Hobbyist Gamedev Group http://www.mpe-online.org
Walkover is now on Steam => http://store.steampowered.com/app/348700/
User avatar
Marc
 
Posts: 281
Joined: Sun Mar 14, 2004 4:07 pm
Location: Germany


Return to User Gallery

Who is online

Users browsing this forum: No registered users and 9 guests

cron