本文整理汇总了C++中DisplaySkeleton::ComputeBonePositionsManual方法的典型用法代码示例。如果您正苦于以下问题:C++ DisplaySkeleton::ComputeBonePositionsManual方法的具体用法?C++ DisplaySkeleton::ComputeBonePositionsManual怎么用?C++ DisplaySkeleton::ComputeBonePositionsManual使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DisplaySkeleton
的用法示例。
在下文中一共展示了DisplaySkeleton::ComputeBonePositionsManual方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: display
//////////////////////////////////////////////////////////////////////////////////
// Draws to the OpenGL window
//////////////////////////////////////////////////////////////////////////////////
void display()
{
// precompute all the bone positions of the skeleton
displayer.ComputeBonePositionsManual(DisplaySkeleton::BONES_AND_LOCAL_FRAMES);
// retrieve all the bones of the skeleton
vector<MATRIX4>& rotations = displayer.rotations();
Matrix3 rotation;
vector<MATRIX4>& scalings = displayer.scalings();
Matrix3 scaling;
vector<VEC4F>& translations = displayer.translations();
Vector3 translation;
vector<float>& lengths = displayer.lengths();
int totalBones = rotations.size();
objsPerBone = 2;
// if bones are uninitialized, run inits
int i, obj;
if(boneIndex<0)
{
boneIndex=numObjects;
for(i=1;i<totalBones;i++)
{
rotation = rotations[i];
scaling = scalings[i];
translation = translations[i];
if(i == 23 || i == 30){//draw boxing gloves
spheres[numSpheres] = new Sphere(translation, 0.075, Vector3(1, 0, 0), MAT_DIFFUSE);
objects[numObjects++] = spheres[numSpheres++];
cylinders[numCylinders] = new Cylinder(translation, 0.0001, 0.0001, rotation,Vector3( 1,0,0),MAT_DIFFUSE);
objects[numObjects++] = cylinders[numCylinders++];
}
else{
spheres[numSpheres] = new Sphere(translation, 0.025, Vector3(1, 0, 0), MAT_DIFFUSE);
objects[numObjects++] = spheres[numSpheres++];
cylinders[numCylinders] = new Cylinder(translation,0.025,lengths[i],rotation,Vector3( 1,0,0),MAT_DIFFUSE);
objects[numObjects++] = cylinders[numCylinders++];
}
}
// update bone positions
} else {
for(i=1;i<totalBones;i++)
{
rotation = rotations[i];
scaling = scalings[i];
translation = translations[i];
for(obj=0;obj<objsPerBone;obj++)
{
objects[boneIndex + (i-1)*objsPerBone + obj]->updateLocation(translation, rotation);
}
}
}
// move camera
eye = Vector3(0,5,-1);
focus = Vector3(0, 3, -1);
up = Vector3(0, 1, 0);
rotation = rotations[16]; scaling = scalings[16]; translation = translations[16];
eye = (rotation*scaling) * eye + (translation);
focus = (rotation*scaling) * focus + (translation);
focus[1]=eye[1];
//up = (rotation*scaling) * up + (translation);
glClearColor(0,0,0,0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
int index;
int object;
Vector3 rayDir, color, p, n, tmp;
Matrix3 modelview = getModelviewMatrix();
float dist;
float r = nearx, l = -nearx;
float t = neary, b = -neary;
float u, v;
int x, y;
for(x=0; x<width; x++)
{
for(y=0; y<height; y++)
{
index = 3*width*y + 3*x;
// calculate ray direction
u = l + (r-l)*(x+0.5)/width;
v = b + (t-b)*(y+0.5)/height;
rayDir[0] = u; rayDir[1] = v; rayDir[2] = -nearz;
rayDir = modelview.transpose()*rayDir;
// find closest object intersect point
dist = findClosestIntersect(rayDir, eye, object);
// if intersect exists, determine pixel color from lighting
if(dist>=1)
{
// calculate coords of collision, normal vector
p = eye + rayDir * dist;
//.........这里部分代码省略.........