Page 1 of 2

Mesh (.ms3d or .obj) loaded without textures

Posted: Thu Aug 28, 2003 12:31 pm
by puh
I create my first project based on Quake3Map tutorial but with Milkshape3D model (I also tried .obj mesh).
All I can see is black scene. Mesh is loaded, I saw it, but there is no textures...
Any help will be appreciate.

Posted: Thu Aug 28, 2003 1:07 pm
by Cleves
Make sure that the textures reside in the same dir where the mesh is.
try to put the mesh and the textures in the dir where you have the source code and the compile and try.

Posted: Thu Aug 28, 2003 1:09 pm
by puh
This is exactly what I did. But I'll check everything again.

Posted: Thu Aug 28, 2003 1:21 pm
by Jailbird
if you use dt_opengl, try selecting another renderer and check if it works then

Posted: Thu Aug 28, 2003 1:26 pm
by puh
As I use DevC++ I could use onlu OGL or Software renderer. I tried last one - result is the same except all mesh is white, not black.

Posted: Thu Aug 28, 2003 2:30 pm
by niko
Try to add textures yourself: yourSceneNode->setMaterialTexture(0, yourTexture); Does this help?

Posted: Thu Aug 28, 2003 2:37 pm
by puh
Yesterday I tried it till midnight, but my knowledge of C++ still too pure. I'll put my code here tomorrow, wish it helps locate my mistake...

Posted: Thu Aug 28, 2003 3:03 pm
by saigumi
Are you textures stored as pngs?

From experience, Milkshape loves using png's in it's texture positioning and crashes if you use BMP's. We use pngs to set th texture and then convert it to a bmp for using in Irrlicht

Code: Select all

		irr::scene::ISceneNode* tempNode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("mymesh.ms3d"),0,-1,irr::core::vector3df(0.0f,0.0f,0.0f),irr::core::vector3df(0.0f,0.0f,0.0f),irr::core::vector3df(1.0f,1.0f,1.0f));
		tempNode->setMaterialFlag(irr::video::EMF_LIGHTING, false);
		tempNode->setMaterialTexture(0, driver->getTexture("mytexture.bmp));

Posted: Thu Aug 28, 2003 3:27 pm
by puh
I use .bmp.
My code:

Code: Select all

using namespace irr;

scene::ICameraSceneNode* camera = 0;

class MyEventReceiver : public IEventReceiver
{
public:
	virtual bool OnEvent(SEvent event)
	{
		if (camera)
			return camera->OnEvent(event);

		return false;
	}
};

int main()
{
	MyEventReceiver receiver;

	IrrlichtDevice *device =
		createDevice(video::DT_OPENGL, core::dimension2d<s32>(640, 480), 16, false, false, &receiver);
	video::IVideoDriver* driver = device->getVideoDriver();
	scene::ISceneManager* smgr = device->getSceneManager();

	scene::IAnimatedMesh* mesh = smgr->getMesh("a.ms3d");
	scene::ISceneNode* node = 0;
	
	if (mesh)
		node = smgr->addOctTreeSceneNode(mesh->getMesh(0));

	camera = smgr->addCameraSceneNodeFPS();

	while(device->run())
	{
		driver->beginScene(true, true, video::SColor(0,100,100,100));
		smgr->drawAll();
		driver->endScene();

	}
	device->drop();
	
	return 0;
}
What's wrong with it?

Posted: Thu Aug 28, 2003 3:50 pm
by saigumi
You aren't setting a texture or illuminating your mesh.

Which would cause a black meshed shape nothing to appear.

Code: Select all

//set the model
irr::scene::ISceneNode* tempNode = smgr->addAnimatedMeshSceneNode(smgr->getMesh("mymesh.ms3d"),0,-1,irr::core::vector3df(0.0f,0.0f,0.0f),irr::core::vector3df(0.0f,0.0f,0.0f),irr::core::vector3df(1.0f,1.0f,1.0f)); 

//set lighting to alway lit (EMF lighting = false)
 tempNode->setMaterialFlag(irr::video::EMF_LIGHTING, false); 

//set the texture to the one that should be applied
      tempNode->setMaterialTexture(0, driver->getTexture("mytexture.bmp)); 

Posted: Thu Aug 28, 2003 3:51 pm
by Cleves
if i'm not wrong the lighting is not off...

Posted: Thu Aug 28, 2003 4:10 pm
by puh
But I have hundreeds textures. I can't believe lighting is OFF by default. Maybe my fault that I use IAnimatedMesh? I've static world...

Posted: Thu Aug 28, 2003 4:25 pm
by saigumi
I was wondering something about a mesh autoloading it's textures myself. Don't .X's include such information? Haven't really thought long and hard about .ms3d's though.

Nicolas, Is this a possible added feature?

The solution I went with for ms3d's is to is to combine all the textures into one file and then apply that one texture to the mesh. Since milkshape allows texture positioning for each face, it puts each texture bit into the correct location.

Posted: Thu Aug 28, 2003 4:31 pm
by puh
So you think Irrlicht couldn't take from .ms3d information about textures and I need to load all textures manually? Nonsense...
Is it mean .bsp format used in demo keeps all textures inside?

Posted: Thu Aug 28, 2003 5:06 pm
by Cleves
The .bsp is a special format that stores inside it not only the geomatrical info but as well other info like texutres,materials,stats(e.g. player start location).