About Store Forum Documentation Contact



Post Reply 
[solved] Cant set freezePos when freezeRot(true)
Author Message
Mardok Offline
Member

Post: #1
[solved] Cant set freezePos when freezeRot(true)
I cant set actor.freezePos when freezeRot(1)

It's bug or physx limitation?
(This post was last modified: 06-08-2014 01:03 PM by Mardok.)
05-27-2014 12:31 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Cant set freezePos when freezeRot(true)
Hi,

I've just tried modifying "multi shaped actors" tutorial:
Code:
/******************************************************************************/
Actor ground,
      ball  ,
      actor ;
/******************************************************************************/
void InitPre()
{
   EE_INIT();
   App.flag=APP_MS_EXCLUSIVE;
}
bool Init()
{
   Cam.dist=4;

   Physics.create(EE_PHYSX_DLL_PATH); // create physics by specifying the path to physx dll's
   ground .create(Box (15, 1, 15, Vec(0, -2, 0)), 0);
   ball   .create(Ball(0.3, Vec(0, 1.3, 0)));

   ActorShapes shapes;                           // actor shapes
   shapes.add(Box (0.2                       )); // add box  to 'shapes'
   shapes.add(Ball(0.2,     Vec(-0.3, 0.2, 0))); // add ball to 'shapes'
   shapes.add(Ball(0.2,     Vec( 0.3, 0.2, 0))); // add ball to 'shapes'
   actor.create(shapes).pos(Vec( 0.0, 0.3, 0) ); // create actor from 'shapes'
   actor.orn(Matrix3().setRotateZ(0.5));

   actor.freezeRot(true).freezePos(true);

   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(0.1, 10, CAMH_ZOOM|CAMH_ROT);

   Physics.startSimulation().stopSimulation();

   return true;
}
/******************************************************************************/
void Draw()
{
   D      .clear();
   Physics.draw ();
}
/******************************************************************************/
and it works fine
05-27-2014 12:47 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #3
RE: Cant set freezePos when freezeRot(true)
Press "Z" to set freezePos(1);

Code:
Actor ground, ball;

void InitPre()
{
   EE_INIT();
   App.flag=APP_MS_EXCLUSIVE;
}

bool Init()
{
   Cam.dist=4;
   Physics.create(EE_PHYSX_DLL_PATH);
  
   ground.create(Box (15, 1, 15, Vec(0.0, -2, 0)), 0);  
  
   ball  .create(Ball(0.3      , Vec(0.0,  0, 0)));
  
    
   ball.freezeRot(1);

   return true;
}

void Shut(){}

bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(0.1, 10, CAMH_ZOOM|CAMH_ROT);

   {
      Physics.startSimulation();
      Physics.stopSimulation();
   }

   flt s=3;
  
  
   if(Kb.bp((KB_Z)))ball.freezePos(1);


   if(Kb.b(KB_W))ball.addForce( !PointOnPlane(Cam.matrix.z, Vec(0, 1, 0))*s);
   if(Kb.b(KB_S))ball.addForce(-!PointOnPlane(Cam.matrix.z, Vec(0, 1, 0))*s);
   if(Kb.b(KB_A))ball.addForce(-!PointOnPlane(Cam.matrix.x, Vec(0, 1, 0))*s);
   if(Kb.b(KB_D))ball.addForce( !PointOnPlane(Cam.matrix.x, Vec(0, 1, 0))*s);

   return true;
}

void Draw()
{
   D      .clear();
   Physics.draw ();
}
(This post was last modified: 05-27-2014 12:56 AM by Mardok.)
05-27-2014 12:54 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
RE: Cant set freezePos when freezeRot(true)
Thank you!

I'm investigating this
05-27-2014 01:05 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Cant set freezePos when freezeRot(true)
Thank you for reporting this issue!
I was able to find a fix, it will work OK in next release.
05-27-2014 01:22 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #6
RE: Cant set freezePos when freezeRot(true)
Hi Grzegorz,

Problem is still there but situation was changed.

When i set freezePos(1) to actor with freezeRot(1) then actor.pos is changing to actor base position defined in actor.create function.

Try it. Press Q to set freezePos(1)

Code:
/******************************************************************************/
Actor ground,
      box   ,
      ball  ;
/******************************************************************************/
void InitPre()
{
   EE_INIT();
   App.flag=APP_MS_EXCLUSIVE;
}
bool Init()
{
   Cam.dist=4;

   // create physics
   Physics.create(EE_PHYSX_DLL_PATH); // create physics by specifying the path to physx dll's

   // create actors
   ground.create(Box (15, 1, 15, Vec(0.0, -2, 0)), 0); // create ground actor from Box and density=0 (which means it's a static actor - will not move)
   box   .create(Box (0.3      , Vec(0.1,  1, 0)));
   ball  .create(Ball(0.3      , Vec(0.0,  0, 0)));



   ball.freezeRot(1);
  
  
   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
bool Update()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(0.1, 10, CAMH_ZOOM|CAMH_ROT);

   // physics update
   {
      Physics.startSimulation(); // start frame simulation

      // physics simulation takes some time, so you can do some calculations here
      // important : you may not modify actors between Physics.startSimulation() and Physics.stopSimulation()

      Physics.stopSimulation(); // get results of frame simulation
   }

   if(Kb.bp(KB_Q))ball.freezePos(!ball.freezePos());


   flt s=3;

   // add forces to ball according to camera
   if(Kb.b(KB_W))ball.addForce( !PointOnPlane(Cam.matrix.z, Vec(0, 1, 0))*s);
   if(Kb.b(KB_S))ball.addForce(-!PointOnPlane(Cam.matrix.z, Vec(0, 1, 0))*s);
   if(Kb.b(KB_A))ball.addForce(-!PointOnPlane(Cam.matrix.x, Vec(0, 1, 0))*s);
   if(Kb.b(KB_D))ball.addForce( !PointOnPlane(Cam.matrix.x, Vec(0, 1, 0))*s);

   // add velocity to ball
   if(Kb.bp(KB_SPACE))ball.addVel(Vec(0, 3, 0));
   return true;
}
/******************************************************************************/
void Draw()
{
   D      .clear();
   Physics.draw (); // draw physical actors
}
/******************************************************************************/

And there is a second problem. When we set freezePos(0) to actor which is in the air then actor is neutral to gravity. Actor will be in the air as long as we use some force.
(This post was last modified: 06-08-2014 02:24 AM by Mardok.)
06-08-2014 02:03 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
RE: [open] Cant set freezePos when freezeRot(true)
Thank you, I'm checking this.
06-08-2014 02:36 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #8
RE: [open] Cant set freezePos when freezeRot(true)
I'll try to fix this and upload an update today ASAP.
06-08-2014 02:43 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #9
RE: [open] Cant set freezePos when freezeRot(true)
Ok thx. I'm working on a puzzle game, and I need it in certain situations.

Good night...
06-08-2014 02:56 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #10
RE: [open] Cant set freezePos when freezeRot(true)
The fix has just been uploaded, please let me know if you'll encounter any other issues.
Thank you! smile
06-08-2014 04:32 AM
Find all posts by this user Quote this message in a reply
Mardok Offline
Member

Post: #11
RE: [solved] Cant set freezePos when freezeRot(true)
Great, now all is fine.

thx
06-08-2014 01:04 PM
Find all posts by this user Quote this message in a reply
Post Reply