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


C++ SoCamera::getTypeId方法代码示例

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


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

示例1: finishDragCB

void SoFCCSysDragger::finishDragCB(void *data, SoDragger *)
{
    SoFCCSysDragger *sudoThis = reinterpret_cast<SoFCCSysDragger *>(data);

    // note: when creating a second view of the document and then closing
    // the first viewer it deletes the camera. However, the attached field
    // of the cameraSensor will be detached automatically.
    SoField* field = sudoThis->cameraSensor.getAttachedField();
    if (field)
    {
        SoCamera* camera = static_cast<SoCamera*>(field->getContainer());
        if (camera->getTypeId() == SoPerspectiveCamera::getClassTypeId())
            cameraCB(sudoThis, nullptr);
    }
}
开发者ID:AjinkyaDahale,项目名称:FreeCAD,代码行数:15,代码来源:SoFCCSysDragger.cpp

示例2: main

int main(int argc, char **argv)
{

  using namespace std;
  int numObjects;
  long nRows, nCols;



  char **error;

			 
  if (argc < 4)
    {
      fprintf(stderr,"Usage: lab1 <input file> <output file> <rows>\n");
      return -1;
    }

  filename = (char*)malloc(sizeof(char)*strlen(argv[2]));
  strcpy(filename, argv[2]);

  error = (char**)malloc(sizeof(char**)*10);
  nRows = strtol(argv[3],error,10);
  
  if (**error)
    {
      fprintf(stderr,"Error! use a number for rows!\n");
      return -2;
    }
  
  free(error);
  
  

  SoDB::init();
  OSUInventorScene *scene = new OSUInventorScene(argv[1]);


  //check to see if there are objects
  if (numObjects = scene->Objects.getLength() < 1)
    {
      fprintf(stderr,"Error, no objects");
      return -2;
    }
  
  //get the objects and put them into a list
  for (int i = 0; i < scene->Objects.getLength(); i++)
    {
      OSUObjectData *obj = (OSUObjectData *)scene->Objects[i];
      /*
      if (!obj->Check())
	{
	  fprintf(stderr,"Error detected in OSUObjectData for object %i.\n",i);
	  return 20;
	}
      */
      

      SoType shape_type = obj->shape->getTypeId(); 

      if (shape_type == SoSphere::getClassTypeId()) 
	{ 
	  Sphere *sp = new Sphere;


	  SoSphere * sphere = (SoSphere *) obj->shape; 
	  SoTransform * transformation = obj->transformation; 
	  SbVec3f scale_vector = transformation->scaleFactor.getValue(); 
	  SbVec3f translation_vector = transformation->translation.getValue();
	
	  sp->radius = 1;
	  sp->center = Point(0,0,0,1);
	  
	  //do the materials stuff
	  SoMaterial * material = obj->material;
	  
	  sp->color = rgb(material->diffuseColor[0][0],material->diffuseColor[0][1],material->diffuseColor[0][2]);
	  sp->specular = rgb(material->specularColor[0][0], material->specularColor[0][1],material->specularColor[0][2]);
	  sp->ambient = rgb(material->ambientColor[0][0], material->ambientColor[0][1], material->ambientColor[0][2]);
	  sp->shininess = material->shininess[0];
	  sp->trans = material->transparency[0];
			  
	  printf("Object %d has shininess %f\n", sp->object_number, sp->shininess);
	  //let's get our translation space matrix
	  //void getTranslationSpaceMatrix(SbMatrix &mat, SbMatrix &inv) const
	  SbMatrix tmat, tinv, smat, sinv, rmat, rinv;
	  
	  transformation->getTranslationSpaceMatrix(tmat, tinv);
	  //	  transformation->getScaleSpaceMatrix(smat,sinv);
	  transformation->getRotationSpaceMatrix(rmat, rinv);

	  //	  SbMatrix & multRight(const SbMatrix &m)
	  sp->M =   tmat;
	  sp->Mi =  tinv;
	  
	  sp->M.transpose();
	  sp->Mi.transpose();
	 

	  sp->type = eSPHERE;
//.........这里部分代码省略.........
开发者ID:michaelbernstein,项目名称:OSU-CIS681-Raytracer-from-2004,代码行数:101,代码来源:lab1.cpp

示例3: PRIVATE


//.........这里部分代码省略.........
        SbString enumname;
        SoButtonEvent::enumToString(bevent->getState(), enumname);
        PRIVATE(this)->varstring.sprintf("'%s'", enumname.getString());
        return PRIVATE(this)->varstring.getString();
      }

      else if (strcmp(subkey, "getKey()") == 0 && coinev->isOfType(SoKeyboardEvent::getClassTypeId())) {
        const SoKeyboardEvent * kbevent = coin_assert_cast<const SoKeyboardEvent *>(coinev);
        SbString enumname;
        SoKeyboardEvent::enumToString(kbevent->getKey(), enumname);
        PRIVATE(this)->varstring.sprintf("'%s'", enumname.getString());
        return PRIVATE(this)->varstring.getString();
      }

      else if (strcmp(subkey, "getPrintableCharacter()") == 0 && coinev->isOfType(SoKeyboardEvent::getClassTypeId())) {
        const SoKeyboardEvent * kbevent = coin_assert_cast<const SoKeyboardEvent *>(coinev);
        char printable = kbevent->getPrintableCharacter();
        PRIVATE(this)->varstring.sprintf("'%c'", printable);
        return PRIVATE(this)->varstring.getString();
      }

      else if (strcmp(subkey, "getButton()") == 0 && coinev->isOfType(SoMouseButtonEvent::getClassTypeId())) {
        const SoMouseButtonEvent * mbevent = coin_assert_cast<const SoMouseButtonEvent *>(coinev);
        SbString enumname;
        SoMouseButtonEvent::enumToString(mbevent->getButton(), enumname);
        PRIVATE(this)->varstring.sprintf("'%s'", enumname.getString());
        return PRIVATE(this)->varstring.getString();
      }

      else if (strcmp(subkey, "getButton()") == 0 && coinev->isOfType(SoSpaceballButtonEvent::getClassTypeId())) {
        const SoSpaceballButtonEvent * mbevent = coin_assert_cast<const SoSpaceballButtonEvent *>(coinev);
        SbString enumname;
        SoSpaceballButtonEvent::enumToString(mbevent->getButton(), enumname);
        PRIVATE(this)->varstring.sprintf("'%s'", enumname.getString());
        return PRIVATE(this)->varstring.getString();
      }

      // FIXME: x., .y, .z
      else if (strcmp(subkey, "getTranslation()") == 0 && coinev->isOfType(SoMotion3Event::getClassTypeId())) {
        const SoMotion3Event * m3event = coin_assert_cast<const SoMotion3Event *>(coinev);
        SbVec3f translation = m3event->getTranslation();
        PRIVATE(this)->varstring = SbStringConvert::toString(translation);
        return PRIVATE(this)->varstring.getString();
      }

      // FIXME: .angle, .axis
      else if (strcmp(subkey, "getRotation()") == 0 && coinev->isOfType(SoMotion3Event::getClassTypeId())) {
        const SoMotion3Event * m3event = coin_assert_cast<const SoMotion3Event *>(coinev);
        SbRotation rotation = m3event->getRotation();
        PRIVATE(this)->varstring = SbStringConvert::toString(rotation);
        return PRIVATE(this)->varstring.getString();
      }

      // FIXME: make this into a evaluator-level RayPick(SbVec2f) function instead
      else if (strcmp(key + 7, "pickposition3") == 0) {
        SbVec2s location2 = coinev->getPosition();
        SoRayPickAction rpa(this->getViewportRegion());
        rpa.setPoint(location2);
        rpa.apply(this->getSceneGraphRoot());
        SoPickedPoint * pp = rpa.getPickedPoint();
        if (pp) {
          SbVec3f pickpos = pp->getPoint();
          PRIVATE(this)->varstring = SbStringConvert::toString(pickpos);
        } else {
          PRIVATE(this)->varstring.sprintf("FALSE"); // need a valid undefined-value
        }
        return PRIVATE(this)->varstring.getString();
      }
    }
  }

  else if (strncmp(key, "coin:", 5) == 0) {
    const char * subkey = key + 5;
    if (strncmp(subkey, "camera.", 7) == 0) {
      SoCamera * camera = this->getActiveCamera();
      if (!camera) {
        SoDebugError::post("SoScXMLStateMachine::getVariable",
                           "queried for camera, but no camera is set.");
        return NULL;
      }
      const char * detail = subkey + 7;
      if (strcmp(detail, "getTypeId()") == 0) {
        PRIVATE(this)->varstring.sprintf("'%s'", camera->getTypeId().getName().getString());
        return PRIVATE(this)->varstring.getString();
      }
    }

    // get generic field access working and intercept for more So-specific stuff
    // coin:viewport
    // coin:camera
    // coin:scene
  }

  //else {
  //}

  // couldn't resolve the symbol - try parent class to get '_data' and other '_event'
  // locations resolved
  return inherited::getVariable(key);
}
开发者ID:Alexpux,项目名称:Coin3D,代码行数:101,代码来源:SoScXMLStateMachine.cpp


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