Java Code Examples for com.jme3.scene.Spatial#rotate()

The following examples show how to use com.jme3.scene.Spatial#rotate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestCartoonEdge.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupModel(){
        Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
        makeToonish(model);
        model.rotate(0, FastMath.PI, 0);
//        signpost.setLocalTranslation(12, 3.5f, 30);
//        model.scale(0.10f);
//        signpost.setShadowMode(ShadowMode.CastAndReceive);
        rootNode.attachChild(model);
    }
 
Example 2
Source File: TestEverything.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupSignpost(){
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 3
Source File: TestParallax.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    TangentBinormalGenerator.generate(signpost);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 23.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 4
Source File: TestHoveringTank.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void makeMissile() {
    Vector3f pos = spaceCraft.getWorldTranslation().clone();
    Quaternion rot = spaceCraft.getWorldRotation();
    Vector3f dir = rot.getRotationColumn(2);

    Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml");
    missile.scale(0.5f);
    missile.rotate(0, FastMath.PI, 0);
    missile.updateGeometricState();

    BoundingBox box = (BoundingBox) missile.getWorldBound();
    final Vector3f extent = box.getExtent(null);

    BoxCollisionShape boxShape = new BoxCollisionShape(extent);

    missile.setName("Missile");
    missile.rotate(rot);
    missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0));
    missile.setLocalRotation(hoverControl.getPhysicsRotation());
    missile.setShadowMode(ShadowMode.Cast);
    RigidBodyControl control = new BombControl(assetManager, boxShape, 20);
    control.setLinearVelocity(dir.mult(100));
    control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03);
    missile.addControl(control);


    rootNode.attachChild(missile);
    getPhysicsSpace().add(missile);
}
 
Example 5
Source File: TestSpotLight.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupSignpost(){
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
  //   mat.setBoolean("VertexLighting", true);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
}
 
Example 6
Source File: TestPostFilters.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 7
Source File: TestCartoonEdge.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void setupModel(){
        Spatial model = assetManager.loadModel("Models/MonkeyHead/MonkeyHead.mesh.xml");
        makeToonish(model);
        model.rotate(0, FastMath.PI, 0);
//        signpost.setLocalTranslation(12, 3.5f, 30);
//        model.scale(0.10f);
//        signpost.setShadowMode(ShadowMode.CastAndReceive);
        rootNode.attachChild(model);
    }
 
Example 8
Source File: HelloAssets.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {

    /** Load a teapot model (OBJ file from test-data) */
    Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    Material mat_default = new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
    teapot.setMaterial(mat_default);
    rootNode.attachChild(teapot);

    /** Create a wall (Box with material and texture from test-data) */
    Box box = new Box(Vector3f.ZERO, 2.5f,2.5f,1.0f);
    Spatial wall = new Geometry("Box", box );
    Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
    wall.setMaterial(mat_brick);
    wall.setLocalTranslation(2.0f,-2.5f,0.0f);
    rootNode.attachChild(wall);

    /** Display a line of text (default font from test-data) */
    guiNode.detachAllChildren();
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText helloText = new BitmapText(guiFont, false);
    helloText.setSize(guiFont.getCharSet().getRenderedSize());
    helloText.setText("Hello World");
    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");
    ninja.scale(0.05f, 0.05f, 0.05f);
    ninja.rotate(0.0f, -3.0f, 0.0f);
    ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);
    rootNode.attachChild(ninja);
    /** You must add a light to make the model visible */
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
    rootNode.addLight(sun);
}
 
Example 9
Source File: MapDrawer.java    From OpenRTS with MIT License 5 votes vote down vote up
private void attachManmadeCliff(Cliff c) {
	Node n = new Node();
	tilesSpatial.get(c.getTile()).add(n);
	castAndReceiveNode.attachChild(n);

	ManmadeFace face = (ManmadeFace) (c.face);
	Spatial s = getModel(face.modelPath);
	if (s == null) {
		logger.warning("Can't find model " + face.modelPath);
		return;
	}
	switch (c.type) {
		case Orthogonal:
			s.rotate(0, 0, (float) (c.angle + AngleUtil.RIGHT));
			break;
		case Salient:
			s.rotate(0, 0, (float) (c.angle + AngleUtil.RIGHT));
			break;
		case Corner:
			s.rotate(0, 0, (float) (c.angle));
			break;
		default:
			break;
	}
	s.scale(0.005f);
	s.setLocalTranslation((float)c.getTile().getCoord().x + 0.5f, (float)c.getTile().getCoord().y + 0.5f, (float) (c.level * Tile.STAGE_HEIGHT) + 0.1f);
	n.attachChild(s);
}
 
