1 package com.jme3.scene.plugins.blender.meshes; 2 3 import com.jme3.math.Vector3f; 4 import com.jme3.scene.Geometry; 5 import com.jme3.scene.VertexBuffer; 6 import java.util.HashMap; 7 import java.util.List; 8 import java.util.Map; 9 10 /** 11 * Class that holds information about the mesh. 12 * 13 * @author Marcin Roguski (Kaelthas) 14 */ 15 public class MeshContext { 16 /** The mesh stored here as a list of geometries. */ 17 private List<Geometry> mesh; 18 /** Vertex list that is referenced by all the geometries. */ 19 private List<Vector3f> vertexList; 20 /** The vertex reference map. */ 21 private Map<Integer, List<Integer>> vertexReferenceMap; 22 /** The UV-coordinates for each of the geometries. */ 23 private Map<Geometry, VertexBuffer> uvCoordinates = new HashMap<Geometry, VertexBuffer>(); 24 25 /** 26 * This method returns the referenced mesh. 27 * 28 * @return the referenced mesh 29 */ getMesh()30 public List<Geometry> getMesh() { 31 return mesh; 32 } 33 34 /** 35 * This method sets the referenced mesh. 36 * 37 * @param mesh 38 * the referenced mesh 39 */ setMesh(List<Geometry> mesh)40 public void setMesh(List<Geometry> mesh) { 41 this.mesh = mesh; 42 } 43 44 /** 45 * This method returns the vertex list. 46 * 47 * @return the vertex list 48 */ getVertexList()49 public List<Vector3f> getVertexList() { 50 return vertexList; 51 } 52 53 /** 54 * This method sets the vertex list. 55 * 56 * @param vertexList 57 * the vertex list 58 */ setVertexList(List<Vector3f> vertexList)59 public void setVertexList(List<Vector3f> vertexList) { 60 this.vertexList = vertexList; 61 } 62 63 /** 64 * This method returns the vertex reference map. 65 * 66 * @return the vertex reference map 67 */ getVertexReferenceMap()68 public Map<Integer, List<Integer>> getVertexReferenceMap() { 69 return vertexReferenceMap; 70 } 71 72 /** 73 * This method sets the vertex reference map. 74 * 75 * @param vertexReferenceMap 76 * the vertex reference map 77 */ setVertexReferenceMap( Map<Integer, List<Integer>> vertexReferenceMap)78 public void setVertexReferenceMap( 79 Map<Integer, List<Integer>> vertexReferenceMap) { 80 this.vertexReferenceMap = vertexReferenceMap; 81 } 82 83 /** 84 * This method adds the mesh's UV-coordinates. 85 * 86 * @param geometry 87 * the mesh that has the UV-coordinates 88 * @param vertexBuffer 89 * the mesh's UV-coordinates 90 */ addUVCoordinates(Geometry geometry, VertexBuffer vertexBuffer)91 public void addUVCoordinates(Geometry geometry, VertexBuffer vertexBuffer) { 92 uvCoordinates.put(geometry, vertexBuffer); 93 } 94 95 /** 96 * This method returns the mesh's UV-coordinates. 97 * 98 * @param geometry 99 * the mesh 100 * @return the mesh's UV-coordinates 101 */ getUVCoordinates(Geometry geometry)102 public VertexBuffer getUVCoordinates(Geometry geometry) { 103 return uvCoordinates.get(geometry); 104 } 105 } 106