(Java)Membuat Model,Control,View_Jmonkey Example Part2 Node

Part2 tidak jauh beda dengan part1, disini kita akan membuat 2 model dengan dengan betuk yang sama, sama persisi dengan keadaan postingan ane sebelumnya tentang javaFX, sama dengan pengambilan model 3D yang dilakukan hanya berbeda dalam penulisan code nya saja, ya jelas, karena pembuat nya juga beda.

Code Code

 /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mygame;

import com.jme3.app.SimpleApplication;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Quaternion;
import com.jme3.math.Vector3f;
import com.jme3.scene.Geometry;
import com.jme3.scene.Node;
import com.jme3.scene.shape.Box;

/**
 *
 * @author Victor
 */
public class HelloNode extends SimpleApplication{
    public static void main(String[] args) {
        HelloNode app = new HelloNode();
        app.start();
    }
    @Override
    public void simpleInitApp() {
    //Kotak hijau
        Box box3 = new Box(Vector3f.ZERO,1,-1,1);
        Geometry green = new Geometry("Box",box3);
        Material mat3 = new Material(assetManager, 
                "Common/MatDefs/Misc/Unshaded.j3md");
        mat3.setColor("Color", ColorRGBA.Green);
        green.setMaterial(mat3);
        green.move(1,1,1);
        
        //Kotak biru
        Box box1 = new Box(Vector3f.ZERO,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);
        blue.move(3,1,1);
        
        //kotak Merah
        
        Box box2 = new Box(Vector3f.ZERO,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);
        red.move(5,1,1);
        
        Node pivot = new Node("pivot");
        rootNode.attachChild(pivot);
         pivot.attachChild(green);
        pivot.attachChild(blue);
        pivot.attachChild(red);
       
        pivot.rotate(.4f,.4f,0f);
    }   
    
    
}

RUN

5-16-2013 8-50-44 AM

Advertisements

Published by

jarcode

hello I am jarcode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s