Newbie questions

aserrano1971

17-11-2007 09:06:38

Hi,

First at all I want to thank you this all great work. I really followed the initial tutorial and in only three lines I had physics in my game. :)

Second sorry for my bad english.

The question. I have implemented a third person camera system for some test-game I'm doing in this way:

ResourceGroupManager::getSingleton().openResource(BWMAINMESHNAME,BWMAINRESOURCE);
mCamera=mSceneMgr->getCamera(BWMAINCAMERA);

mMainNode = mSceneMgr->getRootSceneNode()->createChildSceneNode(BWMAINCHARACTERNODE);
mCharNode = mMainNode->createChildSceneNode(BWCHARACTERNODE);

mCharacter = mScene->createCharacter("character",Vector3(0,0,0),"type: box, dimensions: 1,2,1");
mCharacter->setNode(mCharNode);
mCharacter->attachMesh(BWMAINMESHNAME);
mCharacter->getEntity()->setMaterialName(MAINCHARMATERIAL);

mCameNode = mMainNode->createChildSceneNode(BWMAINCAMERANODE);
mPitcNode = mCameNode->createChildSceneNode(BWCAMEPITCHNODE);
mCamera->setPosition(0,7,0);
mPitcNode->attachObject(mCamera);
mPitcNode->setPosition(0,0,-20);

mCamera->lookAt(0,0,0);
mCameNode->setAutoTracking (true, mCharNode);
mCameNode->setFixedYawAxis (true);
mCamera->setNearClipDistance(5);
mCamera->setFarClipDistance(800);


Now I can rotate camera, move and pitch in this way

mCharacter->getCameNode()->yaw(mRotX);
mCharacter->getCameNode()->pitch(mRotY);
...
mMainNode->yaw(Degree(1));
...
mMainNode->translate(Movement);
...


The question would be in this is correct or is there any other way to do this?
You can notice I've added a setNode to character class (I know I could use inheritance...this is quicker actually for me)

Second question is about terrain.
I've created a terrain:
Actor *actor=mScene->createActor("terrain", new TerrainShape("heightmap.raw",118.803,"material:terrain_texture.jpg"),Vector3::ZERO, "static: yes");

But looks like as if the geometry is down the terrain. ??
How can I solve it??

thanks and kind regards!!

betajaen

17-11-2007 09:19:25

I'll post about Character in a bit, but for the terrain question. I believe the Y Position of the terrain must be half the total height. In your case Vector3(0, 118.803 * 0.5f, 0).

aserrano1971

17-11-2007 09:32:38

Thanks for you quick answer, I'll try it as soon as my wife let me... :)

aserrano1971

18-11-2007 08:13:39

I'll answer myself about character. Now I can see my errors.

I was adding an unnecessary node to the main character when the character is the main node.
Now I move the character with addMovement and setDirection

that's right?

How can I give the character more speed? It's moving too slow...



mCharacter = mScene->createCharacter(BWMAINCHARACTERNODE,Vector3(0,0,0),"type: box, dimensions: 1,2,1");
mCharacter->attachMesh(BWMAINMESHNAME);
mCharacter->getEntity()->setMaterialName(MAINCHARMATERIAL);

mCameNode = mCharacter->getNode()->createChildSceneNode(BWMAINCAMERANODE);
mPitcNode = mCameNode->createChildSceneNode(BWCAMEPITCHNODE);
mCamera->setPosition(0,7,0);
mPitcNode->attachObject(mCamera);
mPitcNode->setPosition(0,0,-20);

mCamera->lookAt(0,0,0);
mCameNode->setAutoTracking (true, mCharacter->getNode());
mCameNode->setFixedYawAxis (true);
mCamera->setNearClipDistance(5);
mCamera->setFarClipDistance(800);

denreaper

18-11-2007 08:37:23

How can I give the character more speed? It's moving too slow...


First create a class similar to the following:

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


Down in your character creation, you want to call:
myCharacterMovement *mCharMove = new myCharacterMovement();
Note that you must clean that up yourself.

Now call character->setMovementVectorController(mCharMove);
(character is your NxOgre::Character instance)

Now tweak the speed settings in myCharacterMovement until you get it how you want it.

aserrano1971

18-11-2007 08:55:32

Yep!!! It's working,

Thank you!!!! :)

Another update:

BetaJaen, Now with the main character perfectly created it's working fine the terrain and the half max height :)