Mesh (.ms3d or .obj) loaded without textures

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.
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Mesh (.ms3d or .obj) loaded without textures

Post 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.
Cleves

Post 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.
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post by puh »

This is exactly what I did. But I'll check everything again.
Jailbird
Posts: 5
Joined: Wed Aug 27, 2003 12:53 pm
Location: Wil, Switzerland
Contact:

Post by Jailbird »

if you use dt_opengl, try selecting another renderer and check if it works then
Jailbird
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post 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.
niko
Site Admin
Posts: 1759
Joined: Fri Aug 22, 2003 4:44 am
Location: Vienna, Austria
Contact:

Post by niko »

Try to add textures yourself: yourSceneNode->setMaterialTexture(0, yourTexture); Does this help?
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post 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...
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post 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));
Crud, how do I do this again?
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post 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?
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post 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)); 
Crud, how do I do this again?
Cleves

Post by Cleves »

if i'm not wrong the lighting is not off...
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post 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...
saigumi
Posts: 921
Joined: Fri Aug 22, 2003 11:31 am
Location: St. Louis, MO USA
Contact:

Post 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.
Crud, how do I do this again?
puh
Posts: 356
Joined: Tue Aug 26, 2003 3:53 pm

Post 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?
Cleves

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