I will use the same code from my previous question on this question:
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.
I hope you understand. I need to “resize” the mesh of the doll, now it is “stretched” on the doll but I wanted a lot of power, for example, transform a mesh sphere
You must be curious to know why I need it, you may find my interesting idea:
When a Scene is loaded with “Spatial scene = assetManager.loadModel (road map)” Your mesh is extremely thin, and that’s bad because an object falling at high speed can easily cross it.
It has been possible to change the mesh Scene, I can avoid objects crossing a Scene, simply letting your larger-mesh on the floor!