Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11855 Posts in 1569 Topics- by 3024 Members - Latest Member: floutleMili

07. February 2012, 03:43:43 AM
Xith3D CommunityProjectsYour Projects (Moderator: 'n ddrylliog)Xith3D Applet
Pages: [1] 2 3
Print
Author Topic: Xith3D Applet  (Read 11889 times)
tinsukE
Just dropped in

Offline Offline

Posts: 14


View Profile
« on: 10. September 2007, 09:57:22 PM »

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:
Code:
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:
Code:
<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:
Code:
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  Wink and for the bad coding (no package, etc).
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #1 on: 10. September 2007, 10:36:18 PM »

I will try to track this down, but it will probably until next sunday, before I have a fix.
Logged

kukanani
Fierce Warrior
****
Offline Offline

Posts: 504


My game is coming along fairly smoothly...


View Profile WWW
« Reply #2 on: 10. September 2007, 11:41:03 PM »

That might actually help solve my problem, given in the "Half a Project" topic.
Logged

xith.setCoolnessLevel(10);
jMe.setCoolnessLevel(0);
xith.rock();
tinsukE
Just dropped in

Offline Offline

Posts: 14


View Profile
« Reply #3 on: 11. September 2007, 12:27:02 AM »

I'm not sure if the Applet Xith problem is relationed to your "quit immediately" problem, since, in my case, the Applet isn't even launched (due to som awfully bad bad Canvas3DPanel initialization problem). Do you even use Canvas3DPanel?

Anyway, I will keep an eye at your topic.

(Can anyone else take a look at this problem before Sunday?)
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #4 on: 11. September 2007, 12:39:43 AM »

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)?

When a Canvas3D is created (which a Canvas3DPanel does internally), an implementation dependent class is created through reflection, which is necessary to make the code runnable with e.g. JOGL without having the LWJGL/SWT/etc. jars in your classpath.

Could this be a problem here?

Marvin
Logged
tinsukE
Just dropped in

Offline Offline

Posts: 14


View Profile
« Reply #5 on: 11. September 2007, 01:11:07 AM »

I've added some 'System.out.prinln()' (I know thats weird, but works) to the Canvas3DPanel constructor:
Code:
public Canvas3DPanel(OpenGLLayer layer, int bpp, FSAA fsaa)
    {
    System.out.println("Im here");
        if ((layer != OpenGLLayer.JOGL_AWT) && (layer != OpenGLLayer.LWJGL_AWT))
            throw( new IllegalArgumentException( "You can only use JOGL_AWT and LWJGL_AWT as OpenGLLayer" ) );
        System.out.println("Im here2");
       
        super.setLayout( new GridLayout() );
        System.out.println("Im here3");
        super.setBackground( Color.BLACK );
        System.out.println("Im here4");
       
        this.canvas = Canvas3DFactory.create( layer, 800, 600, bpp, DisplayMode.WINDOWED, fsaa, this );
       
        this.setFocusable( true );
       
        isInitialized = true;
    }

And it does not even reach the first one. Wich means the failure occurs when the class file is being loaded, not when executed.

Quote
When a Canvas3D is created (which a Canvas3DPanel does internally), an implementation dependent class is created through reflection, which is necessary to make the code runnable with e.g. JOGL without having the LWJGL/SWT/etc. jars in your classpath.

Reflection? Don't know much about it and, consequently, if this could be the problem, but I didn't find nothing on web about Applet Reflection problems.

About the others "Xith3D Applet" posts on the forum, has ANY of them been solved?
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4337


May the 4th, be with you...


View Profile
« Reply #6 on: 11. September 2007, 01:41:29 AM »

About the others "Xith3D Applet" posts on the forum, has ANY of them been solved?

I think, yes. But I'm not sure. Since I'm not an Applet pro (never made one), I always left this mostly to others.

Marvin
Logged
'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #7 on: 11. September 2007, 04:04:53 PM »

Hi tinsukE, you're very welcome to the Xith3D community ! I hope you'll enjoy the stay Wink

I don't think the sysouts are strange, you have the same programming style as me Cheesy

For your error, I think investigating the JNLP applet-launcher code would help but it seems like it has been "written once, forgotten since".. I'd like to have some code for web deployment (including applets) in OneClick.
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #8 on: 11. September 2007, 04:39:35 PM »

For your error, I think investigating the JNLP applet-launcher code would help but it seems like it has been "written once, forgotten since".. I'd like to have some code for web deployment (including applets) in OneClick.

