Path finding camera

Hi im trying to modify a currently basic camera that orbits around a center point always looking at the center point.

I want to set up a camera system where i can give the camera a point in 3d space and it will smoothly orbit around to the point.

at the moment i just have a basic algorithm that takes the mouse diplacement as its parameters



float cos = (float)Math.cos(rotXDisplacement);
            float x = cos*(float)Math.cos(rotYDisplacement) * zoomDisplacement;
            float y =                  (float)Math.sin(rotXDisplacement) * zoomDisplacement;
            float z = cos*(float)Math.sin(rotYDisplacement) * zoomDisplacement; 
            
            view.getTransform().lookAt(new Vector3f( x, y, z),  // location of eye
                                 centerVector,                           // center of view
                                 upVector);                          

I have no idea of where to start implementing a path finding algorithm so if anyone has any good ideas links to tutorails etc. it’id be great ;D

Look into Java Cool Dude’s examples, because I think he had some good camera code. I couldn’t find it now, but search in this forum.

I think a possible way to approach this is to interpolate between the two states of the view. That is, given a new location and orientation, interpolate bewteen the old and new view’s transforms.

There is some utility code on Xith that implement interpolators, but I haven’t really used them. Look on the net for keyframe animation, and interpolators that you are bound to find something useful :wink:

Since I haven’t implemented anything like that before, I don’t think I can help more. But if I learn anything, I’ll let you know ;p

Will do thanks pedro :wink:

Preacher, did you actually use interpolators to move the camera along a path?

I am trying to do similar stuff now Did you use the Java3D utils package? It seems the best approach to me, but I am not sure if I’m going to face problems trying to make them compabible with Xith.

Has anyone used those TCP interpolators ( i.e. RotPosScaleTCBSplinePathInterpolator) with success in Xith? They extend Behaviour, so I think to work they must be added to the scene graph. I’m guessing some modification will be necessary so they can be added to a Xith scenegraph. I’m also guessing that these modifications are almost trivial, but, if anyone attempted similar stuff before, it would kind if they could alert me of any big unforeseen problems with this approach.

Not necessarily helpful here, but I’m throwing it out for other readers. There’s some good gems in GameProgrammingGems 2 on smooth animation of cameras, particularly one using “Parallel Transport Frames”. Might be worth looking up for people doing complex animated cameras and wanting smooth movement of the camera…

Thanks blah^3h :wink: I heard about the book series a while ago, but never actually saw a physical copy of the book. This might sound very newbie, but well: they seem they could be very useful 8)

And sure there are very cool /strange maths around CG :o I had to print a few papers to try to digest their dense lines, but it seems that for what I want kocanek-Bartels spline interpolation should suffice.

What I did just now was to get some of the source from the j3d utility package, and hopefully I’ll make it work under Xith.

Hi havent used interpolaters yet i’m just loking into them at the mo (bit of a newbie :slight_smile: got pointed towards quaternions for smooth rotations, apparently most top class games use tham for rotaions in place of the standard matrix. so anyway i’m just printing off stuff about quaternions now and going to give it a look over other than that i’m not much help at the mo :slight_smile:

I was going through some quaternions yesterday too, maybe these links are useful:

http://www.flipcode.com/documents/matrfaq.html

And an example using interpolators:
http://fivedots.coe.psu.ac.th/Software.coe/Java%20Games/Background/Selman/ch12/3DJava_Ch12.htm

Will give them a look pedro thanks. I want to apply the camera to a college chess project but ive only a week and a half to polish the whole thing off so it looks like i won’t have the time to look into it at the moment. If anyont else has something simular done already even that would be great.

was looking at the interpolate(Quad4f target, int alpha) method of the Quad4f class in the vecmath packages and was under the impression that it would interpolate between two points in increments specified by alpha. But it seems to just jump from the source point to the target point no matter what value alpha is. i know that this is usually used in-directly with a Java3d interpolator but pressumed that it could be used maually. any info on this would be good :slight_smile:

Alpha must be a float (you wrote int?) in the range [0, 1] that will interpolate between the angles defined by two quartinion. Also try using interpolate(Quat4f q1, Quat4f q2, float alpha) instead. That way you don’t use the result of the interpolation as the endpoint of the next frames interpolation.

the quad.interpolate(Quad4f, Quad4f, int) was a typo, i am using the quad.interpolate(Quad4f, Quad4f, float)method im using the resulting quad to set the view.Transform().set(Quad4f) but whatever value of alpha i use the view snaps straight to the end point.