Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (754)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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  
  Positioning the camera in overhead view  (Read 2551 times)
0 Members and 1 Guest are viewing this topic.
Offline sproket

Junior Devvie

Medals: 1

« Posted 2009-11-29 22:42:00 »

Hi all,

In my game design I use first person view for movement and then switch to an overhead view for combat. This is working fine.

When I setup combat I select a player and the scene is re-rendered with the camera raised few meters and facing down.

Then I want to select a specific player on the screen at a coordinate a move the camera so it's directly overhead. This part for me is not working.

So in my keyBehavior class I get the Transform3D from the player object and from that get his vector. Then I try to place the camera at that vector. But the camera view goes haywire.

Code is like this:

// Local new transform3D so it should be empty
Transform3D t = new Transform3D();

// init the Transform3D from the selected object

// Get the vector for this object
Vector3d vector = new Vector3d();

// Reset the KeyBehavior Transform3D
t3d = new Transform3D();

// Set the KeyBehavior TransformGroup

// This is an instance var for repeated calcs

// move the camera?  Huh



Offline rdcarvallo

Senior Devvie

Projects: 5
Exp: 15 years

2D Java games forever!

« Reply #1 - Posted 2009-12-16 19:43:00 »


    You can use the helper method  void lookAt(Point3d eye, Point3d center, Vector3d up) in the Transform3D class.

Transform3D trns = new Transform3D();
Point3D center = "position of player"
Point3D eye = "position of player + x distance over his head"  

Vector3D up ="forward direction of the player"  //assuming Z axis as Up in the game world , this vector must be in X/Y plane

trns.lookAt(eye, center, up);

Pages: [1]
  ignore  |  Print  

DesertCoockie (33 views)
2018-05-13 18:23:11

nelsongames (75 views)
2018-04-24 18:15:36

nelsongames (70 views)
2018-04-24 18:14:32

ivj94 (752 views)
2018-03-24 14:47:39

ivj94 (82 views)
2018-03-24 14:46:31

ivj94 (622 views)
2018-03-24 14:43:53

Solater (98 views)
2018-03-17 05:04:08

nelsongames (179 views)
2018-03-05 17:56:34

Gornova (405 views)
2018-03-02 22:15:33

buddyBro (1065 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!