Don't fall for the "not invented here syndrome". You have other things to do ;P The JNLPAppletLauncher is a project evolved from another AppletLauncher specifically for JOGL, solves some nasty problems and is nowhere near being dead. Quite the contrary, the JNLPAppletLauncher will probably become the standard way of distributing applets using extensions.

The problem here lies in Xith, not in the JNLPAppletLauncher.
« Last Edit: 11. September 2007, 04:43:43 PM by Mathias 'cylab' Henze » Logged

'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #9 on: 11. September 2007, 06:23:19 PM »

cylab : Yeah, I do have the tendance to ""nih"" a bit Smiley But you now all that native deployment etc. thing, OneClick does that already.. adapting it to Applets shouldn't be too hard.
Alternatively, I could figure out a way of using JNLPAppletLauncher from OneClick
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #10 on: 11. September 2007, 06:59:01 PM »

Actually adapting it to oneclick is very hard, since the JNLPAppletLauncher should free you from the signing restriction you have with native loading or _direct_file_access_. Also you will never be able to start a new java instance from an applet _and_ rendering the output to the applet frame in the browser.

Or maybe I misunderstood you and you want to add an JNLPAppletLauncher target to your Eclipse GUI of OneClick, so you can export a correct <applet> snippet for launching xith applets. That would be nice, indeed.
Logged

'n ddrylliog
Moderator
Guru
*****
Offline Offline

Posts: 1188



View Profile WWW Email
« Reply #11 on: 11. September 2007, 07:28:45 PM »

Or maybe I misunderstood you and you want to add an JNLPAppletLauncher target to your Eclipse GUI of OneClick, so you can export a correct <applet> snippet for launching xith applets. That would be nice, indeed.
Yep, that was exactly the thingy I was thinking about.
Since, as you explained very clearly (just what I had in mind), it is not possible (at least efficiently) to start a new java instance from an applet and render the output to the applet frame in the browser.
Logged
tinsukE
Just dropped in

Offline Offline

Posts: 14


View Profile
« Reply #12 on: 11. September 2007, 11:23:37 PM »

I'm getting lost in this thread Huh.

Let me see... by the sourceforge project's description, this OneClick seems to be wonderful!
Quote
Java Application Packager allowing Seamless Launch of your Eclipse Projects on major platforms (Linux, Mac OS X, Windows), including correct handling of Jars-in-jars and Native libraries.

But, w/o JNLPAppletLauncher, jars that uses jars with native code have to be signed, isn't it?

And with JNLPAppletLauncher, guess this security exception won't disappear. Any ideas of how to fix it? Since debugging didn't work for me, I won't be able to help tracing this anymore.

As I don't know how to spend my time tracing this, I've tried jME. The coding style is (at a first glance) nasty! The 'simple applet' code is so huge n' so many other issues I disliked, but... it worked (actually, I got an error when running more advanced code, but its running...). I liked very much the Xith simplicity and 'no burocracy' style, but if I cannot get an Applet running, think I'll have to abandon it.  Cry

Buuuuuut... this board is SO active and I still hope I'll use Xith3D to deploy my applet.

Thanks for the warm welcome.

About the sysout thing... I've been coding J2ME games, so... sometimes inserting debug points that saves 'this point was reached!' info is the only debug option in real devices. That's why I use it A LOT, hehe.
Logged
Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #13 on: 12. September 2007, 10:13:58 AM »

As I stated above, I am on it. It will be fixed and documented in the WIKI or the XIN in the next couple of days. Be patient.
Logged

Mathias 'cylab' Henze
Fierce Warrior
****
Offline Offline

Posts: 540

1064620
View Profile WWW
« Reply #14 on: 12. September 2007, 12:03:27 PM »

Update: I can start an Applet, if I self-sign both, the applet and the xith.jar with the same certificate. I will try to create a self-signed JNLP extension and see if this would remove the restriction from the applet itself being signed. If it works, we should raise an appeal for funds to buy a valid certificate from thawte, which is at $550 for two years. I would invest $200 for a start...

BTW. If you create a jMonkey Applet you have to self-sign it, resulting in an ugly security warning, or buy a valid certificate by yourself...
« Last Edit: 12. September 2007, 12:06:56 PM by Mathias 'cylab' Henze » Logged

Pages: [1] 2 3
Print
Jump to:  

Theme orange-lt created by panic