Home » Eclipse Projects » Plugin Development Environment (PDE) » Java 3d view Plug-in
Java 3d view Plug-in [message #788070] |
Wed, 01 February 2012 10:11 |
Federico Pozzoni Messages: 16 Registered: December 2011 |
Junior Member |
|
|
Hi,
I'm trying to create a new eclipse view with a java 3d viewer.
When i try to launch the new eclipse application i get an error,
Quote:
Error
Wed Feb 01 11:04:22 CET 2012
Unable to create view ID org.eclipse.j3d.view.ColladaView: javax/media/j3d/Bounds
java.lang.ClassNotFoundException: javax.media.j3d.Bounds
at org.eclipse.osgi.internal.loader.BundleLoader.findClassInternal(BundleLoader.java:489)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:405)
at org.eclipse.osgi.internal.loader.BundleLoader.findClass(BundleLoader.java:393)
at org.eclipse.osgi.internal.baseadaptor.DefaultClassLoader.loadClass(DefaultClassLoader.java:105)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.j3d.view.ColladaView.createPartControl(ColladaView.java:27)
at org.eclipse.ui.internal.ViewReference.createPartHelper(ViewReference.java:367)
at org.eclipse.ui.internal.ViewReference.createPart(ViewReference.java:226)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:313)
at org.eclipse.ui.internal.ViewPane.setVisible(ViewPane.java:529)
at org.eclipse.ui.internal.presentations.PresentablePart.setVisible(PresentablePart.java:180)
at org.eclipse.ui.internal.presentations.util.PresentablePartFolder.select(PresentablePartFolder.java:270)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrder.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation.selectPart(TabbedStackPresentation.java:473)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelection(PartStack.java:1256)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:668)
at org.eclipse.ui.internal.PartStack.createControl(PartStack.java:576)
at org.eclipse.ui.internal.PartSashContainer.createControl(PartSashContainer.java:568)
at org.eclipse.ui.internal.PerspectiveHelper.activate(PerspectiveHelper.java:272)
at org.eclipse.ui.internal.Perspective.onActivate(Perspective.java:981)
at org.eclipse.ui.internal.WorkbenchPage.onActivate(WorkbenchPage.java:2626)
at org.eclipse.ui.internal.WorkbenchWindow$27.run(WorkbenchWindow.java:2964)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.WorkbenchWindow.setActivePage(WorkbenchWindow.java:2945)
at org.eclipse.ui.internal.WorkbenchWindow$21.runWithException(WorkbenchWindow.java:2262)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.application.WorkbenchAdvisor.openWindows(WorkbenchAdvisor.java:803)
at org.eclipse.ui.internal.Workbench$28.runWithException(Workbench.java:1384)
at org.eclipse.ui.internal.StartupThreading$StartupRunnable.run(StartupThreading.java:31)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3855)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3476)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2316)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
at org.eclipse.equinox.launcher.Main.main(Main.java:1287)
I think that eclipse are unable to see the external .jar that my View.java (that lounched alone work fine) requires.
my plugin.xml
Quote:
<plugin
name="Java3d Views Plugin"
id="org.eclipse.J3d.view"
version="1.0.0"
provider-name="OTI">
<requires>
<import plugin="org.eclipse.core.boot"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.swt"/>
<import plugin="org.eclipse.ui"/>
</requires>
<extension point="org.eclipse.ui.views">
<view id="org.eclipse.j3d.view.ColladaView"
name="ColladaView"
class="org.eclipse.j3d.view.ColladaView"
icon="icons\view.gif"/>
</extension>
</plugin>
My colladaview.java
Quote:
package org.eclipse.j3d.view;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
import org.jdesktop.j3d.loaders.collada.Collada14Loader;
import org.jdesktop.j3d.loaders.collada.xml_walker.*;
import com.sun.j3d.loaders.Loader;
import com.sun.j3d.loaders.Scene;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
public class ColladaView extends ViewPart
{
public String filename= "macchina.dae";
public View collada;
public ColladaView() {
System.out.println("costruttore");
}
@Override
public void createPartControl(Composite arg0) {
try {
System.out.println("create oart control");
collada=new View(this.filename);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void setFocus() {
collada.setFocusable(true);
collada.requestFocus();
}
@Override
public void dispose() {
super.dispose();
}
}
my view.java
Quote:
package org.eclipse.j3d.view;
import java.applet.Applet;
import java.awt.*;
import java.net.URL;
import javax.media.j3d.*;
import javax.vecmath.*;
import org.jdesktop.j3d.loaders.collada.Collada14Loader;
import org.jdesktop.j3d.loaders.collada.xml_walker.*;
import com.sun.j3d.loaders.Loader;
import com.sun.j3d.loaders.Scene;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.SimpleUniverse;
import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
public class View extends Applet
{
String filename;
//java.net.URL url;
URL url;
public View(final String model)throws Exception
{
this.filename = model;
//this.filename = "macchina.dae";
System.out.println("costruttore view");
setLayout(new BorderLayout());
Canvas3D canvas = createCanvas();
add("Center", canvas);
SimpleUniverse u = new SimpleUniverse(canvas);
BranchGroup scene = createContent();
OrbitBehavior orbit = new OrbitBehavior(canvas);
orbit.setSchedulingBounds(new BoundingSphere(new Point3d(10.0, 10.0, 0.0), 10.0));
u.getViewingPlatform().setViewPlatformBehavior(orbit);
TransformGroup vtg = u.getViewingPlatform().getViewPlatformTransform();
Transform3D moveback = new Transform3D();
moveback.setTranslation(new Vector3f(0.0f, 0.0f, 10.0f));
vtg.setTransform(moveback);
scene.compile();
u.getViewer().getView().setBackClipDistance(100.0);
u.addBranchGraph(scene);
}
private Canvas3D createCanvas()
{
GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
GraphicsConfiguration gc1 = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template);
return new Canvas3D(gc1);
}
private BranchGroup createContent()
throws Exception
{
System.out.println("loader");
Loader loader = new Collada14Loader();
//Loader loader = new MS3DLoader();
//Loader loader = new KmzLoader();
// Use these 4 lines to load from a local file
java.io.File file = new java.io.File(filename);
System.out.println(file.getParent() + java.io.File.separator);
if (file.getParent() != null)
if (file.getParent().length() > 0) // figure out the base path
loader.setBasePath(file.getParent() + java.io.File.separator);
System.out.println(file.getName());
Scene scene = loader.load(file.getName());
BranchGroup group = scene.getSceneGroup();
createLights(group);
return group;
}
private void createLights(BranchGroup graphRoot)
{
// Create a bounds for the light source influence
BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
// Set up the global, ambient light
Color3f alColor = new Color3f(1.0f, 1.0f, 1.0f);
AmbientLight aLgt = new AmbientLight(alColor);
aLgt.setInfluencingBounds(bounds);
graphRoot.addChild(aLgt);
// Set up the point (infinite) light source
Point3f location = new Point3f(0.0f, 0.0f, 100.0f);
PointLight lgt1 = new PointLight(new Color3f(1.0f, 1.0f, 1.0f),
location,
new Point3f(1.0f, 0.0f, 0.0f));
lgt1.setInfluencingBounds(bounds);
graphRoot.addChild(lgt1);
// create an Appearance and Material
Appearance app = new Appearance( );
Color3f objColor = new Color3f( 1.0f, 0.7f, 0.8f );
Color3f black = new Color3f( 0.0f, 0.0f, 0.0f );
app.setMaterial( new Material( objColor, black, objColor, black, 80.0f ) );
Sphere sphere = new Sphere(1.0f, Sphere.GENERATE_NORMALS, app);
// a sphere to represent the light source.
Transform3D trans = new Transform3D();
trans.setTranslation(new Vector3f(location));
TransformGroup tg = new TransformGroup();
tg.setTransform(trans);
tg.addChild(sphere);
graphRoot.addChild(tg);
}
}
[Updated on: Wed, 01 February 2012 10:18] Report message to a moderator
|
|
| |
Re: Java 3d view Plug-in [message #788103 is a reply to message #788070] |
Wed, 01 February 2012 10:52 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
This looks like the pre 3.0 plugin way (older than 7 years!!!!)! You
should switch to OSGi-Usage!
Next problem is that you are using Swing and to embed this into SWT you
need to do extra steps using the SWT-Awt-Bridge.
Might I also suggest that you take a look at JavaFX 2.0 if you want to
3d stuff in Java?
I'd suggest you start with one of the many only tutorials on writing a
Tom
Am 01.02.12 11:11, schrieb Federico Pozzoni:
> Hi,
> I'm trying to create a new eclipse view with a java 3d viewer.
> When i try to launch the new eclipse application i get an error,
> I think that eclipse are unable to see the external .jar that my
> View.java (that lounched alone work fine) requires.
>
> my plugin.xml
> Quote:
>> <plugin
>> name="Java3d Views Plugin"
>> id="org.eclipse.J3d.view"
>> version="1.0.0"
>> provider-name="OTI">
>> <requires>
>> <import plugin="org.eclipse.core.boot"/>
>> <import plugin="org.eclipse.core.runtime"/>
>> <import plugin="org.eclipse.core.resources"/>
>> <import plugin="org.eclipse.swt"/>
>> <import plugin="org.eclipse.ui"/>
>> </requires>
>>
>> <extension point="org.eclipse.ui.views">
>> <view id="org.eclipse.j3d.view.ColladaView"
>> name="ColladaView"
>> class="org.eclipse.j3d.view.ColladaView"
>> icon="icons\view.gif"/>
>> </extension>
>> </plugin>
>
>
>
> My colladaview.java
>
>
> Quote:
>> package org.eclipse.j3d.view;
>>
>> import org.eclipse.swt.widgets.Composite;
>> import org.eclipse.ui.part.ViewPart;
>> import org.jdesktop.j3d.loaders.collada.Collada14Loader;
>> import org.jdesktop.j3d.loaders.collada.xml_walker.*;
>> import com.sun.j3d.loaders.Loader;
>> import com.sun.j3d.loaders.Scene;
>> import com.sun.j3d.utils.geometry.*;
>> import com.sun.j3d.utils.applet.MainFrame;
>> import com.sun.j3d.utils.universe.SimpleUniverse;
>> import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
>>
>>
>> public class ColladaView extends ViewPart
>> {
>> public String filename= "macchina.dae";
>> public View collada;
>> public ColladaView() {
>> System.out.println("costruttore");
>> }
>> @Override
>> public void createPartControl(Composite arg0) {
>> try {
>> System.out.println("create oart control");
>> collada=new View(this.filename);
>> } catch (Exception e) {
>> e.printStackTrace();
>> }
>> }
>> @Override
>> public void setFocus() {
>> collada.setFocusable(true);
>> collada.requestFocus();
>>
>> } @Override
>> public void dispose() {
>> super.dispose();
>> }
>> }
>
>
> my view.java
>
> Quote:
>> package org.eclipse.j3d.view;
>>
>> import java.applet.Applet;
>> import java.awt.*;
>> import java.net.URL;
>>
>> import javax.media.j3d.*;
>> import javax.vecmath.*;
>>
>> import org.jdesktop.j3d.loaders.collada.Collada14Loader;
>> import org.jdesktop.j3d.loaders.collada.xml_walker.*;
>>
>> import com.sun.j3d.loaders.Loader;
>> import com.sun.j3d.loaders.Scene;
>> import com.sun.j3d.utils.geometry.*;
>> import com.sun.j3d.utils.applet.MainFrame;
>> import com.sun.j3d.utils.universe.SimpleUniverse;
>> import com.sun.j3d.utils.behaviors.vp.OrbitBehavior;
>>
>>
>> public class View extends Applet
>> {
>> String filename;
>> //java.net.URL url;
>> URL url;
>> public View(final String model)throws Exception
>> {
>> this.filename = model;
>> //this.filename = "macchina.dae";
>> System.out.println("costruttore view");
>>
>> setLayout(new BorderLayout());
>> Canvas3D canvas = createCanvas();
>> add("Center", canvas);
>> SimpleUniverse u = new SimpleUniverse(canvas);
>>
>> BranchGroup scene = createContent();
>>
>> OrbitBehavior orbit = new OrbitBehavior(canvas);
>> orbit.setSchedulingBounds(new BoundingSphere(new Point3d(10.0,
>> 10.0, 0.0), 10.0));
>> u.getViewingPlatform().setViewPlatformBehavior(orbit);
>>
>> TransformGroup vtg =
>> u.getViewingPlatform().getViewPlatformTransform();
>> Transform3D moveback = new Transform3D();
>> moveback.setTranslation(new Vector3f(0.0f, 0.0f, 10.0f));
>> vtg.setTransform(moveback);
>>
>> scene.compile();
>> u.getViewer().getView().setBackClipDistance(100.0);
>> u.addBranchGraph(scene);
>> }
>>
>> private Canvas3D createCanvas()
>> {
>> GraphicsConfigTemplate3D template = new GraphicsConfigTemplate3D();
>> GraphicsConfiguration gc1 =
>> GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getBestConfiguration(template);
>>
>> return new Canvas3D(gc1);
>> }
>>
>> private BranchGroup createContent()
>> throws Exception
>> {
>> System.out.println("loader");
>> Loader loader = new Collada14Loader();
>> //Loader loader = new MS3DLoader();
>> //Loader loader = new KmzLoader();
>>
>> // Use these 4 lines to load from a local file
>> java.io.File file = new java.io.File(filename);
>> System.out.println(file.getParent() + java.io.File.separator);
>> if (file.getParent() != null)
>> if (file.getParent().length() > 0) // figure out the base path
>> loader.setBasePath(file.getParent() + java.io.File.separator);
>> System.out.println(file.getName());
>> Scene scene = loader.load(file.getName());
>> BranchGroup group = scene.getSceneGroup();
>> createLights(group);
>> return group;
>>
>>
>> }
>>
>> private void createLights(BranchGroup graphRoot)
>> {
>> // Create a bounds for the light source influence
>> BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0,
>> 0.0), 100.0);
>>
>> // Set up the global, ambient light
>> Color3f alColor = new Color3f(1.0f, 1.0f, 1.0f);
>> AmbientLight aLgt = new AmbientLight(alColor);
>> aLgt.setInfluencingBounds(bounds);
>> graphRoot.addChild(aLgt);
>>
>> // Set up the point (infinite) light source
>> Point3f location = new Point3f(0.0f, 0.0f, 100.0f);
>> PointLight lgt1 = new PointLight(new Color3f(1.0f, 1.0f, 1.0f),
>> location,
>> new Point3f(1.0f, 0.0f, 0.0f));
>> lgt1.setInfluencingBounds(bounds);
>> graphRoot.addChild(lgt1);
>>
>> // create an Appearance and Material
>> Appearance app = new Appearance( );
>> Color3f objColor = new Color3f( 1.0f, 0.7f, 0.8f );
>> Color3f black = new Color3f( 0.0f, 0.0f, 0.0f );
>> app.setMaterial( new Material( objColor, black, objColor, black,
>> 80.0f ) );
>>
>> Sphere sphere = new Sphere(1.0f, Sphere.GENERATE_NORMALS, app);
>> // a sphere to represent the light source.
>> Transform3D trans = new Transform3D();
>> trans.setTranslation(new Vector3f(location));
>> TransformGroup tg = new TransformGroup();
>> tg.setTransform(trans);
>> tg.addChild(sphere);
>> graphRoot.addChild(tg);
>>
>> }
>> }
>
|
|
| | | | |
Goto Forum:
Current Time: Fri Sep 20 20:03:08 GMT 2024
Powered by FUDForum. Page generated in 0.04186 seconds
|