[DEV] add capability to update mesh

This commit is contained in:
Edouard DUPIN 2021-05-29 00:46:31 +02:00
parent 891f6ba5bc
commit 320be27f8c
2 changed files with 207 additions and 185 deletions

View File

@ -5,10 +5,12 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import org.atriasoft.etk.Color; import org.atriasoft.etk.Color;
import org.atriasoft.etk.Uri; import org.atriasoft.etk.Uri;
import org.atriasoft.etk.math.Vector2f; import org.atriasoft.etk.math.Vector2f;
import org.atriasoft.etk.math.Vector2i;
import org.atriasoft.etk.math.Vector3f; import org.atriasoft.etk.math.Vector3f;
import org.atriasoft.gale.backend3d.OpenGL.RenderMode; import org.atriasoft.gale.backend3d.OpenGL.RenderMode;
import org.atriasoft.gale.resource.Resource; import org.atriasoft.gale.resource.Resource;
@ -27,6 +29,7 @@ public class ResourceMesh extends ResourceStaticMesh {
protected List<Vector3f> listFacesNormal = new ArrayList<>(); //!< List of all Face normal, when calculated protected List<Vector3f> listFacesNormal = new ArrayList<>(); //!< List of all Face normal, when calculated
protected List<Vector3f> listVertexNormal = new ArrayList<>(); //!< List of all Face normal, when calculated protected List<Vector3f> listVertexNormal = new ArrayList<>(); //!< List of all Face normal, when calculated
protected Map<String,FaceIndexing> listFaces = new HashMap<>(); //!< List of all Face for the mesh protected Map<String,FaceIndexing> listFaces = new HashMap<>(); //!< List of all Face for the mesh
protected Map<String,Vector2i> listFacesDrawIndex = new HashMap<>(); //!< List of all Face for the mesh
protected Map<String,FaceIndexing> listPaletteFaces = new HashMap<>(); //!< List of all Face for the mesh protected Map<String,FaceIndexing> listPaletteFaces = new HashMap<>(); //!< List of all Face for the mesh
protected Map<String,Material> materials = new HashMap<>(); protected Map<String,Material> materials = new HashMap<>();
protected Map<String,Material> palettes = new HashMap<>(); // this is for information when we use external palette protected Map<String,Material> palettes = new HashMap<>(); // this is for information when we use external palette
@ -36,6 +39,36 @@ public class ResourceMesh extends ResourceStaticMesh {
//void (*this.functionFreeShape)(void* _pointer); //void (*this.functionFreeShape)(void* _pointer);
//private void* this.pointerShape; //!< all mesh have a basic shape (bullet or other) the void pointer mermit to not depent on the bullet lib //private void* this.pointerShape; //!< all mesh have a basic shape (bullet or other) the void pointer mermit to not depent on the bullet lib
// TODO: Rework this: this is for the GUI dynamic modiification:
List<Vector3f> outPosition = null;
public List<Vector3f> getGeneratedPosition() {
return this.outPosition;
}
public void setModifiedPosition(final List<Vector3f> position) {
this.vao.setPosition(position);
this.vao.flush();
}
public void setModifiedPosition(final Vector3f[] position) {
this.vao.setPosition(position);
this.vao.flush();
}
public void setModifiedPosition(final float[] position) {
this.vao.setPosition(position);
this.vao.flush();
}
@Override
public void render() {
super.render();
}
public void render(final String layerName) {
Vector2i elements = this.listFacesDrawIndex.get(layerName);
super.render(elements.x(), elements.y());
}
public Set<String> getLayers() {
return this.listFacesDrawIndex.keySet();
}
void clean(){ void clean(){
//this.physics.clear(); //this.physics.clear();
@ -53,7 +86,7 @@ public class ResourceMesh extends ResourceStaticMesh {
public ResourceMesh() { public ResourceMesh() {
this(null); this(null);
} }
public ResourceMesh( Uri _fileName) { public ResourceMesh( final Uri _fileName) {
super(_fileName); super(_fileName);
Log.verbose("Load a new mesh : '" + _fileName + "'"); Log.verbose("Load a new mesh : '" + _fileName + "'");
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
@ -62,25 +95,6 @@ public class ResourceMesh extends ResourceStaticMesh {
// TO facilitate some debugs we add a name of the VBO: // TO facilitate some debugs we add a name of the VBO:
this.vao.setName("[VBO] of " + _fileName); this.vao.setName("[VBO] of " + _fileName);
// ------------------------------------------------------------------------------------------------ // ------------------------------------------------------------------------------------------------
// load the curent file :
String extention = _fileName.getExtention().toLowerCase();
// select the corect loader :
if (extention == "obj") {
Log.error("Can not load OBJ file ...");
// if (loadOBJ(_fileName) == false) {
// Log.error("Error To load OBJ file " + _fileName );
// return;
// }
} else if (extention == "emf") {
Log.error("Can not load EMF file ...");
// if (loadEMF(_fileName) == false) {
// Log.error("Error To load EMF file " + _fileName );
// return;
// }
//Log.critical("Load a new mesh : '" + _fileName + "' (end)");
} else {
// nothing to do == > reject an empty mesh ==> user manage it ...
}
} }
// public void draw(Matrix4f _positionMatrix) { // public void draw(Matrix4f _positionMatrix) {
@ -214,7 +228,7 @@ public class ResourceMesh extends ResourceStaticMesh {
// Log.verbose("draw Mesh : " + this.name + " ( end )"); // Log.verbose("draw Mesh : " + this.name + " ( end )");
// } // }
void setNormalMode(NormalMode _mode) { void setNormalMode(final NormalMode _mode) {
this.normalMode = _mode; this.normalMode = _mode;
} }
// public void draw(Matrix4f _positionMatrix, // public void draw(Matrix4f _positionMatrix,
@ -292,12 +306,9 @@ void setNormalMode(NormalMode _mode) {
// } // }
// _draw.drawLine(vertices, tmpColor, _positionMatrix); // _draw.drawLine(vertices, tmpColor, _positionMatrix);
// } // }
public void generateElementFromPalettes() {
}
public void generateVBO() { public void generateVBO() {
generateElementFromPalettes(); this.listFacesDrawIndex.clear();
List<Vector3f> outPosition = new ArrayList<>(); this.outPosition = new ArrayList<>();
List<Vector3f> outNormal = new ArrayList<>(); List<Vector3f> outNormal = new ArrayList<>();
List<Vector2f> outTexturePosition = new ArrayList<>(); List<Vector2f> outTexturePosition = new ArrayList<>();
List<Color> outColor = new ArrayList<>(); List<Color> outColor = new ArrayList<>();
@ -310,6 +321,7 @@ void setNormalMode(NormalMode _mode) {
} }
Log.warning("Generate VBO for nb faces layers: " + this.listFaces.size() + " list layer=" + this.listFaces.keySet()); Log.warning("Generate VBO for nb faces layers: " + this.listFaces.size() + " list layer=" + this.listFaces.keySet());
// generate element in 2 pass: // generate element in 2 pass:
// - create new index depending on a vertex is a unique component of position, texture, normal // - create new index depending on a vertex is a unique component of position, texture, normal
@ -318,6 +330,7 @@ void setNormalMode(NormalMode _mode) {
for (Entry<String, FaceIndexing> elem : this.listFaces.entrySet()) { for (Entry<String, FaceIndexing> elem : this.listFaces.entrySet()) {
// clean faces indexes : // clean faces indexes :
elem.getValue().index().clear(); elem.getValue().index().clear();
int outPositionIndewStart = this.outPosition.size();
int nbIndicInFace = 3; int nbIndicInFace = 3;
if (this.materials.containsKey(elem.getKey()) == false) { if (this.materials.containsKey(elem.getKey()) == false) {
Log.warning("missing materials : '" + elem.getKey() + "' not in " + this.materials.keySet() ); Log.warning("missing materials : '" + elem.getKey() + "' not in " + this.materials.keySet() );
@ -396,19 +409,22 @@ void setNormalMode(NormalMode _mode) {
// } // }
// #endif // #endif
if (elementFind == false) { if (elementFind == false) {
outPosition.add(position); this.outPosition.add(position);
if (this.normalMode != NormalMode.NONE) { if (this.normalMode != NormalMode.NONE) {
outNormal.add(normal); outNormal.add(normal);
} }
outTexturePosition.add(texturepos); outTexturePosition.add(texturepos);
outColor.add(color); outColor.add(color);
vertexVBOId[indice] = outPosition.size()-1; vertexVBOId[indice] = this.outPosition.size()-1;
} }
} }
for(int indice=0 ; indice<nbIndicInFace; indice++) { for(int indice=0 ; indice<nbIndicInFace; indice++) {
tmpFaceList.index().add(vertexVBOId[indice]); tmpFaceList.index().add(vertexVBOId[indice]);
} }
this.listFacesDrawIndex.put(elem.getKey(), new Vector2i(outPositionIndewStart, this.outPosition.size() ));
} }
// #ifdef TRY_MINIMAL_VBO // #ifdef TRY_MINIMAL_VBO
// Log.debug("nb cycle ? : " + tmpppppp); // Log.debug("nb cycle ? : " + tmpppppp);
// #endif // #endif
@ -416,6 +432,7 @@ void setNormalMode(NormalMode _mode) {
List<Integer> outIndex = new ArrayList<>(); List<Integer> outIndex = new ArrayList<>();
if (this.listPaletteFaces.size() != 0) { if (this.listPaletteFaces.size() != 0) {
int outPositionIndewStart = this.outPosition.size();
FaceIndexing outputIndex = new FaceIndexing(); FaceIndexing outputIndex = new FaceIndexing();
//Add palette virtual material: //Add palette virtual material:
this.listFaces.put("palette", outputIndex); this.listFaces.put("palette", outputIndex);
@ -473,13 +490,13 @@ void setNormalMode(NormalMode _mode) {
break; break;
} }
outPosition.add(position); this.outPosition.add(position);
if (this.normalMode != NormalMode.NONE) { if (this.normalMode != NormalMode.NONE) {
outNormal.add(normal); outNormal.add(normal);
} }
outTexturePosition.add(texturepos); outTexturePosition.add(texturepos);
outColor.add(color); outColor.add(color);
vertexVBOId[indice] = outPosition.size()-1; vertexVBOId[indice] = this.outPosition.size()-1;
} }
for(int indice=0 ; indice<nbIndicInFace; indice++) { for(int indice=0 ; indice<nbIndicInFace; indice++) {
outputIndex.index().add(vertexVBOId[indice]); outputIndex.index().add(vertexVBOId[indice]);
@ -487,17 +504,18 @@ void setNormalMode(NormalMode _mode) {
} }
} }
} }
this.listFacesDrawIndex.put("palette", new Vector2i(outPositionIndewStart, this.outPosition.size() ));
} }
// update all the VBO elements ... // update all the VBO elements ...
this.vao.setNormals(outNormal); this.vao.setNormals(outNormal);
this.vao.setPosition(outPosition); this.vao.setPosition(this.outPosition);
this.vao.setTextureCoordinate(outTexturePosition); this.vao.setTextureCoordinate(outTexturePosition);
this.vao.setColors(outColor); this.vao.setColors(outColor);
this.vao.setIndices(outIndex); this.vao.setIndices(outIndex);
this.vao.flush(); this.vao.flush();
} }
private void calculateNormaleFace( String _materialName) { private void calculateNormaleFace( final String _materialName) {
this.listFacesNormal.clear(); this.listFacesNormal.clear();
if (this.normalMode == NormalMode.FACE) { if (this.normalMode == NormalMode.FACE) {
Log.verbose("calculateNormaleFace(" + _materialName + ")"); Log.verbose("calculateNormaleFace(" + _materialName + ")");
@ -527,7 +545,7 @@ void setNormalMode(NormalMode _mode) {
} }
} }
} }
private void calculateNormaleEdge( String _materialName) { private void calculateNormaleEdge( final String _materialName) {
this.listVertexNormal.clear(); this.listVertexNormal.clear();
if (this.normalMode == NormalMode.VERTEX) { if (this.normalMode == NormalMode.VERTEX) {
List<Vector3f> outNormal = new ArrayList<>(); List<Vector3f> outNormal = new ArrayList<>();
@ -547,9 +565,9 @@ void setNormalMode(NormalMode _mode) {
// add the vertex from all the element in the list for face when the element in the face ... // add the vertex from all the element in the list for face when the element in the face ...
for(int jjj=0 ; jjj<tmpFaceList.size() ; jjj++) { for(int jjj=0 ; jjj<tmpFaceList.size() ; jjj++) {
outNormal.add(normal); outNormal.add(normal);
if( tmpFaceList.get(jjj).vertex[0] == (int)iii if( tmpFaceList.get(jjj).vertex[0] == iii
|| tmpFaceList.get(jjj).vertex[1] == (int)iii || tmpFaceList.get(jjj).vertex[1] == iii
|| tmpFaceList.get(jjj).vertex[2] == (int)iii) { || tmpFaceList.get(jjj).vertex[2] == iii) {
normal = normal.add(this.listFacesNormal.get(jjj)); normal = normal.add(this.listFacesNormal.get(jjj));
} }
} }
@ -578,7 +596,7 @@ void setNormalMode(NormalMode _mode) {
//private boolean loadOBJ( Uri _fileName); //private boolean loadOBJ( Uri _fileName);
//private boolean loadEMF( Uri _fileName); //private boolean loadEMF( Uri _fileName);
public void addMaterial( String _name, Material _data){ public void addMaterial( final String _name, final Material _data){
if (_data == null) { if (_data == null) {
Log.error(" can not add material with null pointer"); Log.error(" can not add material with null pointer");
return; return;
@ -596,16 +614,16 @@ void setNormalMode(NormalMode _mode) {
* @brief set the check of normal position befor sending it to the openGl card * @brief set the check of normal position befor sending it to the openGl card
* @param _status New state. * @param _status New state.
*/ */
public void setCheckNormal(boolean _status) { public void setCheckNormal(final boolean _status) {
this.checkNormal=_status; this.checkNormal=_status;
}; }
/** /**
* @brief get the check value of normal position befor sending it to the openGl card * @brief get the check value of normal position befor sending it to the openGl card
* @return get the chcking stus of normal or not * @return get the chcking stus of normal or not
*/ */
public boolean getCheckNormal() { public boolean getCheckNormal() {
return this.checkNormal; return this.checkNormal;
}; }
// public List<ege::physics::Shape> getPhysicalProperties() { // public List<ege::physics::Shape> getPhysicalProperties() {
// for (auto it: this.physics) { // for (auto it: this.physics) {
@ -675,13 +693,13 @@ void setNormalMode(NormalMode _mode) {
* @brief Add in the faces list the layer requested * @brief Add in the faces list the layer requested
* @param _layerName face index to add * @param _layerName face index to add
*/ */
public void addFaceIndexing( String _layerName){ public void addFaceIndexing( final String _layerName){
if (this.listFaces.containsKey(_layerName) == false) { if (this.listFaces.containsKey(_layerName) == false) {
FaceIndexing empty = new FaceIndexing(); FaceIndexing empty = new FaceIndexing();
this.listFaces.put(_layerName, empty); this.listFaces.put(_layerName, empty);
} }
} }
public void addPoint( String _layerName, Vector3f _pos, Color _color) { public void addPoint( final String _layerName, final Vector3f _pos, final Color _color) {
if ( this.listFaces.containsKey(_layerName) == false if ( this.listFaces.containsKey(_layerName) == false
|| this.materials.containsKey(_layerName) == false) { || this.materials.containsKey(_layerName) == false) {
Log.error("Mesh layer : " + _layerName + " does not exist in list faces=" + this.listFaces.containsKey(_layerName) + " materials=" + this.listFaces.containsKey(_layerName) + " ..."); Log.error("Mesh layer : " + _layerName + " does not exist in list faces=" + this.listFaces.containsKey(_layerName) + " materials=" + this.listFaces.containsKey(_layerName) + " ...");
@ -702,10 +720,10 @@ void setNormalMode(NormalMode _mode) {
this.listFaces.get(_layerName).face().add(tmpFace); this.listFaces.get(_layerName).face().add(tmpFace);
} }
public void addLine( String _layerName, Vector3f _pos1, Vector3f _pos2, Color _color) { public void addLine( final String _layerName, final Vector3f _pos1, final Vector3f _pos2, final Color _color) {
addLine( _layerName, _pos1, _pos2, _color, _color); addLine( _layerName, _pos1, _pos2, _color, _color);
} }
public void addLine( String _layerName, Vector3f _pos1, Vector3f _pos2, Color _color1, Color _color2) { public void addLine( final String _layerName, final Vector3f _pos1, final Vector3f _pos2, final Color _color1, final Color _color2) {
if ( this.listFaces.containsKey(_layerName) == false if ( this.listFaces.containsKey(_layerName) == false
|| this.materials.containsKey(_layerName) == false) { || this.materials.containsKey(_layerName) == false) {
Log.error("Mesh layer : " + _layerName + " does not exist in list faces=" + this.listFaces.containsKey(_layerName) + " materials=" + this.listFaces.containsKey(_layerName) + " ..."); Log.error("Mesh layer : " + _layerName + " does not exist in list faces=" + this.listFaces.containsKey(_layerName) + " materials=" + this.listFaces.containsKey(_layerName) + " ...");
@ -729,13 +747,13 @@ void setNormalMode(NormalMode _mode) {
tmpFace.setColor(color1, color2, color2); tmpFace.setColor(color1, color2, color2);
this.listFaces.get(_layerName).face().add(tmpFace); this.listFaces.get(_layerName).face().add(tmpFace);
} }
public void addLines( String _layerName, List<Vector3f> _list, Color _color) { public void addLines( final String _layerName, final List<Vector3f> _list, final Color _color) {
for (int iii=1; iii<_list.size(); ++iii) { for (int iii=1; iii<_list.size(); ++iii) {
addLine(_layerName, _list.get(iii-1), _list.get(iii), _color); addLine(_layerName, _list.get(iii-1), _list.get(iii), _color);
} }
} }
public void addLines( String _layerName, List<Vector3f> _list, List<Color> _color) { public void addLines( final String _layerName, final List<Vector3f> _list, final List<Color> _color) {
if (_color.size() != _list.size()) { if (_color.size() != _list.size()) {
Log.error("Can not add line with changing color without same number of color"); Log.error("Can not add line with changing color without same number of color");
return; return;
@ -747,33 +765,33 @@ void setNormalMode(NormalMode _mode) {
/** /**
* @not_in_doc * @not_in_doc
* @brief draw a colored triangle (usefull for debug and test) * @brief draw a colored triangle (usefull for debug and test)
* @param _layerName Material and face indexing layer name * @param _layerName Material and face indexing layer name
* @param _pos1 First point position * @param _pos1 First point position
* @param _pos2 Second point position * @param _pos2 Second point position
* @param _pos3 Third point position * @param _pos3 Third point position
* @param _color1 color of the _pos1 element * @param _color1 color of the _pos1 element
* @param _color2 color of the _pos2 element * @param _color2 color of the _pos2 element
* @param _color3 color of the _pos3 element * @param _color3 color of the _pos3 element
*/ */
public void addTriangle( String _layerName, Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, Color _color) { public void addTriangle( final String _layerName, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3, final Color _color) {
addTriangle(_layerName, _pos1, _pos2, _pos3, _color, _color, _color); addTriangle(_layerName, _pos1, _pos2, _pos3, _color, _color, _color);
} }
/** /**
* @not_in_doc * @not_in_doc
* @brief draw a colored triangle (usefull for debug and test) * @brief draw a colored triangle (usefull for debug and test)
* @param _layerName Material and face indexing layer name * @param _layerName Material and face indexing layer name
* @param _pos1 First point position * @param _pos1 First point position
* @param _pos2 Second point position * @param _pos2 Second point position
* @param _pos3 Third point position * @param _pos3 Third point position
* @param _color1 color of the _pos1 element * @param _color1 color of the _pos1 element
* @param _color2 color of the _pos2 element * @param _color2 color of the _pos2 element
* @param _color3 color of the _pos3 element * @param _color3 color of the _pos3 element
*/ */
public void addTriangle( String _layerName, Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, public void addTriangle( final String _layerName, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3,
Color _color1, Color _color2, Color _color3){ final Color _color1, final Color _color2, final Color _color3){
if ( this.listFaces.containsKey(_layerName) == false if ( this.listFaces.containsKey(_layerName) == false
|| this.materials.containsKey(_layerName) == false) { || this.materials.containsKey(_layerName) == false) {
Log.error("Mesh layer : " + _layerName + " does not exist in list faces=" + this.listFaces.containsKey(_layerName) + " materials=" + this.listFaces.containsKey(_layerName) + " ..."); Log.error("Mesh layer : " + _layerName + " does not exist in list faces=" + this.listFaces.containsKey(_layerName) + " materials=" + this.listFaces.containsKey(_layerName) + " ...");
@ -802,61 +820,60 @@ void setNormalMode(NormalMode _mode) {
this.listFaces.get(_layerName).face().add(tmpFace); this.listFaces.get(_layerName).face().add(tmpFace);
} else { } else {
Log.error("try to add Quad in a mesh material section that not support Quad"); Log.error("try to add Quad in a mesh material section that not support Quad");
return;
} }
} }
/** /**
* @not_in_doc * @not_in_doc
* @brief draw a colored quad (usefull for debug and test) * @brief draw a colored quad (usefull for debug and test)
* @param _layerName Material and face indexing layer name * @param _layerName Material and face indexing layer name
* @param _pos1 First point position * @param _pos1 First point position
* @param _pos2 Second point position * @param _pos2 Second point position
* @param _pos3 Third point position * @param _pos3 Third point position
* @param _pos4 faurth point position * @param _pos4 faurth point position
* @param _color color of all elements * @param _color color of all elements
*/ */
public void addQuad( String _layerName, Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, Vector3f _pos4, Color _color) { public void addQuad( final String _layerName, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3, final Vector3f _pos4, final Color _color) {
addQuad(_layerName, _pos1, _pos2, _pos3, _pos4, _color, _color, _color, _color); addQuad(_layerName, _pos1, _pos2, _pos3, _pos4, _color, _color, _color, _color);
} }
/** /**
* @not_in_doc * @not_in_doc
* @brief draw a colored quad (usefull for debug and test) * @brief draw a colored quad (usefull for debug and test)
* @param _layerName Material and face indexing layer name * @param _layerName Material and face indexing layer name
* @param _pos1 First point position * @param _pos1 First point position
* @param _pos2 Second point position * @param _pos2 Second point position
* @param _pos3 Third point position * @param _pos3 Third point position
* @param _pos4 faurth point position * @param _pos4 faurth point position
* @param _color1 color of the _pos1 element * @param _color1 color of the _pos1 element
* @param _color2 color of the _pos2 element * @param _color2 color of the _pos2 element
* @param _color3 color of the _pos3 element * @param _color3 color of the _pos3 element
* @param _color4 color of the _pos4 element * @param _color4 color of the _pos4 element
*/ */
public void addQuad( String _layerName, Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, Vector3f _pos4, public void addQuad( final String _layerName, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3, final Vector3f _pos4,
Color _color1, Color _color2, Color _color3, Color _color4) { final Color _color1, final Color _color2, final Color _color3, final Color _color4) {
addTriangle(_layerName, _pos1, _pos2, _pos3, _color1, _color2, _color3); addTriangle(_layerName, _pos1, _pos2, _pos3, _color1, _color2, _color3);
addTriangle(_layerName, _pos1, _pos3, _pos4, _color1, _color3, _color4); addTriangle(_layerName, _pos1, _pos3, _pos4, _color1, _color3, _color4);
} }
/** /**
* @not_in_doc * @not_in_doc
* @brief draw a textured colored triangle (usefull for debug and test) * @brief draw a textured colored triangle (usefull for debug and test)
* @param _layerName Material and face indexing layer name * @param _layerName Material and face indexing layer name
* @param _pos1 First point position * @param _pos1 First point position
* @param _pos2 Second point position * @param _pos2 Second point position
* @param _pos3 Third point position * @param _pos3 Third point position
* @param _color color of all elements * @param _color color of all elements
* @param _uv1 texture position of the _pos1 element * @param _uv1 texture position of the _pos1 element
* @param _uv2 texture position of the _pos2 element * @param _uv2 texture position of the _pos2 element
* @param _uv3 texture position of the _pos3 element * @param _uv3 texture position of the _pos3 element
*/ */
public void addTriangle( String _layerName, public void addTriangle( final String _layerName,
Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3,
Vector2f _uv1, Vector2f _uv2, Vector2f _uv3, final Vector2f _uv1, final Vector2f _uv2, final Vector2f _uv3,
Color _color) { final Color _color) {
addTriangle(_layerName, _pos1, _pos2, _pos3, _uv1, _uv2, _uv3, _color, _color, _color); addTriangle(_layerName, _pos1, _pos2, _pos3, _uv1, _uv2, _uv3, _color, _color, _color);
} }
public void addTriangle( String _layerName, public void addTriangle( final String _layerName,
Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3,
Vector2f _uv1, Vector2f _uv2, Vector2f _uv3){ final Vector2f _uv1, final Vector2f _uv2, final Vector2f _uv3){
addTriangle(_layerName,_pos1, _pos2, _pos3, addTriangle(_layerName,_pos1, _pos2, _pos3,
_uv1, _uv2, _uv3, _uv1, _uv2, _uv3,
Color.WHITE, Color.WHITE, Color.WHITE); Color.WHITE, Color.WHITE, Color.WHITE);
@ -875,10 +892,10 @@ void setNormalMode(NormalMode _mode) {
* @param _uv2 texture position of the _pos2 element * @param _uv2 texture position of the _pos2 element
* @param _uv3 texture position of the _pos3 element * @param _uv3 texture position of the _pos3 element
*/ */
public void addTriangle( String _layerName, public void addTriangle( final String _layerName,
Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3,
Vector2f _uv1, Vector2f _uv2, Vector2f _uv3, final Vector2f _uv1, final Vector2f _uv2, final Vector2f _uv3,
Color _color1, Color _color2, Color _color3){ final Color _color1, final Color _color2, final Color _color3){
Log.info("add Triangle: " + _layerName + " ..."); Log.info("add Triangle: " + _layerName + " ...");
if ( this.listFaces.containsKey(_layerName) == false if ( this.listFaces.containsKey(_layerName) == false
@ -911,63 +928,63 @@ void setNormalMode(NormalMode _mode) {
tmpFace.setColor(color1, color2, color3); tmpFace.setColor(color1, color2, color3);
this.listFaces.get(_layerName).face().add(tmpFace); this.listFaces.get(_layerName).face().add(tmpFace);
Log.info(" nbFace: " + this.listFaces.get(_layerName).face().size()); Log.info(" nbFace: " + this.listFaces.get(_layerName).face().size());
} }
/** /**
* @not_in_doc * @not_in_doc
* @brief draw a textured colored quad (usefull for debug and test) * @brief draw a textured colored quad (usefull for debug and test)
* @param _layerName Material and face indexing layer name * @param _layerName Material and face indexing layer name
* @param _pos1 First point position * @param _pos1 First point position
* @param _pos2 Second point position * @param _pos2 Second point position
* @param _pos3 Third point position * @param _pos3 Third point position
* @param _pos4 faurth point position * @param _pos4 faurth point position
* @param _color color of all elements * @param _color color of all elements
* @param _uv1 texture position of the _pos1 element * @param _uv1 texture position of the _pos1 element
* @param _uv2 texture position of the _pos2 element * @param _uv2 texture position of the _pos2 element
* @param _uv3 texture position of the _pos3 element * @param _uv3 texture position of the _pos3 element
* @param _uv4 texture position of the _pos4 element * @param _uv4 texture position of the _pos4 element
*/ */
public void addQuad( String _layerName, public void addQuad( final String _layerName,
Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, Vector3f _pos4, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3, final Vector3f _pos4,
Vector2f _uv1, Vector2f _uv2, Vector2f _uv3, Vector2f _uv4, final Vector2f _uv1, final Vector2f _uv2, final Vector2f _uv3, final Vector2f _uv4,
Color _color) { final Color _color) {
addQuad(_layerName, _pos1, _pos2, _pos3, _pos4, _uv1, _uv2, _uv3, _uv4, _color, _color, _color, _color); addQuad(_layerName, _pos1, _pos2, _pos3, _pos4, _uv1, _uv2, _uv3, _uv4, _color, _color, _color, _color);
} }
public void addQuad( String _layerName, public void addQuad( final String _layerName,
Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, Vector3f _pos4, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3, final Vector3f _pos4,
Vector2f _uv1, Vector2f _uv2, Vector2f _uv3, Vector2f _uv4) { final Vector2f _uv1, final Vector2f _uv2, final Vector2f _uv3, final Vector2f _uv4) {
addQuad( _layerName, addQuad( _layerName,
_pos1, _pos2, _pos3, _pos4, _pos1, _pos2, _pos3, _pos4,
_uv1, _uv2, _uv3, _uv4, _uv1, _uv2, _uv3, _uv4,
Color.WHITE, Color.WHITE, Color.WHITE, Color.WHITE); Color.WHITE, Color.WHITE, Color.WHITE, Color.WHITE);
} }
/** /**
* @not_in_doc * @not_in_doc
* @brief draw a textured quad (usefull for debug and test) * @brief draw a textured quad (usefull for debug and test)
* @param _layerName Material and face indexing layer name * @param _layerName Material and face indexing layer name
* @param _pos1 First point position * @param _pos1 First point position
* @param _pos2 Second point position * @param _pos2 Second point position
* @param _pos3 Third point position * @param _pos3 Third point position
* @param _pos4 faurth point position * @param _pos4 faurth point position
* @param _uv1 texture position of the _pos1 element * @param _uv1 texture position of the _pos1 element
* @param _uv2 texture position of the _pos2 element * @param _uv2 texture position of the _pos2 element
* @param _uv3 texture position of the _pos3 element * @param _uv3 texture position of the _pos3 element
* @param _uv4 texture position of the _pos4 element * @param _uv4 texture position of the _pos4 element
* @param _color1 color of the _pos1 element * @param _color1 color of the _pos1 element
* @param _color2 color of the _pos2 element * @param _color2 color of the _pos2 element
* @param _color3 color of the _pos3 element * @param _color3 color of the _pos3 element
* @param _color4 color of the _pos4 element * @param _color4 color of the _pos4 element
*/ */
public void addQuad( String _layerName, public void addQuad( final String _layerName,
Vector3f _pos1, Vector3f _pos2, Vector3f _pos3, Vector3f _pos4, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3, final Vector3f _pos4,
Vector2f _uv1, Vector2f _uv2, Vector2f _uv3, Vector2f _uv4, final Vector2f _uv1, final Vector2f _uv2, final Vector2f _uv3, final Vector2f _uv4,
Color _color1, Color _color2, Color _color3, Color _color4) { final Color _color1, final Color _color2, final Color _color3, final Color _color4) {
addTriangle(_layerName, _pos1, _pos2, _pos3, _uv1, _uv2, _uv3, _color1, _color2, _color3); addTriangle(_layerName, _pos1, _pos2, _pos3, _uv1, _uv2, _uv3, _color1, _color2, _color3);
addTriangle(_layerName, _pos1, _pos3, _pos4, _uv1, _uv3, _uv4, _color1, _color3, _color4); addTriangle(_layerName, _pos1, _pos3, _pos4, _uv1, _uv3, _uv4, _color1, _color3, _color4);
} }
protected int findPositionInList( Vector3f _pos){ protected int findPositionInList( final Vector3f _pos){
for (int iii=0; iii<this.listVertex.size(); ++iii) { for (int iii=0; iii<this.listVertex.size(); ++iii) {
if (this.listVertex.get(iii) == _pos) { if (this.listVertex.get(iii) == _pos) {
return iii; return iii;
@ -976,7 +993,7 @@ void setNormalMode(NormalMode _mode) {
this.listVertex.add(_pos); this.listVertex.add(_pos);
return this.listVertex.size()-1; return this.listVertex.size()-1;
} }
protected int findTextureInList( Vector2f _uv){ protected int findTextureInList( final Vector2f _uv){
for (int iii=0; iii<this.listUV.size(); ++iii) { for (int iii=0; iii<this.listUV.size(); ++iii) {
if (this.listUV.get(iii) == _uv) { if (this.listUV.get(iii) == _uv) {
return iii; return iii;
@ -985,7 +1002,7 @@ void setNormalMode(NormalMode _mode) {
this.listUV.add(_uv); this.listUV.add(_uv);
return this.listUV.size()-1; return this.listUV.size()-1;
} }
protected int findColorInList( Color _color){ protected int findColorInList( final Color _color){
for (int iii=0; iii<this.listColor.size(); ++iii) { for (int iii=0; iii<this.listColor.size(); ++iii) {
if (this.listColor.get(iii) == _color) { if (this.listColor.get(iii) == _color) {
return iii; return iii;
@ -995,8 +1012,7 @@ void setNormalMode(NormalMode _mode) {
return this.listColor.size()-1; return this.listColor.size()-1;
} }
public static ResourceMesh create(Uri uri) { public static ResourceMesh create(final Uri uri) {
Log.verbose("KEEP: Resource Mesh: " + uri); Log.verbose("KEEP: Resource Mesh: " + uri);
ResourceMesh object = null; ResourceMesh object = null;
final Resource object2 = Resource.getManager().localKeep(uri); final Resource object2 = Resource.getManager().localKeep(uri);
@ -1010,9 +1026,8 @@ void setNormalMode(NormalMode _mode) {
Log.debug("CREATE: new Mesh: " + uri); Log.debug("CREATE: new Mesh: " + uri);
if (uri.getExtention().equals("emf")) { if (uri.getExtention().equals("emf")) {
return new ResourceMeshEmf(uri); return new ResourceMeshEmf(uri);
} else {
Log.error("Not managed extention type: '" + uri.getExtention() + "'");
} }
Log.error("Not managed extention type: '" + uri.getExtention() + "'");
return null; return null;
} }

View File

@ -56,5 +56,12 @@ public class ResourceStaticMesh extends Resource {
} }
this.vao.unBindForRendering(); this.vao.unBindForRendering();
} }
public void render(final int start, final int stop) {
if (this.vao == null) {
return;
}
this.vao.render(this.mode, start, stop);
}
} }