Applying Texture using Collada model

Hi All,



I have created a small collada model and have it showing up in jME… I want to now apply a texture to the surfaces in jME (not in Blender which I used to create the model). I have tried many things and the texture never shows up. I am new to jME, so this could be a simple problem.



Here is my code (mostly from examples). Thanks for any help! I assume it's possible, but don't seem to know how?!?



Thanks for a great product…I think it'll be very fun to use!

Dan



package houseviewer;

import com.jme.app.SimpleGame;

import com.jme.bounding.BoundingBox;
import com.jme.image.Texture;
import com.jme.math.FastMath;
import com.jme.math.Quaternion;
import com.jme.math.Vector3f;
import com.jme.scene.Node;
import com.jme.scene.Spatial;
import com.jme.scene.state.TextureState;
import com.jme.util.TextureManager;
import com.jmex.model.collada.ColladaImporter;
import java.io.InputStream;

/**
 *
 */
public class RotateHouse extends SimpleGame {

    private Quaternion rotQuat = new Quaternion();
    private float angle = 0;
    private Vector3f axis = new Vector3f(0, 1, 0);
    private Node house;

    public void applyTexture(Spatial n, String texture) {

        if (n == null) {
            System.err.println("Node is null in applyTexture!");
            return;
        }

        Texture t0 = TextureManager.loadTexture(
                TestBoxDan.class.getClassLoader().getResource(
                "houseviewer/marvin_martian.jpg"),
                Texture.MinificationFilter.Trilinear,
                Texture.MagnificationFilter.Bilinear);

        t0.setWrap(Texture.WrapMode.Repeat);

        TextureState ts = display.getRenderer().createTextureState();
        ts.setEnabled(true);
        ts.setTexture(t0);
        t0.setApply(Texture.ApplyMode.Replace);

        n.setRenderState(ts);
        n.updateRenderState();
    }



    public Node loadMyColladaModel() {
        InputStream gamemap = Main.class.getClassLoader().
                getResourceAsStream("houseviewer/house2.dae");
        if (gamemap == null) {
            System.out.println("Collada data file not found");
            System.exit(0);
        }
        ColladaImporter.load(gamemap, "model");
        Node n = ColladaImporter.getModel();

        n.setModelBound(new BoundingBox()); // collision detection
        n.updateModelBound(); // collision detection

        return n;
    }

    protected void simpleUpdate() {
        if (tpf < 1) {
            angle = angle + tpf * 25;
            if (angle > 360) {
                angle = 0;
            }
        }
        rotQuat.fromAngleAxis(angle * FastMath.DEG_TO_RAD, axis);
        rootNode.setLocalRotation(rotQuat);
    }

    protected void simpleInitGame() {
        // Point to a URL of my model
        try {
            house = loadMyColladaModel();
            applyTexture(house, "dummy");
            rootNode.attachChild(house);
            rootNode.updateRenderState();
        } catch (Exception e) {   // Just in case anything happens
            System.out.println("Damn exceptions!" + e);
            e.printStackTrace();
            System.exit(0);
        }
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Main app = new Main();
        app.setConfigShowMode(ConfigShowMode.AlwaysShow);
        app.start();
    }
}

The code looks ok to me, do you see no texture (if so what color has the model?) at all or the default jme texture?

