Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (476)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Newbie & Debugging Questions / Re: Problems with rotX, rotY and rotZ on: 2004-12-23 23:15:01
I'm trying to move the perspective of the person viewing the shapes. I figured rotating the shapes in one direction would be just like moving the viewer in the opposite direction (or opposite rotation in this case).

objRoot is a branchgroup that consists of all of the shapes that I have created. I added all of my shapes to objRoot before I am attempting this transformation. These are mainly spheres and ellipsoids.

I'd rather move the user instead of the shapes in my transform but am unsure how to do it without simply rotating the shapes.

If you view my source at the above mentioned link, the initial branchgroup that is created pretty much includes the necessary information and there isn't much beyond it that is needed.
2  Game Development / Newbie & Debugging Questions / Problems with rotX, rotY and rotZ on: 2004-12-23 05:44:44
Hello. I am trying to get rotations about an axis to work for me but I can't get them to work. Basically I have an entire scene created and can't get it to rotate using rotX, rotY and rotZ.

The scene originally places me at a point along the z-axis but I want the user to be on the x-axis. So I have tried using a 90 degree rotation about the y-axis to get the user to that point but it doesn't do anything. Below is the transformation group that I am using.

// Transform Group used to rotate entire scene
       TransformGroup objRotate = new TransformGroup();
       javax.media.j3d.Transform3D tp3d = new javax.media.j3d.Transform3D();
       double rot = 1.571;
       tp3d.rotY(rot);
       objRotate.setTransform(tp3d);
       objRoot.addChild(objRotate);
       
Any ideas? You can view the full source at http://www.astroh.org/SphereMotion.java

Thanks!
Michael
3  Java Game APIs & Engines / Java 3D / Re: Using KeyListener to modify a transform on: 2004-12-11 00:54:27
I figured out that NullPointerException problem and reworked some of the code, but the transforms still don't make the rotations work. Any ideas? Sourcecode has been updated.
4  Java Game APIs & Engines / Java 3D / Re: Using KeyListener to modify a transform on: 2004-12-10 01:37:53
Here is some of the code I have changed in response to the help given above:

TransformGroup userRot = new TransformGroup();
userRot.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);



public void keyPressed( KeyEvent evt ){

   Transform3D xRott3d = new Transform3D();
   Transform3D yRott3d = new Transform3D();
   Transform3D zRott3d = new Transform3D();
   
     switch(evt.getKeyCode())
     {
         case KeyEvent.VK_UP   :   System.out.println("Up");
                                   xRot+=0.1;
                                   xRott3d.rotX(xRot);
                                   userRot.setTransform(xRott3d);
                                   break;
         case KeyEvent.VK_DOWN :   System.out.println("Down");
                                   xRot-=0.1;
                                   xRott3d.rotX(xRot);
                                   userRot.setTransform(xRott3d);
                                   break;
.....

It compiles fine but when I try using one of my keys connected to a KeyEvent I get something like the following in reference to the userRot.setTransform lines in KeyPressed.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
     at SphereMotion.keyPressed(SphereMotion.java:294)
     at java.awt.Component.processKeyEvent(Component.java:5446)
     at java.awt.Component.processEvent(Component.java:5265)
     at java.awt.Component.dispatchEventImpl(Component.java:3955)
     at java.awt.Component.dispatchEvent(Component.java:3803)
     at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1810)
     at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:668)
     at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:916)
     at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:794)
     at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:632)
     at java.awt.Component.dispatchEventImpl(Component.java:3841)
     at java.awt.Component.dispatchEvent(Component.java:3803)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

I've also updated my code at the address given in the first comment of this section incase that is useful.

Thanks in advance!
Michael
5  Java Game APIs & Engines / Java 3D / Re: Using KeyListener to modify a transform on: 2004-12-09 01:56:12
Thanks for the help but I now keep getting a NullPointerException when I run the program on the line:

tg.setTransform(t3d);

Any idea what my problem here could be? I'm running this in my keyPressed section whereas I am defining tg in a different section. My guess is that this isn't working because I don't have tg set up as a class variable as you have assumed in your reply. How do I do that?

