CameraAnimationController

hey there.



i nedded camera animation at some point. not just camera movement along a curve. as far as i found out, you were just able to choose between a fixed direction of the camera while the movement or the camera facing toward a spatial or things like that.



Use Case for CAC:

You move your camera through a scene with mouse-look and keyboard (i use FirstPersonHandler) and every now and then you push a button that writes all four (location, left, up, direction) camera vectors to a console or whereever. You pass four curves based on Arrays of Vector3f objects to the camera controller and voila: the camera moves as before, nicely round and it is facing where you want it to face.



i am quite sure it can be optimized but it works for me.



i use the CatmullRomCurve (provided by another jme user) for the curves.



/*
 * Copyright (c) 2003-2006 jMonkeyEngine
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 * * Redistributions of source code must retain the above copyright
 *   notice, this list of conditions and the following disclaimer.
 *
 * * Redistributions in binary form must reproduce the above copyright
 *   notice, this list of conditions and the following disclaimer in the
 *   documentation and/or other materials provided with the distribution.
 *
 * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
 *   may be used to endorse or promote products derived from this software
 *   without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

import com.jme.curve.Curve;
import com.jme.intersection.CollisionResults;
import com.jme.intersection.PickResults;
import com.jme.math.FastMath;
import com.jme.math.Matrix3f;
import com.jme.math.Ray;
import com.jme.math.Vector3f;
import com.jme.scene.Spatial;
import com.jme.util.geom.BufferUtils;

/**
 * <code>CatmullRomCurve</code>
 *
 * @see <a href="http://www.mvps.org/directx/articles/catmull/">Catmull-Rom Splines</a>
 * @author Frederik B

Awesome, I wanted to make something like this myself. Would it be possible for it to load and save the camera motion parameters from/to a md5camera file?

See this for specs: http://www.modwiki.net/wiki/MD5CAMERA_(file_format)

This would be especially for exporting cutscenes from Blender, as the md5 exporter there supports camera motions.

well, it should be possible, since all the information needed is in the file. i just think that the frames (and other things) of the cameraanimation in the MD5 format have to be ignored for it to work in a real-time 3d environment. furthermore, one would have to extract the up, left and direction vectors from the quaternion "direction" in md5. this shouldnt be difficult, since these three vectors are the first three lines in the quaternion i think (?). well, maybe i will have the time to integrate the md5 format into the controller after i hand in my masters thesis  :wink: anybody interested is welcome to do it themselves though  :wink:



so long,

Andy

I made a MD5camera importer that uses this. In testing phase now…

i knew you couldn't resist  :wink:

Heh, I didn't have a reason to :slight_smile:

For Radakan we need cutscenes and so having the ability to import them from a modeling tool is a requirement…

Hi,



any news about this subject?



Thank you very much.



Best Regards