From 01256f9089dad9ed955b77110c99591798a14731 Mon Sep 17 00:00:00 2001 From: Hesper Yin Date: Mon, 16 Nov 2020 03:11:31 -0500 Subject: [PATCH] Add files via upload --- docs/animation/generate_videos.md | 15 ++++ docs/animation/overview.md | 12 ++- docs/animation/skeleton_kinematics.md | 105 ++++++++++++++++++++++++++ 3 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 docs/animation/generate_videos.md create mode 100644 docs/animation/skeleton_kinematics.md diff --git a/docs/animation/generate_videos.md b/docs/animation/generate_videos.md new file mode 100644 index 0000000..50dddb5 --- /dev/null +++ b/docs/animation/generate_videos.md @@ -0,0 +1,15 @@ +--- +layout: default +title: "Generating Videos" +permalink: /generate_videos/ +--- + +# Generating Videos + +## Converting frames to video with ffmpeg + +Once you've rendered all the frames of your video, you can combine them into a video by using: + +`ffmpeg -r 60 -f image2 -s 800x600 -i ./Video_[TIME]_%4d.png -vcodec libx264 out.mp4` + +Where `[TIME]` should be replaced by the timestamp in each frame's filename (they should all be identical). If you don't have ffmpeg installed on your system, you can get it through most package managers, or you can [download it directly](https://ffmpeg.org/download.html), or use your own video creation program. diff --git a/docs/animation/overview.md b/docs/animation/overview.md index 522dcf8..bcdbf91 100644 --- a/docs/animation/overview.md +++ b/docs/animation/overview.md @@ -6,4 +6,14 @@ permalink: /animation/ # Animation Overview -As always, be mindful of the [project philosophy](../philosophy). +There are four primary components that must be implemented to support Animation functionality. + +- [(Task 1) Spline Interpolation](camera_rays.md) +- [(Task 2) Skeleton Kinematics](intersecting_objects.md) +- [(Task 3) Linear Blend Skinning]() +- [(Task 4) Physical Simulation]() + +Each of these components is described at the linked page. + +Additionally, the assignment specification asks you to create a video of your animation. Some brief technical notes on creating videos from images are [here](generate_videos.md). + diff --git a/docs/animation/skeleton_kinematics.md b/docs/animation/skeleton_kinematics.md new file mode 100644 index 0000000..66f8a4a --- /dev/null +++ b/docs/animation/skeleton_kinematics.md @@ -0,0 +1,105 @@ +--- +layout: default +title: "Skeleton Kinematics" +permalink: /animation/skeleton_kinematics +--- + +# Skeleton Kinematics + +A `Skeleton`(defined in `scene/skeleton.h`) is what we use to drive our animation. You can think of them like the set of bones we have in our own bodies and joints that connect these bones. For convenience, we have merged the bones and joints into the `Joint` class which holds the orientation of the joint relative to its parent as euler angle in its `pose`, and `extent` representing the direction and length of the bone with respect to its parent `Joint`. Each `Mesh` has an associated `Skeleton` class which holds a rooted tree of `Joint`s, where each `Joint` can have an arbitrary number of children. + +All of our joints are ball `Joint`s which have a set of 3 rotations around the [[task2_media/0027.png|height=9px]], [[task2_media/0028.png|height=12px]], and [[task2_media/0029.png|height=9px]] axes, called _Euler angles_. Whenever you deal with angles in this way, a fixed order of operations must be enforced, otherwise the same set of angles will not represent the same rotation. In order to get the full rotational transformation matrix, [[task2_media/0030.png|height=14px]], we can create individual rotation matrices around the [[task2_media/0031.png|height=14px]], [[task2_media/0032.png|height=14px]], and [[task2_media/0033.png|height=14px]] axes, which we call [[task2_media/0034.png|height=16px]], [[task2_media/0035.png|height=18px]], and [[task2_media/0036.png|height=16px]] respectively. The particular order of operations that we adopted for this assignment is that [[task2_media/0037.png|height=18px]]. + +### Forward Kinematics + +_Note: These diagrams are in 2D for visual clarity, but we will work with a 3D kinematic skeleton._ + +When a joint's parent is rotated, that transformation should be propagated down to all of its children. In the diagram below, [[task2_media/0038.png|height=12px]] is the parent of [[task2_media/0039.png|height=12px]] and [[task2_media/0040.png|height=12px]] is the parent of [[task2_media/0041.png|height=12px]]. When a translation of [[task2_media/0042.png|height=12px]] and rotation of [[task2_media/0043.png|height=16px]] is applied to [[task2_media/0044.png|height=12px]], all of the descendants are affected by this transformation as well. Then, [[task2_media/0045.png|height=12px]] is rotated by [[task2_media/0046.png|height=16px]] which affects itself and [[task2_media/0047.png|height=12px]]. Finally, when rotation of [[task2_media/0048.png|height=16px]] is applied to [[task2_media/0049.png|height=12px]], it only affects itself because it has no children. + +[[media/forward_kinematic_diagram.jpg]] + +You need to implement these routines in `student/skeleton.cpp` for forward kinematics. + +* `Joint::joint_to_bind` + Rreturn a matrix transforming points in the space of this joint + to points in mesh space in bind position up to the base of this joint (end of its parent joint). You should traverse upwards from this joint's parent all the way up to the root joint and accumulate their transformations. +* `Joint::joint_to_posed` + Return a matrix transforming points in the space of this joint to points in mesh space, taking into account joint poses. Again, you should traverse upwards from this joint's parent to the root joint. +* `Skeleton::end_of` + Returns the end position of the joint in world coordinate frame, and you should take into account the base position of the skeleton (`Skeleton::base_pos`). +* `Skeleton::posed_end_of` + Returns the end position of the joint in world coordinate frame with poses, and you should take into account `Skeleton::base_pos`. +* `Skeleton::joint_to_bind` + Rreturn a matrix transforming points in the space of this joint + to points in mesh space in bind position but with the base position of the skeleton taken in to account. Hint: use some function that you have implemented wisely! +* `Skeleton::joint_to_posed` + Return a matrix transforming points in the space of this joint to points in mesh space, taking into account joint poses but with the base position of the skeleton taken in to account. Hint: use some function that you have implemented wisely! + +Once you have implemented these basic kinematics, you should be able to define skeletons, set their positions at a collection of keyframes, and watch the skeleton smoothly interpolate the motion (see the [user guide](../guide/animate.md) for an explanation of the interface). The gif below shows a very hasty demo defining a few joints and interpolating their motion. + +![gif1](task2_media/gif1.gif) + +![gif1](task2_media/gif2.gif) + +Note that the skeleton does not yet influence the geometry of the cube in this scene -- that will come in Task 3! + + \ No newline at end of file -- GitLab