Thanks again!
6  Java Game APIs & Engines / Java 3D / Using KeyListener to modify a transform on: 2004-12-03 06:25:17
Hello. I posted this under the Newbies category but haven't gotten anywhere so I thought I'd post it here and see if I might be able to get some more assistance.

I am currently trying to take Sun's SphereMotion.java file and work it into a black hole simulator for a college project. I am trying to setup my basic geometry and am currently trying to add a KeyListener whereby I can use keyboard commands (the arrows in particular) to rotate the view around my ellipsoids. Also note that I am a newbie.

The KeyListener is added to my canvas as it is the only think I could find that would allow a KeyListener to be added to. I then read online that it would be good to create a switch to tell the program when to process the rotations however I can't get it to work. It simply doesn't do anything.  

Thus far I have tried adding my transforms to the BranchGroup createSceneGraph but that didn't work. Recently I tried placing the rotation transforms in their own BranchGroup and adding the other transforms for the ellispoids as a child under that BranchGroup. But this also has not worked. I'm fairly certain that my KeyListener is working.

Does anybody have any suggestions on the proper way to pull this off?

I have posted my code at http://www.astroh.org/SphereMotion.java since it is too long to post in this forum.

Much thanks in advance!
Michael
7  Game Development / Newbie & Debugging Questions / Re: Adding a KeyListener to SphereMotion.java on: 2004-11-30 04:18:25
Try downloading the file again. It should work without those calls (at least it seems to for me using netBeans). If you do need those calls could you specify how you added those to the lines?

Once it runs it should show a couple of nested ellipsoids with a smaller sphere in the center of them and another larger sphere outside of them. I also have a JPanel added to the bottom of the applet but haven't had time to work on it yet. I want to first get this keyboard command interface working before moving on to that.

Thanks!
8  Game Development / Newbie & Debugging Questions / Re: Adding a KeyListener to SphereMotion.java on: 2004-11-28 03:22:13
No, that doesn't help.

The KeyListener works and does read my keys but it is the link from my keys changing my rotation variables and the transforms is where I'm having problems.

You can pretty much skip the first branchgroup in my code. That just sets up my basic geometry. I have my transforms in that portion where you found the c.addKeyListener(this) and for some reason they aren't working.

Thanks for the suggestion though, however, without that "c." portion my KeyListener doesn't even work.
9  Game Development / Newbie & Debugging Questions / Adding a KeyListener to SphereMotion.java on: 2004-11-28 00:51:02
Hello. I am currently trying to take Sun's SphereMotion.java file and work it into a black hole simulator for a college project. I am trying to setup my basic geometry and am currently trying to add a KeyListener whereby I can use keyboard commands (the arrows in particular) to rotate the view around my ellipsoids. Also note that I am a newbie.

The KeyListener is added to my canvas as it is the only think I could find that would allow a KeyListener to be added to. I then read online that it would be good to create a switch to tell the program when to process the rotations however I can't get it to work. It simply doesn't do anything.

Thus far I have tried adding my transforms to the BranchGroup createSceneGraph but that didn't work. Recently I tried placing the rotation transforms in their own BranchGroup and adding the other transforms for the ellispoids as a child under that BranchGroup. But this also has not worked. I'm fairly certain that my KeyListener is working.

Does anybody have any suggestions on the proper way to pull this off?

I have posted my code at http://www.astroh.org/SphereMotion.java since it is too long to post in this forum.

Much thanks in advance!
Michael
Pages: [1]
 

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

The first screenshot will be displayed as a thumbnail.

pw (18 views)
2014-07-24 01:59:36

Riven (17 views)
2014-07-23 21:16:32

Riven (14 views)
2014-07-23 21:07:15

Riven (17 views)
2014-07-23 20:56:16

ctomni231 (45 views)
2014-07-18 06:55:21

Zero Volt (40 views)
2014-07-17 23:47:54

danieldean (32 views)
2014-07-17 23:41:23

MustardPeter (36 views)
2014-07-16 23:30:00

Cero (51 views)
2014-07-16 00:42:17

Riven (50 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
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!