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

The following examples show how to use com.jme3.scene.Node#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: TestGimpactShape.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private RigidBodyControl drop(Vector3f offset, String model, float scale, float mass) {
    scale *= scaleMod;
    Node n = (Node) assetManager.loadModel(model);
    n.setLocalTranslation(offset);
    n.rotate(0, 0, -FastMath.HALF_PI);

    Geometry tp = ((Geometry) n.getChild(0));
    tp.scale(scale);
    Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    tp.setMaterial(mat);

    Mesh mesh = tp.getMesh();
    GImpactCollisionShape shape = new GImpactCollisionShape(mesh);
    shape.setScale(new Vector3f(scale, scale, scale));

    RigidBodyControl control = new RigidBodyControl(shape, mass);
    n.addControl(control);
    addObject(n);
    return control;
}
 
Example 2
Source File: TranslateUtil.java    From OpenRTS with MIT License 6 votes vote down vote up
public static DirectionalLight toJMELight(DirectionalLighting dl) {
	DirectionalLight res = new DirectionalLight();
	res.setColor(toColorRGBA(dl.color).multLocal((float) (dl.intensity)));

	Node world = new Node();

	Node yaw = new Node();
	world.attachChild(yaw);

	Node pitch = new Node();
	yaw.attachChild(pitch);

	Node offset = new Node();
	pitch.attachChild(offset);
	offset.setLocalTranslation(Vector3f.UNIT_X);

	pitch.rotate(0, (float) dl.pitch, 0);

	yaw.rotate(0, 0, (float) dl.yaw);
	res.setDirection(offset.getWorldTranslation());
	return res;
}
 
Example 3
Source File: TranslateUtil.java    From OpenRTS with MIT License 6 votes vote down vote up
public static void toJMELight(DirectionalLight JMEdl, DirectionalLighting dl) {
	JMEdl.setColor(toColorRGBA(dl.color).multLocal((float) (dl.intensity)));
	Node world = new Node();

	Node yaw = new Node();
	world.attachChild(yaw);

	Node pitch = new Node();
	yaw.attachChild(pitch);

	Node offset = new Node();
	pitch.attachChild(offset);
	offset.setLocalTranslation(Vector3f.UNIT_X);

	pitch.rotate(0, (float) dl.pitch, 0);

	yaw.rotate(0, 0, (float) dl.yaw);
	JMEdl.setDirection(offset.getWorldTranslation());
}
 
Example 4
Source File: TestIssue1138.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {
    Node cgModel = (Node) assetManager.loadModel(
            "Models/Elephant/Elephant.mesh.xml");
    rootNode.attachChild(cgModel);
    cgModel.rotate(0f, -1f, 0f);
    cgModel.scale(0.04f);

    AnimComposer composer = cgModel.getControl(AnimComposer.class);
    composer.setCurrentAction("legUp");
    sControl = cgModel.getControl(SkinningControl.class);

    AmbientLight light = new AmbientLight();
    rootNode.addLight(light);
}
 
Example 5
Source File: HelloNode.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void simpleInitApp() {

    /** create a blue box at coordinates (1,-1,1) */
    Box box1 = new Box(1,1,1);
    Geometry blue = new Geometry("Box", box1);
    blue.setLocalTranslation(new Vector3f(1,-1,1));
    Material mat1 = new Material(assetManager, 
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setColor("Color", ColorRGBA.Blue);
    blue.setMaterial(mat1);

    /** create a red box straight above the blue one at (1,3,1) */
    Box box2 = new Box(1,1,1);      
    Geometry red = new Geometry("Box", box2);
    red.setLocalTranslation(new Vector3f(1,3,1));
    Material mat2 = new Material(assetManager, 
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Red);
    red.setMaterial(mat2);

    /** Create a pivot node at (0,0,0) and attach it to the root node */
    Node pivot = new Node("pivot");
    rootNode.attachChild(pivot); // put this node in the scene

    /** Attach the two boxes to the *pivot* node. (And transitively to the root node.) */
    pivot.attachChild(blue);
    pivot.attachChild(red);
    /** Rotate the pivot node: Note that both boxes have rotated! */
    pivot.rotate(.4f,.4f,0f);
}
 
Example 6
Source File: HelloNode.java    From chuidiang-ejemplos with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void simpleInitApp() {

    /** create a blue box at coordinates (1,-1,1) */
    Box box1 = new Box(1,1,1);
    Geometry blue = new Geometry("Box", box1);
    blue.setLocalTranslation(new Vector3f(1,-1,1));
    Material mat1 = new Material(assetManager,
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setColor("Color", ColorRGBA.Blue);
    blue.setMaterial(mat1);

    /** create a red box straight above the blue one at (1,3,1) */
    Box box2 = new Box(1,1,1);
    Geometry red = new Geometry("Box", box2);
    red.setLocalTranslation(new Vector3f(1,3,1));
    Material mat2 = new Material(assetManager,
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Red);
    red.setMaterial(mat2);

    /** Create a pivot node at (0,0,0) and attach it to the root node */
    pivot = new Node("pivot");
    rootNode.attachChild(pivot); // put this node in the scene

    /** Attach the two boxes to the *pivot* node. (And transitively to the root node.) */
    pivot.attachChild(blue);
    pivot.attachChild(red);
    /** Rotate the pivot node: Note that both boxes have rotated! */
    pivot.rotate(.4f,.4f,0f);

}
 
Example 7
Source File: HelloNode.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void simpleInitApp() {

    /** create a blue box at coordinates (1,-1,1) */
    Box box1 = new Box( new Vector3f(1,-1,1), 1,1,1);
    Geometry blue = new Geometry("Box", box1);
    Material mat1 = new Material(assetManager, 
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat1.setColor("Color", ColorRGBA.Blue);
    blue.setMaterial(mat1);

    /** create a red box straight above the blue one at (1,3,1) */
    Box box2 = new Box( new Vector3f(1,3,1), 1,1,1);
    Geometry red = new Geometry("Box", box2);
    Material mat2 = new Material(assetManager, 
            "Common/MatDefs/Misc/Unshaded.j3md");
    mat2.setColor("Color", ColorRGBA.Red);
    red.setMaterial(mat2);

    /** Create a pivot node at (0,0,0) and attach it to the root node */
    Node pivot = new Node("pivot");
    rootNode.attachChild(pivot); // put this node in the scene

    /** Attach the two boxes to the *pivot* node. (And transitively to the root node.) */
    pivot.attachChild(blue);
    pivot.attachChild(red);
    /** Rotate the pivot node: Note that both boxes have rotated! */
    pivot.rotate(.4f,.4f,0f);
}