Calm, I’ll explain better:
When you run this code:
package game;
import com.jme3.app.SimpleApplication;
import com.jme3.asset.TextureKey;
import com.jme3.bullet.BulletAppState;
import com.jme3.bullet.control.RigidBodyControl;
import com.jme3.material.Material;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Spatial;
import com.jme3.scene.shape.Box;
import com.jme3.system.AppSettings;
import com.jme3.texture.Texture;
import com.jme3.texture.Texture.WrapMode;
public class BrickGame extends SimpleApplication {
private BulletAppState bulletAppState;
private Material floor_mat;
private RigidBodyControl floor_phy;
private static final Box floor;
private RigidBodyControl player_phy;
private Spatial player;
public static void main(String[] args) {
AppSettings settings = new AppSettings(true);
settings.setRenderer(AppSettings.LWJGL_OPENGL1);
settings.setTitle("My3DGame");
settings.setResolution(800, 600);
BrickGame app = new BrickGame();
app.setShowSettings(false);
app.setSettings(settings);
app.start();
}
static {
floor = new Box(Vector3f.ZERO, 10f, 0.1f, 5f);
floor.scaleTextureCoordinates(new Vector2f(3, 6));
}
@Override
public void simpleInitApp() {
bulletAppState = new BulletAppState();
stateManager.attach(bulletAppState);
flyCam.setMoveSpeed(4);
flyCam.setZoomSpeed(8);
cam.setLocation(new Vector3f(0, 4f, 6f));
cam.lookAt(new Vector3f(2, 2, 0), Vector3f.UNIT_Y);
initMaterials();
initFloor();
initPlayer();
bulletAppState.getPhysicsSpace().enableDebug(assetManager);
}
public void initPlayer() {
player = assetManager.loadModel("Models/Oto/Oto.mesh.xml");
player_phy = new RigidBodyControl(1);
player.scale(0.1f);
player.setLocalTranslation(0, 0.4f, 2);
rootNode.attachChild(player);
player.addControl(player_phy);
bulletAppState.getPhysicsSpace().add(player_phy);
}
public void initMaterials() {
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 initFloor() {
Geometry floor_geo = new Geometry("Floor", floor);
floor_geo.setMaterial(floor_mat);
floor_geo.setLocalTranslation(0, -0.1f, 0);
this.rootNode.attachChild(floor_geo);
floor_phy = new RigidBodyControl(0);
floor_geo.addControl(floor_phy);
bulletAppState.getPhysicsSpace().add(floor_phy);
}
}
You will see a doll on the floor.
Pay attention to how to knit doll is … She is “stretched” on the doll.
Now change the mass of the doll to 0 and run the code!
Now the puppet mesh is prissy on the doll!
Why does it happen? Its dummy load with a mass so that the loop is right?