I see no texture, just grey faces. It may be something I need to do with the collada model (the model is > 20000 chars though so I couldn't attach).



I'll do it in two posts… here is half of the collada file I'm using:



<?xml version="1.0" encoding="utf-8"?>
<COLLADA version="1.4.0" xmlns="http://www.collada.org/2005/11/COLLADASchema">
   <asset>
   <unit meter="0.01" name="centimeter"/>
   <up_axis>Z_UP</up_axis>
   </asset>
   <library_geometries>
   <geometry id="Plane_013" name="Plane_013">
   <mesh>
   <source id="Plane_013-Position">
      <float_array count="12" id="Plane_013-Position-array">1.87983 1.36121 7.24291 1.88845 -0.98969 8.07023 -2.58684 -0.97140 8.05821 -2.58683 1.35143 7.22908</float_array>
      <technique_common>
   <accessor count="4" source="#Plane_013-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_013-Normals">
      <float_array count="3" id="Plane_013-Normals-array">-0.00241 0.33405 0.94255</float_array>
      <technique_common>
   <accessor count="1" source="#Plane_013-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_013-Vertex">
      <input semantic="POSITION" source="#Plane_013-Position"/>
   </vertices>
   <triangles count="2">
      <input offset="0" semantic="VERTEX" source="#Plane_013-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_013-Normals"/>
      <p>0 0 3 0 2 0 2 0 1 0 0 0</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_012" name="Plane_012">
   <mesh>
   <source id="Plane_012-Position">
      <float_array count="12" id="Plane_012-Position-array">3.49867 5.80983 6.03781 3.48457 2.33246 4.68432 -3.82285 2.31646 4.66169 -3.82286 5.83976 6.01814</float_array>
      <technique_common>
   <accessor count="4" source="#Plane_012-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_012-Normals">
      <float_array count="3" id="Plane_012-Normals-array">-0.00304 -0.36099 0.93257</float_array>
      <technique_common>
   <accessor count="1" source="#Plane_012-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_012-Vertex">
      <input semantic="POSITION" source="#Plane_012-Position"/>
   </vertices>
   <triangles count="2">
      <input offset="0" semantic="VERTEX" source="#Plane_012-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_012-Normals"/>
      <p>0 0 3 0 2 0 2 0 1 0 0 0</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_011" name="Plane_011">
   <mesh>
   <source id="Plane_011-Position">
      <float_array count="12" id="Plane_011-Position-array">-1.43537 -2.78551 3.36004 -1.38476 -2.78551 -0.68760 -5.37089 -2.83511 -0.70154 -5.37787 -2.83516 3.35203</float_array>
      <technique_common>
   <accessor count="4" source="#Plane_011-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_011-Normals">
      <float_array count="3" id="Plane_011-Normals-array">0.01252 -0.99992 0.00008</float_array>
      <technique_common>
   <accessor count="1" source="#Plane_011-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_011-Vertex">
      <input semantic="POSITION" source="#Plane_011-Position"/>
   </vertices>
   <triangles count="2">
      <input offset="0" semantic="VERTEX" source="#Plane_011-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_011-Normals"/>
      <p>0 0 3 0 2 0 2 0 1 0 0 0</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_010" name="Plane_010">
   <mesh>
   <source id="Plane_010-Position">
      <float_array count="12" id="Plane_010-Position-array">10.50307 1.00000 -0.68627 10.56049 -1.04163 -0.68195 -1.05964 -1.04163 0.15721 -1.00000 1.00000 0.00000</float_array>
      <technique_common>
   <accessor count="4" source="#Plane_010-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_010-Normals">
      <float_array count="3" id="Plane_010-Normals-array">0.06578 0.03941 0.99706</float_array>
      <technique_common>
   <accessor count="1" source="#Plane_010-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_010-Vertex">
      <input semantic="POSITION" source="#Plane_010-Position"/>
   </vertices>
   <triangles count="2">
      <input offset="0" semantic="VERTEX" source="#Plane_010-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_010-Normals"/>
      <p>0 0 3 0 2 0 2 0 1 0 0 0</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_009-Geometry" name="Plane_009-Geometry">
   <mesh>
   <source id="Plane_009-Geometry-Position">
      <float_array count="12" id="Plane_009-Geometry-Position-array">0.92820 0.99930 -0.01938 0.92810 -10.53337 0.37780 -1.07190 -10.53337 0.37780 -1.07180 0.99930 -0.01938</float_array>
      <technique_common>
   <accessor count="4" source="#Plane_009-Geometry-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_009-Geometry-Normals">
      <float_array count="3" id="Plane_009-Geometry-Normals-array">0.00000 0.03442 0.99941</float_array>
      <technique_common>
   <accessor count="1" source="#Plane_009-Geometry-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_009-Geometry-Vertex">
      <input semantic="POSITION" source="#Plane_009-Geometry-Position"/>
   </vertices>
   <triangles count="2">
      <input offset="0" semantic="VERTEX" source="#Plane_009-Geometry-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_009-Geometry-Normals"/>
      <p>0 0 3 0 2 0 2 0 1 0 0 0</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_008-Geometry" name="Plane_008-Geometry">
   <mesh>
   <source id="Plane_008-Geometry-Position">
      <float_array count="12" id="Plane_008-Geometry-Position-array">1.80727 0.00941 -0.06985 1.80727 0.00941 4.29455 0.31288 0.04602 4.27185 0.30863 0.02870 -0.03188</float_array>
      <technique_common>
   <accessor count="4" source="#Plane_008-Geometry-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_008-Geometry-Normals">
      <float_array count="3" id="Plane_008-Geometry-Normals-array">0.01866 0.99982 -0.00201</float_array>
      <technique_common>
   <accessor count="1" source="#Plane_008-Geometry-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_008-Geometry-Vertex">
      <input semantic="POSITION" source="#Plane_008-Geometry-Position"/>
   </vertices>
   <triangles count="2">
      <input offset="0" semantic="VERTEX" source="#Plane_008-Geometry-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_008-Geometry-Normals"/>
      <p>0 0 3 0 2 0 2 0 1 0 0 0</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_007-Geometry" name="Plane_007-Geometry">
   <mesh>
   <source id="Plane_007-Geometry-Position">
      <float_array count="12" id="Plane_007-Geometry-Position-array">4.59439 2.39264 6.38220 4.60112 2.38591 4.55819 3.91092 2.39597 4.55676 3.91092 2.39597 6.38076</float_array>
      <technique_common>
   <accessor count="4" source="#Plane_007-Geometry-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_007-Geometry-Normals">
      <float_array count="3" id="Plane_007-Geometry-Normals-array">-0.00974 -0.99995 0.00183</float_array>
      <technique_common>
   <accessor count="1" source="#Plane_007-Geometry-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_007-Geometry-Vertex">
      <input semantic="POSITION" source="#Plane_007-Geometry-Position"/>
   </vertices>
   <triangles count="2">
      <input offset="0" semantic="VERTEX" source="#Plane_007-Geometry-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_007-Geometry-Normals"/>
      <p>0 0 3 0 2 0 2 0 1 0 0 0</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_006-Geometry" name="Plane_006-Geometry">
   <mesh>
   <source id="Plane_006-Geometry-Position">
      <float_array count="15" id="Plane_006-Geometry-Position-array">-8.29896 -0.24533 16.88643 -8.29896 -8.05855 16.88643 -8.29896 -8.05855 12.28455 -8.29896 -0.24533 12.28455 -8.29897 -4.29961 18.33360</float_array>
      <technique_common>
   <accessor count="5" source="#Plane_006-Geometry-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_006-Geometry-Normals">
      <float_array count="9" id="Plane_006-Geometry-Normals-array">-1.00000 0.00000 -0.00000 -1.00000 -0.00000 0.00000 -1.00000 0.00000 -0.00000</float_array>
      <technique_common>
   <accessor count="3" source="#Plane_006-Geometry-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_006-Geometry-Vertex">
      <input semantic="POSITION" source="#Plane_006-Geometry-Position"/>
   </vertices>
   <triangles count="3">
      <input offset="0" semantic="VERTEX" source="#Plane_006-Geometry-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_006-Geometry-Normals"/>
      <p>4 0 3 0 2 0 1 1 4 1 2 1 4 2 0 2 3 2</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_005-Geometry" name="Plane_005-Geometry">
   <mesh>
   <source id="Plane_005-Geometry-Position">
      <float_array count="12" id="Plane_005-Geometry-Position-array">-0.09859 -6.28772 11.56451 -0.08754 -6.29876 8.57183 -5.14210 -6.29876 8.57183 -5.14210 -6.29876 11.54890</float_array>
      <technique_common>
   <accessor count="4" source="#Plane_005-Geometry-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_005-Geometry-Normals">
      <float_array count="3" id="Plane_005-Geometry-Normals-array">0.00109 -1.00000 0.00185</float_array>
      <technique_common>
   <accessor count="1" source="#Plane_005-Geometry-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_005-Geometry-Vertex">
      <input semantic="POSITION" source="#Plane_005-Geometry-Position"/>
   </vertices>
   <triangles count="2">
      <input offset="0" semantic="VERTEX" source="#Plane_005-Geometry-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_005-Geometry-Normals"/>
      <p>0 0 3 0 2 0 2 0 1 0 0 0</p>
   </triangles>
   </mesh>
   </geometry>
   <geometry id="Plane_004-Geometry" name="Plane_004-Geometry">
   <mesh>
   <source id="Plane_004-Geometry-Position">
      <float_array count="15" id="Plane_004-Geometry-Position-array">0.58851 -0.82786 3.39779 0.58851 -2.68389 3.39779 0.59257 -2.68795 2.29888 0.59257 -0.83192 2.29888 0.59209 -1.80260 3.74081</float_array>
      <technique_common>
   <accessor count="5" source="#Plane_004-Geometry-Position-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <source id="Plane_004-Geometry-Normals">
      <float_array count="9" id="Plane_004-Geometry-Normals-array">-1.00000 0.00000 -0.00033 -0.99998 0.00550 -0.00371 -0.99998 -0.00496 -0.00367</float_array>
      <technique_common>
   <accessor count="3" source="#Plane_004-Geometry-Normals-array" stride="3">
      <param type="float" name="X"></param>
      <param type="float" name="Y"></param>
      <param type="float" name="Z"></param>
   </accessor>
      </technique_common>
   </source>
   <vertices id="Plane_004-Geometry-Vertex">
      <input semantic="POSITION" source="#Plane_004-Geometry-Position"/>
   </vertices>
   <triangles count="3">
      <input offset="0" semantic="VERTEX" source="#Plane_004-Geometry-Vertex"/>
      <input offset="1" semantic="NORMAL" source="#Plane_004-Geometry-Normals"/>
      <p>4 0 3 0 2 0 1 1 4 1 2 1 4 2 0 2 3 2</p>
   </triangles>
   </mesh>
   </geometry>
   </library_geometries>
   <library_visual_scenes>
   <visual_scene id="Scene" name="Scene">
   <node layer="L1" id="Plane" name="Plane">
   <translate sid="translate">-5.42360 -3.95496 -21.34554</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">4.39577 4.39577 4.39577</scale>
   <instance_geometry url="#Plane_013"/>
   </node>
   <node layer="L1" id="Plane_009" name="Plane_009">
   <translate sid="translate">-6.52305 -23.91593 -2.09374</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">2.68691 2.68691 2.68691</scale>
   <instance_geometry url="#Plane_012"/>
   </node>
   <node layer="L1" id="Plane_008" name="Plane_008">
   <translate sid="translate">2.40777 12.02109 0.84740</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">2.84675 2.84675 2.84675</scale>
   <instance_geometry url="#Plane_011"/>
   </node>
   <node layer="L1" id="Plane_007" name="Plane_007">
   <translate sid="translate">-1.60633 3.09144 9.41520</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 85.86948</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">1.00000 1.00000 1.00000</scale>
   <instance_geometry url="#Plane_010"/>
   </node>
   <node layer="L1" id="Plane_006" name="Plane_006">
   <translate sid="translate">-12.88273 2.87834 9.39045</translate>
   <rotate sid="rotateZ">0 0 1 -89.88217</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 92.07108</rotate>
   <scale sid="scale">1.00000 1.00000 1.00000</scale>
   <instance_geometry url="#Plane_009-Geometry"/>
   </node>

Here is the second half of the Collada model file:



   <node layer="L1" id="Plane_005" name="Plane_005">
   <translate sid="translate">-11.99548 2.01059 10.24634</translate>
   <rotate sid="rotateZ">0 0 1 -0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -180.00000</rotate>
   <rotate sid="rotateX">1 0 0 -0.00000</rotate>
   <scale sid="scale">2.65551 -2.65551 2.65551</scale>
   <instance_geometry url="#Plane_008-Geometry"/>
   </node>
   <node layer="L1" id="Plane_004" name="Plane_004">
   <translate sid="translate">-26.50603 -13.25393 -30.27236</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">6.38729 6.38729 6.38729</scale>
   <instance_geometry url="#Plane_007-Geometry"/>
   </node>
   <node layer="L1" id="Plane_003" name="Plane_003">
   <translate sid="translate">4.10603 2.60346 -32.09623</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">2.51848 2.51848 2.51848</scale>
   <instance_geometry url="#Plane_006-Geometry"/>
   </node>
   <node layer="L1" id="Plane_002" name="Plane_002">
   <translate sid="translate">3.22349 6.82927 -34.52802</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">3.89300 3.89300 3.89300</scale>
   <instance_geometry url="#Plane_005-Geometry"/>
   </node>
   <node layer="L1" id="Plane_001" name="Plane_001">
   <translate sid="translate">-3.39964 10.80551 -25.53035</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">10.60189 10.60189 10.60189</scale>
   <instance_geometry url="#Plane_004-Geometry"/>
   </node>
   <node layer="L1" id="TestGroup" name="TestGroup">
   <translate sid="translate">18.74864 -7.41819 -33.36597</translate>
   <rotate sid="rotateZ">0 0 1 0.00000</rotate>
   <rotate sid="rotateY">0 1 0 -0.00000</rotate>
   <rotate sid="rotateX">1 0 0 0.00000</rotate>
   <scale sid="scale">1.00000 1.00000 1.00000</scale>
   </node>
   </visual_scene>
   </library_visual_scenes>
   <library_physics_materials>
   <physics_material id="Plane-PhysicsMaterial" name="Plane-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_009-PhysicsMaterial" name="Plane_009-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_008-PhysicsMaterial" name="Plane_008-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_007-PhysicsMaterial" name="Plane_007-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_006-PhysicsMaterial" name="Plane_006-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_005-PhysicsMaterial" name="Plane_005-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_004-PhysicsMaterial" name="Plane_004-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_003-PhysicsMaterial" name="Plane_003-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_002-PhysicsMaterial" name="Plane_002-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   <physics_material id="Plane_001-PhysicsMaterial" name="Plane_001-PhysicsMaterial">
   <technique_common>
   <dynamic_friction>0</dynamic_friction>
   <restitution>0</restitution>
   <static_friction>0</static_friction>
   </technique_common>
   </physics_material>
   </library_physics_materials>
   <library_physics_models>
   <physics_model id="Scene-PhysicsModel" name="Scene-PhysicsModel">
   <rigid_body name="Plane-RigidBody" sid="Plane-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_013"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_009-RigidBody" sid="Plane_009-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_009-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_012"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_008-RigidBody" sid="Plane_008-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_008-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_011"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_007-RigidBody" sid="Plane_007-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_007-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_010"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_006-RigidBody" sid="Plane_006-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_006-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_009-Geometry"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_005-RigidBody" sid="Plane_005-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_005-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_008-Geometry"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_004-RigidBody" sid="Plane_004-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_004-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_007-Geometry"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_003-RigidBody" sid="Plane_003-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_003-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_006-Geometry"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_002-RigidBody" sid="Plane_002-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_002-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_005-Geometry"/>
      </shape>
   </technique_common>
   </rigid_body>
   <rigid_body name="Plane_001-RigidBody" sid="Plane_001-RigidBody">
   <technique_common>
      <dynamic>false</dynamic>
      <mass>0</mass>
      <instance_physics_material url="#Plane_001-PhysicsMaterial"/>
      <shape>
   <instance_geometry url="#Plane_004-Geometry"/>
      </shape>
   </technique_common>
   </rigid_body>
   </physics_model>
   </library_physics_models>
   <library_physics_scenes>
   <physics_scene id="Scene-Physics" name="Scene-Physics">
   <instance_physics_model url="#Scene-PhysicsModel">
   <instance_rigid_body body="Plane-RigidBody" target="#Plane"/>
   <instance_rigid_body body="Plane_009-RigidBody" target="#Plane_009"/>
   <instance_rigid_body body="Plane_008-RigidBody" target="#Plane_008"/>
   <instance_rigid_body body="Plane_007-RigidBody" target="#Plane_007"/>
   <instance_rigid_body body="Plane_006-RigidBody" target="#Plane_006"/>
   <instance_rigid_body body="Plane_005-RigidBody" target="#Plane_005"/>
   <instance_rigid_body body="Plane_004-RigidBody" target="#Plane_004"/>
   <instance_rigid_body body="Plane_003-RigidBody" target="#Plane_003"/>
   <instance_rigid_body body="Plane_002-RigidBody" target="#Plane_002"/>
   <instance_rigid_body body="Plane_001-RigidBody" target="#Plane_001"/>
   </instance_physics_model>
   </physics_scene>
   </library_physics_scenes>
   <scene>
   <instance_physics_scene url="#Scene-Physics"/>
   <instance_visual_scene url="#Scene"/>
   </scene>
</COLLADA>



i don't really know about modeling sorry :)  are there texture coordinates in the collada file (didn't see any, but i don't know what to look for anyway)?

No, I don't think so. I guess one thing I don't understand in jME is texture coordinates. I've read the docs that there are a range from [0 1], but don't quite understand what that represents.



If you know that, let me know and that may help me debug from there.



Thanks so much for your help! I do appreciate it!  :smiley:

Try researching UV Texture mapping. I found this blog post which will explain the concepts to you, it even has a 3D applet running to show how it looks. Neat! http://rozengain.com/?postid=45







Edit: Also added this link to the wiki @ http://www.jmonkeyengine.com/wiki/doku.php?id=links

Yep, i guess you need to create the uv mapping in your 3d modeling app.

Then later when you apply the TextureState to your model in jME, the Textures will be applied correctly (hopefully :))

