From 343934129a85972b012b70a78fa9d7d2835da9a2 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Sun, 20 Mar 2022 23:39:27 +0100 Subject: [PATCH] [DEV] commit all with new insland --- .gitignore | 43 ++++++++++++ out/.gitignore | 2 + .../loader3d/resources/ResourceMesh.java | 69 ++++++++++++------- .../resources/ResourceMeshHeightMap.java | 2 +- .../test/atriasoft/loader3d/TestBasicLog.java | 10 +-- 5 files changed, 94 insertions(+), 32 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b87fbf1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,43 @@ +# ---> Java +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +*.class +*~ +*.bck +build.number +/extern/ +/out/ +/.settings/ +/junit/ +/target/ +/__pycache__/ + + +*.pdfd +*.dbc +SchedulerConfig.txt +scenicView.properties +ScenariumConfig.txt +*.blend* diff --git a/out/.gitignore b/out/.gitignore index 7aa2c8d..9a45729 100644 --- a/out/.gitignore +++ b/out/.gitignore @@ -1 +1,3 @@ + +/__pycache__/ /eclipse/ diff --git a/src/org/atriasoft/loader3d/resources/ResourceMesh.java b/src/org/atriasoft/loader3d/resources/ResourceMesh.java index 919fc43..87ec098 100644 --- a/src/org/atriasoft/loader3d/resources/ResourceMesh.java +++ b/src/org/atriasoft/loader3d/resources/ResourceMesh.java @@ -195,6 +195,20 @@ public class ResourceMesh extends ResourceStaticMesh { this.listFaces.get(_layerName).face().add(tmpFace); } + /** + * @not_in_doc + * @brief draw a colored quad (usefull for debug and test) + * @param _layerName Material and face indexing layer name + * @param _pos1 First point position + * @param _pos2 Second point position + * @param _pos3 Third point position + * @param _pos4 faurth point position + * @param _color color of all elements + */ + 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); + } + // public void draw(Matrix4f _positionMatrix) { // draw(_positionMatrix, true, true); // } @@ -326,20 +340,6 @@ public class ResourceMesh extends ResourceStaticMesh { // Log.verbose("draw Mesh : " + this.name + " ( end )"); // } - /** - * @not_in_doc - * @brief draw a colored quad (usefull for debug and test) - * @param _layerName Material and face indexing layer name - * @param _pos1 First point position - * @param _pos2 Second point position - * @param _pos3 Third point position - * @param _pos4 faurth point position - * @param _color color of all elements - */ - 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); - } - /** * @not_in_doc * @brief draw a colored quad (usefull for debug and test) @@ -459,6 +459,10 @@ public class ResourceMesh extends ResourceStaticMesh { } } + public void addTriangle(final String _layerName, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3, final Vector2f _uv1, final Vector2f _uv2, final Vector2f _uv3) { + addTriangle(_layerName, _pos1, _pos2, _pos3, _uv1, _uv2, _uv3, Color.WHITE, Color.WHITE, Color.WHITE); + } + // public List getPhysicalProperties() { // for (auto it: this.physics) { // if (it == null) { @@ -495,10 +499,6 @@ public class ResourceMesh extends ResourceStaticMesh { // return this.physics; // } - public void addTriangle(final String _layerName, final Vector3f _pos1, final Vector3f _pos2, final Vector3f _pos3, final Vector2f _uv1, final Vector2f _uv2, final Vector2f _uv3) { - addTriangle(_layerName, _pos1, _pos2, _pos3, _uv1, _uv2, _uv3, Color.WHITE, Color.WHITE, Color.WHITE); - } - /** * @not_in_doc * @brief draw a textured colored triangle (usefull for debug and test) @@ -630,6 +630,14 @@ public class ResourceMesh extends ResourceStaticMesh { } } + protected void calculateNormaleFaces(final List materialsNames) { + this.listFacesNormal.clear(); + for (String name : materialsNames) { + Log.warning("generate normal for: '" + name + "'"); + calculateNormaleFaceLocal(name); + } + } + // public void createViewBox( String _materialName,float _size=1.0){ // this.normalMode = NormalMode.NONE; // ege::viewBox::create(this.materials, this.listFaces, this.listVertex, this.listUV, @@ -646,14 +654,6 @@ public class ResourceMesh extends ResourceStaticMesh { //private boolean loadOBJ( Uri _fileName); //private boolean loadEMF( Uri _fileName); - protected void calculateNormaleFaces(final List materialsNames) { - this.listFacesNormal.clear(); - for (String name : materialsNames) { - Log.warning("generate normal for: '" + name + "'"); - calculateNormaleFaceLocal(name); - } - } - void clean() { //this.physics.clear(); this.materials.clear(); @@ -678,6 +678,23 @@ public class ResourceMesh extends ResourceStaticMesh { this.vao = ResourceVirtualArrayObject.createDynamic(); } + public void clearData() { + this.listVertex = new ArrayList<>(); //!< List of all vertex in the element + this.listUV = new ArrayList<>(); //!< List of all UV point in the mesh (for the specify texture) + this.listColor = new ArrayList<>(); //!< List of all Color point in the mesh + this.listFacesNormal = new ArrayList<>(); //!< List of all Face normal, when calculated + this.listVertexNormal = new ArrayList<>(); //!< List of all Face normal, when calculated + this.listFaces = new HashMap<>(); //!< List of all Face for the mesh + this.listFacesDrawIndex = new HashMap<>(); //!< List of all Face for the mesh + this.listPaletteFaces = new HashMap<>(); //!< List of all Face for the mesh + this.materials = new HashMap<>(); + this.palettes = new HashMap<>(); // this is for information when we use external palette + this.normalMode = NormalMode.NONE; + this.mode = RenderMode.QUAD_STRIP; + this.checkNormal = false; + this.outPosition = null; + } + protected int findColorInList(final Color _color) { for (int iii = 0; iii < this.listColor.size(); ++iii) { if (this.listColor.get(iii) == _color) { diff --git a/src/org/atriasoft/loader3d/resources/ResourceMeshHeightMap.java b/src/org/atriasoft/loader3d/resources/ResourceMeshHeightMap.java index 871ed7d..5473c31 100644 --- a/src/org/atriasoft/loader3d/resources/ResourceMeshHeightMap.java +++ b/src/org/atriasoft/loader3d/resources/ResourceMeshHeightMap.java @@ -124,7 +124,7 @@ public class ResourceMeshHeightMap extends ResourceMesh { int pos = this.listVertex.size(); Vector3f vertex1 = new Vector3f(ratio * (xxx + 1), ratio * (yyy + 1), ratio * heightMap[yyy + 1][xxx + 1]); this.listVertex.add(vertex1); - Vector3f vertex2 = new Vector3f(ratio * (xxx), ratio * (yyy + 1 + offsetA), ratio * heightMap[yyy + 1][xxx + 1]); + Vector3f vertex2 = new Vector3f(ratio * (xxx), ratio * (yyy + 1 + offsetA), ratio * heightMap[yyy + 1][xxx]); this.listVertex.add(vertex2); Vector3f vertex3 = new Vector3f(ratio * xxx, ratio * (yyy + offsetA), ratio * heightMap[yyy][xxx]); this.listVertex.add(vertex3); diff --git a/test/src/test/atriasoft/loader3d/TestBasicLog.java b/test/src/test/atriasoft/loader3d/TestBasicLog.java index 0cd19d5..9936a8c 100644 --- a/test/src/test/atriasoft/loader3d/TestBasicLog.java +++ b/test/src/test/atriasoft/loader3d/TestBasicLog.java @@ -8,18 +8,18 @@ ******************************************************************************/ package test.atriasoft.loader3d; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.atriasoft.etk.Uri; import org.atriasoft.gale.Gale; import org.atriasoft.gale.context.GaleContextTest; import org.atriasoft.loader3d.resources.ResourceMeshHeightMap; +import org.junit.jupiter.api.MethodOrderer.OrderAnnotation; import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestMethodOrder; @TestMethodOrder(OrderAnnotation.class) public class TestBasicLog { - + @Test @Order(1) public void aaFirstInitialisation() { @@ -30,8 +30,8 @@ public class TestBasicLog { Uri.addLibrary("test", ResourceMeshHeightMap.class, "/resources"); //ResourceMeshEmf tmp = new ResourceMeshEmf(new Uri("EMF", "tree1.emf", "test")); - ResourceMeshHeightMap tmp = new ResourceMeshHeightMap(new Uri("FILE", "/home/heero/dev/workspace-game/atriasoft/loader3d/out/eclipse/classes/resources/emf/tree1.emf")); + //ResourceMeshHeightMap tmp = new ResourceMeshHeightMap(new Uri("FILE", "/home/heero/dev/workspace-game/atriasoft/loader3d/out/eclipse/classes/resources/emf/tree1.emf")); } - + }