Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public void simpleInitApp() {
}

private void buildPlayer() {
spaceCraft = assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
spaceCraft = assetManager.loadModel("Models/HoverTank/Tank2.gltf");
CollisionShape colShape = CollisionShapeFactory.createDynamicMeshShape(spaceCraft);
spaceCraft.setShadowMode(ShadowMode.CastAndReceive);
spaceCraft.setLocalTranslation(startLocation);
Expand All @@ -164,7 +164,7 @@ public void makeMissile() {
Quaternion rot = spaceCraft.getWorldRotation();
Vector3f dir = rot.getRotationColumn(2);

Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml");
Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.gltf");
missile.scale(0.5f);
missile.rotate(0, FastMath.PI, 0);
missile.updateGeometricState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void simpleInitApp() {
stateManager.attach(bulletAppState);
initCrossHair();

Spatial s = assetManager.loadModel("Models/Elephant/Elephant.mesh.xml");
Spatial s = assetManager.loadModel("Models/Elephant/Elephant.gltf");
s.setLocalScale(0.1f);

CollisionShape collisionShape = CollisionShapeFactory.createMeshShape(s);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,19 +262,19 @@ private void dropTest2(Vector3f offset) {
}

private void dropPot(Vector3f offset) {
drop(offset.add(-12, 7, 15), "Models/Teapot/Teapot.mesh.xml", 1.0f, 2);
drop(offset.add(-12, 7, 15), "Models/Teapot/Teapot.gltf", 1.0f, 2);
}

private void dropSword(Vector3f offset) {
drop(offset.add(-10, 5, 3), "Models/Sinbad/Sword.mesh.xml", 1.0f, 2);
drop(offset.add(-10, 5, 3), "Models/Sinbad/Sword.gltf", 1.0f, 2);
}

private void dropSign(Vector3f offset) {
drop(offset.add(9, 15, 5), "Models/Sign Post/Sign Post.mesh.xml", 1.0f, 1);
drop(offset.add(9, 15, 5), "Models/Sign Post/Sign Post.gltf", 1.0f, 1);
}

private void dropRocket(Vector3f offset) {
RigidBodyControl c = drop(offset.add(26, 4, 7), "Models/SpaceCraft/Rocket.mesh.xml", 4.0f, 3);
RigidBodyControl c = drop(offset.add(26, 4, 7), "Models/SpaceCraft/Rocket.gltf", 4.0f, 3);
c.setAngularDamping(0.5f);
c.setLinearDamping(0.5f);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ private void setupScene() {
shootables.attachChild(torus);

// load a character from jme3-testdata
Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Spatial golem = assetManager.loadModel("Models/Elephant/Elephant.gltf");
golem.scale(0.5f);
golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);
shootables.attachChild(golem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void simpleInitApp() {
q.updateBound();
// Geometry teapot = new Geometry("MyGeom", q);

teapot = assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
teapot = assetManager.loadModel("Models/Teapot/Teapot.gltf");
// teapot.scale(2f, 2f, 2f);
// teapot.move(2f, 2f, -.5f);
teapot.rotate(FastMath.HALF_PI, FastMath.HALF_PI, FastMath.HALF_PI);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void simpleInitApp() {
rootNode.attachChild(geom1);

// load a character from jme3-testdata
golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
golem = assetManager.loadModel("Models/Elephant/Elephant.gltf");
golem.scale(0.5f);
golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,15 @@ public void setupFloor(){
// }

public void setupRobotGuy(){
Node model = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Material mat = assetManager.loadMaterial("Models/Oto/Oto.j3m");
model.getChild(0).setMaterial(mat);
// model.setAnimation("Walk");
Node model = (Node) assetManager.loadModel("Models/Elephant/Elephant.gltf");
model.setLocalTranslation(30, 10.5f, 30);
model.setLocalScale(2);
model.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(model);
}

public void setupSignpost(){
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.gltf");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
signpost.setMaterial(mat);
signpost.rotate(0, FastMath.HALF_PI, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public static void main(String[] args){
@Override
public void simpleInitApp() {
AssetLinkNode loaderNode=new AssetLinkNode();
loaderNode.addLinkedChild(new ModelKey("Models/MonkeyHead/MonkeyHead.mesh.xml"));
loaderNode.addLinkedChild(new ModelKey("Models/MonkeyHead/MonkeyHead.gltf"));
//load/attach the children (happens automatically on load)
// loaderNode.attachLinkedChildren(assetManager);
// rootNode.attachChild(loaderNode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ public void simpleInitApp() {
helloText.setLocalTranslation(300, helloText.getLineHeight(), 0);
guiNode.attachChild(helloText);

/* Load a Ninja model (OgreXML + material + texture from test_data) */
Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
/* Load a Ninja model (glTF format from test_data) */
Spatial ninja = assetManager.loadModel("Models/Ninja/Ninja.gltf");
Comment thread
NwosuTy marked this conversation as resolved.
ninja.scale(0.05f, 0.05f, 0.05f);
ninja.rotate(0.0f, -3.0f, 0.0f);
ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ private void initCrossHairs() {

private Spatial makeCharacter() {
// load a character from jme3-testdata
Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Spatial golem = assetManager.loadModel("Models/Elephant/Elephant.gltf");
golem.scale(0.5f);
golem.setLocalTranslation(-1.0f, -1.5f, -0.6f);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void simpleInitApp() {
dlsr.setLight(dl);
viewPort.addProcessor(dlsr);

Node player = (Node) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Node player = (Node) assetManager.loadModel("Models/Elephant/Elephant.gltf");
player.setShadowMode(RenderQueue.ShadowMode.Cast);
rootNode.attachChild(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void simpleInitApp() {
characters.setShadowMode(ShadowMode.Cast);
rootNode.attachChild(characters);

Spatial golem = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Spatial golem = assetManager.loadModel("Models/Elephant/Elephant.gltf");
golem.scale(0.5f);
golem.setLocalTranslation(200.0f, -6f, 200f);
golem.setShadowMode(ShadowMode.CastAndReceive);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void setupFloor(){


public void setupSignpost(){
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.gltf");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
// mat.setBoolean("VertexLighting", true);
signpost.setMaterial(mat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ public void setupFloor() {
}

public void setupSignpost() {
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.gltf");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
// mat.setBoolean("VertexLighting", true);
signpost.setMaterial(mat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void main(String[] args){

@Override
public void simpleInitApp() {
Spatial signpost = assetManager.loadAsset(new OgreMeshKey("Models/Sign Post/Sign Post.mesh.xml"));
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.gltf");
signpost.setMaterial(assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m"));
MikktspaceTangentGenerator.generate(signpost);
rootNode.attachChild(signpost);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void setupFloor() {
}

public void setupSignpost() {
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.gltf");
Material matSp = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
MikktspaceTangentGenerator.generate(signpost);
signpost.setMaterial(matSp);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void setupFloor() {
}

public void setupSignpost() {
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.gltf");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
MikktspaceTangentGenerator.generate(signpost);
signpost.setMaterial(mat);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void main(String[] args) {

@Override
public void simpleInitApp() {
Node tank = (Node) assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
Node tank = (Node) assetManager.loadModel("Models/HoverTank/Tank2.gltf");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Switching to the glTF format for the tank model will cause a ClassCastException on line 69: Geometry tankGeom = (Geometry) tank.getChild(0);. Due to the glTF loader's node structure, tank.getChild(0) is now a Node. You should update line 69 to correctly locate the geometry within the new hierarchy, perhaps by using a recursive search.

References
  1. Issues found in test code should be reported with a reduced priority, at most medium.


flyCam.setEnabled(false);
ChaseCamera chaseCam = new ChaseCamera(cam, tank, inputManager);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static void main(String[] args){
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.DarkGray);

Spatial bumpy = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
Spatial bumpy = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.gltf");
rootNode.attachChild(bumpy);

lightMdl = new Geometry("Light", new Sphere(10, 10, 0.1f));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void setupLighting(){
}

public void setupModel(){
Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.gltf");
makeToonish(model);
model.rotate(0, FastMath.PI, 0);
// signpost.setLocalTranslation(12, 3.5f, 30);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private void setupLighting() {
}

private void setupModel() {
Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.gltf");
makeToonish(model);
rootNode.attachChild(model);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public void simpleInitApp() {
//cam.setFrustumFar(1000);
flyCam.setMoveSpeed(10);
Material mat = assetManager.loadMaterial("Textures/Terrain/Rocky/Rocky.j3m");
Spatial scene = assetManager.loadModel("Models/Terrain/Terrain.mesh.xml");
MikktspaceTangentGenerator.generate(((Geometry) ((Node) scene).getChild(0)).getMesh());
Spatial scene = assetManager.loadModel("Models/Terrain/Terrain.gltf");
MikktspaceTangentGenerator.generate(scene);
scene.setMaterial(mat);
scene.setShadowMode(ShadowMode.CastAndReceive);
scene.setLocalScale(400);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void setupFloor() {
}

public void setupSignpost() {
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.gltf");
Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
signpost.setMaterial(mat);
signpost.rotate(0, FastMath.HALF_PI, 0);
Expand Down
24 changes: 22 additions & 2 deletions jme3-examples/src/main/java/jme3test/post/TestSSAO2.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ public void simpleInitApp() {
floor.setMaterial(mat);
rootNode.attachChild(floor);

Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
Geometry teapot = (Geometry) teapotNode.getChild(0);
Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.gltf");
Geometry teapot = findFirstGeometry(teapotNode);
teapot.setMaterial(mat);
// Sphere sph = new Sphere(16, 16, 4);
// Geometry teapot = new Geometry("teapot", sph);
Expand Down Expand Up @@ -113,4 +113,24 @@ public void simpleInitApp() {
@Override
public void simpleUpdate(float tpf) {
}

/**
* Recursively finds the first Geometry in a spatial hierarchy.
* Handles both simple flat structures and complex nested node trees.
*/
private Geometry findFirstGeometry(com.jme3.scene.Spatial spatial) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This helper method is duplicated in TestBatchLod.java. Consider moving it to a common utility class to improve maintainability. Additionally, the fully qualified class name com.jme3.scene.Spatial is redundant here as Spatial is already imported.

if (spatial instanceof Geometry) {
return (Geometry) spatial;
}
if (spatial instanceof Node) {
Node node = (Node) spatial;
for (com.jme3.scene.Spatial child : node.getChildren()) {
Geometry geom = findFirstGeometry(child);
if (geom != null) {
return geom;
}
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void simpleInitApp() {
tankMat.setFloat("EmissivePower", emissionPower);
tankMat.setFloat("EmissiveIntensity", 50);
tankMat.setFloat("Metallic", .5f);
Spatial tank = assetManager.loadModel("Models/HoverTank/Tank2.mesh.xml");
Spatial tank = assetManager.loadModel("Models/HoverTank/Tank2.gltf");
tank.setLocalTranslation(-10, 5, -10);
tank.setMaterial(tankMat);
rootNode.attachChild(tank);
Expand Down
24 changes: 22 additions & 2 deletions jme3-examples/src/main/java/jme3test/stress/TestBatchLod.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ public void simpleInitApp() {
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
rootNode.addLight(dl);

Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
Geometry teapot = (Geometry) teapotNode.getChild(0);
Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.gltf");
Geometry teapot = findFirstGeometry(teapotNode);

Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setFloat("Shininess", 16f);
Expand Down Expand Up @@ -85,4 +85,24 @@ public void simpleInitApp() {
cam.setRotation(new Quaternion(0.18343268f, 0.34531063f, -0.069015436f, 0.9177962f));

}

/**
* Recursively finds the first Geometry in a spatial hierarchy.
* Handles both simple flat structures and complex nested node trees.
*/
private Geometry findFirstGeometry(com.jme3.scene.Spatial spatial) {
if (spatial instanceof Geometry) {
return (Geometry) spatial;
}
if (spatial instanceof Node) {
Node node = (Node) spatial;
for (com.jme3.scene.Spatial child : node.getChildren()) {
Geometry geom = findFirstGeometry(child);
if (geom != null) {
return geom;
}
}
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void simpleInitApp() {
dl.setDirection(new Vector3f(-1,-1,-1).normalizeLocal());
rootNode.addLight(dl);

Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.gltf");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Switching to the glTF format for the teapot model will cause a ClassCastException on line 60. The glTF loader introduces a wrapper node hierarchy, meaning teapotNode.getChild(0) will return a Node instead of a Geometry. This test should be updated to use a recursive search for the geometry, similar to the findFirstGeometry() helper method implemented in TestSSAO2.java or TestBatchLod.java.

References
  1. Issues found in test code should be reported with a reduced priority, at most medium.

Geometry teapot = (Geometry) teapotNode.getChild(0);
Comment thread
NwosuTy marked this conversation as resolved.

// Sphere sph = new Sphere(16, 16, 4);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void simpleInitApp() {
myPlayer.setUserData("points", 0);

// Attach the model to the Node.
Spatial model = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Spatial model = assetManager.loadModel("Models/Elephant/Elephant.gltf");
myPlayer.attachChild(model);

// Before saving the game, detach the model since it doesn't need to be saved.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public void simpleInitApp() {
Node scene = new Node("Scene");
Spatial obj1 = assetManager.loadModel("Models/Ferrari/Car.scene");
obj1.setLocalTranslation(-4, 0, 0);
Spatial obj2 = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
Spatial obj2 = assetManager.loadModel("Models/Elephant/Elephant.gltf");
obj2.setLocalTranslation(-2, 0, 0);
Spatial obj3 = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
Spatial obj3 = assetManager.loadModel("Models/Ninja/Ninja.gltf");
obj3.setLocalTranslation(-0, 0, 0);
Spatial obj4 = assetManager.loadModel("Models/Sinbad/Sinbad.mesh.xml");
Spatial obj4 = assetManager.loadModel("Models/Sinbad/Sword.gltf");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Replacing the Sinbad character model with just his sword significantly reduces the complexity of this texture atlas test. If the full Sinbad character model is not available in glTF, consider using another character model (like Elephant.gltf or Ninja.gltf) to maintain the test's original intent of batching multiple complex models with distinct textures.

obj4.setLocalTranslation(2, 0, 0);
Spatial obj5 = assetManager.loadModel("Models/Tree/Tree.mesh.j3o");
Spatial obj5 = assetManager.loadModel("Models/Tree/Tree.gltf");
obj5.setLocalTranslation(4, 0, 0);
scene.attachChild(obj1);
scene.attachChild(obj2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void simpleInitApp() {

//create water quad
//waterPlane = waterProcessor.createWaterGeometry(100, 100);
waterPlane = assetManager.loadModel("Models/WaterTest/WaterTest.mesh.xml");
waterPlane = assetManager.loadModel("Models/WaterTest/WaterTest.gltf");
waterPlane.setMaterial(waterProcessor.getMaterial());
waterPlane.setLocalScale(40);
waterPlane.setLocalTranslation(-5, 0, 5);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
import java.util.logging.Level;
import java.util.logging.Logger;

/**
* Loads Ogre3D .material material files into jMonkey.
*
* @deprecated The Ogre format is outdated and no longer maintained.
* Use glTF (.gltf/.glb) or J3O format instead.
* See the <a href="https://jmonkeyengine.org/wiki/">jMonkeyEngine Wiki</a>
* for migration guidance.
*/
@Deprecated
public class MaterialLoader implements AssetLoader {

private static final Logger logger = Logger.getLogger(MaterialLoader.class.getName());
Expand Down
Loading
Loading