I’m building a maze / dungeon using the bricks and the wall that was in the example. I can make the wall longer and higher but it falls into pieces. Is is better to model a maze / labyrinth from a .scene file instead? If I can make it with the example component, what should be done to make the wall stand and not fall?
[java] public void initWall() {
float startpt = bLength / 4;
float height = 0;
for (int j = 0; j < 30; j++) {
for (int i = 0; i < 4; i++) {
Vector3f vt = new Vector3f(i * bLength * 2 + startpt, bHeight + height, 0);
addBrick(vt);
}
startpt = -startpt;
height += 2 * bHeight;
}
} /** Initialize the materials used in this scene. */
public void initMaterials() {
mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
wall_mat = new Material(assetManager,
“Common/MatDefs/Misc/Unshaded.j3md”);
TextureKey key = new TextureKey(
“Textures/Terrain/BrickWall/BrickWall.jpg”);
key.setGenerateMips(true);
Texture tex = assetManager.loadTexture(key);
wall_mat.setTexture(“ColorMap”, tex);
mat.setTexture(“ColorMap”, tex);
stone_mat = new Material(assetManager,
“Common/MatDefs/Misc/Unshaded.j3md”);
TextureKey key2 = new TextureKey(“Textures/Terrain/Rock/Rock.PNG”);
key2.setGenerateMips(true);
Texture tex2 = assetManager.loadTexture(key2);
stone_mat.setTexture(“ColorMap”, tex2);
floor_mat = new Material(assetManager,
“Common/MatDefs/Misc/Unshaded.j3md”);
TextureKey key3 = new TextureKey(“Textures/Terrain/Pond/Pond.jpg”);
key3.setGenerateMips(true);
Texture tex3 = assetManager.loadTexture(key3);
tex3.setWrap(WrapMode.Repeat);
floor_mat.setTexture(“ColorMap”, tex3);
} public void addBrick(Vector3f ori) {
Geometry reBoxg = new Geometry(“brick”, brick);
reBoxg.setMaterial(mat);
reBoxg.setLocalTranslation(ori);
// for geometry with sphere mesh the physics system automatically uses a
// sphere collision shape
reBoxg.addControl(new RigidBodyControl(1.5f));
reBoxg.setShadowMode(ShadowMode.CastAndReceive);
reBoxg.getControl(RigidBodyControl.class).setFriction(0.6f);
this.rootNode.attachChild(reBoxg);
this.getPhysicsSpace().add(reBoxg);
}[/java]
That way is not going to work very well, as you will have so many objects in your scene, and you dont need them, if all you want is a wall with a brick texture. You can probably use a heightmap for this. Or create a flat plane in blender for your maze and extrude it up.
your bug is that you use physics, simple dont use physics if you want you walls to be static.
I think “Hello Physics” or “Hello Collision” gives exactly this example, of a crumbling building and explicitly says that you should not build your whole world from physics enabled objects…
Thank you for the answers. I’ll wait with the problem how to generate a random maze and I can use a static scene instead that is pre-rendered. I can use a .scene instead and I am now practicing on the quake scene but I can’t the character to walk properly so please so my other question where I want to learn how to enable third person walk for the ninja character: http://hub.jmonkeyengine.org/groups/graphics/forum/topic/how-to-make-ninja-walk-properly-in-3rd-person/
Many thanks!