Getting started, I'm new with Xith3D (but not new with 3D graphics and Java). I've rewritten XIN sample native applications n' everything works just fine.
I have read many 'Xith3D Applet' topics here at the board, but all of the authors started with great inthusiasm although the topics ended with no answer.
I wish to write such Applet. The code I wrote is pretty much simple:
import java.applet.Applet;
import org.openmali.vecmath.Vector3f;
import org.xith3d.base.Xith3DEnvironment;
import org.xith3d.loop.RenderLoop;
import org.xith3d.render.Canvas3DPanel;
import org.xith3d.scenegraph.BranchGroup;
import org.xith3d.scenegraph.primitives.Cube;
public class Xith3DApplet extends Applet {
public void init() {
RenderLoop rl = new RenderLoop(60f);
Canvas3DPanel canvas = new Canvas3DPanel();
Xith3DEnvironment env = new Xith3DEnvironment(rl);
env.addCanvas(canvas);
env.addPerspectiveBranch(createScene());
env.getView().setPosition(new Vector3f(1, -1, 5));
rl.begin();
add(canvas);
}
private BranchGroup createScene() {
Cube cube = new Cube(3.0f);
BranchGroup bg = new BranchGroup();
bg.addChild(cube);
return bg;
}
public void start() {
}
public void stop() {
}
}
It creates a white cube rendered at the left/upper corner. I'm using Canvas3DPanel for visualisation at the Applet.
To launch the Applet (as JOGL is required) I'm using JNLPAppletLauncher. The code is the following:
<applet code="org.jdesktop.applet.util.JNLPAppletLauncher"
width=600
height=400
archive="http://download.java.net/media/applet-launcher/applet-launcher.jar,
http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar,
http://download.java.net/media/gluegen/webstart/gluegen-rt.jar,
xith3d.jar,
xith3d-tk.jar,
jagatoo.jar,
hial.jar,
openmali.jar,
xith3dapplet.jar">
<param name="codebase_lookup" value="false">
<param name="subapplet.classname" value="Xith3DApplet">
<param name="subapplet.displayname" value="Xith3D Applet">
<param name="noddraw.check" value="true">
<param name="progressbar" value="true">
<param name="jnlpNumExtensions" value="1">
<param name="jnlpExtension1" value="http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp">
</applet>
Pretty simple, huuh! The jar archives I've added (with the exception of xith-tk, wich is there.. 4fun) were needed for the Applet to be launched (I tested the Applet without the third-party jars and added 'em as they caused ClassNotFoundException's).
Actually I'm getting the following error at the Java console:
JNLPAppletLauncher: static initializer
os.name = windows xp
nativePrefix = nativeSuffix = .dll
tmpRootDir = C:\DOCUME~1\suzuki\CONFIG~3\Temp\jnlp-applet\jln43764
Applet.init
subapplet.classname = Xith3DApplet
subapplet.displayname = Xith3D Applet
Applet.start
JNLPAppletLauncher: static initializer
os.name = windows xp
nativePrefix = nativeSuffix = .dll
tmpRootDir = C:\DOCUME~1\suzuki\CONFIG~3\Temp\jnlp-applet\jln43764
Applet.init
subapplet.classname = demos.applets.GearsApplet
subapplet.displayname = JOGL Gears Applet
Applet.start
os.name = windows xp
os.arch = x86
processNativeJar: using previously cached: C:\Documents and Settings\suzuki\.jnlp-applet\cache\10_90_150_90\8f0d7d69daf39b292f5c09591642a059bfd2d919\jogl-natives-windows-i586.jar
validateCertificates:
VALIDATE: jogl.dll
VALIDATE: jogl_awt.dll
VALIDATE: jogl_cg.dll
extractNativeLibs:
EXTRACT: jogl.dll(jogl)
EXTRACT: jogl_awt.dll(jogl_awt)
EXTRACT: jogl_cg.dll(jogl_cg)
processNativeJar: using previously cached: C:\Documents and Settings\suzuki\.jnlp-applet\cache\10_90_150_90\8f0d7d69daf39b292f5c09591642a059bfd2d919\gluegen-rt-natives-windows-i586.jar
validateCertificates:
VALIDATE: gluegen-rt.dll
extractNativeLibs:
EXTRACT: gluegen-rt.dll(gluegen-rt)
JNLPAppletLauncher.loadLibrary("jogl")
loading: C:\DOCUME~1\suzuki\CONFIG~3\Temp\jnlp-applet\jln43764\jln43788\jogl.dll
os.name = windows xp
os.arch = x86
processNativeJar: http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl-natives-windows-i586.jar --> C:\Documents and Settings\suzuki\.jnlp-applet\cache\10_90_150_90\a44326ec065fe209b6ee667eb2cbb0b12aa834a6\jogl-natives-windows-i586.jar : 60708 bytes written
validateCertificates:
VALIDATE: jogl.dll
VALIDATE: jogl_awt.dll
VALIDATE: jogl_cg.dll
extractNativeLibs:
EXTRACT: jogl.dll(jogl)
EXTRACT: jogl_awt.dll(jogl_awt)
EXTRACT: jogl_cg.dll(jogl_cg)
JNLPAppletLauncher.loadLibrary("jogl_awt")
loading: C:\DOCUME~1\suzuki\CONFIG~3\Temp\jnlp-applet\jln43764\jln43788\jogl_awt.dll
INIT GL IS: com.sun.opengl.impl.GLImpl
Chosen GLCapabilities: GLCapabilities [DoubleBuffered: true, Stereo: false, HardwareAccelerated: true, DepthBits: 24, StencilBits: 8, Red: 8, Green: 8, Blue: 8, Alpha: 8, Red Accum: 0, Green Accum: 0, Blue Accum: 0, Alpha Accum: 0, Multisample: false ]
GL_VENDOR: ATI Technologies Inc.
GL_RENDERER: Radeon 7500 DDR x86/SSE2
GL_VERSION: 1.3.3036 WinXP Release
processNativeJar: http://download.java.net/media/gluegen/webstart/gluegen-rt-natives-windows-i586.jar --> C:\Documents and Settings\suzuki\.jnlp-applet\cache\10_90_150_90\a44326ec065fe209b6ee667eb2cbb0b12aa834a6\gluegen-rt-natives-windows-i586.jar : 4778 bytes written
validateCertificates:
VALIDATE: gluegen-rt.dll
extractNativeLibs:
EXTRACT: gluegen-rt.dll(gluegen-rt)
java.security.AccessControlException: access denied (java.lang.RuntimePermission accessClassInPackage.sun.security.pkcs)
at java.security.AccessControlContext.checkPermission(Unknown Source)
at java.security.AccessController.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPermission(Unknown Source)
at java.lang.SecurityManager.checkPackageAccess(Unknown Source)
at sun.applet.AppletSecurity.checkPackageAccess(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.xith3d.render.Canvas3DPanel.<init>(Canvas3DPanel.java:355)
at Xith3DApplet.init(Xith3DApplet.java:14)
at org.jdesktop.applet.util.JNLPAppletLauncher.startSubApplet(JNLPAppletLauncher.java:1889)
at org.jdesktop.applet.util.JNLPAppletLauncher.access$200(JNLPAppletLauncher.java:650)
at org.jdesktop.applet.util.JNLPAppletLauncher$5.run(JNLPAppletLauncher.java:1261)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
By seeing that error, I was led to think that it was caused by some call to a native method (through some bind, like JOGL) that raised a SecurityException. Here are some things to consider:
- Just jars using native methods need to be signed! (Note that xith3d was succesfully loaded and the crash happened when using some resource I don't know);
- My Applet isn't and DOES not to be signed. (Since the Applet being launched is Sun's applet-launcher, which loads and lanches my Applet);
What does Xith3D processes when creating a Canvas3DPanel? Does it uses something that is restricted due to security issues or calls some native method from a binding library (if the problem is this one, JNLPAppletLauncher offers a method to add the binding library to the Applet w/o generating security problems, reference here:
https://applet-launcher.dev.java.net/#MODIFYING)?
Don't know if I am crystal clear addressing the problem, but I hope you can help me and future 3D Applet developers.
If you want to see the Applet, access:
http://flockin.servegame.org/labs/xith3d (you can also see here that the Gears Applet works just fine for me)
Sorry for any English mistakes, I'm brazilian

and for the bad coding (no package, etc).