problems with models

ta2025

02-10-2006 01:32:56

I am trying to import a model....

I used Mikshape and the plugin to Ogre3d...

I get a .mesh, .skeleton, and .material files and I put these files in the folders where other similar material files are stored from the demos. my resource.cfg still points to these folders.

my code to load this model is:


tree = sceneManager.createEntity('palm1', 'palm1.mesh')
tree.setMaterialName('palm1.material')
tree.scale = (100, 100, 100)
tree.position = (100,10,100)

sceneManager.rootSceneNode.createChildSceneNode().attachObject(tree)


I get a white tree at 0,0,0

If I remove the setmaterialName() statement, I get a black tree.

so, my questions are: 1. What is the secret of materials?

and 2. why would the model remain at 0,0,0 whwn I explicitly said 100,10,100? Incidently, the scale(100,100,100) works fine (I get a very big tree!)

bigjhnny

02-10-2006 03:07:33

Material should have been automatically loaded.

Open up palm1.material and see if it looks correct. Also check that your texture files are in the texture folder.

bigjhnny

02-10-2006 03:09:37

You place entities in the scene via scene nodes. That's why setting the position on the entity has no effect. You clearly should go through a couple of tutorals in the pyogre wiki to get a better grasp of things.

ta2025

02-10-2006 03:31:40

Since I'm such an obvious noob....

Where in the docs does it say that material will automatically load? I dont want to miss anything else basic. I've been poring over this stuff for days just to get this far.

also, how am I going to know if everything looks "all right" in the material file? I place the material file in the media/material/scripts folder and the PNG files it calls in the media/material/textures folder and the mesh in the media/models folder.

The contents of my "palm1.material" file


material palm1.material
{
technique
{
pass
{
ambient 0 0 0 1
diffuse 0.752941 0.752941 0.752941 1
specular 0 0 0 1 40

texture_unit
{
texture_alias 0
texture palm1.png
}
}

}

}



and here is an appropriate entry from the log...

]
21:15:56: Can't assign material palmt1.png to SubEntity of palm1 because this Material does not exist. Have you forgotten to define it in a .material script?
21:15:56: Texture: palm1.png: Loading 1 faces(PF_A8B8G8R8,512x512x1) with 9 hardware generated mipmaps from Image. Internal format is PF_A8R8G8B8,512x512x1.


any help you can offer would be great!

ta2025

02-10-2006 03:41:08

I actually figured that out finally by myself!

The export routine does not set any ambient color.... I fixed it. I now have a palm tree... EXCEPT... the PNG file contains transparency between the palm fronds that is showing up black in the rendering. How do we get Ogre to respect and use the transparency in an image?

ta2025

02-10-2006 03:45:00

It does still require me to use the:

tree.setMaterialName('palm1.material')

statement or it renders the tree solid white. If that info is supposed to be in the mesh itself, I have no idea how to do it any differently.

ta2025

02-10-2006 03:56:30

Never mind....

I still need to know why I have to set the material seperately and how the model could be exported to avoid it, however, I have correwct transparencies now!!!

My palm trees look correct again.

I followed the examples here: http://www.ogre3d.org/wiki/index.php/Materials

and it showed me how to turn the alpha channel on in a PNG file.

viblo2

04-10-2006 21:43:43

It does still require me to use the:

tree.setMaterialName('palm1.material')

statement or it renders the tree solid white. If that info is supposed to be in the mesh itself, I have no idea how to do it any differently.


Yes, a default material can be stored in the mesh file. Maybe the Milkshape plugin didnt export the correct material name? You can check the material name if you convert the mesh file to xml with OgreXMLConveter (in Command Line Tools).

ta2025

04-10-2006 23:54:53

is there a document that outlines the expected variables in the XML file?

Whats *in* the XML is a single reference to a material file. I assume (in this case) that its referring to my "tree4.material" file. It had been the default name that came from milkshape. However, I change it and it makes no difference.

The models are not rendering at all and there are no error messages.

viblo2

05-10-2006 22:27:59

There is a .dtd for the xml format in the source package of ogre. I don't know any other documentation of it.

Just to make sure, you probably know this:
You need to convert the xml-file (with the new material) back to the mesh format before you can use it.
In both the xml-file and when you load your material in code, its always the material name and not the name of the file where the material is stored that is used (so its possible to store 2 materials in one file).
And finally, there should be an material attribute for each submesh in the xml-file (and they set the default material for each submesh of the mesh). Therefore, make sure you edited all the <submesh> tags.