Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (707)
Games in Android Showcase (206)
games submitted by our members
Games in WIP (781)
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 1232 times)
0 Members and 1 Guest are viewing this topic.
Offline juangamnik

Senior Newbie

Java games rock!

« Posted 2003-09-08 15: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:

  vpNewPosition.x = shipPosition.x + vpSTARTX; //vpSTARTX = 0.0f
  vpNewPosition.y = shipPosition.y + vpSTARTY; //vpSTARTY = 50.0f
  vpNewPosition.z = shipPosition.z + vpSTARTZ; //vpSTARTZ = 130.0f  
  vpTrans3d.lookAt(vpNewPosition, shipPosition, vUp);


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

Offline Breakfast

Senior Devvie

for great justice!

« Reply #1 - Posted 2003-09-08 16: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 09: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));

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.

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

Junior Devvie

Java games rock! Do they .. ?

« Reply #3 - Posted 2003-09-12 16: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 .. 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 and then I'll send you the code.
Offline misterX

Junior Devvie

java forever!

« Reply #4 - Posted 2003-09-13 19: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?!?
            ViewingPlatform vp = myUniverse.getViewingPlatform(); //if you use a SimpleUniverse
            TransformGroup cameraToShip = ....; //Sets the relative pos of the camera to the ship
            cameraToShip .addChild(vp);

that's all!
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Galdo (256 views)
2017-01-12 13:44:09

Archive (424 views)
2017-01-02 05:31:41

0AndrewShepherd0 (883 views)
2016-12-16 03:58:39

0AndrewShepherd0 (821 views)
2016-12-15 21:50:57

Lunch (956 views)
2016-12-06 16:01:40

ral0r2 (1189 views)
2016-11-23 16:08:26

ClaasJG (1289 views)
2016-11-10 17:36:32

CoffeeChemist (1316 views)
2016-11-05 00:46:53

jay4842 (1400 views)
2016-11-01 19:04:52

theagentd (1214 views)
2016-10-24 17:51:53
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 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‑
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!