Advertisement
stuart6854

Mesh.java

Jun 1st, 2016
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. package org.bearengine.graphics.types;
  2.  
  3. import java.util.List;
  4.  
  5. /**
  6.  * Created by Stuart on 22/05/2016.
  7.  */
  8. public class Mesh {
  9.  
  10.     public String Mesh_Name = "";
  11.  
  12.     public Material material;
  13.  
  14.     public int IndicesCount;
  15.     private int[] indices;
  16.     private float[] vertices;
  17.     private float[] uvs;
  18.     private float[] normals;
  19.  
  20.     public RenderModel renderModel;
  21.  
  22.     public Mesh(){
  23.  
  24.     }
  25.  
  26.     public void SetIndices(List<Integer> indicesList){
  27.         int[] indices = new int[indicesList.size()];
  28.         for(int i = 0; i < indicesList.size(); i++) indices[i] = indicesList.get(i);
  29.         this.indices = indices;
  30.         this.IndicesCount = indices.length;
  31.     }
  32.  
  33.     public void SetVertices(List<Float> verticesList){
  34.         float[] verts = new float[verticesList.size()];
  35.         for(int i = 0; i < verticesList.size(); i++) verts[i] = verticesList.get(i);
  36.         this.vertices = verts;
  37.     }
  38.  
  39.     public void SetUVs(List<Float> uvsList){
  40.         float[] uvs = new float[uvsList.size()];
  41.         for(int i = 0; i < uvsList.size(); i++) uvs[i] = uvsList.get(i);
  42.         this.uvs = uvs;
  43.     }
  44.  
  45.     public void SetNormals(List<Float> normalsList){
  46.         float[] normals = new float[normalsList.size()];
  47.         for(int i = 0; i < normalsList.size(); i++) normals[i] = normalsList.get(i);
  48.         this.normals = normals;
  49.     }
  50.  
  51.     public void CreateRenderModel(){
  52.         renderModel = RenderModel.Create3DModel(vertices, uvs, normals, indices);
  53.     }
  54.  
  55.     public float[] GetVertices(){
  56.         return vertices;
  57.     }
  58.  
  59.     public float[] GetUvs() {
  60.         return uvs;
  61.     }
  62.  
  63.     public float[] GetNormals() {
  64.         return normals;
  65.     }
  66.  
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement