Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Problem by  runing Applet  (Read 1799 times)
0 Members and 1 Guest are viewing this topic.
Offline ruprecht

Senior Newbie




Do you Linux?


« Posted 2003-01-02 17:45:02 »

Hi,

Ich habe mich an einem Beispielapplet zur Rotation eines Farbwüürfels um 2 Achsen probiert. Compilieren und Builden ging ohne Probleme, allerdings wird mir das Applet nicht richtig aufgebaut. Es wird nur gemeldet, dass das applet gestartet wurde.

Der Code sieht wie folgt aus:

import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.event.*;
import java.awt.GraphicsConfiguration;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.geometry.ColorCube;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;

public class HelloUniverse4 extends Applet {

 private SimpleUniverse u = null;

   public BranchGroup createSceneGraph() {
       BranchGroup objRoot = new BranchGroup();

//rotate object has composite transformation matrix
Transform3D rotate =new Transform3D();
Transform3D tempRotate =new Transform3D();

rotate.rotX(Math.PI/4.0d);
tempRotate.rotY(Math.PI/5.0d);
rotate.mul(tempRotate);

TransformGroup objRotate =new TransformGroup(rotate);

//Create the transform group node and initialize it to the
//identity.Enable the TRANSFORM_WRITE capability so that
//our behavior code can modify it at runtime.Add it to the
//root of the subgraph.
TransformGroup objSpin =new TransformGroup();
objSpin.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);

objRoot.addChild(objRotate);
objRotate.addChild(objSpin);

//Create a simple shape leaf node,add it to the scene graph.
//ColorCube is a Convenience Utility class
objSpin.addChild(new ColorCube(0.4));

//Create a new Behavior object that performs the desired
//operation on the specified transform object and add it into
//the scene graph.
Transform3D yAxis =new Transform3D();
Alpha rotationAlpha =new Alpha(-1,4000);


RotationInterpolator rotator =
   new RotationInterpolator(rotationAlpha,objSpin,yAxis,
    0.0f,(float)Math.PI*2.0f);

//a bounding sphere specifies a region a behavior is active
//create a sphere centered at the origin with radius of 1
BoundingSphere bounds =new BoundingSphere();
rotator.setSchedulingBounds(bounds);
objSpin.addChild(rotator);

return objRoot;
}
}
   //end of createSceneGraph method of HelloJava3Dd


Gruss
Ruprecht
Offline ruprecht

Senior Newbie




Do you Linux?


« Reply #1 - Posted 2003-01-02 18:09:48 »

Hi,

sorry I have posted my message before I've seen that it was an english webforum. OK here the english translation.  The Code in my first posting is the axample for rotatiing a ColorCube araound two axis. The Compiling and Building acts without any problem. On Running the applet I get  only a statusline-message that the applet is starting.

What can be the problem that the cube will not be displayeed and I can't see any rotation.

Regards,
Ruprecht
Offline elias

Senior Member





« Reply #2 - Posted 2003-01-02 19:27:58 »

Maybe you're running it with another jvm than you compiled the test with. IE's build in jvm is old and specifically cannot run java3d apps. Try running your test in the appletviewer included with the java sdk.

- elias

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ruprecht

Senior Newbie




Do you Linux?


« Reply #3 - Posted 2003-01-03 08:18:37 »

Hi Elias,

thanks for the quick answer.
I tried the following with this result

linux:/usr/java/j2sdk1.4.0_02/bin # ./appletviewer HelloUniverse4.html
Xlib: connection to ":0.0" refused by server
Xlib: Client is not authorized to connect to Server
Exception in thread "main" java.lang.InternalError: Can't connect to X11 window server using ':0.0' as the value of the DISPLAY variable.
       at sun.awt.X11GraphicsEnvironment.initDisplay(Native Method)
       at sun.awt.X11GraphicsEnvironment.<clinit>(X11GraphicsEnvironment.java:126)
       at java.lang.Class.forName0(Native Method)
       at java.lang.Class.forName(Class.java:130)
       at java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment(GraphicsEnvironment.java:62)
       at java.awt.Window.init(Window.java:223)
       at java.awt.Window.<init>(Window.java:267)
       at java.awt.Frame.<init>(Frame.java:398)
       at java.awt.Frame.<init>(Frame.java:363)
       at sun.applet.AppletViewer.<init>(AppletViewer.java:139)
       at sun.applet.StdAppletViewerFactory.createAppletViewer(AppletViewer.java:80)
       at sun.applet.AppletViewer.parse(AppletViewer.java:1062)
       at sun.applet.AppletViewer.parse(AppletViewer.java:996)
       at sun.applet.Main.run(Main.java:138)
       at sun.applet.Main.main(Main.java:80)

