Color Loading with OGREMaterialLoader

So… I've implemented ambient, diffuse and specular color loading from an Ogre Materiallist file.

Here's the patch:

--- Base (BASE)
+++ Locally Modified (Based On LOCAL)
@@ -24,7 +24,7 @@
     private String folderName;
     private AssetManager assetManager;
     private Scanner scan;
-    private ColorRGBA diffuse, specular;
+    private ColorRGBA ambient, diffuse, specular;
     private Texture texture;
     private String texName;
     private String matName;
@@ -155,6 +155,8 @@
                 diffuse = readColor();
+        }else if(keyword.equals("ambient")) {
+            ambient = readColor();
         }else if (keyword.equals("specular")){
             specular = new ColorRGBA();
             specular.r = scan.nextFloat();
@@ -282,6 +284,10 @@
         if (texture != null)
             mat.setTexture("m_DiffuseMap", texture);
+        if(diffuse  != null) mat.setColor("m_Diffuse",  diffuse);
+        if(ambient  != null) mat.setColor("m_Ambient",  ambient);
+        if(specular != null) mat.setColor("m_Specular", specular);
         texture = null;
         diffuse = null;
         specular = null;


Thanks, added it in my local copy.

Hi Momoko_Fan,

Is this allready in the repository ? My OGRE models won't show the materials correctly.

Thanks in advance.

This is already in the Repository, but did you updated it?

if you're using jMonkeyPlatform, you have to compile it yourself with the newest jME3 (from SVN)

the alpha release doesn't support color loading.

I've updated my jMonkeyPlatform today with the NetBeans updater.

The model loads correctly in the SceneViewer now, but only if I turn the light button on.

It won't show in my own application though. Do you know what kind of light I should create in my own application to show the model ?

If u want to only display a Model i would suggest to add a DirectionalLight to your model.

Of course, you could also add a PointLight and I'm no lighting expert :wink:

Thanks for your answers. It works now.  :slight_smile: