Advertisement
Guest User

ModelReader.java

a guest
Feb 16th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.57 KB | None | 0 0
  1. package engine.models;
  2.  
  3. import com.opencsv.CSVReader;
  4. import com.opencsv.bean.CsvToBean;
  5. import com.opencsv.bean.CsvToBeanBuilder;
  6.  
  7. import engine.models.textures.ModelTexture;
  8. import engine.objconverter.Vertex;
  9. imports... etc..
  10.  
  11. import org.lwjgl.util.vector.Vector3f;
  12.  
  13. /**
  14. *
  15. * Reads the models.csv file
  16. * @author
  17. *
  18. */
  19.  
  20. public class ModelReader {
  21.  
  22. static int modelTotalNumber;
  23.  
  24. /*
  25. *
  26. * Start of ArrayList for X,Y,Z coordinates
  27. */
  28. //List<Float> x = new ArrayList<Float>();
  29. //List<Float> y = new ArrayList<Float>();
  30. //List<Float> z = new ArrayList<Float>();
  31. /*
  32. *
  33. * End of ArrayList for X,Y,Z coordinates
  34. */
  35.  
  36. /*
  37. *
  38. * Start of HashMap test!
  39. */
  40. static HashMap<String,String> modFTNamesh = new HashMap<String,String>();
  41. static HashMap<Float, Float> xy = new HashMap<Float,Float>();
  42. float x;
  43. float y;
  44. float zc;
  45. public static HashMap<Float, Float> getXy() {
  46. return xy;
  47. }
  48.  
  49. public static HashMap<Float, Float> getZ() {
  50. return z;
  51. }
  52.  
  53.  
  54. static HashMap<Float, Float> z = new HashMap<Float,Float>();
  55. public static HashMap<String, String> getModFTNamesh() {
  56. return modFTNamesh;
  57. }
  58.  
  59. /*
  60. *
  61. * End of Hashmap test!
  62. */
  63. public ModelReader() {
  64.  
  65. try {
  66. CSVReader reader = new CSVReader(new FileReader("res/read/models.csv"));
  67. String[] nextLine;
  68. int modelNum = 0;
  69. while((nextLine = reader.readNext()) != null) {
  70. modelNum++;
  71. if(nextLine != null) {
  72. String modelNumber = nextLine[0];
  73. String modelName = nextLine[1];
  74. String modelFileName = nextLine[2];
  75. String modelTexture = nextLine[3];
  76. String modelCoordX = nextLine[4];
  77. String modelCoordY = nextLine[5];
  78. String modelCoordZ = nextLine[6];
  79. float modelCoordXFloat = Float.parseFloat(modelCoordX);
  80. float modelCoordYFloat = Float.parseFloat(modelCoordY);
  81. float modelCoordZFloat = Float.parseFloat(modelCoordZ);
  82. zc = modelCoordZFloat;
  83. x = modelCoordXFloat;
  84. y = modelCoordYFloat;
  85.  
  86. /*
  87. *
  88. * Start of HashMap
  89. */
  90. modFTNamesh.put(modelFileName, modelTexture);
  91. xy.put(modelCoordXFloat, modelCoordYFloat);
  92. z.put(modelCoordZFloat, 0f);
  93. /*
  94. *
  95. * End of Hashmap
  96. */
  97. }
  98. }
  99. } catch(Exception e) {
  100. System.out.println(e);
  101. }
  102. }
  103.  
  104. //get the value then get the row then get the x y z
  105.  
  106.  
  107. public float getX() {
  108. return x;
  109. }
  110.  
  111. public float getY() {
  112. return y;
  113. }
  114.  
  115. public float getZc() {
  116. return zc;
  117. }
  118.  
  119. public static int getModelTotalNumber() {
  120. return modelTotalNumber;
  121. }
  122.  
  123.  
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement