Pages: 1
- Accueil forums
- » Physique
- » [newton] enfin un bon moteur mais un gros bug
01-12-2010 20:34:22
- kiricou974
- Membres
- Date d'inscription:
- Messages: 34
- IP: 77.205.172.249
- Courriel
Bonjour, j'ai fini par choisir un moteur physique répondant a mes besoins Newton.
Or une nouvelle venant toujours avec un bug, quand je lance mon programme il me dit dans une fenêtre windows disant :
L'application n'a pas réussi a démarrer correctement (0xc000007b). Cliquer sur OK ...
voila mon code si sa peut vous aidez :
Code c++ :
#include <Irrlicht.h>
#include <newton.h>
// use scale factor between Newton and IRR
const float NewtonToIrr = 32.0f;
const float IrrToNewton = (1.0f / NewtonToIrr);
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
int main()
{
//create Newton world
NewtonWorld* nWorld = NewtonCreate ();
// set Irrlicht
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<u32>(1024, 768), 32,false, false, false);
video::IVideoDriver* driver = device->getVideoDriver();
scene::ISceneManager* smgr = device->getSceneManager();
// add mesh
scene::IMeshSceneNode* beat = smgr->addSphereSceneNode(10,64);
if (beat)
{
beat->setMaterialFlag(video::EMF_LIGHTING, false);
}
core::aabbox3d<f32> box = beat->getBoundingBox();
core::vector3df size = box.getExtent() * IrrToNewton;
NewtonCollision* collision = NewtonCreateBox(nWorld, size.X, size.Y, size.Z, NULL, NULL);
static NewtonBody* beat_Body = NewtonCreateBody(nWorld, collision);
NewtonReleaseCollision (nWorld, collision);
// set the body mass and inertia
NewtonBodySetMassMatrix (beat_Body, 1.0f, 5.0f, 1.0f, 5.0f);
//NewtonBodySetUserData(beat_Body, beat);
//NewtonBodySetDestructorCallback (beat_Body, DestroyPistonEvent);
core::matrix4 matrix = beat->getRelativeTransformation();
core::vector3df origin = matrix.getTranslation() * IrrToNewton;
matrix.setTranslation (origin);
NewtonBodySetMatrix(beat_Body, &matrix.M[0]);
// animate the body by setting the angular velocity
float omega[] = {0.0f, 10.0f, 0.0f};
NewtonBodySetOmega (beat_Body, &omega[0]);
// add camera & hide cursor
smgr->addCameraSceneNode(0, core::vector3df(3,0,3), core::vector3df(0,0,0));
device->getCursorControl()->setVisible(false);
// count FPS
int lastFPS = -1;
while(device->run())
{
driver->beginScene(true, true, video::SColor(255,100,101,140));
//update the physics at the same rate as the render
float fps = (float) driver->getFPS();
if (fps > 0.0f)
NewtonUpdate(nWorld, 1.0f / fps);
// rotate node
core::matrix4 mat;
NewtonBodyGetMatrix(beat_Body, &mat.M[0]);
//Set node position
beat->setPosition(mat.getTranslation() * NewtonToIrr);
// set node rotation
core::vector3df euler;
NewtonGetEulerAngle ( &mat.M[0], &euler.X);
beat->setRotation(euler * (180.0f / 3.1416f));
smgr->drawAll();
driver->endScene();
int fps_int = driver->getFPS();
if (lastFPS != fps_int)
{
core::stringw str = L"Irrlicht Engine - Quake 3 Map example [";
str += driver->getName();
str += "] FPS:"; str += fps_int;
device->setWindowCaption(str.c_str());
lastFPS = fps_int;
}
}
// instead call
NewtonDestroyAllBodies (nWorld);
// finish newton & irrlicht
NewtonDestroy(nWorld);
device->drop();
return 0;
}
j'utilise irrlicht 1.8 et newton 2.25
voila merci d'avance.
Hors ligne
01-12-2010 20:51:11
- nabouill
- Membres

- Date d'inscription:
- Messages: 242
- IP: 77.198.97.165
- Courriel
j'ai l'impression que Newton n'est pas bien initialisé. Dans mes test avec Newton j'avais plutôt un truc du genre:
Code c++ :
NewtonWorld* World;
World = NewtonCreate();
NewtonSetPlatformArchitecture(World, 0);
dVector minSize(-500.0f, -500.0f, -500.0f);
dVector maxSize(500.0f, 500.0f, 500.0f);
NewtonSetWorldSize(World, &minSize[0], &maxSize[0]);
NewtonSetSolverModel(World, 1);Aussi, Irrlicht 1.8 est un peu buger, il serait peut-être pas mal d'essayer avec le version 1.7.2 au cas où.
@+
Hors ligne
02-12-2010 19:21:11
- kiricou974
- Membres
- Date d'inscription:
- Messages: 34
- IP: 77.205.172.249
- Courriel
Non le programme veut toujours pas se lancer ...
Hors ligne
02-12-2010 20:18:51
- TUpac
- Membres

- Date d'inscription:
- Messages: 387
- IP: 88.168.3.38
- Courriel
tu n'as pas un debugger pour localiser le problème stp?
décortiquer des heures ça fatigue vite ...
"Si vous ne partagez pas votre stabilité avec les pauvres, les pauvres partageront leur instabilité avec vous."
Hors ligne
02-12-2010 21:37:06
- kiricou974
- Membres
- Date d'inscription:
- Messages: 34
- IP: 77.205.172.249
- Courriel
heu j'ai lancer le débugger mais le programme se lance et se ferme et il fait comme si il n'y avait pas de problème
Hors ligne
03-12-2010 08:51:41
- nabouill
- Membres

- Date d'inscription:
- Messages: 242
- IP: 82.127.58.127
- Courriel
Tu utilise quel compilateur ?
Quel lib de Newton (il y en a au moin 8 différentes) ?
Utilise tu la bonne DLL qui correspond à la lib que tu as linker (question con peut-être, mais desfois une faute d'inatention...) ?
Hors ligne
03-12-2010 09:22:49
- TUpac
- Membres

- Date d'inscription:
- Messages: 387
- IP: 80.13.52.19
- Courriel
As tu bien utiliser la lib debug de irrlicht et newton ?
"Si vous ne partagez pas votre stabilité avec les pauvres, les pauvres partageront leur instabilité avec vous."
Hors ligne
03-12-2010 09:29:26
- kiricou974
- Membres
- Date d'inscription:
- Messages: 34
- IP: 77.205.172.249
- Courriel
j'utilise le compilo de code block (mingw je crois mais pas sur) ensuite j'utilise la lib de vs9.
je vais voir si c'est un problème qui vient de la ou pas.
finalement sa venait effectivement de la ... galérer 3jours pour finalement une erreur de lib ... enfin bref merci a vous.
Hors ligne



