Messed up mesh

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
residentofcity17
Posts: 3
Joined: Thu Nov 06, 2008 9:57 am

Messed up mesh

Post 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();
	}
} 
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post 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.
Image Image Image
residentofcity17
Posts: 3
Joined: Thu Nov 06, 2008 9:57 am

Post by residentofcity17 »

ImageImage

Here is the image of the mesh
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post 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
Post Reply