摄像机路径动画及动画录制
Here's the Blender camera path project that I mentioned here. In the interest of focus (and size), I stripped out everything except the basics. I got the basic idea when I came across this page on making control-point-less bezier curve motion in Flash. Or rather, the control points are generated from the points already existing in the path. This way you can get nice curves straight from mesh data.
To use it, in Blender first make a straight line using the curve tool (if that isn't a contradiction
). Add -> Curve -> Bezier Curve, then press V to straighten the points, and then press Tab to leave edit mode. In the Link & Materials pane, call it "line". You only have to make one of these and you can use it with any number of 3D paths.
So, make a 3D path (Add -> Curve -> Path). In the Curve & Surface pane, click in the BevOb: field and type "line". This uses the bezier curve we made first to define the shape. In this case we just want a simple line so we can tilt the path and get surface normals from it later. Move points in the path by clicking on them and pressing G (Grab) then clicking again to place. Extend the path by selecting a point on the end and pressing E and clicking to place. Press T to tilt selected points left or right. Continue as long as you want, but if you're making a looping path, do not try to close the loop...just leave a gap between the first and last points. In the DefResolU: field, you can go very low; probably 1 is fine, or 2 if you want extra precision. Outside of edit mode, press option-C to convert the path to a mesh, and save it (be sure to make a copy of the pre-converted path, in case you want to go back and easily edit it later).
When you bring it into Unity, make sure that "Automatically calculate normals" is set to 180. Otherwise, if you did some funky things with the path (like 360 degree spins), Unity makes some extra points, which obviously messes up the end of the path.
When you place the path somewhere in your scene, you can position, rotate, and scale it however you want, and these transforms are accounted for properly. You can leave the mesh renderer on to visually see where the path goes exactly, and then disable the renderer when you have it positioned where you want it.
To make a camera go along the path, put the PathFollow script on it (I put it in the Camera-Control menu, but you can also use it for other objects). Drag the path from Blender onto the Path slot. Use Move Speed to control the overall speed of the camera movement, though relative speeds within the path are controlled by how far apart the points are. So if you want a completely even speed, make all the points pretty much the same distance apart from each other.
Direction is either forward or backward, though backward just traverses the points in reverse order; it doesn't make the camera face backward or anything. The little arrows you see in Blender, conveniently enough, tell you what direction the path goes in.
Movement Only makes the camera follow the points through space, but leaves the rotation alone so the camera stays facing the direction it's in when it starts. Typically you'd use this with the Motion Record script (see below) to add manual rotation to all the points.
Loop...I'm sure you can figure that one out.
Startpoint starts the camera movement at a given point. So if you have a path made up of 120 points, using 60 for Startpoint makes the camera start halfway along the path.
Endpoint ends the camera movement at a given point, counting backwards from the last point. It only works in non-looping mode. If you're not looping, this should be set to at least 3, or else movement data from the first few points "bleeds" into the last few. This is how loop mode works, but you typically don't want that for non-looping.
Ease in and Ease out are for starting and ending smoothly. Intended for non-looping mode.
"Object to track" is a transform, which if used makes the camera always point at that object as it moves along the path. If this is none, then it has no effect.
Rotation Data is a string generated by Motion Record. If you leave it empty, it does nothing.
Zoom Data is also a string generated by Motion Record. If left empty, it does nothing. Otherwise it behaves like Rotation Data, but changes the zoom (field of view).
The rest of the variables you can ignore, but they need to be public for MotionRecord to access...is there a way to do hidden public variables? (Short of static, which won't work in this case since you might want to use multiple objects on paths at once).
The use of Motion Record is detailed in the next post.
动画录制
OK, docs for Motion Record:
If you want to add extra rotation to camera path movement, either in combination with Movement Only or just to add some additional rotation to that which you get from the path itself, put the Motion Record script on the same camera that's using the Path Follow script. This allows you to steer the view with the mouse/keyboard as the camera goes along, and edit each point afterward if you want.
(My Storm City demo uses Movement Only with manual rotation for the helicopter--this allows the helicopter to move along the path, with the manual rotation making it behave more like a helicopter. It also uses regular mode--not Movement Only--with extra manual rotation for the chase viewpoint, in order to get a sort of "hand-held" movement which you can't get from the path alone. The car demo in that same topic uses regular mode without any extra rotation, with the Object To Track set to the car.)
You also need the three Motion Record GUI objects, which exist as a prefab. Probably easiest to make a package of this and import it into whatever project you want.
Sensitivity is how sensitive the mouse controls are. Key Sensitivity is how sensitive the keyboard controls are for motion. Invert Y Axis does just that, and File Name is the name of a text file that will be generated when you're done. This gets put in the base folder of the project, outside of Assets, because it's not used directly.
When you run the scene, you'll see "Recording" in the lower right. This means you can move the view around as you go along the path, and the rotation and/or zoom at each point is recorded. If it says Rotation/Zoom, then you are recording both. If it says Rotation, then you're using zoom data that you recorded before and put on the camera, so you're only recording rotation, but you can edit the zoom. If it says Zoom, then you've got some rotation data, so you're only recording zoom, but you can edit the rotation. If you have both rotation and zoom data, then you can only edit them. If you remove the rotation and/or zoom data from the camera, then you can record them again.
The % in the upper left is what point you're on at the moment, out of the total number of points in the path.
Press H to get a reminder of keyboard commands. (Or the help key, theoretically, though it doesn't seem to work even though Unity doesn't object to the name.) These are:
WSAD to rotate the view on the X and Y axes instead of/in addition to the mouse. ZX or < > (really . and ,) rotates on the forward axis. [ (left bracket) zooms out, ] (right bracket) zooms in. Hold down shift to make the movement go 10 times slower for fine control. Press space to reset all axes to 0 and the zoom back to the field of view you started out with (usually 60, unless you've changed it).
Press 0 (zero) to set the overall speed to none. That way you can move the view around as much as you want at that point before continuing. Press 1 to go back to 100% speed, or 2 to go 10X faster. Press + and - (really = and -) or left and right arrows to go a little bit faster or slower. It's sometimes useful to go in slow-motion...I did most of the helicopter movement in one "take" that way, with a little editing afterward. On the other hand, the viewpoint movement was done in real-time to get a sort of hand-held feel.
When you get to the end of the path, or if you press Q, then the rotation data is saved to a text file with the specified name. Open this file up and select all, then copy, then switch back to Unity and paste into the Rotation Data field on the Path Follow script. (Yep, the whole thing will fit even if you've got zillions of points.) This may seem slightly clunky, but I can't think of any other way to do this, short of just reading a data file directly, which I don't want to do because I want the data to be self-contained in the project. Any suggestions welcome.
If you run the scene again with data in the Rotation Data field, you can then edit each point. "Recording" no longer shows, to be replaced by "Edit" if you're in edit mode. Controls as above, except you normally can't rotate the view, but now you can press E to enter edit mode. This allows you to change the rotation of whatever point you're at (see upper left display). E again goes back to movement mode (or you can use 1 or 2 to jump to that speed and exit edit mode at the same time). Press up or down arrows to jump to the next or previous point (and enter edit mode if it's not active already). Again, pressing Q or reaching the end of the path will save the edited data, which you can then paste into the Rotation Data field, overwriting the original data. Probably a good idea to use different names for the files so you can go back to the pre-edited version if necessary.
Keep in mind that you're just creating/editing rotations on each point in the path, so the Path Follow script is generating bezier curves on the fly. This means that playback will probably not exactly match what you did when recording. It's useful after editing some points to go backward before those points and then enter play mode to see exactly what you did. If you want finer control, make the path resolution higher in Blender (and adjust Move Speed to compensate).
And I think that's about it, unless I forgot something.... If anyone uses this, let me know if you find any bugs/problems. Also let me know if you think of some additional functionality. Or better yet, implement it yourself and post it.
I can already think of an external view mode for editing the rotation of objects on the path, though it was surprisingly intuitive to do the helicopter rotation from first-person mode...also quite a bit faster than external editing would be, I think.
--Eric
Last edited by Eric5h5 on Mon Jul 02, 2007 7:37 pm; edited 3 times in total
原贴地址:http://forum.unity3d.com/viewtopic.php?t=5898&highlight=gui+motion

那些鸡肠子看不懂,还是看甲骨文更是在点
哎,麻烦高手能不能翻译下再上传
官方的吧。
看不懂
WOW又是全英的
这个····看不懂,没有中文嘛???
谁能翻译一下啊
有没有哪位高手,帮忙翻译一下就好了!期待啊............
英文啊,头痛啊!
头疼
这都可以有,呵呵厉害。