About Store Forum Documentation Contact



Post Reply 
Running uphill
Author Message
maxest Offline
Member

Post: #1
Running uphill
I made a simple geometry which consists of two thin boxes. One is a simple "floor", the second one is also a "floor" but is angled a bit (maybe 20 degrees) and the controller has problems when trying to walk uphill. Is there some parameter that I can control, let's say, a number of degrees that the controller can be walking as easily as on a not-angled surface?
02-15-2009 04:10 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
Re: Running uphill
Can you post the code of the two boxes creation?
so I could check it manually.

and how do you update the controller? could you please paste your code?

Thanks
02-15-2009 06:04 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #3
Re: Running uphill
Well, boxes are being kept in one *.ase file. This the init step:
Code:
Bool Init()
{
    Material *material1 = Materials("data/materials/brick/0.mtrl");
    Material *material2 = Materials("data/meshes/test/smok_text copy.tga.mtrl");

    scene.Import("data/meshes/scene/scene.ase");
    scene.setTangents().setBinormals();
    scene.setMaterial(material1).setRender().setBox();

    dragon.load("data/meshes/test/test.mesh");
    dragon.setTangents().setBinormals();
    dragon.setMaterial(material2).setRender().setBox();
    dragonSkeleton.create("data/meshes/test/test.skel");



    Physics.create();
    ctrl.create(Capsule(5.0f, 20.0f, Vec(20.0f, 20.0f, 20.0f)));

    scenePhys.createMesh(scene);
    sceneActor.create(scenePhys);



    return true;
}

Updating:
Code:
    Physics.sim().get();
    Physics.gravity(Vec(0.0f, -75.0f, 0.0f));
    ctrl.update(50.0f*velocity, Kb.shift, Kb.bp(KB_SPACE) ? 250.0f : 0.0f);

If a gravity vector is much smaller (like Vec(0, -5, 0)) it works much better but because of the scale of my world I need a greater gravity value
02-15-2009 10:27 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #4
Re: Running uphill
Thanks, sorry for the delay, I'll check it and report back to you soon.
02-17-2009 03:21 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
Re: Running uphill
Thank you for posting about the issue.
I have reproduced the problem on a sample level, and resolved the issue - the fix will be in the next engine version.
If in the next version you'll encounter any other problems, please write freely.
Thanks
02-17-2009 06:57 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #6
Re: Running uphill
I think you overacted pfft. Now the controller can walk on every angled-surface with almost the same speed. Is it possible to set somehow the upper-angle which the character cannot walk on? Besides I would like to have the ability to make controller not sliding when it's not moving (I want it to stay still on angled surface)

And there's some other serious problem with PhysX. Controller doesn't move smoothly. When I try some simple object moving around the scene it's ok, but when I put on the physics and watch the controller moving it "bounces" a bit. A bit enough to be noticed and this is really annoying. I though it might be caused by the gravity vector. And it is but only partly. When the controller is *standing* on some angled surface and it slides down you may see hard bouncing when gravity vector is huge. When it's small enough it's ok. But while the controller is walking around, no matter on what surface (angled or not), it bounces a really bit.
02-21-2009 12:35 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #7
Re: Running uphill
for smoothness please make sure that you're setting the camera at the end of the Main function (after Physics update and controller update)

for maximum smoothness PhysX works great when you have the framerate limited to 60fps (enable D.sync(true))

as for sliding while standing please check Physics.create parameters

I'll check the angle-limit

EDIT:

I've checked the angle limit and it works ok,

you can try this code:

