maroxe
05-09-2008 18:38:17
Posted: Wed Sep 03, 2008 10:46 pm Post subject:
i istalled the 0.9 version, but know i have a probleme with my tracking camera.
if update my camera like that:
the camera vibrates when the body moves . i didin't have this problem with blending.
but if do like that:
it doesn't vibrate.
this a small test application:
application.h
main.cpp:
PS: with belnding, i didn't have this problem
i istalled the 0.9 version, but know i have a probleme with my tracking camera.
if update my camera like that:
Camera->lookAt(BodyPosition());
the camera vibrates when the body moves . i didin't have this problem with blending.
but if do like that:
Camera->setAutoTrack(true, BodyNode);
it doesn't vibrate.
this a small test application:
application.h
using namespace Ogre;
class Application : public Ogre::FrameListener
{
public:
Root* pRoot ;
RenderWindow* pRenderWindow;
SceneManager* pSceneManager;
Camera* pCamera;
Viewport* pViewport;
OIS::InputManager *pInputManager;
OIS::Mouse *pMouse;
OIS::Keyboard *pKeyboard;
NxOgre::World* mWorld;
NxOgre::Body* mBody;
public :
Application();
~Application();
void run();
virtual bool frameStarted(const Ogre::FrameEvent& evt);
virtual bool frameEnded(const Ogre::FrameEvent& evt);
};
main.cpp:
#include"Ogre.h"
#include<NxOgre.h>
#include"OIS/OIS.h"
#include"application.h"
using namespace Ogre;
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char *argv[])
#endif
{
try
{
Application* app = new Application;
app->run() ;
}
catch( Ogre::Exception& e )
{
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
std::cerr << "An exception has occured: " <<< std::endl;
#endif
}
return 0;
}
Application::Application()
{
//OGRE
pRoot = new Root();
if(!pRoot->restoreConfig())
pRoot->showConfigDialog();
pRenderWindow=pRoot->initialise(true,"Ma premiere application Ogre");
pSceneManager=pRoot->createSceneManager(ST_GENERIC,"MonGestionnaireDeScene");
pCamera = pSceneManager->createCamera("MaCamera");
pCamera->setPosition(Ogre::Vector3(100,0,0));
pViewport = pRenderWindow->addViewport(pCamera);
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("C:/OgreSDK/media/models","FileSystem","General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("C:/OgreSDK/media/materials/scripts","FileSystem","General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("C:/OgreSDK/media/materials/textures","FileSystem","General");
Ogre::ResourceGroupManager::getSingleton().addResourceLocation("C:/OgreSDK/media/materials/programs","FileSystem","General");
Ogre::ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
//PHYSX
mWorld = new NxOgre::World("FrameListener: Yes, log: no");
NxOgre::Scene* mScene = mWorld->createScene("Paris", pSceneManager, "gravity: yes, floor: yes");
mBody = mScene->createBody("OgreHead.mesh", new NxOgre::CubeShape(0.5f), Ogre::Vector3(5,30,5), "Mass: 50");
pRoot->addFrameListener(this);
//OIS
OIS::ParamList pl;
size_t windowHnd = 0;
std::ostringstream windowHndStr;
pRenderWindow->getCustomAttribute("WINDOW", &windowHnd);
windowHndStr << windowHnd;
pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
pInputManager = OIS::InputManager::createInputSystem( pl );
pMouse = static_cast<OIS::Mouse*>(pInputManager->createInputObject(OIS::OISMouse, false));
pKeyboard = static_cast<OIS::Keyboard*>(pInputManager->createInputObject(OIS::OISKeyboard, false));
unsigned int width, height, depth;
int top, left;
pRenderWindow->getMetrics(width, height, depth, left, top);
const OIS::MouseState &ms = pMouse->getMouseState();
ms.width = width;
ms.height = height;
};
Application::~Application()
{
delete mWorld;
delete pRoot;
};
void Application::run()
{
pRoot->startRendering();
};
bool Application::frameStarted(const FrameEvent& evt)
{
pKeyboard->capture();
if (pKeyboard->isKeyDown(OIS::KC_ESCAPE)) return false;
if (pKeyboard->isKeyDown(OIS::KC_UP)) mBody->addForce(Vector3(0, 0, 1000));
if (pKeyboard->isKeyDown(OIS::KC_DOWN)) mBody->addForce(Vector3(0, 0, -1000));
pCamera->lookAt(mBody->getGlobalPosition());
return true;
}
bool Application::frameEnded(const FrameEvent& evt)
{
return true;
}
PS: with belnding, i didn't have this problem
