Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (623)
Games in Android Showcase (176)
games submitted by our members
Games in WIP (676)
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 1089 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.

BurntPizza (22 views)
2015-10-08 03:11:46

BurntPizza (15 views)
2015-10-08 00:30:40

BurntPizza (17 views)
2015-10-07 17:15:53

BurntPizza (32 views)
2015-10-07 02:11:23

KaiHH (37 views)
2015-10-06 20:22:20

KaiHH (16 views)
2015-10-06 19:41:59

BurntPizza (32 views)
2015-10-06 19:04:48

basil_ (46 views)
2015-09-30 17:04:40

shadowstryker (24 views)
2015-09-29 15:55:06

TheSpaceHedgehog (30 views)
2015-09-29 01:58:48
Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36 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!