0
\$\begingroup\$

I have searched forums and tried to read the Ogre 2.1 samples, but I still have no clue how to apply texture on mesh :(

Here what I've done so far.

  1. I use Easy Ogre Exporter to export the scene (actually I just need the model and texture). I got the following files:
    • modelRoot.mesh
    • modelRoot.skeleton
    • model.material
    • model.tga

Note: I also use OgreMeshTool_d.exe to upgrade the mesh from v1 to v2.

  1. I render this model into Ogre:

In the file resources2.cfg:

[Essential]
Zip=../Data/DebugPack.zip

I add the model files (4 files I got from Easy Ogre Exporter at step 1 above) into DebugPack.zip file.

And I use this code to add the model into the Ogre scene

void MeshHelper::CreateMesh(Ogre::String szFileName, Ogre::Vector3* scale)
{
    /*Bring the mesh to scene*/
    m_meshItem = m_sceneManager->createItem(szFileName,
        Ogre::ResourceGroupManager::
        AUTODETECT_RESOURCE_GROUP_NAME,
        Ogre::SCENE_DYNAMIC);
    m_meshSceneNode = m_sceneManager->getRootSceneNode(Ogre::SCENE_DYNAMIC)->
        createChildSceneNode(Ogre::SCENE_DYNAMIC);
    m_meshSceneNode->attachObject(m_meshItem);
    if (nullptr != scale)
        m_meshSceneNode->scale(scale->x, scale->y, scale->z);
}
...
meshHelper.CreateMesh("modelRoot.mesh", &meshScale);

But I can only render the model without texture :(

Please help me to apply these texture into my model

  • model.material
  • model.tga

Thanks for reading :)

\$\endgroup\$
0
\$\begingroup\$

Oh boy, finally I discover how Ogre apply texture on mesh.

Ogre just read the mesh file (.mesh), then read the skeleton file (.skeleton), then read the material file, the material file (.material) tells Ogre where is the texture file for this mesh, then Ogre read the texture file (.tga). So in C++ code, just tell Ogre where is the mesh file is enough.

The problem here is the file model.material, which Easy Ogre Exporter generated, is outdated to Ogre 2.1. So Ogre did read this file, but it didn't accept the format of this file. All I have to do is read other material file format in Ogre 2.1's sample to learn the format so that I can re-write this material file (model.material).

Currently, in Ogre 2.1, the model.material should be fixed like this:

hlms modelMaterial__46 pbs
{
    roughness   0.4
    fresnel     1.33

    diffuse_map     model.tga
}

Note:

  • modelMaterial__46 is the material name generated by Easy Ogre Exporter, better keep the name because the mesh file (modelRoot.mesh) recognize this name. Maybe in your case, it is other name (for example: modelMaterial__69)
  • model.tga is the file name of the texture file, of course :)
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.