Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (568)
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  Java Game APIs & Engines / Java 3D / Re: retrieving angle from a Transform ? on: 2003-05-13 19:07:21
Oupps you were right.
I used a AxisAngle4d with a null vector to do it.
It was a code I got from I don't know where in the net, and it doesn't seem to fit in my case.

Now I'm using transform.set (new Quat4d (0,0,-1,0)); to set the inital view direction, anf I have (it seems !) correct values when I make a transform.get (Quat4d)..

I'm fine now, I can go on.

  Thanks a lot !
 Gérard
2  Java Game APIs & Engines / Java 3D / Doesn't seem to work on: 2003-05-09 19:32:09
I'm sorry to bother you once again, but ....
I tried your idea and displayed the value of q.x,q.y,q.z and q.w.

At the beginning of my test, I set the viewDir to (0,0,-1), => watching to the front of the screen.

With your method, I retreive x=0,y=0,z=0 and w=1. That is a null vector (how can it show a direction when it is null) ? and a rotation to 1.

If I move to the right (using Sun's KeyNavigatorBehavior) then y lowers to -1 and w goes down to 0.
To my mind it should be x growing to 1, y shouldn't move and z should come up from -1 to 0.

I don't know where I'm wrong, and I don't know what is the meaning of the Quad4d, but I don't get the expected result....

  Gérard

3  Java Game APIs & Engines / Java 3D / Re: retrieving angle from a Transform ? on: 2003-05-09 10:07:30
I'll try that.

Thank you !

Gérard
4  Java Game APIs & Engines / Java 3D / test variable on: 2003-05-08 18:14:05
Oh, I forgot test is a Vector3d object used for calculation....


 Gérard

5  Java Game APIs & Engines / Java 3D / More source on: 2003-05-08 18:12:29
Here is the complete source code of the method drawing into the background.

Breakfast:
   I'm sorry, I'm new to Java3d (but not Java), how do you change the fold angle ? I've played a bit with the Background and Sphere class and hasn't been able to get a correct thing... Maybe I missed something here.
My image is 2300x1575... I can take a smaller one, but not so much and using Background I get memory exception (with a 512Mo RAM, ATI Radeon 8500 32Mo DDR video card) when I load a 640x480 image, It's definitively too small.


Ifadolai:

Constants.up and Constants.right are Vector3d meaning up (0.0,1.0,0.0) and right (1.0,0.0,0.0).
So the angle function is the one from Vector3d.

My idea is to apply the transform to up and right and then gets the angle between the transformed Vector3d and it's source.
This way I should get the angles with X and Y axis....


I guess the ideal would be a Background with a compressed texture (because it's fast), and a good fold angle parameter, so that it would feel like space.

Here is the complete source code. It's a Canvas3D derived class.

viewDirection is the rotational TransformGroup of the viewer,
vImage is the VolatileImage I'm trying to display.

Thank you all for your help and ideas.

  Gérard
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
    public void preRender ()
    {
       // super.preRender ();
       int drawWidth = 0;
        int drawHeight = 0;
        int screenWidth = getWidth();
        int screenHeight = getHeight();
        int posX=0,posY=0;
       
        if (viewDirection!=null)
        {
            viewDirection.getTransform(trans);
            double xPos=0;
            double yPos=0;
               
            test.x=Constants.right.x;
            test.y=Constants.right.y;
            test.z=Constants.right.z;
            trans.transform(test);
            test.y=0.0;
           
            double angleRight = Constants.right.angle(test);
            if (test.z<0.0)
               angleRight=2*Math.PI-angleRight;
           
            test.x=Constants.up.x;
            test.y=Constants.up.y;
            test.z=Constants.up.z;
            trans.transform(test);
            test.x=0.0;
           
            double angleUp = Constants.up.angle(test);
            if (test.z>0.0)
               angleUp=2*Math.PI-angleUp;

            yPos = ((double)imageHeight)*angleUp/(2*Math.PI);
            xPos = ((double)imageWidth)*angleRight/(2*Math.PI);
            posX =(int)xPos;
            posY =(int)yPos;
        }
       
        J3DGraphics2D graph = getGraphics2D ();
        checkVolatile (vImage, image);
       
        drawWidth = Math.min(screenWidth, imageWidth-posX);
        drawHeight = Math.min(screenHeight, imageHeight-posY);
       
        graph.drawImage (vImage,0,0,drawWidth, drawHeight, posX, posY, drawWidth+posX, drawHeight+posY,null);
        if (drawWidth<screenWidth)
        {
            graph.drawImage (vImage,drawWidth, 0, screenWidth, drawHeight, 0, posY, screenWidth-drawWidth, drawHeight+posY,null);
        }
        if (drawHeight<screenHeight)
        {
            graph.drawImage (vImage,0, drawHeight, drawWidth, screenHeight, posX, 0, drawWidth+posX, screenHeight-drawHeight,null);
        }
        graph.flush (false);
    }
6  Java Game APIs & Engines / Java 3D / Not easier but... on: 2003-05-08 07:29:24
Well, it's not easier, but it's much more beautifull.

I tried the technique you describe first, but I had to discard it because
  - Either the background image is too big to be mapped as a texture (OutOfMemoryError)
  - Or the texture is too low and you see the sphere triangles...

If you look at the Background Demo sun provides, you see the result is terrible.

Using a 2D image provides a much more convincing intergalactic space....

It's much slower too....

  Gérard
7  Java Game APIs & Engines / Java 3D / retrieving angle from a Transform ? on: 2003-05-07 19:15:37
Hi,

I'm quite new to this wonderfull world of Java3d, and, of course, I've got lots of problems....

I'm trying to display a part of a huge background image depending on the direction the viewer is watching.
To do this, I get his rotational TransformGroup, and try to guess the angles between the direction it is watching and the right and up axis.

Alas, this doesn't seem to work well.
I guess I'm not alone in this case, does anyone knows how to do it ?

For info, here is my source code. I apply the transform to the right and up axis and then retrieve the angle between them.

I don't know what's wrong here... I get incorrect values for angleUp and angleRight when I move too much my point of view.

 Gérard


           viewDirection.getTransform(trans);

           double xPos=0;
           double yPos=0;
               
           test.x=Constants.right.x;
           test.y=Constants.right.y;
           test.z=Constants.right.z;
           trans.transform(test);
           test.y=0.0;
           
           double angleRight = Constants.right.angle(test);
           if (test.z<0.0)
              angleRight=2*Math.PI-angleRight;
           
           test.x=Constants.up.x;
           test.y=Constants.up.y;
           test.z=Constants.up.z;
           trans.transform(test);
           test.x=0.0;
           
           double angleUp = Constants.up.angle(test);
           if (test.z>0.0)
              angleUp=2*Math.PI-angleUp;
         
8  Java Game APIs & Engines / Java 3D / Yes you can on: 2003-01-20 09:23:26
You can mix Java 2D and 3D anyway you like (with java3D).
I do this for a space game.
The starfield background is simply a picture drawn in Java2D before the 3D.

If you want your 2D to be behind the 3D stuff, use
  Canvas3D.preRender()

if you want 2D to be in front of 3D, use
  Canvas3D.postRender().

Hope this helps.
Gérard
9  Java Game APIs & Engines / Java 3D / Re: New Java3D Demos on: 2002-12-26 12:16:43
The links are outdatted...

Too bad:


Gérard Angry
10  Java Game APIs & Engines / Java 3D / Same trouble on: 2002-12-04 10:00:59
Looks like you want to do the same as me.

BackgroundGeometry only allows for Sphere, other geometry are not displayed at all.

For the background starfield problem, here is what I want to do:

- Design a huge bitmap with stars in it.
- Display this bitmap in the preRender method of the Canvas3D. This way the image is always shown behind any 3d objects.
- Move the bitmap accordingly to the point of view. This should allow for a quite good starfield.

The only things that annoys me are : I need a huge bitmap stored in memory and if the point of view rotate along the Z axis I need to rotate the huge bitmap as well.
I don't know if java can handle this well.


Gérard

Gerard Wink
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.

Pippogeek (39 views)
2014-09-24 16:13:29

Pippogeek (30 views)
2014-09-24 16:12:22

Pippogeek (20 views)
2014-09-24 16:12:06

Grunnt (45 views)
2014-09-23 14:38:19

radar3301 (28 views)
2014-09-21 23:33:17

BurntPizza (64 views)
2014-09-21 02:42:18

BurntPizza (34 views)
2014-09-21 01:30:30

moogie (42 views)
2014-09-21 00:26:15

UprightPath (50 views)
2014-09-20 20:14:06

BurntPizza (54 views)
2014-09-19 03:14:18
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!