Author Topic: Suggestions for Next Release  (Read 18881 times)

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Suggestions for Next Release
« on: August 16, 2006, 10:27:33 pm »
Apart from better lighting controls (already promised in the docs), how about a Camera.follow(Object3D)? Could either start its own thread, or take the Object3D's current position plus the camera's delta from it once. That would be cool.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Suggestions for Next Release
« Reply #1 on: August 16, 2006, 11:28:26 pm »
The improved light source handling is already done and will be part of the next release. It'll leave the current implementation untouched but adds a little helper class to the util-package that wraps each light into an object. Handling is much better with this IMHO.
About the camera stuff...i'm not really sure if i fully understand what to want this method to do!?

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Suggestions for Next Release
« Reply #2 on: August 17, 2006, 01:45:08 am »
Just that: follow an object. Like the camera follows the X-Wing in the Rogue Squadron series, or like you would want a camera following a character who is walking around an environment (over the shoulder) for an RPG. Example of the camera following the x-wing:


Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Suggestions for Next Release
« Reply #3 on: August 17, 2006, 08:47:51 pm »
Egon, Can I take your lack of response to indicate that you aprove of my camera suggestion?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Suggestions for Next Release
« Reply #4 on: August 17, 2006, 09:03:57 pm »
No, you can indicate that as my lack of time due to the fact that i have to install my new Core2 Duo machine... :wink:
Anyway, i don't think that such a method belongs into the engine. It depends too much on the game's/application's needs IMHO. The car example already contains an example on how to do something like this and so do the Paradroidz sources. I don't think there is a generic solution to this that fits everyones needs.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Suggestions for Next Release
« Reply #5 on: August 17, 2006, 11:13:21 pm »
Yes, but a lot of the things you put in an engine don't fit everyone's needs. This would be very cool because camera-handling is always a pain-in-the-ass.

Anyway, I was thinking about it and you would need two methods. A Camera.set(Object3D) indicating that the camera's position relative to the object has been set, and the aforementioned Camera.follow(Object3D). Pretty please?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Suggestions for Next Release
« Reply #6 on: August 17, 2006, 11:38:15 pm »
Some stuff may not fit everyones needs, but if it does...it does. That's not the case with camera stuff IMO. Take Camera.follow(Object3D) as an example: What should that method do? move the camera behind the object? In which distance? With which viewing angle? How should it react to acceleration? How to deceleration? How to rotations? Should it just "stick" onto the object or have a "flow"? Should it collide with obstacles or not? What should be done, if it does?
A method that handles all this has to have a lot of configuration variables...i don't think, that it's worth it. However, i'll think about some camera related stuff for the util-package to decouple it from the engine's core.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Suggestions for Next Release
« Reply #7 on: August 17, 2006, 11:44:49 pm »
I just answered all your questions: you would set the distance and angle, then call Camera.set(Object3D). From then on, you would call Camera.follow(Object3D) which would adjust its position relative to the object as if it were being pulled by a stick.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Suggestions for Next Release
« Reply #8 on: August 17, 2006, 11:56:16 pm »
That's simple:

Code: [Select]
   
SimpleVector center=object.getTransformedCenter();
SimpleVector camPos=new SimpleVector(center);
SimpleVector zOffset=object.getZAxis();
SimpleVector yOffset=object.getYAxis();
zOffset.scalarMul(-100f);
yOffset.scalarMul(60f);
camPos.add(zOffset);
camPos.add(yOffset);
camera.setPosition(camPos);
camera.lookAt(center);


That should work. But as you can see, it doesn't take collisions into account (for example) and it can't do that in a generic way. But a lot of people will need that, so i still think you're better off with your own, tailored method. But i'll add some stuff like this into util. I'm just not sure that it'll make it into the next release.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Suggestions for Next Release
« Reply #9 on: August 18, 2006, 12:07:48 am »
That's neither set() nor follow(). Follow has to consider the camera's previous settings (as determined by set()).

They would be two cool methods to have but if you won't include them I'll be happy to get their respective codes from you. :-)

Seriously I'll be grateful for any help.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Suggestions for Next Release
« Reply #10 on: August 18, 2006, 12:16:04 am »
Quote from: "AGP"
That's neither set() nor follow(). Follow has to consider the camera's previous settings (as determined by set()).
No, it's both. The position is determined by the -100 (in z-direction) and the 60 (in y-direction). The lookAt makes you look at the objects center (or whatever point you put in there). Call this every frame and it should do what you want. If it doesn't, then i'm still not getting what you want.

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Suggestions for Next Release
« Reply #11 on: August 18, 2006, 12:18:04 am »
Just so you don't think I'm a moron, I believe my problem comes from adjusting the camera before building all the objects. Building the objects just seems like the last thing to do when initializing. I still think that the set() and follow() methods are useful, but I understand your position.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Suggestions for Next Release
« Reply #12 on: August 18, 2006, 12:53:35 am »
Maybe this will help. It doesn't work with angles directly, because that will cause a lot more math to be involved. The set()-method needs a camera position and an initial lookAt position in world space (if you want to work with angles, derive the lookAt from the position and the angles). Then call follow() each frame. It may do, what you want.

Code: [Select]
import com.threed.jpct.*;

public class Follower {
   
   private SimpleVector initial=null;
   private SimpleVector angles=null;
   private SimpleVector offsets=null;
   private SimpleVector lookAt=null;
   private boolean firstRun=true;
   
   public Follower() {
      initial=new SimpleVector();
   }
   
   public void set(SimpleVector start, SimpleVector lookAt) {
      initial=start;
      this.angles=angles;
      this.lookAt=lookAt;
   }
   
   public void follow(Object3D obj, Camera cam) {
      if (firstRun) {
         SimpleVector c=obj.getTransformedCenter();
         offsets=initial.calcSub(c);
         lookAt=lookAt.calcSub(c);
         firstRun=false;
      }
     
      SimpleVector center=obj.getTransformedCenter();
      SimpleVector camPos=new SimpleVector(center);
      SimpleVector zOffset=obj.getZAxis();
      SimpleVector yOffset=obj.getYAxis();
      SimpleVector xOffset=obj.getXAxis();
      zOffset.scalarMul(offsets.z);
      yOffset.scalarMul(offsets.y);
      xOffset.scalarMul(offsets.x);
     
      SimpleVector zlookOffset=obj.getZAxis();
      SimpleVector ylookOffset=obj.getYAxis();
      SimpleVector xlookOffset=obj.getXAxis();

      SimpleVector look=new SimpleVector(center);
      zlookOffset.scalarMul(lookAt.z);
      ylookOffset.scalarMul(lookAt.y);
      xlookOffset.scalarMul(lookAt.x);
      look.add(zlookOffset);
      look.add(xlookOffset);
      look.add(ylookOffset);
     
      camPos.add(zOffset);
      camPos.add(yOffset);
      camPos.add(xOffset);
      cam.setPosition(camPos);
      cam.lookAt(look);
   }
}

Offline AGP

  • quad
  • ******
  • Posts: 1726
    • View Profile
Suggestions for Next Release
« Reply #13 on: August 18, 2006, 05:03:45 am »
Thanks a lot. I'm about to try it out.

But how about a public Camera Object3D.lookThrough()? That way you could set an invisible object as your camera. That's probably insanely easy to do, and you could just addChild(cameraObject) to another object. You have to admit that is very useful. How about it?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Suggestions for Next Release
« Reply #14 on: August 18, 2006, 07:58:12 pm »
Code: [Select]

camera.setBack(obj.getWorldTransformation().invert3x3());
camera.setPosition(obj.getTransformedCenter());
 :?: