资源简介

opengl的配置请自行google。Computer Animation课的homework2,简单模拟了人体的行走,只有躯干(torso)和腿(legs),但Hierarchical Object Motion Control的基本原理都有。人体躯干的朝向为spline曲线的切线方向。B-Spline和Catmull-rom spline生成曲线请参考我上传的上一个资源:http://download.csdn.net/detail/thankfly/4621442 如何实现朝向的正确需要构建新的坐标系,请参考CMU的link:http://www.cs.cmu.edu/~jkh/462_s07/assts/assignment2/asst2camera.html 效果视频请点击https://www.youtube.com/watch?v=TPXZHCSRc8U

资源截图

代码片段和文件信息

/* CSCI 6555 Computer Animation   Assignemnt 2
Author: Fei XIE  email: xiefei@gwmail.gwu.edu
10/17/2012
**/

#include “stdafx.h“
#include 
#include 
#define MAX 50 
#define pi 3.14159265358979



// screen width and height
int screenWidth;
int screenHeight;
//user initializetion for Sloan‘s method
static GLfloat T[3]={0};
static GLfloat B[3]={0};
static GLfloat N[3]={0};
static int loop=0;

// user initialization
static GLfloat M2[16]={0};
static GLfloat M1[16]={0};
static GLfloat M[16]={0};
static GLfloat t=0;
static int PNumber = 0; // point number
static int Number = 5;
static GLfloat InterArray[7]={0};

static GLfloat QuaternionArray[5][3]={{-80-20}{80-20}{80-5}{-80-5}{-80-15}};
static GLfloat CRSplineMatrix[16]={-1.0f/2.0f1.0f-1.0f/2.0f03.0f/2.0f-5.0f/2.0f01.0f-3.0f/2.0f4.0f/2.0f1.0f/2.0f01.0f/2.0f-1.0f/2.0f00};
static GLfloat BSplineMatrix[16]={-1.0f/6.0f3.0f/6.0f-3.0f/6.0f1.0f/6.0f3.0f/6.0f-1.0f04.0f/6.0f-3.0f/6.0f3.0f/6.0f3.0f/6.0f1.0f/6.0f1.0f/6.0f000};

//compute T*M*Gand return the result
GLfloat MatrixMult(GLfloat T[4]GLfloat MT[16]GLfloat G[4]) { 
GLfloat Temp[4]={0};
Temp[0]=T[0]*MT[0]+T[1]*MT[1]+T[2]*MT[2]+T[3]*MT[3];
Temp[1]=T[0]*MT[4]+T[1]*MT[5]+T[2]*MT[6]+T[3]*MT[7];
Temp[2]=T[0]*MT[8]+T[1]*MT[9]+T[2]*MT[10]+T[3]*MT[11];
Temp[3]=T[0]*MT[12]+T[1]*MT[13]+T[2]*MT[14]+T[3]*MT[15];
GLfloat result=Temp[0]*G[0]+Temp[1]*G[1]+Temp[2]*G[2]+Temp[3]*G[3];
return result;
}

