about 0.9's change

ANdys

09-05-2007 05:04:09

HI,betajaen

Thanks your Big Project First ^^.

I have 2 question.

1.I can't find the "debugnode" and "debugoverlay" in 0.9.
Does debug mode has a new system or new use way in 0.9 ?
or in the future :cry: ?

2.Relative to 0.6 , "NxOgreWorld" of 0.9 reduce some function.
If i want use the time modifer or other.
Does it has a new way ?


Thanks your hard work!!


(Excuse my broken english,I come from Taiwan :oops: )

betajaen

09-05-2007 09:23:53

1. I've decided long and hard not to include the debug node or debug overlay. It's entire function can be replicated and extended using PhysX's Remote Debugger program that comes with the PhysX SDK. Since it works almost like a networked program it can run on a separate computer.

2. If the time modifier variable isn't in PhysXDriver it isn't there. But since it's the SVN, things can change.

But if you really NEED it then you can tell the PhysXDriver to not use a framelistener and inject the time yourself.

mWorld = new World("framelistener: no");
...
mWorld->simulate(myTime * timeModifier);
mWorld->render(myTime * timeModifier);

ANdys

09-05-2007 17:41:19

Thanks your patience to reply my question.
I will try your method.

Thank you very much ,betajaen! :D

ANdys

13-05-2007 10:22:01

Hi again!!

2 CharacterController Question :

I use these codes.
Character* player;
CreateScene:
mScene->createCharacter("one", Vector3(5,120,7),"Mass: 10");
player=mWorld->getCharacterController()->get("one");
player->attachMesh("cube.1m.mesh");

FrameStarted:
if (mKeyboard->isKeyDown(OIS::KC_I))
{
  for(i=0;i<step;i++)
   player->addMovement(Character::DR_Forward);
}

if (mKeyboard->isKeyDown(OIS::KC_SPACE))
{
  for(i=0;i<step;i++)
   player->addMovement(Character::DR_Jump_Up);
}


1.I use " for(i=0;i<step;i++) " to control Character move speed,does any smart method can control move speed too?

2.The Character::DR_Jump_Up i use in demo,It doesn't seem to Jump the Character.My Character just stay same location.Has it any problems ?

thanks!!

betajaen

13-05-2007 12:02:38

Don't use the for loop for the character speed because although it works that way, it's not designed to be worked that way.

What you want to do is implement your own version of the CharacterMovementVectorController class and tell the character to use it, instead of using the default one. The idea of the MovementVectorController is so the user can have some say on how exactly the character moves, so you can implement running or power ups, without hacking NxOgre code.

Nearly all of the code is implemented to do it, and by default it uses the code in the CharacterController class to work by. But for some reason the custom way isn't implemented yet, so you can wait until the next SVN commit or you can hack NxOgre to do it yourself:-

Goto NxOgreCharacter.h and move the line CharacterMovementVectorController* mMoveVectorController; bit in the Character class, to the public bit.

Create your own MovementVector class in your own code with the following:

myCharacterMovement : public NxOgre::CharacterMovementVectorController {
public
void CharacterMovementVectorController::move(NxVec3 &out, NxVec3 &moveVector, NxQuat &direction, NxVec3 &g, float t, Character*) {
NxReal mySpeed = 1.5;
out = ((direction.rot(moveVector) * mySpeed) + g) * t;
}
};


Then do:

// Character setup code here.
myCharacter->mMoveVectorController = new myCharacterMovement();


I'm afraid the jumping part isn't implemented yet.

ANdys

13-05-2007 19:16:59

OK!! thank your method,betajaen!! :o
I will try~~

AND~~~
I find new little problem with "RayCaster". :oops:

I try to update the old "move_or_grab" function to use 0.9 .

void mouseMoveOrGrab(float x, float y, bool move_or_grab)
{
Ogre::Ray r = mCamera->getCameraToViewportRay(float(x / mWindow->getWidth()),float(y / mWindow->getHeight()));

mRayCaster->setOrigin(r.getOrigin());
mRayCaster->setDirection(r.getDirection());

if (!mRayCaster->castShape(RayCaster::NONE))
{
mDebugText = "return";
return;
}

// Move it
if (move_or_grab)
{
................................. (In this case,I confirmed the "move" code is right to work)
}

// Grab it
if (!move_or_grab)
{
Actor *t = mRayCaster->getClosestActor(); // <====== my problem here
if (t)
mDebugText = "Grab" + StringConverter::toString(t->getGlobalPosition());
else
mDebugText = "Grab";
targetBody = t;
hasTargetBody = true;
}

}


getClosestActor(),it returns the most closest actor, but " Actor *t " always get zero from getClosestActor().
so I try to know the getClosestActor() and castShape() form source code.
and just change some code like this


Actor *t = mRayCaster->getClosestActor();
Change and Add

NxShape* hitShape;
NxRaycastHit hit;
NxRay mRay;
mRay = NxRay(toNxVec3(r.getOrigin()), toNxVec3(r.getDirection()));
hitShape = mScene->getNxScene()->raycastClosestShape(mRay, (NxShapesType) RayCaster::ActorFilter::NONE, hit,-1, 200);
Actor *t = static_cast<Actor*>(hitShape->getActor().userData);


it's work!! I can Grab some DYNAMIC body and move it.
what's problem of my code ( getClosestActor() )?

betajaen

13-05-2007 19:24:03

The 0.6 RayCaster only supported the closest raycast type, 0.9 supports all three.

This is normally how you do it:

RayCaster* caster = new RayCaster(origin, direction, maxDistance, RayCaster::CLOSEST, mScene);
caster->castShape(RayCaster::NONE);
actor = caster->getClosestActor();


If you use the "default" constructor, then it just falls back to ANY, which just returns if it hits something or not, but not what it hit. Which I suspect is what your doing.

ANdys

13-05-2007 19:47:19

Yes,it's work!!!

thank you very much!! :P