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


C++ SbRotation类代码示例

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


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

示例1: unsetEdit

void ViewProviderMirror::unsetEdit(int ModNum)
{
    if (ModNum == ViewProvider::Default) {
        SoCenterballManip* manip = static_cast<SoCenterballManip *>(pcEditNode->getChild(0));

        SbVec3f move = manip->translation.getValue();
        SbVec3f center = manip->center.getValue();
        SbRotation rot = manip->rotation.getValue();

        // get the whole translation
        move += center;
        rot.multVec(center,center);
        move -= center;

        // the new axis of the plane
        SbVec3f norm(0,0,1);
        rot.multVec(norm,norm);

        // apply the new values
        Part::Mirroring* mf = static_cast<Part::Mirroring*>(getObject());
        mf->Base.setValue(move[0],move[1],move[2]);
        mf->Normal.setValue(norm[0],norm[1],norm[2]);

        pcRoot->removeChild(pcEditNode);
        pcEditNode->removeAllChildren();
    }
    else {
        ViewProviderPart::unsetEdit(ModNum);
    }
}
开发者ID:pacificIT,项目名称:FreeCAD,代码行数:30,代码来源:ViewProviderMirror.cpp

示例2: getPoint

void 
SoXipOverlayTransformBoxManip::rotate( SoHandleEventAction* action )
{
	SbVec3f projPt;
	getPoint( action, projPt );
	
	const SbVec3f* point = mControlPointsCoords->point.getValues(0);

	SbVec3f center = (point[0] + point[4]) / 2.;

	SbVec3f rotateFrom	= point[mControlPointId] - center;
	SbVec3f rotateTo	= projPt - center;

	SbVec3f normal = mViewVolume.getPlane(0).getNormal();
	
	SbRotation rotation;
	rotation.setValue( normal, angleBetweenVectors( rotateFrom, rotateTo, normal ) );
	
	SbMatrix centerMatrix;
	centerMatrix.setTranslate( center );

	SbMatrix rotationMatrix;
	rotationMatrix.setRotate( rotation );

	mTransformationMatrix = centerMatrix.inverse() * rotationMatrix * centerMatrix;
	transform( mActionNode );
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:27,代码来源:SoXipOverlayTransformBoxManip.cpp

示例3: rotateVector

/*! \param[in,out] vect vector to rotate
 *  \param axis
 *  \param angle
 */
void kCamera::rotateVector(SbVec3f& vect, const SbVec3f axis, const double angle)
{
	SbRotation vecRotation;
	vecRotation.setValue(axis,angle);
	vecRotation.multVec(vect,vect);
	vect.normalize();
}
开发者ID:cguagliano,项目名称:communitymodules,代码行数:11,代码来源:kCamera.cpp

示例4: rotatePosition

/*! \param rotAxis
 *  \param rotAngle
 */
void kCamera::rotatePosition(SbVec3f rotAxis, double rotAngle, SbVec3f axisPoint)
{
	//Error20051017: Er rotierte immer nur um eine Achse, ohne diese zu verschieben (in den LookAt-Punkt).
	//Daher zunächst eine Translation der aktuellen Position um den Rotationspunkt und anschließend wieder zurück

	SbVec3f tempPos = currentPosition - axisPoint; //Error20051017

	// Position rotieren
	SbRotation pointRotation;
	pointRotation.setValue(rotAxis,rotAngle);
	//pointRotation.multVec(currentPosition, currentPosition);
	pointRotation.multVec(tempPos, tempPos); //Error20051017
	currentPosition = tempPos + axisPoint; //Error20051017

	currentLookDir = currentLookAt-currentPosition;
	currentLookDir.normalize();

	currentUpVec = calcUpVector(currentLookDir,NormPlump); //! Neuen UpVec ausrechnen - Rotation wird schon in calcUpVector vollzogen
	currentUpVec.normalize();

	currentOrientation = calcOrientation(currentUpVec,currentLookDir); //! Berechnet neue orientation

//	writeOrientation(currentOrientation); //! Schreibt orientation in ObjMgr
//	writePosition(currentPosition); //! Schreibt position in ObjMgr
}
开发者ID:cguagliano,项目名称:communitymodules,代码行数:28,代码来源:kCamera.cpp

示例5: transform

void Cone::transform(SoTransform *transformation){

	scale_vector = transformation->scaleFactor.getValue();
    radius = scale_vector[0];

	SbRotation rotation = transformation->rotation.getValue();
	rotation.getValue(rotation_axis, rotation_angle);
	translation_vector = transformation->translation.getValue();
	SbMatrix T,S, R, F;
	T.setTranslate(translation_vector);
	print_vector(translation_vector); //ntc
	print_vector(scale_vector); //ntc
	//std::cout << rotation[0] << rotation[1]<<rotation[2]<<rotation[3]; //ntc
	print_vector(rotation_axis); //ntc
	std::cout<<rotation_angle<<std::endl<<std::endl;

	R.setRotate(rotation);
	S.setScale(scale_vector);
//	F = T*R*S;
    F = S * R *T;
	SbVec3f pos(0,0,0);
	F.multVecMatrix(pos, pos);
	M = F; // save transformation matrix
	if(M.det4() != 0 ){
	    iM = F.inverse(); // store inverse if inverse exists
    }
	position = pos;
	print_vector(position);
}
开发者ID:tarunrs,项目名称:homework-fall-2011,代码行数:29,代码来源:cone.C

示例6:

void
vpSimulator::moveInternalCamera(vpHomogeneousMatrix &cMf)
{

  SbMatrix matrix;
  SbRotation rotCam;
  SbMatrix rotX;
  rotX.setRotate (SbRotation (SbVec3f(1.0f, 0.0f, 0.0f), (float)M_PI));
  for(unsigned int i=0;i<4;i++)
    for(unsigned int j=0;j<4;j++)
      matrix[(int)j][(int)i]=(float)cMf[i][j];

  matrix= matrix.inverse();
  matrix.multLeft (rotX);
  rotCam.setValue(matrix);


  internalCamera->ref() ;
  internalCamera->orientation.setValue(rotCam);
  internalCamera->position.setValue(matrix[3][0],matrix[3][1],matrix[3][2]);
  internalCamera->unref() ;

  rotX.setRotate (SbRotation (SbVec3f(-1.0f, 0.0f, 0.0f), (float)M_PI));
  matrix.multLeft (rotX);
  rotCam.setValue(matrix);
  internalCameraPosition->ref() ;
  internalCameraPosition->rotation.setValue(rotCam);
  internalCameraPosition->translation.setValue(matrix[3][0],matrix[3][1],matrix[3][2]);
  internalCameraPosition->unref() ;
}
开发者ID:tswang,项目名称:visp,代码行数:30,代码来源:vpSimulator.cpp

示例7: right

void NaviCubeImplementation::rotateView(int axis,float rotAngle) {
	SbRotation viewRot = m_View3DInventorViewer->getCameraOrientation();

	SbVec3f up;
	viewRot.multVec(SbVec3f(0,1,0),up);

	SbVec3f out;
	viewRot.multVec(SbVec3f(0,0,1),out);

	SbVec3f& u = up;
	SbVec3f& o = out;
	SbVec3f right  (u[1]*o[2]-u[2]*o[1], u[2]*o[0]-u[0]*o[2], u[0]*o[1]-u[1]*o[0]);

	SbVec3f direction;
	switch (axis) {
	default :
		return;
	case DIR_UP :
		direction = up;
		break;
	case DIR_OUT :
		direction = out;
		break;
	case DIR_RIGHT :
		direction = right;
		break;
	}

	SbRotation rot(direction, -rotAngle*M_PI/180.0);
	SbRotation newViewRot = viewRot * rot;
	m_View3DInventorViewer->setCameraOrientation(newViewRot);

}
开发者ID:lanigb,项目名称:FreeCAD,代码行数:33,代码来源:NaviCube.cpp

示例8: normalise

/*!
  Sets this quaternion by converting from Inventor format.
*/
void
Quaternion::set(const SbRotation &SbRot)
{
  w = (double)SbRot.getValue()[3];
  x = (double)SbRot.getValue()[0];
  y = (double)SbRot.getValue()[1];
  z = (double)SbRot.getValue()[2];
  normalise();
}
开发者ID:HumanoidRobotics,项目名称:graspit,代码行数:12,代码来源:matvec.cpp

示例9: povViewCamera

/// return the camera definition of the active view
static PyObject *
povViewCamera(PyObject *self, PyObject *args)
{
    // no arguments
    if (!PyArg_ParseTuple(args, ""))
        return NULL;
    PY_TRY {
        std::string out;
        const char* ppReturn=0;

        Gui::Application::Instance->sendMsgToActiveView("GetCamera",&ppReturn);

        SoNode* rootNode;
        SoInput in;
        in.setBuffer((void*)ppReturn,std::strlen(ppReturn));
        SoDB::read(&in,rootNode);

        if (!rootNode || !rootNode->getTypeId().isDerivedFrom(SoCamera::getClassTypeId()))
            throw Base::Exception("CmdRaytracingWriteCamera::activated(): Could not read "
                                  "camera information from ASCII stream....\n");

        // root-node returned from SoDB::readAll() has initial zero
        // ref-count, so reference it before we start using it to
        // avoid premature destruction.
        SoCamera * Cam = static_cast<SoCamera*>(rootNode);
        Cam->ref();

        SbRotation camrot = Cam->orientation.getValue();

        SbVec3f upvec(0, 1, 0); // init to default up vector
        camrot.multVec(upvec, upvec);

        SbVec3f lookat(0, 0, -1); // init to default view direction vector
        camrot.multVec(lookat, lookat);

        SbVec3f pos = Cam->position.getValue();
        float Dist = Cam->focalDistance.getValue();

        // making gp out of the Coin stuff
        gp_Vec gpPos(pos.getValue()[0],pos.getValue()[1],pos.getValue()[2]);
        gp_Vec gpDir(lookat.getValue()[0],lookat.getValue()[1],lookat.getValue()[2]);
        lookat *= Dist;
        lookat += pos;
        gp_Vec gpLookAt(lookat.getValue()[0],lookat.getValue()[1],lookat.getValue()[2]);
        gp_Vec gpUp(upvec.getValue()[0],upvec.getValue()[1],upvec.getValue()[2]);

        // getting image format
        ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Raytracing");
        int width = hGrp->GetInt("OutputWidth", 800);
        int height = hGrp->GetInt("OutputHeight", 600);

        // call the write method of PovTools....
        out = PovTools::getCamera(CamDef(gpPos,gpDir,gpLookAt,gpUp),width,height);

        return Py::new_reference_to(Py::String(out));
    } PY_CATCH;
}
开发者ID:Barleyman,项目名称:FreeCAD_sf_master,代码行数:58,代码来源:AppRaytracingGuiPy.cpp

示例10: cameray

SbRotation
SoBillboard::calculateRotation(SoState *state)
{
    SbRotation rot;
#ifdef INVENTORRENDERER
    const SbViewVolume &viewVolume = SoViewVolumeElement::get(state);

    if (SbVec3f(0.0f, 0.0f, 0.0f) == axis.getValue())
    {
        rot = viewVolume.getAlignRotation();
    }
#else
    const SbMatrix &mm = SoModelMatrixElement::get(state);
    SbMatrix imm = mm.inverse();

    SbVec3f toviewer;
    SbVec3f cameray(0.0f, 1.0f, 0.0f);
    const SbViewVolume &vv = SoViewVolumeElement::get(state);

    toviewer = -vv.getProjectionDirection();
    imm.multDirMatrix(toviewer, toviewer);

    (void)toviewer.normalize();

    SbVec3f rotaxis = this->axis.getValue();

    if (rotaxis == SbVec3f(0.0f, 0.0f, 0.0f))
    {
        // 1. Compute the billboard-to-viewer vector.
        // 2. Rotate the Z-axis of the billboard to be collinear with the
        //    billboard-to-viewer vector and pointing towards the viewer's position.
        // 3. Rotate the Y-axis of the billboard to be parallel and oriented in the
        //    same direction as the Y-axis of the viewer.
        rot.setValue(SbVec3f(0.f, 0.0f, 1.0f), toviewer);
        SbVec3f viewup = vv.getViewUp();
        imm.multDirMatrix(viewup, viewup);

        SbVec3f yaxis(0.0f, 1.0f, 0.0f);
        rot.multVec(yaxis, yaxis);
        SbRotation rot2(yaxis, viewup);

        SbVec3f axis;
        float angle;
        rot.getValue(axis, angle);
        rot2.getValue(axis, angle);
        rot = rot * rot2;
        //SoModelMatrixElement::rotateBy(state, (SoNode*) this, rot);
    }
#endif
    else
    {
        fprintf(stderr, "SoBillboard: axis != (0.0, 0.0, 0.0) not implemented\n");
    }

    return rot;
}
开发者ID:nixz,项目名称:covise,代码行数:56,代码来源:SoBillboard.cpp

示例11: init

bool Save_camera_settings_to_file::
init( std::string& parameters, GsTL_project* proj,
      Error_messages_handler* errors ) {

  std::vector< std::string > params = 
    String_Op::decompose_string( parameters, Actions::separator,
                      				   Actions::unique );

  if( params.size() != 1 ) {
    errors->report( "save_camera_settings filename" );  
    return false;
  }

  SmartPtr<Named_interface> view_ni =
    Root::instance()->interface( projectViews_manager + "/main_view"  );
  Oinv_view* view = dynamic_cast<Oinv_view*>( view_ni.raw_ptr() );
  if( !view ) {
    return false;
  }
  
  SoCamera* camera = view->get_render_area()->getCamera();
  if( !camera ) return false;


  std::ofstream out( params[0].c_str() );
  if( !out ) {
    std::ostringstream message;
    message << "Can't write to file " << params[0]; 
    errors->report( message.str() );  
    return false;
  }

  SbVec3f pos = camera->position.getValue();
  SbRotation rot = camera->orientation.getValue();
  float rot1, rot2, rot3, rot4;
  rot.getValue( rot1, rot2, rot3, rot4 );


  out << pos[0] << " " << pos[1] << " " << pos[2] << "\n"
      << rot1 << " " << rot2 << " " << rot3 << " " << rot4 << "\n"
      << camera->aspectRatio.getValue() << "\n"
      << camera->nearDistance.getValue() << "\n"
      << camera->farDistance.getValue() << "\n"
      << camera->focalDistance.getValue() << std::endl;
  out.close();

  return true;
}
开发者ID:ahinoamp,项目名称:Research,代码行数:48,代码来源:visu_actions.cpp

示例12: copyCameraSettings

    static
    void copyCameraSettings(SoCamera* cam1, SbRotation& rot_cam1, SbVec3f& pos_cam1,
                            SoCamera* cam2, SbRotation& rot_cam2, SbVec3f& pos_cam2)
    {
        // recompute the diff we have applied to the camera's orientation
        SbRotation rot = cam1->orientation.getValue();
        SbRotation dif = rot * rot_cam1.inverse();
        rot_cam1 = rot;

        // copy the values
        cam2->enableNotify(false);
        cam2->nearDistance = cam1->nearDistance;
        cam2->farDistance = cam1->farDistance;
        cam2->focalDistance = cam1->focalDistance;
        reorientCamera(cam2,dif);
        rot_cam2 = cam2->orientation.getValue();

        // reverse engineer the translation part in wc
        SbVec3f pos = cam1->position.getValue();
        SbVec3f difpos = pos - pos_cam1;
        pos_cam1 = pos;
        // the translation in pixel coords
        cam1->orientation.getValue().inverse().multVec(difpos,difpos);
        // the translation again in wc for the second camera
        cam2->orientation.getValue().multVec(difpos,difpos);
        cam2->position.setValue(cam2->position.getValue()+difpos);

        if (cam1->getTypeId() == cam2->getTypeId()) {
            if (cam1->getTypeId() == SoOrthographicCamera::getClassTypeId())
                static_cast<SoOrthographicCamera*>(cam2)->height =
                static_cast<SoOrthographicCamera*>(cam1)->height;
        }

        cam2->enableNotify(true);
    }
开发者ID:kkoksvik,项目名称:FreeCAD,代码行数:35,代码来源:ManualAlignment.cpp

示例13: if

void
vpSimulator::addObject(SoSeparator * object,
		       const vpHomogeneousMatrix &fMo,
		       SoSeparator * root)
{

  bool identity = true ;
  for (unsigned int i=0 ; i <4 ;i++){
    for (unsigned int j=0 ; j < 4 ; j++){
      if (i==j){
	      if  (fabs(fMo[i][j] -1) > 1e-6)  identity=false ;
      }
      else{
      	if (fabs(fMo[i][j]) > 1e-6)  identity=false ;
      }
    }
  }

  if (identity==true)
  {
    root->addChild (object);
  }
  else
  {
    SbMatrix matrix;
    SbRotation rotation;
    for(unsigned int i=0;i<4;i++)
      for(unsigned int j=0;j<4;j++)
      	matrix[(int)j][(int)i]=(float)fMo[i][j];

    //  matrix= matrix.inverse();
    rotation.setValue(matrix);

    SoTransform *displacement = new SoTransform;
    SoSeparator *newNode =  new SoSeparator;

    displacement->rotation.setValue(rotation);
    displacement->translation.setValue(matrix[3][0],
				       matrix[3][1],
				       matrix[3][2]);

    root->addChild (newNode);
    newNode->addChild (displacement);
    newNode->addChild (object);

  }
}
开发者ID:tswang,项目名称:visp,代码行数:47,代码来源:vpSimulator.cpp

示例14: calculateRotation

void
SoBillboard::getMatrix(SoGetMatrixAction *action)
//
////////////////////////////////////////////////////////////////////////
{
    //if (! rotation.isIgnored() && ! rotation.isDefault()) {
    SbRotation rot = calculateRotation(action->getState());
    SbMatrix &ctm = action->getMatrix();
    SbMatrix &inv = action->getInverse();
    SbMatrix m;

    rot.getValue(m);
    ctm.multLeft(m);
    rot.invert();
    rot.getValue(m);
    inv.multRight(m);
    //}
}
开发者ID:nixz,项目名称:covise,代码行数:18,代码来源:SoBillboard.cpp

示例15: getCamera

void SoXipDicomExaminer::tiltCamera( const SbRotation& rot )
{
	SbMatrix m;
	m = getCamera()->orientation.getValue();

	SbVec3f camy;
	rot.multVec( SbVec3f( m[1][0], m[1][1], m[1][2] ), camy );
	m[1][0] = camy[0];
	m[1][1] = camy[1];
	m[1][2] = camy[2];
	
	SbVec3f camx;
	rot.multVec( SbVec3f( m[0][0], m[0][1], m[0][2] ), camx );
	m[0][0] = camx[0];
	m[0][1] = camx[1];
	m[0][2] = camx[2];

	getCamera()->orientation.setValue( SbRotation(m) );
}
开发者ID:OpenXIP,项目名称:xip-libraries,代码行数:19,代码来源:SoXipDicomExaminer.cpp


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