[SOLVED] Loading texture set

Yaga-Shura

07-04-2007 08:51:04

Hi Guys,

I think, it's a silly question, but I can't find the answer anywhere.
I'm using MAX 9 and VS 8.0.

I downloaded a .3ds file out of the internet. I import it into MAX. The object consists out of many editable meshs with diffrent materials on them. I select one mesh and attach all other meshs to it. Then I export the single mesh. oFusion creates a .mesh file, which is ok. It also creates a material file like this:


material Material_#818/Material_#1
{
technique
{
pass
{
ambient 0.690196 0.690196 0.690196 1
diffuse 0.690196 0.690196 0.690196 1
specular 1 1 1 1 27
}

}

}

material Material_#818/dark_hull
{
technique
{
pass
{
ambient 0 0 0 1
specular 1 1 1 1 27
alpha_rejection greater 128

texture_unit
{
texture_alias 0
texture HULLMAP.BMP
scale 2 10
}
}

}

}

material Material_#818/hull
{
technique
{
pass
{
ambient 0 0 0 1
specular 1 1 1 1 27
alpha_rejection greater 128

texture_unit
{
texture_alias 0
texture HULLMAP.BMP
scale 2 10
}
}

}

}

material Material_#818/engine
{
technique
{
pass
{
ambient 0.172549 0.172549 0.188235 1
diffuse 0.172549 0.172549 0.188235 1
specular 0.278392 0.278392 0.278392 1 24
}

}

}

material Material_#818/Material_#2
{
technique
{
pass
{
ambient 0.0313726 0.0117647 0 1
diffuse 0.0313726 0.0117647 0 1
specular 1 1 1 1 38
}

}

}


In my C++ Code, I load the object: createEntity( "Player", "models\\Cylinder04.mesh" );

My question is: How do i attach the material to it? If i try setMaterialName("#818"); or setMaterialName("_#818"); , the Ogre.log tells me, that Ogre can't find the material.

So how do I have to attach the material?

syedhs

07-04-2007 13:25:46

Actually you dont need to attach material(s) to a mesh. When you export a .mesh file, there is a default material for the mesh file so if you simply load it via createEntity, the default mesh is already assigned.

One of the reasons (if not the only one!) to set the material manually in code is if the mesh has many materials that you want to change programmatically in the app. For example in a game, a character can wear an army, normal & doctor suit - so you will need to manually change the material when the character is changing the suit.


My question is: How do i attach the material to it? If i try

setMaterialName("#818");


You will need the full name of the material for example

ent->setMaterialName("Material_#818/Material_#1");

Yaga-Shura

08-04-2007 14:03:32

Ha, i got the problem.

pass
{
ambient 0 0 0 1
specular 1 1 1 1 27
alpha_rejection greater 128

texture_unit
{
texture_alias 0
texture HULLMAP.BMP
scale 2 10
}
}


i have to change ambient 0 0 0 1 to ambient 1 1 1 1

After i changed it in the whole material set, i got my textures *yippie*

THX for help