Code to add a scene?

Hi there guys! I’m 100% new to jMonkeyEngine and still a novice at Java. I am however not a beginner when it comes to programming.



So i’ve constructed a scene consisting of one node being a model which will be a player, the terrain, the directional lighting and the skybox. These were made using jMonkeyEngine (except the player model and terrain textures)



Can somebody point me in the right direction towards a tutorial which says how to put a scene into your game via code? I can’t find anything which is specifically adding a premade scene to the game. Collision would be great too!



Thanks guys

http://www.hub.jmonkeyengine.org/wiki/doku.php/jme3:faq#i_want_to_load_my_scene

2 Likes
@glaucomardano said:
http://www.hub.jmonkeyengine.org/wiki/doku.php/jme3:faq#i_want_to_load_my_scene


Thanks for the link, but doesn't that refer to creating a new scene from scratch purely from code?
What should i do if i wanted to load my scene which i already created? It is a j3o file (newScene.j3o)


EDIT: Forgive me, i've got it :)
[java]Spatial scenefile = assetManager.loadModel("Scenes/newScene.j3o");
rootNode.attachChild(scenefile);[/java]

I thought we had to treat Scene files as their own type of object

You load and attach it like any other model:

rootNode.attachChild(assetManager.loadModel(“Models/MyModel.j3o”));

1 Like
@olliepop said:
What should i do if i wanted to load my scene which i already created? It is a j3o file (newScene.j3o)


@glaucomardano said:
http://www.hub.jmonkeyengine.org/wiki/doku.php/jme3:faq#i_want_to_load_my_scene


:P
1 Like

Ah just refreshed the page to get these replies! Thanks guys!

@normen said:

You load and attach it like any other model:

rootNode.attachChild(assetManager.loadModel(“Models/MyModel.j3o”));




Haha, i just read that after i posted my first reply :P
Silly me

Thanks a bunch anyway!