Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
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   
Pages: [1]
  ignore  |  Print  
  view following an moving & rotating object???  (Read 861 times)
0 Members and 1 Guest are viewing this topic.
Offline juangamnik

Senior Newbie




Java games rock!


« Posted 2003-09-08 17:47:58 »

Hi there,

I have a ship which rotates around the x- and y-axis and move in the direction of rotation.

My only problem is, that the View doesn't follow properly! It should follow behind the ship looking at it all the time. I tried it this way:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
  vpNewPosition.x = shipPosition.x + vpSTARTX; //vpSTARTX = 0.0f
 vpNewPosition.y = shipPosition.y + vpSTARTY; //vpSTARTY = 50.0f
 vpNewPosition.z = shipPosition.z + vpSTARTZ; //vpSTARTZ = 130.0f  
 
  shipRotXY3d.transform(vpNewPosition);
   
  vpTrans3d.lookAt(vpNewPosition, shipPosition, vUp);
 
  vpTrans3d.invert();

  vpTrans.setTransform(vpTrans3d);


But this doesn't work properly for example my view always looks upwards, so it looks like the ship turns around the z-axis, but only the view doesn't follow!!!

The second step would be to smooth the camera movement and rotation, so that you can see the rotation and movement of the ship!!! Can anyone help me???

Greets,
Juan
Offline Breakfast

Senior Member




for great justice!


« Reply #1 - Posted 2003-09-08 18:12:01 »

I did write a tutorial on something approximate to this, but I'm not sure how relevant it is to your exact case. If you take a look at the last section here you should find some working code that may be adaptable.
Offline juangamnik

Senior Newbie




Java games rock!


« Reply #2 - Posted 2003-09-09 11:27:02 »

In another thread I described my problem more clear, I think, so here is my problem again:

The View doesn't follow the Ship proberly.

What the view should do:
1. When my ship rotates, the View has to rotate around the ship so that it is always a littlebit behind (130m) and higher (50m) as the ship.
2. The View should always look at the ship.
3. It would be great if the camera would smooth a littlebit, so that, when the ship rotates and moves, the view doesn't follow directly (e.g. viewPosition = ((shipPosition.x/y/z - vpSTARTX/vpSTARTY/vpSTARTZ)/CAMERASMOOTH); //vpSTARTX = 0.0f, vpSTARTY = 50.0f, vpSTARTZ = 130.0f, CAMERASMOOTH = 6.0f ).

What I tried:
I used the function viewTrans3d.setLookAt(viewPosition, shipPosition, vpUp);. shipPosition is clear and viewPosition is rotation.transform(new Transform3D(shipPosition.x/y/z - vpSTARTX/vpSTARTY/vpSTARTZ));

Problems:
1. Because of the vpUP(0.0f,1.0f,0.0f);, my View y-axis looks Upwards everytime. But when I make a looping for example it looks like the ship is rotating around his z-axis, though only the View doesn't follow this rotation!
2. there's no smooth, so the motion of the Ship looks very rigid (or stiff?Sorry, but I have looked up this words in a dictionary)and you can only see the movement by the movement of the background.

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

Junior Member




Java games rock! Do they .. ?


« Reply #3 - Posted 2003-09-12 18:17:35 »

well I wrote this code 2 days ago to do a smooth camera which always follows my avator .. something Mario like, but still quite a lot of work to do about that one Smiley

You can simply get the main idee for rotating around a point at www.gametutorials.com .. the OpenGL tutorial of third person has this method good explained.

But to do smooth camera is rather hard to explain, but if you want you can e-mail me at kozen@pandora.be and then I'll send you the code.
Offline misterX

Junior Member




java forever!


« Reply #4 - Posted 2003-09-13 21:58:39 »

damn, i've seen that so many times, i wonder why people never use the scenegraph?!?
why not simply attach the camera on your ship?!?
1  
2  
3  
4  
5  
            ViewingPlatform vp = myUniverse.getViewingPlatform(); //if you use a SimpleUniverse
           vp.detach();
            TransformGroup cameraToShip = ....; //Sets the relative pos of the camera to the ship
           cameraToShip .addChild(vp);
            shipTG.addChild(cameraToShip);

that's all!
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.

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

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

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

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

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

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

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

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

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

Riven (55 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!