Hi, everyone.  I have encountered the same problem.  I'm using 3d max + ColladaMax plugin to generate the simple textured model.  But the texture just doesn't show up in JME.  Has anyone sucessed to get the collada  model texture from 3d max or Maya work in JME?  Hopefully the problem can be solve soon.

Hi,



Actually, I think based on the previous emails I did solve my problem. The key was UV mapping. When I added in a UV texture map in Blender, then saved the model file.



I then loaded the model using jME. From there, when I use the code I posted to add my own texture to the model, the new texture showed up. One oddness is that if I do not add my own texture, the Collada texture did not show up (just shows up as gray). However, exporting an Obj file instead does show the initial texture from Blender also.



The key (as the previous posters told me) was UV mapping. Thanks to all for the help!



Let me know if you need more help.


  • Dan

Programmically texturing the model after it's loaded in JME may solve the problem.  But most frequently we just want to keep the texture originally created in the collada model.  I just can't get it work. ://

It's strange that in the sample code named TestColladaLoading with JME  the models works fine with the texture.

Really quite strange… :?

haha, problem finally sovled! :smiley:

The reason of the problem is the colllada importer in jME currently only supports lambert and phong shading.  So by applying textures using these two methods in modeing applications,  the texture is finally displayed in jME.



Walk animation:





Walk animation bone debug:


it would be good to collect those collada importer limitation, maybe in a wiki page or in the jme 2 issue tracker so that the a developer or the community can implement or fix missing features.