Example 10
Source File: TestEverything.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost(){
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 11
Source File: RollingTheMonkey.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleUpdate(float tpf) {
    // Update and position the score
    scoreText.setText("Score: " + score);
    scoreText.setLocalTranslation((cam.getWidth() - scoreText.getLineWidth()) / 2.0f,
            scoreText.getLineHeight(), 0.0f);
    
    // Rotate all the pickups
    float pickUpSpeed = PICKUP_SPEED * tpf;
    for(Spatial pickUp : pickUps.getChildren()) {
        pickUp.rotate(pickUpSpeed, pickUpSpeed, pickUpSpeed);
    }
    
    Vector3f centralForce = new Vector3f();
    
    if(keyForward) centralForce.addLocal(cam.getDirection());
    if(keyBackward) centralForce.addLocal(cam.getDirection().negate());
    if(keyLeft) centralForce.addLocal(cam.getLeft());
    if(keyRight) centralForce.addLocal(cam.getLeft().negate());
    
    if(!Vector3f.ZERO.equals(centralForce)) {
        centralForce.setY(0);                   // stop ball from pusing down or flying up
        centralForce.normalizeLocal();          // normalize force
        centralForce.multLocal(PLAYER_FORCE);   // scale vector to force

        player.applyCentralForce(centralForce); // apply force to player
    }
    
    cam.lookAt(player.getPhysicsLocation(), Vector3f.UNIT_Y);
}
 
Example 12
Source File: TestParallaxPBR.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    TangentBinormalGenerator.generate(signpost);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 23.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 13
Source File: TestParallax.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material matSp = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    TangentBinormalGenerator.generate(signpost);
    signpost.setMaterial(matSp);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 23.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 14
Source File: TestHoveringTank.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void makeMissile() {
    Vector3f pos = spaceCraft.getWorldTranslation().clone();
    Quaternion rot = spaceCraft.getWorldRotation();
    Vector3f dir = rot.getRotationColumn(2);

    Spatial missile = assetManager.loadModel("Models/SpaceCraft/Rocket.mesh.xml");
    missile.scale(0.5f);
    missile.rotate(0, FastMath.PI, 0);
    missile.updateGeometricState();

    BoundingBox box = (BoundingBox) missile.getWorldBound();
    final Vector3f extent = box.getExtent(null);

    BoxCollisionShape boxShape = new BoxCollisionShape(extent);

    missile.setName("Missile");
    missile.rotate(rot);
    missile.setLocalTranslation(pos.addLocal(0, extent.y * 4.5f, 0));
    missile.setLocalRotation(hoverControl.getPhysicsRotation());
    missile.setShadowMode(ShadowMode.Cast);
    RigidBodyControl control = new BombControl(assetManager, boxShape, 20);
    control.setLinearVelocity(dir.mult(100));
    control.setCollisionGroup(PhysicsCollisionObject.COLLISION_GROUP_03);
    missile.addControl(control);


    rootNode.attachChild(missile);
    getPhysicsSpace().add(missile);
}
 
Example 15
Source File: TestSpotLight.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost(){
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
  //   mat.setBoolean("VertexLighting", true);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
}
 
Example 16
Source File: TestSpotLightShadows.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    //   mat.setBoolean("VertexLighting", true);
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    TangentBinormalGenerator.generate(signpost);
    rootNode.attachChild(signpost);
}
 
Example 17
Source File: TestPostFilters.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void setupSignpost() {
    Spatial signpost = assetManager.loadModel("Models/Sign Post/Sign Post.mesh.xml");
    Material mat = assetManager.loadMaterial("Models/Sign Post/Sign Post.j3m");
    signpost.setMaterial(mat);
    signpost.rotate(0, FastMath.HALF_PI, 0);
    signpost.setLocalTranslation(12, 3.5f, 30);
    signpost.setLocalScale(4);
    signpost.setShadowMode(ShadowMode.CastAndReceive);
    rootNode.attachChild(signpost);
}
 
Example 18
Source File: HelloAssets.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {

    /** Load a teapot model (OBJ file from test-data) */
    Spatial teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
    Material mat_default = new Material( assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
    teapot.setMaterial(mat_default);
    rootNode.attachChild(teapot);

    /** Create a wall (Box with material and texture from test-data) */
    Box box = new Box(2.5f, 2.5f, 1.0f);
    Spatial wall = new Geometry("Box", box );
    Material mat_brick = new Material( assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    mat_brick.setTexture("ColorMap", assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
    wall.setMaterial(mat_brick);
    wall.setLocalTranslation(2.0f,-2.5f,0.0f);
    rootNode.attachChild(wall);

    /** Display a line of text (default font from test-data) */
    setDisplayStatView(false);
    guiFont = assetManager.loadFont("Interface/Fonts/Default.fnt");
    BitmapText helloText = new BitmapText(guiFont, false);
    helloText.setSize(guiFont.getCharSet().getRenderedSize());
    helloText.setText("Hello World");
    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");
    ninja.scale(0.05f, 0.05f, 0.05f);
    ninja.rotate(0.0f, -3.0f, 0.0f);
    ninja.setLocalTranslation(0.0f, -5.0f, -2.0f);
    rootNode.attachChild(ninja);
    /** You must add a light to make the model visible */
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f).normalizeLocal());
    rootNode.addLight(sun);
}
 
Example 19
Source File: SceneEditorController.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void doRotateSpatial(Spatial selected, Quaternion rotation) {
    Quaternion before = new Quaternion(selected.getLocalRotation());
    selected.rotate(rotation);
    Quaternion after = new Quaternion(selected.getLocalRotation());
    rotateUndo(selected, before, after, selectedSpat);
}