mrkissinger
30-08-2007 23:01:14
I tried to load mesh/material/texture/skeleton manually by these codes:
The mesh and skeleton and even the animation were loaded.
The material affected as well.
But the texture is not loaded.
The material file is:
I do NOT want to use resources.cfg, can anyone help?
mm = ogre.MaterialManager.getSingleton()
rm = ogre.ResourceGroupManager.getSingleton()
tm = ogre.TextureManager.getSingleton()
meshm=ogre.MeshManager.getSingleton()
tm.setDefaultNumMipmaps (5)
mm.setDefaultTextureFiltering(ogre.TFO_ANISOTROPIC)
mm.setDefaultAnisotropy(2)
rm.initialiseAllResourceGroups()
mesh=meshm.load('data/Mesh/robot.mesh',ogre.ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)
logger.debug("Mesh ===> %s " % mesh.getName() )
mesh.setSkeletonName("data/Skeleton/robot.skeleton")
ds = rm.openResource("data/Material/robot.material", "General", True)
mm.parseScript(ds, "General")
# TODO: Material name must be changed
material=mm.getByName("Robot")
logger.debug("Material ===> %s, %s" % (material.getName(), material) )
texture=tm.load("data/Map/r2skin.jpg", "General")
logger.debug("Texture ===> %s" % texture)
mpass=material.getTechnique(1).getPass(0)
mpass.getTextureUnitState(texture.getName())
entity = sceneManager.createEntity('robot', mesh.getName())
entity.setMaterialName(material.getName())
#entity = sceneManager.createEntity('robot', 'data/Mesh/robot.mesh')
sceneManager.getRootSceneNode().attachObject(entity)
state=entity.getAnimationState('Walk')
The mesh and skeleton and even the animation were loaded.
The material affected as well.
But the texture is not loaded.
The material file is:
material Robot
{
// Hardware skinning techniique
technique
{
pass
{
vertex_program_ref Ogre/HardwareSkinningOneWeight
{
param_named_auto worldMatrix3x4Array world_matrix_array_3x4
param_named_auto viewProjectionMatrix viewproj_matrix
param_named_auto lightPos[0] light_position 0
param_named_auto lightPos[1] light_position 1
param_named_auto lightDiffuseColour[0] light_diffuse_colour 0
param_named_auto lightDiffuseColour[1] light_diffuse_colour 1
param_named_auto ambient ambient_light_colour
}
// alternate shadow caster program
shadow_caster_vertex_program_ref Ogre/HardwareSkinningOneWeightShadowCaster
{
param_named_auto worldMatrix3x4Array world_matrix_array_3x4
param_named_auto viewProjectionMatrix viewproj_matrix
param_named_auto ambient ambient_light_colour
}
texture_unit
{
// texture r2skin.jpg
}
}
}
// Software blending technique
technique
{
pass
{
texture_unit
{
// texture r2skin.jpg
}
}
}
}
I do NOT want to use resources.cfg, can anyone help?