Eclipse'View & JME'Canvas

Hi all It's my first time to use JME to do my graduate project. Please give me some tips to solve my questions.

Thanks a lot (Because I'm not good in English,I'm sorry to write poor grammar in English.)



Q:I wanna use "View" (Eclipse RCP) to combine with the Canvas (JME). That I can show some grapgic or 3D in the View. But I don't know how to do. because almost 3D in jme are extends "Simplegame",I don't know how to combine

View with Simplegame. Please teach me. >"<



Code in "View"

import org.eclipse.ui.part.ViewPart;

import org.eclipse.swt.layout.GridLayout;

import org.eclipse.swt.widgets.Composite;

import org.eclipse.swt.SWT;



public class HelloViewPart3 extends ViewPart

{

    public static final String ID ="Demo.HelloViewPart3"; //$NON-NLS-1$



    Composite composite1;

   

   

    public HelloViewPart3() {

        super();

       

    }



   

    public void createPartControl(Composite parent) {

        composite1 = new Composite(parent, SWT.NULL);

        composite1.setLayout(new GridLayout(4, false));

    }



   

    public void setFocus() {

       

    }

   

   

    public void dispose() {

        super.dispose();

    }

   

}



test code I want to show  in  View



import com.jme.app.SimpleGame;

import com.jme.math.Vector2f;

import com.jme.math.Vector3f;

import com.jme.renderer.ColorRGBA;

import com.jme.scene.Point;

import com.jme.scene.Line;

import com.jme.scene.TriMesh;

import com.jme.scene.shape.*;

import com.jme.util.geom.BufferUtils;



public class test extends SimpleGame {

public static void main(String[] args) {

test app = new test();

app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG, test.class

.getClassLoader().getResource("jtest/72000373_1.jpg"));

app.start();

}



public void simpleInitGame() {

Point p1 = new Point();

Vector3f[] vertex1 = { new Vector3f(10, 0, 0) };

Vector3f[] normal = { new Vector3f(0, 1, 0) };

ColorRGBA[] color = { new ColorRGBA(1, 1, 1, 1) };

Vector2f[] texCoords = { new Vector2f(0, 0) };

p1.reconstruct(BufferUtils.createFloatBuffer(vertex1), BufferUtils

.createFloatBuffer(normal), BufferUtils

.createFloatBuffer(color), BufferUtils

.createFloatBuffer(texCoords));

p1.setPointSize(10);



Point p2 = new Point();

Vector3f[] vertex2 = { new Vector3f(0, 10, 0) };

p2.reconstruct(BufferUtils.createFloatBuffer(vertex2), BufferUtils

.createFloatBuffer(normal), BufferUtils

.createFloatBuffer(color), BufferUtils

.createFloatBuffer(texCoords));

p2.setPointSize(10);



Point p3 = new Point();

Vector3f[] vertex3 = { new Vector3f(0, 0, 5) };

Vector3f[] normal2 = { new Vector3f(1, 0, 0) };

ColorRGBA[] color2 = { new ColorRGBA(0, 0, 1, 1) };

p3.reconstruct(BufferUtils.createFloatBuffer(vertex3), BufferUtils

.createFloatBuffer(normal2), BufferUtils

.createFloatBuffer(color2), BufferUtils

.createFloatBuffer(texCoords));

p3.setPointSize(10);



Point p4 = new Point();

Vector3f[] vertex4 = { new Vector3f(0, 0, 0) };

p4.reconstruct(BufferUtils.createFloatBuffer(vertex4), BufferUtils

.createFloatBuffer(normal), BufferUtils

.createFloatBuffer(color), BufferUtils

.createFloatBuffer(texCoords));

p4.setPointSize(10);



Line l1 = new Line();

Vector3f[] vertex5 = { new Vector3f(10, 0, 0), new Vector3f(0, 10, 0) };

Vector3f[] normals = { new Vector3f(0, 0, 1), new Vector3f(0, 0, 1) };

ColorRGBA[] colors = { new ColorRGBA(1, 0, 0, 1),

new ColorRGBA(0, 1, 0, 1) };

Vector2f[] texs = { new Vector2f(1, 1), new Vector2f(1, 1) };

l1.reconstruct(BufferUtils.createFloatBuffer(vertex5),

BufferUtils.createFloatBuffer(normals),

BufferUtils.createFloatBuffer(colors),

BufferUtils.createFloatBuffer(texs));

l1.setLineWidth(10);



TriMesh m = new TriMesh();

Vector3f[] vertex6 = { new Vector3f(-5, -5, 0), new Vector3f(-5, 0, 0),

new Vector3f(0, -5, 0), new Vector3f(-1, -1, 0) };

Vector3f[] normal3 = {new Vector3f(0,0,1),new Vector3f(0,0,1),new Vector3f(0,0,1)

,new Vector3f(0,0,1)};

ColorRGBA[] color3 = {new ColorRGBA(0,0,1,1), new ColorRGBA(0,0,1,1),new ColorRGBA(0,0,1,1)

,new ColorRGBA(0,0,1,1)};

Vector2f[] texs2 = {new Vector2f(0,0),new Vector2f(0,1),new Vector2f(1,1),

new Vector2f(1,0)};

int[] indexes = {0,1,2,1,2,3};

m.reconstruct(BufferUtils.createFloatBuffer(vertex6), BufferUtils.createFloatBuffer(normal3)

, BufferUtils.createFloatBuffer(color3),BufferUtils.createFloatBuffer(texs2)

,BufferUtils.createIntBuffer(indexes));



rootNode.attachChild(p1);

rootNode.attachChild(p2);

// rootNode.attachChild(p3);

rootNode.attachChild(p4);

rootNode.attachChild(l1);

rootNode.attachChild(m);

lightState.setEnabled(false);

}

}

Or have a look here:



http://code.google.com/p/monklypse/

hiya, please use [ code ] tags :slight_smile:

And for the eclipse rcp integration, you could check out the jMonkeyWorld source and see how they do it.

http://code.google.com/p/mw3d/