Page 1 of 1

Messed up mesh

Posted: Thu Nov 06, 2008 10:16 am
by residentofcity17
[Moved to Beginners's Help]

Here is my code and the output am getting is a messed up mesh.. Can you please point out the mistake???

Code: Select all

#include <irrlicht.h>
#include <iostream>


#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")	//// To Disable the console window	////



using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace gui; 


#pragma comment(lib, "Irrlicht.lib")


int main() 

{


	//	The irrlicht device is the most important of all, running irrlicht: //

	IrrlichtDevice *device = createDevice( EDT_DIRECT3D9 );		///		will create an irrlicht device with DIRECTX rendering.

	IVideoDriver* video = device->getVideoDriver();				///		grabs the Video Driver from the irrlicht device.

	ISceneManager* smgr = device->getSceneManager();			///		That code pretty much grabs the scene manager from the irrlicht device. the scene manager is how
																///		you will handle irrlicht from here on out, from creating a cube to adding complex animators.


	IMesh* mesh = smgr->getMesh("../../media/sydney.md2");
	IMeshSceneNode* node = smgr->addMeshSceneNode( mesh );
	
	ICameraSceneNode* cam = smgr->addCameraSceneNode(0, vector3df(0,30,-45));

	while(device->run() && device) {
		video->beginScene(true, true, video::SColor(255,0,0,255));

		smgr->drawAll();		

		video->endScene();
	}
} 

Posted: Thu Nov 06, 2008 10:18 am
by JP
Make a post in the beginner's help forum with this info and also a screenshot of the 'messed up' mesh if possible, if not then describe how it's messed up.

Posted: Thu Nov 06, 2008 10:24 am
by residentofcity17
ImageImage

Here is the image of the mesh

Posted: Thu Nov 06, 2008 6:10 pm
by vitek
I'm pretty sure the problem lies here...

Code: Select all

   IMesh* mesh = smgr->getMesh("../../media/sydney.md2"); 
The method ISceneManager::getMesh() method returns an IAnimatedMesh*, which happens to be convertable to IMesh*, but that was causing some problems in the recent past.

I believe that you want to write something like this...

Code: Select all

   IAnimatedMesh* amesh = smgr->getMesh("../../media/sydney.md2");
   IMeshSceneNode* node = smgr->addMeshSceneNode(mesh->getMesh(0));
or even this

Code: Select all

   IAnimatedMesh* amesh = smgr->getMesh("../../media/sydney.md2");
   IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode(mesh);
Travis