Skip to content
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 0 additions & 248 deletions gradlew

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void simpleInitApp() { }
@Test
public void testIssue1138() {
AssetManager am = JmeSystem.newAssetManager(PreventCoreIssueRegressions.class.getResource("/com/jme3/asset/Desktop.cfg"));
Node cgModel = (Node)am.loadModel("Models/Elephant/Elephant.mesh.xml");
Node cgModel = (Node)am.loadModel("Models/Elephant/Elephant.gltf");
cgModel.rotate(0f, -1f, 0f);
cgModel.scale(0.04f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ private void createCameraMotion() {

private void createScene() {

model = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
model = assetManager.loadModel("Models/Oto/Oto.gltf");
model.center();
model.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import com.jme3.scene.Mesh;
import com.jme3.scene.Node;
import com.jme3.scene.VertexBuffer;
import jme3test.app.SpatialUtils;

/**
* Test for JMonkeyEngine issue #2076: software skinning requires vertex
Expand Down Expand Up @@ -100,7 +101,7 @@ private void testOldAnimationSystem(String assetPath) {
skeletonControl.setHardwareSkinningPreferred(false);

// remove its vertex normals:
Geometry oldGeometry = (Geometry) oldJaime.getChild(0);
Geometry oldGeometry = SpatialUtils.findFirstGeometry(oldJaime);
Mesh oldMesh = oldGeometry.getMesh();
oldMesh.clearBuffer(VertexBuffer.Type.Normal);
oldMesh.clearBuffer(VertexBuffer.Type.BindPoseNormal);
Expand All @@ -124,7 +125,7 @@ private void testNewAnimationSystem(String assetPath) {
skinningControl.setHardwareSkinningPreferred(false);

// remove its vertex normals:
Geometry newGeometry = (Geometry) newJaime.getChild(0);
Geometry newGeometry = SpatialUtils.findFirstGeometry(newJaime);
Mesh newMesh = newGeometry.getMesh();
newMesh.clearBuffer(VertexBuffer.Type.Normal);
newMesh.clearBuffer(VertexBuffer.Type.BindPoseNormal);
Expand Down
86 changes: 86 additions & 0 deletions jme3-examples/src/main/java/jme3test/app/SpatialUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package jme3test.app;

import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;

/**
* Utility class for working with spatial hierarchies.
* Provides helper methods for searching and manipulating spatial scene graphs.
*/
public class SpatialUtils {

/**
* Recursively finds the first Geometry in a spatial hierarchy.
* This is useful for handling both simple flat structures (Ogre models) and
* complex nested node trees (glTF models).
*
* @param spatial The root spatial to search from
* @return The first Geometry found, or null if none exists
*/
public static Geometry findFirstGeometry(Spatial spatial) {
if (spatial instanceof Geometry) {
return (Geometry) spatial;
}
if (spatial instanceof Node) {
Node node = (Node) spatial;
for (Spatial child : node.getChildren()) {
Geometry geom = findFirstGeometry(child);
if (geom != null) {
return geom;
}
}
}
return null;
}

/**
* Recursively finds a Geometry by name in a spatial hierarchy.
* Searches depth-first through the entire spatial tree.
*
* @param spatial The root spatial to search from
* @param name The name of the geometry to find
* @return The Geometry with the matching name, or null if not found
*/
public static Geometry findGeometryByName(Spatial spatial, String name) {
if (spatial.getName() != null && spatial.getName().equals(name) && spatial instanceof Geometry) {
return (Geometry) spatial;
}
if (spatial instanceof Node) {
Node node = (Node) spatial;
for (Spatial child : node.getChildren()) {
Geometry geom = findGeometryByName(child, name);
if (geom != null) {
return geom;
}
}
}
return null;
}

/**
* Counts the total number of Geometries in a spatial hierarchy.
* Useful for debugging and understanding scene structure.
*
* @param spatial The root spatial to count from
* @return The total number of geometries in the hierarchy
*/
public static int countGeometries(Spatial spatial) {
if (spatial instanceof Geometry) {
return 1;
}
if (spatial instanceof Node) {
int count = 0;
Node node = (Node) spatial;
for (Spatial child : node.getChildren()) {
count += countGeometries(child);
}
return count;
}
return 0;
}

private SpatialUtils() {
// Utility class, no instantiation
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public void simpleInitApp() {
PhysicsTestHelper.createPhysicsTestWorld(rootNode, assetManager,
physicsSpace);

model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
model = (Node) assetManager.loadModel("Models/Sinbad/Sinbad.gltf");
rootNode.attachChild(model);

composer = model.getControl(AnimComposer.class);
Expand Down
Loading
Loading