Add impulse to Kinematic Body?

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Add impulse to Kinematic Body?

Postby Neo » Tue Dec 11, 2012 1:19 am

So far I know that Kinematic body wouldn't interact with dynamic bodies,
however I also dicovered that NewtonBodyAddImpulse do not work with Kinematic bodies.
So what can I do when I need to add impulse to the Kinematic body? (The only Kinematic body in the scene is player controller,
I need it react to the explosion happened nearby)
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Add impulse to Kinematic Body?

Postby PJani » Tue Dec 11, 2012 4:32 am

Actually you can't, you could write your own logics for that sequence. Kinematic body is "static" without any dynamics forces...
| i7-5930k@4.2Ghz, EVGA 980Ti FTW, 32GB RAM@3000 |
| Dell XPS 13 9370, i7-8550U, 16GB RAM |
| Ogre 1.7.4 | VC++ 9 | custom OgreNewt, Newton 300 |
| C/C++, C# |
User avatar
PJani
 
Posts: 448
Joined: Mon Feb 02, 2009 7:18 pm
Location: Slovenia

Re: Add impulse to Kinematic Body?

Postby Neo » Tue Dec 11, 2012 5:12 am

PJani wrote:Actually you can't, you could write your own logics for that sequence. Kinematic body is "static" without any dynamics forces...

Can can get the Kinematic body via NewtonWorldForEachBodyInAABBDo ?
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Add impulse to Kinematic Body?

Postby Julio Jerez » Tue Dec 11, 2012 8:50 am

if you are using the CustomPlayerControllerManager, it has a update funtion where you are in control, o fteh player velociy
the callcack look like this
Code: Select all
   virtual void ApplyPlayerMove (CustomPlayerController* const controller, dFloat timestep)
   {
      NewtonBody* const body = controller->GetBody();

      BasicPlayerEntity* const player = (BasicPlayerEntity*) NewtonBodyGetUserData(body);
      PlayerInputs (controller, timestep);

                     
      // calculate desired linear and angular velocity form the input
      dVector gravity (0.0f, DEMO_GRAVITY, 0.0f, 0.0f);

      // set player linear and angular velocity
      controller->SetPlayerVelocity (player->m_forwarSpeed, player->m_strafeSpeed, player->m_jumpSpeed, player->m_headinAngle, gravity, timestep);

                                // here you apply the velocity explsion velocity.  something like.
                                expVelocity  = expVelocity - expVelocity.Scale (timestep * 0.25);
                               // when the explsion havvemen you set expVelocity to the velocity that the impulse will create, then expVelocity will be reduce gradually
                                dVcetor veloc;
                                NewtonBodySetVelocity (player, veloc);
                                veloc += expVelocity ;
                               NewtonBodySetVelocity (player, expVelocity );
   }

you can do some experimentation untill you get wan you want.


Neo wrote:Can can get the Kinematic body via NewtonWorldForEachBodyInAABBDo ?

is that right? kinamtic bodies are bodies, NewtonWorldForEachBodyInAABBDo should collect players if they are in the AABB o fteh scan
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Add impulse to Kinematic Body?

Postby Neo » Tue Dec 11, 2012 11:00 am

Oh...Typing error,sorry :oops:
Julio Jerez wrote:if you are using the CustomPlayerControllerManager, it has a update funtion where you are in control, o fteh player velociy
the callcack look like this
Code: Select all
                             // when the explsion havvemen you set expVelocity to the velocity that the impulse will create, then expVelocity will be reduce gradually
                                dVcetor veloc;
                                NewtonBodySetVelocity (player, veloc);
                                veloc += expVelocity ;
                               NewtonBodySetVelocity (player, expVelocity );
   }

The NewtonBodySetVelocity is called twice. Is it this code:
Code: Select all
 dVcetor veloc;
                                NewtonBodyGetVelocity (player, veloc);
                                veloc += expVelocity ;
                               NewtonBodySetVelocity (player, expVelocity );

And What's the type of expVelocity? dVector?
Neo
 
Posts: 127
Joined: Fri May 11, 2012 12:29 pm
Location: China,Sichuan

Re: Add impulse to Kinematic Body?

Postby Julio Jerez » Tue Dec 11, 2012 12:42 pm

Code: Select all
 dVcetor veloc;
                                NewtonBodyGetVelocity (player, veloc);
                                veloc += expVelocity ;
                               NewtonBodySetVelocity (player, expVelocity );

yes this is correct

And What's the type of expVelocity? dVector?

this would be teh velocity that teh explision impusle wants to apply to the player.
Julio Jerez
Moderator
Moderator
 
Posts: 12426
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 3 guests