package org.bimserver.plugins.renderengine;

import java.nio.ByteBuffer;

/******************************************************************************
 * Copyright (C) 2009-2019  BIMserver.org
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see {@literal<http://www.gnu.org/licenses/>}.
 *****************************************************************************/

public class RenderEngineGeometry {
	private final ByteBuffer indices;
	private final ByteBuffer vertices;
	private final ByteBuffer normals;
	private final ByteBuffer materials;
	private final ByteBuffer materialIndices;

	public RenderEngineGeometry(ByteBuffer indices, ByteBuffer vertices, ByteBuffer normals, ByteBuffer materials, ByteBuffer materialIndices) {
		this.indices = indices;
		this.vertices = vertices;
		this.normals = normals;
		this.materials = materials;
		this.materialIndices = materialIndices;
	}
	
	public int getIndex(int index) {
		return indices.get(index);
	}
	
	public double getVertex(int index) {
		return vertices.get(index);
	}
	
	public float getNormal(int index) {
		return normals.get(index);
	}

	public ByteBuffer getMaterials() {
		return materials;
	}
	
	public ByteBuffer getMaterialIndices() {
		return materialIndices;
	}
	
	public int getNrVertices() {
		return vertices.asDoubleBuffer().capacity();
	}

	public int getNrNormals() {
		return normals.asFloatBuffer().capacity();
	}

	public int getNrIndices() {
		return indices.asIntBuffer().capacity();
	}

	public ByteBuffer getVertices() {
		return vertices;
	}
	
	public ByteBuffer getNormals() {
		return normals;
	}
	
	public ByteBuffer getIndices() {
		return indices;
	}

	public int getMaterialIndex(int index) {
		return materialIndices.get(index);
	}

	public float getMaterial(int index) {
		return materials.get(index);
	}

	public int getNrMaterials(){
		return materials.asFloatBuffer().capacity();
	}

	public int getNrMaterialIndices() {
		return materialIndices.asIntBuffer().capacity();
	}
}
@@ -1690,34 +1690,29 @@
 %09%7D%0A%0A%09public 
-ByteBuffer
+float
  getMaterial
@@ -1711,18 +1711,26 @@
 Material
-s
 (
+int index
 ) %7B%0A%09%09re
@@ -1743,22 +1743,32 @@
 aterials
+.get(index)
 ;%0A%09%7D%0A
-%09
 %0A%09public
@@ -1764,34 +1764,27 @@
 %09%7D%0A%0A%09public 
-ByteBuffer
+int
  getMaterial
@@ -1778,37 +1778,44 @@
 t getMaterialInd
-ices(
+ex(int index
 ) %7B%0A%09%09return mat
@@ -1818,38 +1818,124 @@
  materialIndices
+.get(index);%0A%09%7D%0A%0A%09public int getNrIndices() %7B%0A%09%09return indices.asIntBuffer().capacity()
 ;%0A%09%7D%0A
-%09
 %0A%09public int get
@@ -2091,34 +2091,35 @@
 ic int getNr
-Indice
+Material
 s()
- 
 %7B%0A%09%09return i
@@ -2113,36 +2113,40 @@
 )%7B%0A%09%09return 
-indices.asIn
+materials.asFloa
 tBuffer().ca
@@ -2171,115 +2171,91 @@
 lic 
-ByteBuffer getVertices() %7B%0A%09%09return vertices;%0A%09%7D%0A%09%0A%09public ByteBuffer getNormals() %7B%0A%09%09return normals
+int getNrMaterialIndices() %7B%0A%09%09return materialIndices.asIntBuffer().capacity()
 ;%0A%09%7D%0A
-%09
 %0A%09pu
@@ -2319,82 +2319,58 @@
 lic 
-int getMaterialIndex(int index) %7B%0A%09%09return materialIndices.get(index)
+ByteBuffer getVertices() %7B%0A%09%09return vertices
 ;%0A%09%7D%0A
+%09
 %0A%09pu
@@ -2378,73 +2378,56 @@
 lic 
-float getMaterial(int index) %7B%0A%09%09return materials.get(index)
+ByteBuffer getNormals() %7B%0A%09%09return normals
 ;%0A%09%7D%0A
+%09
 %0A%09pu
@@ -2427,33 +2427,38 @@
 %7D%0A%09%0A%09public 
-int
+ByteBuffer
  get
-Nr
 Materials()%7B
@@ -2448,32 +2448,33 @@
 r getMaterials()
+ 
 %7B%0A%09%09return mater
@@ -2481,35 +2481,8 @@
 ials
-.asFloatBuffer().capacity()
 ;%0A%09%7D
@@ -2487,33 +2487,38 @@
 %09%7D%0A%0A%09public 
-int
+ByteBuffer
  get
-Nr
 MaterialIndi
@@ -2553,33 +2553,8 @@
 ices
-.asIntBuffer().capacity()
 ;%0A%09%7D

consistent method order