当前位置: 首页>>代码示例>>C++>>正文


C++ DisplaySkeleton类代码示例

本文整理汇总了C++中DisplaySkeleton的典型用法代码示例。如果您正苦于以下问题:C++ DisplaySkeleton类的具体用法?C++ DisplaySkeleton怎么用?C++ DisplaySkeleton使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DisplaySkeleton类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Redisplay

/*
* Redisplay() is called by Player_Gl_Window::draw().
*
* The display is double buffered, and FLTK swap buffers when
* Player_Gl_Window::draw() returns.  The GL context associated with this
* instance of Player_Gl_Window is set to be the current context by FLTK
* when it calls draw().
*/
void Redisplay() 
{
  /* clear image buffer to black */
  glClearColor(1.0, 1.0, 1.0, 0);
  glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); /* clear image, zbuf */

  glPushMatrix();  /* save current transform matrix */

  cameraView();

  glLineWidth(2.0);  /* we'll draw background with thick lines */

  if (renderWorldAxes == ON)
  {
    glDisable(GL_LIGHTING);
    glDisable(GL_TEXTURE_2D);
    glDisable(GL_FOG);
    RenderWorldAxes();  /* draw a triad in the origin of the world coordinate */
  }

  if (groundPlane == ON)
  { 
    if (useFog == ON)
    {
      glEnable(GL_FOG);
      GLfloat fogColor[4] = {1.0, 1.0, 1.0, 1.0};
      glFogfv(GL_FOG_COLOR, fogColor);
      glFogf(GL_FOG_START, (float)fogStart);
      glFogf(GL_FOG_END, (float)fogEnd);
      glFogf(GL_FOG_DENSITY, (float)fogDensity);
      glFogi(GL_FOG_MODE, GL_LINEAR);
    }

    // draw_ground();
    glEnable(GL_LIGHTING);
    glDisable(GL_TEXTURE_2D);
    glCallList(displayListGround);

    glDisable(GL_LIGHTING);
    glDisable(GL_FOG);
    glLineWidth(1.0);
    glColor3f(0.1f, 0.1f, 0.1f);
    double ground[4] = {0,1,0,0};
    double light[4] = {0,groundPlaneLightHeight,0,1};
    displayer.RenderShadow(ground, light);
  }

  // render the skeletons
  if (displayer.GetNumSkeletons()) 
  {
    glEnable(GL_LIGHTING);
    glDisable(GL_FOG);
    displayer.Render(DisplaySkeleton::BONES_AND_LOCAL_FRAMES);
  }

  glPopMatrix(); // restore current transformation matrix
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:65,代码来源:mocapPlayer.cpp

示例2: 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;
//.........这里部分代码省略.........
开发者ID:pcbennion,项目名称:ucsb-graphics-rayTrace03-final,代码行数:101,代码来源:skeletonViewer.cpp

示例3: skeletonID_callback

