asafdav2
18-07-2007 21:30:33
i'm trying to do a minimal character thingy based on the one here
http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=4350
here's the code (all in cake)
void start() {
mWorld = new World("log: html");
mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes");
mScene->createActor("FakeFloor", new CubeShape(100,2.1f,100), Vector3(0,-0.05f,0), "static: yes");
mCharacter = mScene->createCharacter("Char", Vector3(0,4,0), "type: box, dimensions: 1 2 1");
mCharacter->attachMesh("Cube.1m.mesh");
mCharacter->getNode()->scale(1,2,1);
}
void onFrame(float deltaTime) {
if (mInputHandler->isKeyDown(Z)) {
mCharacter->addMovement(Character::DR_StepLeft);
cout << "KeyDown(Z)" << endl;
}
else if (mInputHandler->isKeyDown(NEG_Z)) {
mCharacter->addMovement(Character::DR_StepRight);
cout << "KeyDown(NEG_Z)" << endl;
}
else if (mInputHandler->isKeyDown(X)) {
mCharacter->addMovement(Character::DR_Forward);
cout << "KeyDown(X)" << endl;
}
else if (mInputHandler->isKeyDown(NEG_X)) {
mCharacter->addMovement(Character::DR_Backward);
cout << "KeyDown(NEG_X)" << endl;
}
//mCharacter->simulate(deltaTime);
}
the problem is that when hitting the keys, except for the couts that work fine, the cube won't move . any ideas?
betajaen
18-07-2007 21:59:12
Using your exact code it works for me.
Are you pressing the IJKL and not the WASD keys?
asafdav2
19-07-2007 06:06:31
yea. the couts are showing so i'm pretty sure the addMovement() is being called.
betajaen
19-07-2007 10:37:05
Odd. It works properly on my computer using Cake. May I ask, what versions of software are you using?
asafdav2
19-07-2007 13:31:08
Version information:
- PhysX => 2.7.2
- NxOgre => NxOgre 0.9-28.Debug
- Ogre => 1.5.0 'Shoggoth'.
betajaen
19-07-2007 13:42:07
The only difference between our setups is your using Shoggoth and I'm not. So I wonder, what would happen if you just put a few cubes into the scene. Will they move or not?
for (int i=0;i < 10;i++)
mScene->createBody("cube.1m.mesh", new CubeShape(1), Vector3(0, i * 2.5f, i), "mass: 10");
asafdav2
19-07-2007 15:48:21
if by 'move' you mean that i can select the body and apply forces with the mouse, then yes
could you please show your whole .cpp file? maybe you have there something i'm missing
betajaen
19-07-2007 16:37:25
Then that works.
Here is the code as you requested, but I would imagine it's the same as yours.
#include "Ogre.h"
#include "NxOgre.h"
#include "Cake.h"
using namespace NxOgre;
using namespace Ogre;
using namespace std;
class Sponge_Cake : public Cake {
public:
World* mWorld;
Scene* mScene;
Character* mCharacter;
void start() {
mWorld = new World("log: html");
mScene = mWorld->createScene("Main", mSceneMgr, "gravity: yes, floor: yes");
mScene->createActor("FakeFloor", new CubeShape(100,2.1f,100), Vector3(0,-0.05f,0), "static: yes");
mCharacter = mScene->createCharacter("Char", Vector3(0,4,0), "type: box, dimensions: 1 2 1");
mCharacter->attachMesh("cube.1m.mesh");
mCharacter->getNode()->scale(1,2,1);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void stop() {
delete mWorld;
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void onFrame(float deltaTime) {
// Want a key pressed?
//
// if (mInputHandler->isKeyDown(Action::OPTION_1)) {
// ...
// }
//
// Search the solution for "#KEYCONFIG" to find the key configuration.
if (mInputHandler->isKeyDown(Z)) {
mCharacter->addMovement(Character::DR_StepLeft);
cout << "KeyDown(Z)" << endl;
}
else if (mInputHandler->isKeyDown(NEG_Z)) {
mCharacter->addMovement(Character::DR_StepRight);
cout << "KeyDown(NEG_Z)" << endl;
}
else if (mInputHandler->isKeyDown(X)) {
mCharacter->addMovement(Character::DR_Forward);
cout << "KeyDown(X)" << endl;
}
else if (mInputHandler->isKeyDown(NEG_X)) {
mCharacter->addMovement(Character::DR_Backward);
cout << "KeyDown(NEG_X)" << endl;
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////
BakeMyCake();
};
Hey_Cut_Me_Slice_Of(Sponge_Cake)
asafdav2
19-07-2007 17:07:27
yepp no change.. should the box fall to the ground at the beginning? because it doesn't do that as well. just holds still in place
betajaen
19-07-2007 18:02:38
Sounds like Shoggoth isn't compatible with NxOgre, or your Character Code in NxOgre is broken. I would expect the latter.
I'll investigate tomorrow about Shoggoth - it's about time, that I should try it out. But you could re-download the SVN and try again.
asafdav2
19-07-2007 18:24:23
ok i did re-downloaded and re-compiled the svn, no change
the only thing i had to change in the code for it to compile was to comment the line
mEntity->setNormaliseNormals(true);
inside the Body constructor in nxOgreBody.cpp - i doubt it has anything to do with it.
betajaen
19-07-2007 18:55:55
No body has nothing to do with the Character. The only other difference is I'm working with NxOgre 0.9'29 which I may have altered the Character code somehow.
Loockas
27-07-2007 18:44:54
Hi, I have just the same problem as asafdav2. First I thought I must have missed something but now I can see the character is definetely not working properly. It doesn't want to move and the gravity doesn't have an effect on it. I also use the basic code similiar to yours, I have Ogre 1.4.3 and NxOre 0.9-28.
EDIT: OK, got it working. Installing the newest SDK and NxOgre 0.9-33 did the job.