//Multiply two 4*4 matrix
void Matrix4Mul4(GLfloat M1[16]GLfloat M2[16]GLfloat Result[16]){  // rewrite to more efficiency

GLfloat TempM1[16];
GLfloat TempM2[16];
for (int i=0;i<16;i++){
TempM1[i]=M1[i];
}
for (int i=0;i<16;i++){
TempM2[i]=M2[i];
}
Result[0]=TempM1[0]*TempM2[0]+TempM1[4]*TempM2[1]+TempM1[8]*TempM2[2]+TempM1[12]*TempM2[3];
Result[1]=TempM1[1]*TempM2[0]+TempM1[5]*TempM2[1]+TempM1[9]*TempM2[2]+TempM1[13]*TempM2[3];
Result[2]=TempM1[2]*TempM2[0]+TempM1[6]*TempM2[1]+TempM1[10]*TempM2[2]+TempM1[14]*TempM2[3];
Result[3]=TempM1[3]*TempM2[0]+TempM1[7]*TempM2[1]+TempM1[11]*TempM2[2]+TempM1[15]*TempM2[3];
Result[4]=TempM1[0]*TempM2[4]+TempM1[4]*TempM2[5]+TempM1[8]*TempM2[6]+TempM1[12]*TempM2[7];
Result[5]=TempM1[1]*TempM2[4]+TempM1[5]*TempM2[5]+TempM1[9]*TempM2[6]+TempM1[13]*TempM2[7];
Result[6]=TempM1[2]*TempM2[4]+TempM1[6]*TempM2[5]+TempM1[10]*TempM2[6]+TempM1[14]*TempM2[7];
Result[7]=TempM1[3]*TempM2[4]+TempM1[7]*TempM2[5]+TempM1[11]*TempM2[6]+TempM1[15]*TempM2[7];
Result[8]=TempM1[0]*TempM2[8]+TempM1[4]*TempM2[9]+TempM1[8]*TempM2[10]+TempM1[12]*TempM2[11];
Result[9]=TempM1[1]*TempM2[8]+TempM1[5]*TempM2[9]+TempM1[9]*TempM2[10]+TempM1[13]*TempM2[11];
Result[10]=TempM1[2]*TempM2[8]+TempM1[6]*TempM2[9]+TempM1[10]*TempM2[10]+TempM1[14]*TempM2[11];
Result[11]=TempM1[3]*TempM2[8]+TempM1[7]*TempM2[9]+TempM1[11]*TempM2[10]+TempM1[15]*TempM2[11];
Result[12]=TempM1[0]*TempM2[12]+TempM1[4]*TempM2[13]+TempM1

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2012-10-18 07:22  Assignment2\
     目录           0  2012-10-18 07:20  Assignment2\Assignment2\
     文件        9540  2012-10-18 07:20  Assignment2\Assignment2\Assignment2.cpp
     文件        4374  2012-10-18 06:19  Assignment2\Assignment2\Assignment2.vcxproj
     文件        1335  2012-10-18 06:19  Assignment2\Assignment2\Assignment2.vcxproj.filters
     文件         143  2012-10-18 06:19  Assignment2\Assignment2\Assignment2.vcxproj.user
     目录           0  2012-10-18 07:22  Assignment2\Assignment2\Debug\
     文件         406  2012-10-18 06:20  Assignment2\Assignment2\Debug\Assignment2.exe.embed.manifest
     文件         472  2012-10-18 07:20  Assignment2\Assignment2\Debug\Assignment2.exe.embed.manifest.res
     文件         381  2012-10-18 07:22  Assignment2\Assignment2\Debug\Assignment2.exe.intermediate.manifest
     文件          63  2012-10-18 07:22  Assignment2\Assignment2\Debug\Assignment2.lastbuildstate
     文件        1990  2012-10-18 07:22  Assignment2\Assignment2\Debug\Assignment2.log
     文件       57785  2012-10-18 07:20  Assignment2\Assignment2\Debug\Assignment2.obj
     文件     1179648  2012-10-18 07:20  Assignment2\Assignment2\Debug\Assignment2.pch
     文件         212  2012-10-18 06:20  Assignment2\Assignment2\Debug\Assignment2_manifest.rc
     文件       53664  2012-10-18 07:20  Assignment2\Assignment2\Debug\CL.read.1.tlog
     文件        2282  2012-10-18 07:20  Assignment2\Assignment2\Debug\CL.write.1.tlog
     文件        3346  2012-10-18 07:20  Assignment2\Assignment2\Debug\cl.command.1.tlog
     文件           2  2012-10-18 07:22  Assignment2\Assignment2\Debug\link-cvtres.read.1.tlog
     文件           2  2012-10-18 07:22  Assignment2\Assignment2\Debug\link-cvtres.write.1.tlog
     文件           2  2012-10-18 07:22  Assignment2\Assignment2\Debug\link.13716-cvtres.read.1.tlog
     文件           2  2012-10-18 07:22  Assignment2\Assignment2\Debug\link.13716-cvtres.write.1.tlog
     文件           2  2012-10-18 07:22  Assignment2\Assignment2\Debug\link.13716.read.1.tlog
     文件           2  2012-10-18 07:22  Assignment2\Assignment2\Debug\link.13716.write.1.tlog
     文件        3882  2012-10-18 07:22  Assignment2\Assignment2\Debug\link.command.1.tlog
     文件        7646  2012-10-18 07:22  Assignment2\Assignment2\Debug\link.read.1.tlog
     文件        2406  2012-10-18 07:22  Assignment2\Assignment2\Debug\link.write.1.tlog
     文件         902  2012-10-18 07:22  Assignment2\Assignment2\Debug\mt.command.1.tlog
     文件         842  2012-10-18 07:22  Assignment2\Assignment2\Debug\mt.read.1.tlog
     文件         482  2012-10-18 07:22  Assignment2\Assignment2\Debug\mt.write.1.tlog
     文件        1310  2012-10-18 07:20  Assignment2\Assignment2\Debug\rc.command.1.tlog
............此处省略19个文件信息

评论

共有 条评论