void skeletonID_callback(Fl_Value_Input *obj, void*)
{
  int subnum;
  subnum = (int)sub_input->value();

  if (subnum < 0) 
  {
    sub_input->value(0);
    subnum = 0;
  }
  else
    if (subnum >= displayer.GetNumSkeletons())
    {
      sub_input->value(displayer.GetNumSkeletons() - 1);
      subnum = displayer.GetNumSkeletons() - 1;
    }
    
  // Change values of other inputs to match sub-number
  double translation[3];
  displayer.GetSkeleton(subnum)->GetTranslation(translation);
  double rotationAngle[3];
  displayer.GetSkeleton(subnum)->GetRotationAngle(rotationAngle);
  tx_input->value(translation[0]);
  ty_input->value(translation[1]);
  tz_input->value(translation[2]);
  rx_input->value(rotationAngle[0]);
  ry_input->value(rotationAngle[1]);
  rz_input->value(rotationAngle[2]);
 
  glwindow->redraw();
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:31,代码来源:mocapPlayer.cpp

示例4: rz_callback

void rz_callback(Fl_Value_Input *obj, void*)
{
  int subnum = 0;
  subnum = (int)sub_input->value();
  if (subnum < displayer.GetNumSkeletons() && subnum >= 0)
    displayer.GetSkeleton(subnum)->SetRotationAngleZ(rz_input->value());
  glwindow->redraw();
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:8,代码来源:mocapPlayer.cpp

示例5: tx_callback

void tx_callback(Fl_Value_Input *obj, void*)
{
  int subnum = 0;
  subnum = (int)sub_input->value();
  if (subnum < displayer.GetNumSkeletons() && subnum >= 0)
    displayer.GetSkeleton(subnum)->SetTranslationX(tx_input->value());
  glwindow->redraw();
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:8,代码来源:mocapPlayer.cpp

示例6: UpdateMaxFrameNumber

void UpdateMaxFrameNumber(void)
{
  maxFrames = 0;
  for(int skeletonIndex = 0; skeletonIndex < displayer.GetNumSkeletons(); skeletonIndex++)
  {
    int currentFrames = displayer.GetSkeletonMotion(skeletonIndex)->GetNumFrames();
    if (currentFrames > maxFrames)
      maxFrames = currentFrames;
  }
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:10,代码来源:mocapPlayer.cpp

示例7: load_callback

void load_callback(Fl_Button *button, void *) 
{
  if(button == loadSkeleton_button)
    if (lastSkeleton <= lastMotion)  // cannot load new skeleton until motion is assigned to the current skeleton
    {
      char * filename = fl_file_chooser("Select filename","*.ASF","");
      if(filename != NULL)
      {
        // Read skeleton from asf file
        pSkeleton = new Skeleton(filename, MOCAP_SCALE);
        lastSkeleton++;
        // Set the rotations for all bones in their local coordinate system to 0
        // Set root position to (0, 0, 0)
        pSkeleton->setBasePosture();
        displayer.LoadSkeleton(pSkeleton);
        glwindow->redraw();
      }
    }

  if(button == loadMotion_button)
  {
    if ((lastSkeleton >= 0) && (lastSkeleton >= lastMotion))
    {
      char * filename = fl_file_chooser("Select filename","*.AMC","");
      if(filename != NULL)
      {
        // Read motion (.amc) file and create a motion
        pMotion = new Motion(filename, MOCAP_SCALE, pSkeleton);

        // backup the filename
        strcpy(lastMotionFilename, filename);

        // set sampled motion for display
        displayer.LoadMotion(pMotion);      
        if (lastSkeleton > lastMotion)         
          lastMotion++;
        
        UpdateMaxFrameNumber();
        resetPostureAccordingFrameSlider();
        frame_slider->value(currentFrameIndex);
        frame_slider->maximum((double)maxFrames);
        frame_slider->redraw();
        glwindow->redraw();
        Fl::flush();
      }
    } // if (lastSkeleton > lastMotion)
  }
  glwindow->redraw();
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:49,代码来源:mocapPlayer.cpp

示例8: SetSkeletonsToSpecifiedFrame

//////////////////////////////////////////////////////////////////////////////////
// Load up a new motion captured frame
//////////////////////////////////////////////////////////////////////////////////
void SetSkeletonsToSpecifiedFrame(int frameIndex)
{
  if (frameIndex < 0)
  {
    printf("Error in SetSkeletonsToSpecifiedFrame: frameIndex %d is illegal.\n", frameIndex);
    exit(0);
  }
  if (displayer.GetSkeletonMotion(0) != NULL)
  {
    int postureID;
    if (frameIndex >= displayer.GetSkeletonMotion(0)->GetNumFrames())
      postureID = displayer.GetSkeletonMotion(0)->GetNumFrames() - 1;
    else 
      postureID = frameIndex;
    displayer.GetSkeleton(0)->setPosture(* (displayer.GetSkeletonMotion(0)->GetPosture(postureID)));
  }
}
开发者ID:pcbennion,项目名称:ucsb-graphics-rayTrace03-final,代码行数:20,代码来源:skeletonViewer.cpp

示例9: resetPostureAccordingFrameSlider

void resetPostureAccordingFrameSlider(void)
{
  currentFrameIndex = (int)frame_slider->value() - 1;
  currentFrameIndexDoublePrecision = currentFrameIndex;

  // display
  for (int skeletonIndex = 0; skeletonIndex < displayer.GetNumSkeletons(); skeletonIndex++)
  {
    int postureID;
    if (currentFrameIndex >= displayer.GetSkeletonMotion(skeletonIndex)->GetNumFrames())
      postureID = displayer.GetSkeletonMotion(skeletonIndex)->GetNumFrames() - 1;
    else
      postureID = currentFrameIndex;
    // Set skeleton to the first posture
    Posture * currentPosture = displayer.GetSkeletonMotion(skeletonIndex)->GetPosture(postureID);
    displayer.GetSkeleton(skeletonIndex)->setPosture(*currentPosture);
  }
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:18,代码来源:mocapPlayer.cpp

示例10: reload_callback

void reload_callback(Fl_Button *button, void *) 
{
  if (!displayer.GetNumSkeletons())
    return;

  // Read motion (.amc) file and create a motion
  pMotion = new Motion(lastMotionFilename, MOCAP_SCALE, pSkeleton);

  // Set sampled motion for display
  displayer.LoadMotion(pMotion);
  
  resetPostureAccordingFrameSlider();
  UpdateMaxFrameNumber();
  frame_slider->maximum((double)maxFrames);
  frame_slider->value(currentFrameIndex);
  frame_slider->redraw();
  Fl::flush();
  glwindow->redraw();
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:19,代码来源:mocapPlayer.cpp

示例11: resetScene_callback

void resetScene_callback(Fl_Button *button, void *)
{
  rewindButton = ON;
  playButton = OFF;
  repeatButton = OFF;
  lastSkeleton = -1;
  lastMotion = -1;
  displayer.Reset();
  maxFrames = 0;
  glwindow->redraw();
  framesIncrementDoublePrecision = 1.0;
  currentFrameIndex = 0;
  currentFrameIndexDoublePrecision = 0.0;
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:14,代码来源:mocapPlayer.cpp

示例12: idle

//////////////////////////////////////////////////////////////////////////////////
// Called occasionally to see if anything's happening
//////////////////////////////////////////////////////////////////////////////////
void idle()
{
  // load up the next motion capture frame
  SetSkeletonsToSpecifiedFrame(currentFrameIndex);

  if (animate)
    currentFrameIndex+=2;

  // if we've reached the end of the motion capture sequence,
  // start over from frome 0
  int totalFrames = displayer.GetSkeletonMotion(0)->GetNumFrames();
  if (currentFrameIndex >= maxFrameIndex)
  {
    currentFrameIndex = 0;
    cout << " Hit end frame, exiting" << endl;
    exit(0);
  }

  glutPostRedisplay();
}
开发者ID:pcbennion,项目名称:ucsb-graphics-rayTrace03-final,代码行数:23,代码来源:skeletonViewer.cpp

示例13: main

int main(int argc, char **argv) 
{
  // Initialize form, sliders and buttons
  form = make_window();

  performanceCounter.StartCounter();  // init
  saveFileTimeCounter.StartCounter(); // init

  groundPlane_button->value(groundPlane);
  fog_button->value(useFog);
  worldAxes_button->value(renderWorldAxes);
  frame_slider->value(1);
  if (saveScreenToFile == SAVE_CONTINUOUS)
    record_button->value(1);  // ON
  else
    record_button->value(0);  // OFF

  // just do some timing, no special purpose
  // because the first data is always not trustable according to experience
  performanceCounter.StopCounter(); 
  performanceCounter.GetElapsedTime();
  saveFileTimeCounter.StopCounter();
  saveFileTimeCounter.GetElapsedTime();
  performanceCounter.StartCounter();
  // show form, and do initial draw of model
  form->show();
  glwindow->show(); // glwindow is initialized when the form is built
  performanceCounter.StopCounter();

  if (argc > 2)
  {
    char *filename;

    filename = argv[1];
    if(filename != NULL)
    {
      //Read skeleton from asf file
      pSkeleton = new Skeleton(filename, MOCAP_SCALE);

      //Set the rotations for all bones in their local coordinate system to 0
      //Set root position to (0, 0, 0)
      pSkeleton->setBasePosture();
      displayer.LoadSkeleton(pSkeleton);
      lastSkeleton++;
    }

    if (displayer.GetNumSkeletons())
    {
      filename = argv[2];
      if(filename != NULL)
      {
        //Read motion (.amc) file and create a motion
        pMotion = new Motion(filename, MOCAP_SCALE,pSkeleton);

        //set sampled motion for display
        displayer.LoadMotion(pMotion);               
        
        lastMotion++;

        //Tell skeleton to perform the first pose ( first posture )
        pSkeleton->setPosture(*(displayer.GetSkeletonMotion(0)->GetPosture(0)));          

        // Set skeleton to perform the first pose ( first posture )         
        int currentFrames = displayer.GetSkeletonMotion(0)->GetNumFrames();
        if (currentFrames > maxFrames)
        {
          maxFrames = currentFrames;
          frame_slider->maximum((double)maxFrames);

        }
        frame_slider->maximum((double)maxFrames);

        currentFrameIndex=0;
      } // if(filename != NULL)
    }
    else
      printf("Load a skeleton first.\n");
    framesIncrementDoublePrecision = 1.0;            // Current frame and frame increment
    playButton = ON;
    repeatButton = OFF;
    groundPlane = ON; 
    glwindow->redraw();
  }  // if (argc > 2)
  Fl::add_idle(idle);
  return Fl::run();
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:86,代码来源:mocapPlayer.cpp

示例14: spotJoint_callback

void spotJoint_callback(Fl_Value_Input *obj, void *)
{
  displayer.SetDisplayedSpotJoint((int) joint_idx->value());
  glwindow->redraw();
}
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:5,代码来源:mocapPlayer.cpp

示例15: idle

void idle(void*)
{
  if (previousPlayButtonStatus == ON)  
  {
    // it means we should measure the interval between two frames
    // if it is too tiny, we should slow down the motion
    performanceCounter.StopCounter();
    double actualTimeCostOneFrame = performanceCounter.GetElapsedTime(); // in seconds

    // time spent on saving the screen in previous time-step should be excluded
    if (saveFileTimeCost > 0.0)   
      actualTimeCostOneFrame -= saveFileTimeCost;

    framesIncrementDoublePrecision = actualTimeCostOneFrame * expectedFPS;
  }
  // start counter at the beginning of the new round
  if (playButton == ON)
    performanceCounter.StartCounter();

  if(rewindButton == ON)
  {
    currentFrameIndex = 0;
    currentFrameIndexDoublePrecision = 0.0;
    for (int i = 0; i < displayer.GetNumSkeletons(); i++)
    {
      if (displayer.GetSkeletonMotion(i) != NULL)
      {
        Posture * initSkeleton = displayer.GetSkeletonMotion(i)->GetPosture(0);
        displayer.GetSkeleton(i)->setPosture(*initSkeleton);
      }
    }
    rewindButton = OFF;
  }

  // Initialization
  saveFileTimeCost = -1.0;

  if(playButton == ON) 
  {
    if (saveScreenToFile == SAVE_CONTINUOUS)
    {
      saveFileTimeCounter.StartCounter();
      CreateScreenFilename(SAVE_CONTINUOUS, saveScreenToFileContinuousCount, saveScreenToFileContinuousFilename);
      saveScreenshot(640, 480, saveScreenToFileContinuousFilename);
      printf("%s is saved to disk.\n", saveScreenToFileContinuousFilename);
      saveScreenToFileContinuousCount++;
      saveFileTimeCounter.StopCounter();
      saveFileTimeCost = saveFileTimeCounter.GetElapsedTime();
    }

    if (saveScreenToFile == SAVE_CONTINUOUS)
    {
      currentFrameIndexDoublePrecision += 1.0;
    }
    else
    {
      currentFrameIndexDoublePrecision += framesIncrementDoublePrecision;
    }

    currentFrameIndex = (int)currentFrameIndexDoublePrecision;

    if(currentFrameIndex >= maxFrames)
    {
      if (repeatButton == ON)
      {
        currentFrameIndex = 0;
        currentFrameIndexDoublePrecision = 0.0;
      }
      else  // repeat button is OFF
      {
        currentFrameIndex = maxFrames - 1;
        currentFrameIndexDoublePrecision = currentFrameIndex;
        playButton = OFF;  // important, especially in "recording" mode
      }
    }

    if (currentFrameIndex < 0)
    {
      currentFrameIndex = 0;
      currentFrameIndexDoublePrecision = 0.0;
    }

    SetSkeletonsToSpecifiedFrame(currentFrameIndex);

    frame_slider->value((double) currentFrameIndex + 1);
  }  // if(playButton == ON)

  if (minusOneButton == ON)
    if (displayer.GetNumSkeletons() != 0)
    {
      currentFrameIndex--;
      if (currentFrameIndex < 0)
        currentFrameIndex = 0;
      frame_slider->value((double) currentFrameIndex + 1);

      SetSkeletonsToSpecifiedFrame(currentFrameIndex);    
      if (saveScreenToFile == SAVE_CONTINUOUS)
      {
        CreateScreenFilename(SAVE_CONTINUOUS, saveScreenToFileContinuousCount, saveScreenToFileContinuousFilename);
        saveScreenshot(640, 480, saveScreenToFileContinuousFilename);
//.........这里部分代码省略.........
开发者ID:JSleekXD,项目名称:ModifyMocapData,代码行数:101,代码来源:mocapPlayer.cpp


注:本文中的DisplaySkeleton类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。