Historique des modifications - Message

Message #9032

Sujet: [newton] enfin un bon moteur mais un gros bug


Type Date Auteur Contenu
Création du message 01-12-2010 20:34:22 kiricou974
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.

Retour

Options Liens officiels Caractéristiques Statistiques Communauté
Préférences cookies
Corrections
irrlicht
irrklang
irredit
irrxml
Propulsé par Django
xhtml 1.0
css 2.1
884 membres
1440 sujets
11337 messages
Dernier membre inscrit: Saidov17
554 invités en ligne
membre en ligne: -
RSS Feed