Regards,
ruprecht
Offline elias

Senior Member





« Reply #4 - Posted 2003-01-03 08:33:32 »

Did you run it with the same user that you logged into X with? Specifically, running a graphical program as another user in SuSE requires you to use sux, not the ordinary su.

- elias

Offline ruprecht

Senior Newbie




Do you Linux?


« Reply #5 - Posted 2003-01-03 11:36:35 »

Hi Elias,

you are right my first test was with the same user logged into X.
By using the sux-command the command gives no errormessage but I couldn't get an applet. Running it under netscape it have trouble in initiate the applet. Here messages with sendingcommands are displayed. The problems with netscape are in all j3d-codes. The sun examples executed within the netbeans-ide were executed correctly (HelloUniverse, 3D-Text, mouseturnable polygon).

Regards,
Ruprecht
Offline ruprecht

Senior Newbie




Do you Linux?


« Reply #6 - Posted 2003-01-03 11:36:50 »

Hi Elias,

you are right my first test was with the same user logged into X.
By using the sux-command the command gives no errormessage but I couldn't get an applet. Running it under netscape it have trouble in initiate the applet. Here messages with sendingcommands are displayed. The problems with netscape are in all j3d-codes. The sun examples executed within the netbeans-ide were executed correctly (HelloUniverse, 3D-Text, mouseturnable polygon).

Regards,
Ruprecht
Offline elias

Senior Member





« Reply #7 - Posted 2003-01-03 11:58:54 »

hmm, shouldn't an applet class have a init() or destroy() or something? It seems to me your example code is never called.

- elias

Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #8 - Posted 2003-01-03 12:02:36 »

What happens if you allow full external access to the X server first? (do an "xhost +" as the owner of the X server)

Hellomynameis Charlie Dobbie.
Offline ruprecht

Senior Newbie




Do you Linux?


« Reply #9 - Posted 2003-01-04 08:03:44 »

OK I tried xhost + <hostname>.
The result  I get no errormessage(s)  but I become no output.   Elias could have been right in this sentence that the code is not a normal applet. I have heard that j3d works with applets to output the result.
In the case of E. I don't understand why in the public line you write extends applet.

The whole sourcecode of my script I posted in the german posting (beginn of thread).   What can be that I get no result is that the
returncommand   is written in this form

return  objRoot;     and not     return(objRoot);


Regards,
Ruprecht
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline elias

Senior Member





« Reply #10 - Posted 2003-01-04 08:46:16 »

The way I look at it you only have a createSceneGraph method, but noone's is calling it. Instead, you should be calling it from the init() that you can override from the Applet base class. That method is called from the browser when your applet is shown.

- elias

Offline ruprecht

Senior Newbie




Do you Linux?


« Reply #11 - Posted 2003-01-04 09:42:18 »

Hi Elias,

thank you for the quick answer. You are right I missed this part. Now it is shown in my ide.  Only one question I do have.
How can I build a continous rotation around the x-axis. The interpolator by default turns around the y-axis.

Regards,
Ruprecht
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (29 views)
2014-09-12 09:08:26

Norakomi (57 views)
2014-09-10 13:57:51

TehJavaDev (78 views)
2014-09-10 06:39:09

Tekkerue (38 views)
2014-09-09 02:24:56

mitcheeb (58 views)
2014-09-08 06:06:29

BurntPizza (45 views)
2014-09-07 01:13:42

Longarmx (30 views)
2014-09-07 01:12:14

Longarmx (35 views)
2014-09-07 01:11:22

Longarmx (36 views)
2014-09-07 01:10:19

mitcheeb (40 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!