Code:
/******************************************************************************/
#include "stdafx.h"
#include <EsenthelEngine/EsenthelEngine.h>
#include "../../resource.h"
/******************************************************************************/
Actor      box[2];
Controller ctrl;
const Flt  SCALE=100;
/******************************************************************************/
void InitPre()
{
   App.name="PhysX";
   App.flag=APP_FULL_TOGGLE|APP_MS_EXCLUSIVE;
   D.sync(true).mode(1024,1024);
   ViewportFull.range=100*SCALE;
}
Bool Init()
{
   Physics.create();
   Cam.dist=10*SCALE;
   Physics.gravity(Physics.gravity()*SCALE);
//Physics.skin   (Physics.skin   ()*SCALE);

   box[0].create(Box(5,Vec(0,-6,0))*SCALE,0);
   box[1].create(Box(5,Vec(0,-6,0))*SCALE,0).matrix(Matrix().setRotateX(-1.0).move(Vec(0,-5,10)*SCALE));

   ctrl.create(Capsule(0.4,1.8,Vec(0,1,0))*SCALE);

   return true;
}
void Shut()
{
}
/******************************************************************************/
Bool Main()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(0.1f,100000,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));

   Physics.sim().get();

   Vec m(0);
   if(Kb.b(KB_A))m.x--;
   if(Kb.b(KB_D))m.x++;
   if(Kb.b(KB_W))m.z++;
   if(Kb.b(KB_S))m.z--;
  
   ctrl.update(m*2*SCALE,Kb.shift,(Kb.bp(KB_SPACE)?3.5:0)*SCALE);

   return true;
}
void Draw()
{
   D.clear();
   D.text (0,0.9,S+Tm.fps()+' '+ctrl.onGround());//+' '+ctrl.on_ground_precise);
   Physics.draw();

   ctrl.groundPlane().p.draw(RED);
   D.line(RED,ctrl.groundPlane().p,ctrl.groundPlane().p+ctrl.groundPlane().n*SCALE)​;

   D.text(0,0.7,S+ctrl.groundPlane().n);
}
/******************************************************************************/
02-21-2009 12:56 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #8
Re: Running uphill
This "bouncing" may be the caused by Tm.d().. First of all, which Tm function should I use to multiply by my own "movement" vectors?
Let's leave the whole physics for a while. I have such code:
Code:
    if (Kb.b(KB_LEFT))
    {
        angle += 0.01f;
    }
    else if (Kb.b(KB_RIGHT))
    {
        angle -= 0.01f;
    }

    direction = Vec(cosf(angle), 0.0f, sinf(angle));
    velocity = Vec(0.0f, 0.0f, 0.0f);
    if (Kb.b(KB_UP))
        velocity = direction;
    if (Kb.b(KB_DOWN))
        velocity = -direction;

    p += velocity*1.0f;

    // computing camera at and from by using the above calculations
And it gives me a nice smooth camera movement. But it's not dependent from FPS. So I made such a modification:
Code:
    p += velocity*75.0f*Tm.d();
And after that the movement is no more smooth. The camera "quakes" a bit.
Maybe I should use some other Tm function?
02-21-2009 08:14 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #9
Re: Running uphill
replace all 'angle += 0.01f;'
by 'angle += 0.01f * Tm.d();' changing angle should also be relative to time

p += velocity*75.0f*Tm.d(); <- this is correct

check also time delta smoothing options 'Tm.smooth' - it allows you to set different smoothing modes
02-21-2009 08:35 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #10
Re: Running uphill
CLAMP2 seems to work quite good but it gets some delays/speedups from time to time.
And changing smoothness hasn't affected controller. When my camera traces the controller it "quakes" :/
02-21-2009 09:29 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #11
Re: Running uphill
Quote:for smoothness please make sure that you're setting the camera at the end of the Main function (after Physics update and controller update)
have you checked this?
02-21-2009 09:39 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #12
Re: Running uphill
Yes I have.
If you don't mind, please, download this <!-- m --><a class="postlink" href="http://maxest.fm.interii.pl/Game.zip">http://maxest.fm.interii.pl/Game.zip</a><!-- m -->. "Quakeing" is mostly noticeable when walking around (press "Up" and "Left"/"Right" arrow)
02-24-2009 05:58 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #13
Re: Running uphill
I've checked it, and it runs perfectly smooth.

maybe you could make a video to capture the issue?

but before that, please take a look at Physics.precision and Physics.timestep methods
02-24-2009 10:44 PM
Find all posts by this user Quote this message in a reply
maxest Offline
Member

Post: #14
Re: Running uphill
Quote:but before that, please take a look at Physics.precision and Physics.timestep methods
None of this helps

Quote:I've checked it, and it runs perfectly smooth.

maybe you could make a video to capture the issue?
Before I do any recording... are you sure everything is ok? I thought this issue would occur only on my laptop (GF8400, AMD 2x1.8Ghz) so I tested it on some desktop (GF8800, Core 2 Duo 2x2.4Ghz) and quakeing was even more noticeable.
Try walking around these two "pillars". I really thought it could be something with my camera but when physics not being used it all runs perfectly smooth. And when Physics come it messes up :/
02-26-2009 09:48 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #15
Re: Running uphill
yes, please make a video
02-26-2009 09:50 PM
Find all posts by this user Quote this message in a reply
Post Reply