diff options
author | Matt Strapp <matt@mattstrapp.net> | 2021-11-10 13:40:26 -0600 |
---|---|---|
committer | Matt Strapp <matt@mattstrapp.net> | 2021-11-10 13:40:26 -0600 |
commit | 4be57d24a1fe1540527c4fc80e978cbace528958 (patch) | |
tree | 86e8f20ec08f2b6ca8d25c4a13ad74363914708d /dev | |
parent | Merge branch 'support-code' of https://github.umn.edu/umn-csci-4611-f21/share... (diff) | |
download | csci4611-4be57d24a1fe1540527c4fc80e978cbace528958.tar csci4611-4be57d24a1fe1540527c4fc80e978cbace528958.tar.gz csci4611-4be57d24a1fe1540527c4fc80e978cbace528958.tar.bz2 csci4611-4be57d24a1fe1540527c4fc80e978cbace528958.tar.lz csci4611-4be57d24a1fe1540527c4fc80e978cbace528958.tar.xz csci4611-4be57d24a1fe1540527c4fc80e978cbace528958.tar.zst csci4611-4be57d24a1fe1540527c4fc80e978cbace528958.zip |
do a4submission-p4.0
Diffstat (limited to 'dev')
-rw-r--r-- | dev/a4-dance/animated_character.cc | 89 | ||||
-rw-r--r-- | dev/a4-dance/dance_app.cc | 31 |
2 files changed, 105 insertions, 15 deletions
diff --git a/dev/a4-dance/animated_character.cc b/dev/a4-dance/animated_character.cc index 110dbbe..84edcde 100644 --- a/dev/a4-dance/animated_character.cc +++ b/dev/a4-dance/animated_character.cc @@ -181,7 +181,9 @@ void AnimatedCharacter::DrawBoneRecursive(const std::string &bone_name, const Ma Third, with the rotations applied relative to the appropriate rotation axes, the vertices must now be transformed back into regular "bone space". At this point, the bone should be properly rotated based upon the current pose, but the vertices are still defined in "bone space" so they are close to the origin. Finally, the vertices need to be tranformed to the bone's parent space. - + */ + + /* To start, we give you a current transformation matrix (ctm) that only takes this last step into account. */ Matrix4 ctm = parent_transform; @@ -192,41 +194,108 @@ void AnimatedCharacter::DrawBoneRecursive(const std::string &bone_name, const Ma // character, but once you add the recursive call to draw the children, this // will draw the axes for each bone. Matrix4 S = Matrix4::Scale(Vector3(0.15f, 0.15f, 0.15f)); - quick_shapes_.DrawAxes(ctm * S, view_matrix, proj_matrix); + // quick_shapes_.DrawAxes(ctm * S, view_matrix, proj_matrix); // TODO: Eventually, you'll want to draw something different depending on which part // of the body is being drawn. An if statement like this is an easy way to do that. if (bone_name == "lhipjoint" || bone_name == "rhipjoint") { + Matrix4 hipjoint = Matrix4::Scale(Vector3(0.15f, 0.15f, 0.15f)); + quick_shapes_.DrawSphere(ctm * hipjoint, view_matrix, proj_matrix, Color(0,0,0)); } if (bone_name == "lfemur" || bone_name == "rfemur") { + Matrix4 femur_sc = Matrix4::Scale(Vector3(0.15f, 0.2f, 0.2f)); + Matrix4 femur_tr = Matrix4::Translation(Vector3(0, -0.5f, 0)); + Matrix4 femur_rt = Matrix4::RotationZ(GfxMath::ToRadians(30.0f)); + quick_shapes_.DrawSphere(ctm * femur_sc * femur_rt * femur_tr, view_matrix, proj_matrix, Color(0, 0, 0)); } if (bone_name == "ltibia" || bone_name == "rtibia") { + if (bone_name == "ltibia") { + Matrix4 tibia_sc = Matrix4::Scale(Vector3(0.1f, 0.4f, 0.1f)); + Matrix4 tibia_tr = Matrix4::Translation(Vector3(0.0f, -0.5f, 0.0f)); + Matrix4 tibia_rt = Matrix4::RotationZ(GfxMath::ToRadians(30.0f)); + quick_shapes_.DrawSphere(ctm * tibia_sc * tibia_rt * tibia_tr, view_matrix, proj_matrix, Color(0, 0, 0)); + } + else { + Matrix4 tibia_sc = Matrix4::Scale(Vector3(0.1f, 0.4f, 0.1f)); + Matrix4 tibia_tr = Matrix4::Translation(Vector3(0.0f, -0.5f, 0.0f)); + Matrix4 tibia_rt = Matrix4::RotationZ(GfxMath::ToRadians(-30.0f)); + quick_shapes_.DrawSphere(ctm * tibia_sc * tibia_rt * tibia_tr, view_matrix, proj_matrix, Color(0, 0, 0)); + } + } - if (bone_name == "lfoot" || bone_name == "rfoot") { - } - if (bone_name == "ltoes" || bone_name == "rtoes") { - } + //Feet did not render properly, get rid of them if (bone_name == "lowerback") { + Matrix4 lowerback_sc = Matrix4::Scale(Vector3(0.15f, 0.15f, 0.15f)); + Matrix4 lowerback_tr = Matrix4::Translation(Vector3(0.0f, -1.0f, 0.0f)); + quick_shapes_.DrawSphere(ctm * lowerback_sc * lowerback_tr, view_matrix, proj_matrix, Color(0, 0, 0)); } if (bone_name == "upperback") { + quick_shapes_.DrawLineSegment(ctm * S, view_matrix, proj_matrix, Color(0, 0, 0), Point3(0, 0.4, 0), Point3(0, -0.4, 0), 0.8); } if (bone_name == "thorax") { + quick_shapes_.DrawLineSegment(ctm * S, view_matrix, proj_matrix, Color(0, 0, 0), Point3(0, 0.4, 0), Point3(0, -0.4, 0), 0.6); } if (bone_name == "lowerneck" || bone_name == "upperneck") { + quick_shapes_.DrawLineSegment(ctm * S, view_matrix, proj_matrix, Color(0, 0, 0), Point3(0, 0.4, 0), Point3(0, -0.4, 0), 0.2); } if (bone_name == "head") { + Matrix4 head_sc = Matrix4::Scale(Vector3(0.15f, 0.2f, 0.15f)); + quick_shapes_.DrawSphere(ctm * head_sc, view_matrix, proj_matrix, Color(0, 0, 0)); } if (bone_name == "lclavicle" || bone_name == "rclavicle") { + Matrix4 clavicle_sc = Matrix4::Scale(Vector3(0.2f, 0.1f, 0.1f)); + quick_shapes_.DrawSphere(ctm * clavicle_sc, view_matrix, proj_matrix, Color(0, 0, 0)); } if (bone_name == "lhumerus" || bone_name == "rhumerus" || bone_name == "lradius" || bone_name == "rradius") { + if (bone_name == "lhumerus" || bone_name == "rhumerus") { + Matrix4 humerus_sc = Matrix4::Scale(Vector3(0.08f, 0.04f, 0.04f)); + quick_shapes_.DrawSphere(ctm * humerus_sc, view_matrix, proj_matrix, Color(0, 0, 0)); + } + else { + if (bone_name == "rradius") { + Matrix4 radius_sc = Matrix4::Scale(Vector3(0.15f, 0.05f, 0.05f)); + Matrix4 radius_rt = Matrix4::RotationZ(GfxMath::ToRadians(-90.0f)); + Matrix4 radius_tr = Matrix4::Translation(Vector3(0.0f, 1.0f, 0.0f)); + quick_shapes_.DrawCylinder(ctm * radius_sc * radius_rt * radius_tr, view_matrix, proj_matrix, Color(0, 0, 0)); + } + else { + Matrix4 radius_sc = Matrix4::Scale(Vector3(0.15f, 0.05f, 0.05f)); + Matrix4 radius_rt = Matrix4::RotationZ(GfxMath::ToRadians(90.0f)); + Matrix4 radius_tr = Matrix4::Translation(Vector3(0.0f, 1.0f, 0.0f)); + quick_shapes_.DrawCylinder(ctm * radius_sc * radius_rt * radius_tr, view_matrix, proj_matrix, Color(0, 0, 0)); + } + } } if (bone_name == "lwrist" || bone_name == "rwrist") { + if (bone_name == "lwrist") { + Matrix4 wrist_sc = Matrix4::Scale(Vector3(0.1f, 0.05f, 0.05f)); + Matrix4 wrist_tr = Matrix4::Translation(Vector3(-0.5f, 0.0f, 0.0f)); + quick_shapes_.DrawSphere(ctm * wrist_sc * wrist_tr, view_matrix, proj_matrix, Color(0, 0, 0)); + } + else { + Matrix4 wrist_sc = Matrix4::Scale(Vector3(0.1f, 0.05f, 0.05f)); + Matrix4 wrist_tr = Matrix4::Translation(Vector3(0.5f, 0.0f, 0.0f)); + quick_shapes_.DrawSphere(ctm * wrist_sc * wrist_tr, view_matrix, proj_matrix, Color(0, 0, 0)); + } + } if (bone_name == "lhand" || bone_name == "rhand" || bone_name == "lthumb" || bone_name == "rthumb" || bone_name == "rfingers" || bone_name == "lfingers") { + if (bone_name == "lhand" || bone_name == "rhand") { + Matrix4 hand_sc = Matrix4::Scale(Vector3(0.05f, 0.05f, 0.05f)); + quick_shapes_.DrawSphere(ctm * hand_sc, view_matrix, proj_matrix, Color(0, 0, 0)); + } else if (bone_name == "lthumb" || bone_name == "rthumb") { + Matrix4 thumb_sc = Matrix4::Scale(Vector3(0.03f, 0.03f, 0.03f)); + Matrix4 thumb_tr = Matrix4::Translation(Vector3(1.0f, 0.0f, 0.0f)); + quick_shapes_.DrawCylinder(ctm * thumb_sc * thumb_tr, view_matrix, proj_matrix, Color(0, 0, 0)); + } else if (bone_name == "rfingers" || bone_name == "lfingers") { + Matrix4 fingers_sc = Matrix4::Scale(Vector3(0.01f, 0.01f, 0.01f)); + quick_shapes_.DrawCylinder(ctm * fingers_sc, view_matrix, proj_matrix, Color(0, 0, 0)); + } } + // Step 2: Draw the bone's children /** @@ -239,7 +308,13 @@ void AnimatedCharacter::DrawBoneRecursive(const std::string &bone_name, const Ma DrawBoneRecursive(skeleton_.child_bone(bone_name, i), child_root_transform, view_matrix, proj_matrix); } **/ -} + CalcCurrentPose(); + Matrix4 child_root_transform = ctm * skeleton_.RotAxesSpaceToBoneSpace(bone_name) * pose_.JointRotation(bone_name) * skeleton_.BoneSpaceToRotAxesSpace(bone_name) * skeleton_.BoneSpaceToChildrenSpace(bone_name); + + for (int i=0; i<skeleton_.num_children(bone_name); i++) { + DrawBoneRecursive(skeleton_.child_bone(bone_name, i), child_root_transform, view_matrix, proj_matrix); + } +} diff --git a/dev/a4-dance/dance_app.cc b/dev/a4-dance/dance_app.cc index 84f394a..3393cec 100644 --- a/dev/a4-dance/dance_app.cc +++ b/dev/a4-dance/dance_app.cc @@ -62,10 +62,25 @@ DanceApp::DanceApp() : GraphicsApp(1280,768, "So You Think Ants Can Dance") { // you can use the same dance moves that we did. We used: // 05_10.amc, 05_09.amc, 05_20.amc, and 05_06.amc -- you need to trim them // isolate the interesting portions of the motion. - - - - + ballet_special2_.LoadFromAMC(Platform::FindFile("05_10.amc", searchPath_), *ballet_ant_.skeleton_ptr()); + ballet_special2_.TrimFront(280); + ballet_special2_.TrimBack(200); + ballet_special2_.CalcRelativeTranslations(); + + ballet_special3_.LoadFromAMC(Platform::FindFile("05_09.amc", searchPath_), *ballet_ant_.skeleton_ptr()); + ballet_special3_.TrimFront(280); + ballet_special3_.TrimBack(200); + ballet_special3_.CalcRelativeTranslations(); + + ballet_special4_.LoadFromAMC(Platform::FindFile("05_20.amc", searchPath_), *ballet_ant_.skeleton_ptr()); + ballet_special4_.TrimFront(280); + ballet_special4_.TrimBack(200); + ballet_special4_.CalcRelativeTranslations(); + + ballet_special5_.LoadFromAMC(Platform::FindFile("05_06.amc", searchPath_), *ballet_ant_.skeleton_ptr()); + ballet_special5_.TrimFront(280); + ballet_special5_.TrimBack(200); + ballet_special5_.CalcRelativeTranslations(); // 3. Start the base loop motion ballet_ant_.Play(ballet_base_loop_); @@ -121,22 +136,22 @@ void DanceApp::OnMotion1BtnPressed() { void DanceApp::OnMotion2BtnPressed() { // TODO: add a call similar to this: - // ballet_ant_.OverlayClip(ballet_special2_, 100); + ballet_ant_.OverlayClip(ballet_special2_, 100); } void DanceApp::OnMotion3BtnPressed() { // TODO: add a call similar to this: - // ballet_ant_.OverlayClip(ballet_special3_, 100); + ballet_ant_.OverlayClip(ballet_special3_, 100); } void DanceApp::OnMotion4BtnPressed() { // TODO: add a call similar to this: - // ballet_ant_.OverlayClip(ballet_special4_, 100); + ballet_ant_.OverlayClip(ballet_special4_, 100); } void DanceApp::OnMotion5BtnPressed() { // TODO: add a call similar to this: - // ballet_ant_.OverlayClip(ballet_special5_, 100); + ballet_ant_.OverlayClip(ballet_special5_, 100); } void DanceApp::UpdateSimulation(double dt) { |