simple texture question


18-01-2009 07:00:17

hey all,

I am running through the wiki tutorials. and cannot figure this out. where, for examples does the texture for a basic character (ninja ogrehead) get called up within the code. cannot find where to modify it before the "examples/node" bit within the material script.

also, how can I make my own materials appear on my objects? I successfully did it once. then it stopped working. my .mesh file is in the models folder, my material is in the materials folder but I only have plain white models.

any help would be great.

thanks much.



18-01-2009 12:49:09

It sounds like there is an error either in your material script or in the way you're setting the material on your mesh. First thing to do is check the log output, look for something along the lines 'EXCEPTION: error parsing material script xxxx..'. That should also give you at least the line number of the error so you can try and figure out where its gone wrong.

To setup an entity with a specific material - the syntax in python-ogre is generally:

rootNode = self.sceneManager.getRootSceneNode()
myNode = rootNode.createChildSceneNode()

ent = sceneManager.createEntity( "myNinja", "ninja.mesh" )
ent.setMaterialName( "myMaterial" )
myNode.attachObject( ent )

myNode.setPosition( ogre.Vector3( 10, 10, -10 ) )

( last bit optional of course )

if you're using the sampleframework, this should appear in the _createScene function.

Alternatively, you can create a material in code without using a script, though its often easier to stick to scripting. For example:

mat = ogre.MaterialManager.getSingleton().create("myCustomMaterial", ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
texUnit = mat.getTechnique(0).getPass(0).createTextureUnitState("myImage.jpg")