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 getNrMaterialIndices() {
		return materialIndices.asIntBuffer().capacity();
	}
}
@@ -988,17 +988,16 @@
 ometry %7B
-%0D
 %0A%09privat
@@ -1019,25 +1019,24 @@
 fer indices;
-%0D
 %0A%09private fi
@@ -1059,17 +1059,16 @@
 ertices;
-%0D
 %0A%09privat
@@ -1174,19 +1174,17 @@
 Indices;
-%0D%0A%0D
+%0A
 %0A%09public
@@ -1317,17 +1317,16 @@
 dices) %7B
-%0D
 %0A%09%09this.
@@ -1339,25 +1339,24 @@
 s = indices;
-%0D
 %0A%09%09this.vert
@@ -1371,17 +1371,16 @@
 ertices;
-%0D
 %0A%09%09this.
@@ -1469,24 +1469,21 @@
 Indices;
-%0D
 %0A%09%7D
-%0D
 %0A%09
-%0D
 %0A%09public
@@ -1500,33 +1500,32 @@
 dex(int index) %7B
-%0D
 %0A%09%09return indice
@@ -1533,32 +1533,29 @@
 .get(index);
-%0D
 %0A%09%7D
-%0D
 %0A%09
-%0D
 %0A%09public dou
@@ -1572,33 +1572,32 @@
 tex(int index) %7B
-%0D
 %0A%09%09return vertic
@@ -1614,16 +1614,13 @@
 ex);
-%0D
 %0A%09%7D
-%0D
 %0A%09
-%0D
 %0A%09pu
@@ -1652,17 +1652,16 @@
 index) %7B
-%0D
 %0A%09%09retur
@@ -1681,21 +1681,19 @@
 (index);
-%0D
 %0A%09%7D
-%0D
 %0A%0A%09publi
@@ -1819,17 +1819,16 @@
 es;%0A%09%7D%0A%09
-%0D
 %0A%09public
@@ -1841,33 +1841,32 @@
 etNrVertices() %7B
-%0D
 %0A%09%09return vertic
@@ -1888,39 +1888,36 @@
 er().capacity();
-%0D
 %0A%09%7D
-%0D%0A%0D
+%0A
 %0A%09public int get
@@ -1925,25 +1925,24 @@
 rNormals() %7B
-%0D
 %0A%09%09return no
@@ -1978,15 +1978,12 @@
 y();
-%0D
 %0A%09%7D
-%0D%0A%0D
+%0A
 %0A%09pu
@@ -2007,17 +2007,16 @@
 ices() %7B
-%0D
 %0A%09%09retur
@@ -2050,17 +2050,16 @@
 acity();
-%0D
 %0A%09%7D%0A%0A%09pu
@@ -2376,32 +2376,113 @@
 get(index);%0A%09%7D%0A%0A
+%09public int getNrMaterials()%7B%0A%09%09return materials.asFloatBuffer().capacity();%0A%09%7D%0A%0A
 %09public int getN
@@ -2559,7 +2559,6 @@
 ;%0A%09%7D
-%0D
 %0A%7D

add getNrMaterials method