import com.jme.scene.*; import com.jme.math.*; import com.jme.scene.state.MaterialState; import com.jme.scene.state.TextureState; import com.jme.renderer.ColorRGBA; import javax.vecmath.*; //import java.awt.Color; //import java.awt.color.ColorSpace; class cJME { static boolean gennormals = false; // can be done through UI static boolean trim = true; static boolean stripify = false; // true; static boolean reduction34 = false; static boolean genUV = false; static boolean mergeAttributes = true; Matrix4d tempmat = new Matrix4d(); Matrix4d tempmatR = new Matrix4d(); Matrix4d tempmatS = new Matrix4d(); Matrix4d tempmatT = new Matrix4d(); Quat4d quat = new Quat4d(); javax.vecmath.Vector3d trans = new javax.vecmath.Vector3d(); Object3D Read(Spatial s) { // System.out.println("Parsing: " + s); if (s == null) return new Object3D("NULL"); if (s instanceof Node) return Read((Node)s); if (s instanceof com.jme.scene.TriMesh) return Read((com.jme.scene.TriMesh)s); //if (s instanceof SharedNode) //return Read(((SharedNode)s).getChild()); System.out.println("Unknown node class : " + s.getClass().getSimpleName()); return new Object3D(s.getClass().getName()); } public int count = 0; void ReadTransform(Object3D c, Spatial g) { tempmat.setIdentity(); tempmatR.setIdentity(); tempmatS.setIdentity(); tempmatT.setIdentity(); Quaternion q = g.getLocalRotation(); quat.set(q.x, q.y, q.z, q.w); com.jme.math.Vector3f s = g.getLocalScale(); com.jme.math.Vector3f t = g.getLocalTranslation(); trans.set(t.x, t.y, t.z); tempmatR.setRotation(quat); //tempmat.setScale(s.x); tempmatS.setElement(0,0, s.x); tempmatS.setElement(1,1, s.y); tempmatS.setElement(2,2, s.z); tempmatT.setTranslation(trans); // System.out.println("R = " + quat); // System.out.println("S = " + s); // System.out.println("T = " + trans); switch(count%6) { case 0: tempmat.mul(tempmatT); tempmat.mul(tempmatR); tempmat.mul(tempmatS); // System.out.println("TRS"); break; case 1: tempmat.mul(tempmatT); tempmat.mul(tempmatS); tempmat.mul(tempmatR); // System.out.println("TSR"); break; case 2: tempmat.mul(tempmatR); tempmat.mul(tempmatS); tempmat.mul(tempmatT); // System.out.println("RST"); break; case 3: tempmat.mul(tempmatR); tempmat.mul(tempmatT); tempmat.mul(tempmatS); // System.out.println("RTS"); break; case 4: tempmat.mul(tempmatS); tempmat.mul(tempmatT); tempmat.mul(tempmatR); // System.out.println("STR"); break; case 5: tempmat.mul(tempmatS); tempmat.mul(tempmatR); tempmat.mul(tempmatT); // System.out.println("SRT"); break; } if (c.toParent == null) { c.toParent = LA.newMatrix(); c.fromParent = LA.newMatrix(); } if (count < 6) { FillMatrix(tempmat, c.toParent); LA.matInvert(c.toParent, c.fromParent); } else { FillMatrix(tempmat, c.fromParent); LA.matInvert(c.toParent, c.toParent); } } void ReadMaterial(Object3D o, Spatial s) { //Object texture = s.getRenderState(com.jme.scene.state.RenderState.RS_TEXTURE); o.material = Read((MaterialState)s.getRenderState(com.jme.scene.state.RenderState.RS_MATERIAL)); } void ReadTexture(Object3D o, Spatial s) { o.GetTextures().name = ":"; // Read((TextureState)s.getRenderState(com.jme.scene.state.RenderState.RS_TEXTURE)); } void ReadNode(Object3D c, Spatial g) { ReadTransform(c, g); ReadMaterial(c, g); ReadTexture(c, g); } Object3D Read(Node g) { Composite c = new Composite(g.getClass().getName()); ReadNode(c, g); for (int i=0; i= 3; bRep.AddFace(indexV, indexV+1, indexV+2); indexF++; //bRep.faces.addElement(null); //bRep.setFace(indexF++, indexV, indexV+1, indexV+2); indexV += 3; for (int j=3; j