本文整理汇总了C++中SbRotation::setValue方法的典型用法代码示例。如果您正苦于以下问题:C++ SbRotation::setValue方法的具体用法?C++ SbRotation::setValue怎么用?C++ SbRotation::setValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SbRotation
的用法示例。
在下文中一共展示了SbRotation::setValue方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setViewingDirections
void ManualAlignment::setViewingDirections(const Base::Vector3d& view1, const Base::Vector3d& up1,
const Base::Vector3d& view2, const Base::Vector3d& up2)
{
if (myViewer.isNull())
return;
{
SbRotation rot;
rot.setValue(SbVec3f(0.0f, 0.0f, 1.0f), SbVec3f(-view1.x,-view1.y,-view1.z));
SbRotation rot2;
SbVec3f up(0.0f, 1.0f, 0.0f);
rot.multVec(up, up);
rot2.setValue(up, SbVec3f(up1.x, up1.y, up1.z));
myViewer->getViewer(0)->getCamera()->orientation.setValue(rot * rot2);
myViewer->getViewer(0)->viewAll();
}
{
SbRotation rot;
rot.setValue(SbVec3f(0.0f, 0.0f, 1.0f), SbVec3f(-view2.x,-view2.y,-view2.z));
SbRotation rot2;
SbVec3f up(0.0f, 1.0f, 0.0f);
rot.multVec(up, up);
rot2.setValue(up, SbVec3f(up2.x, up2.y, up2.z));
myViewer->getViewer(1)->getCamera()->orientation.setValue(rot * rot2);
myViewer->getViewer(1)->viewAll();
}
}
示例2:
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() ;
}
示例3: angleBetweenVectors
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 );
}
示例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
}
示例5: 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();
}
示例6: 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;
}
示例7: 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);
}
}
示例8: axis
// Read rotation value from input stream, return TRUE if
// successful. Used from SoSFRotation and SoMFRotation.
SbBool
sosfrotation_read_value(SoInput * in, SbRotation & r)
{
float f[4];
for (int i = 0; i < 4; i++) {
if (!in->read(f[i])) return FALSE;
}
SbVec3f axis(f[0], f[1], f[2]);
const float angle = f[3];
// vrml97 identity rotations are often specified with a null vector.
// test for this and just set to z-axis.
if (axis == SbVec3f(0.0f, 0.0f, 0.0f) && angle == 0.0f) {
axis = SbVec3f(0.0f, 0.0f, 1.0f);
}
r.setValue(axis, angle);
return TRUE;
}
示例9: dragFinishCB
// internal callback
void InvPlaneMover::dragFinishCB(void *me, SoDragger *drag)
{
InvPlaneMover *mee = static_cast<InvPlaneMover *>(me);
if (mee->show_)
{
SbVec3f t = ((SoJackDragger *)drag)->translation.getValue();
int i;
for (i = 0; i < 3; ++i)
t[i] *= mee->scale_->scaleFactor.getValue()[i];
SbRotation r = ((SoJackDragger *)drag)->rotation.getValue();
SbVec3f n;
SbVec3f ax;
float angle;
r.getValue(ax, angle);
SbVec3f axN;
mee->fullRot_->rotation.getValue().multVec(ax, axN);
r.setValue(axN, angle);
r.multVec(mee->nnn_, n);
// we have to rotate the translation around the x-axis
// (because we have a y-axis dragger)
SbVec3f tt;
n.normalize();
// snap normal to the closest coordinate axis
// here done by snaping it to the axis with the biggest projection onto it.
if (mee->motionMode_ == InvPlaneMover::SNAP)
{
int axis;
float mmax;
int dir = 1;
SbVec3f nn;
if (n[0] * n[0] < n[1] * n[1])
{
axis = 1;
mmax = n[1];
if (n[1] < 0)
dir = -1;
else
dir = +1;
//dir = (int) copysign(1,n[1]);
}
else
{
axis = 0;
mmax = n[0];
if (n[0] < 0)
dir = -1;
else
dir = +1;
//dir = (int) copysign(1,n[0]);
}
if (mmax * mmax < n[2] * n[2])
{
axis = 2;
if (n[2] < 0)
dir = -1;
else
dir = +1;
//dir = (int) copysign(1,n[2]);
}
switch (axis)
{
case 0:
nn.setValue(1, 0, 0);
break;
case 1:
nn.setValue(0, 1, 0);
break;
case 2:
nn.setValue(0, 0, 1);
break;
}
n = dir * nn;
}
tt = t[1] * n;
float d;
d = n.dot(tt + mee->distOffset_);
float data[4];
data[0] = n[0];
data[1] = n[1];
data[2] = n[2];
data[3] = d;
// send feedback message to contoller
//.........这里部分代码省略.........
示例10: pitch
void
SoXipNeheStarGenerator::GLRender(SoGLRenderAction *action)
{
float yawAngle = 0;
static float spinAngle = 0;
float distance = 0;
float pitchAngle = M_PI /2; // tilt the view
SbRotation pitch(SbVec3f(1, 0, 0), pitchAngle); // rotation around X
SbMatrix pitchM;
pitch.getValue(pitchM);
SbRotation yaw = SbRotation::identity();
SbMatrix yawM = SbMatrix::identity();
SbRotation spin = SbRotation::identity();
SbMatrix spinM = SbMatrix::identity();
for (int i = 0; i < MAX_STARS; i++)
{
SoXipNeheStar* star = static_cast<SoXipNeheStar*>(this->getChild(i));
// spin angle for this star
spin.setValue(SbVec3f(0,0,1), spinAngle); // rotation around Z
spin.getValue(spinM);
// yaw angle for this star
//_starInfos[i].angle += ((float(i)/MAX_STARS) * (180 / M_PI));
yawAngle = _starInfos[i].angle;
yaw.setValue(SbVec3f(0,1,0), yawAngle); // rotation around Y
yaw.getValue(yawM);
// let's compose all matrices once to position each star
SbMatrix transM = SbMatrix::identity();
transM.setTranslate(SbVec3f(_starInfos[i].distance,0,0));
SbMatrix transform = spinM * pitchM.inverse() * yawM.inverse() * transM * yawM * pitchM ;
// position the star
star->trans.setValue(transform);
unsigned int color = convertRGBtoHex(_starInfos[i].r, _starInfos[i].g, _starInfos[i].b);
star->color.set1Value(0, color);
star->color.set1Value(1, color);
star->color.set1Value(2, color);
star->color.set1Value(3, color);
spinAngle += ( 0.01f * (M_PI / 180));
// change setting of all stars except the very first one (index 0)
if (i)
{
_starInfos[i].angle += ((float(i)/MAX_STARS) * ( M_PI / 180));
_starInfos[i].distance -= 0.01f;
if (_starInfos[i].distance < 0.0f)
{
_starInfos[i].distance += 5.0f;
_starInfos[i].r= rand() % 255 + 1 ;
_starInfos[i].g= rand() % 255 + 1;
_starInfos[i].b= rand() % 255 + 1;
}
}
}
SoXipKit::GLRender(action);
}
示例11: calcNewPosition
void METKAutoFading::calcNewPosition()
{
SbVec3f tempPos;
SbVec4f tempOrientVec4;
bool result = false;
if (_UseMETKValues->getBoolValue())
{
result = myObjMgr->getObjAttributeVec3f(_ViewerName->getStringValue(), LAY_VIEWER_CAMERA, INF_VIEWER_CAMERA_POSITION, tempPos);
result = result && myObjMgr->getObjAttributeVec4f(_ViewerName->getStringValue(), LAY_VIEWER_CAMERA, INF_VIEWER_CAMERA_ORIENTATION, tempOrientVec4);
}
else
{
result = true;
tempPos[0] = _camPosition->getVec3fValue()[0]; tempPos[1] = _camPosition->getVec3fValue()[1]; tempPos[2] = _camPosition->getVec3fValue()[2];
tempOrientVec4[0] = _camOrientation->getVec4fValue()[0]; tempOrientVec4[1] = _camOrientation->getVec4fValue()[1]; tempOrientVec4[2] = _camOrientation->getVec4fValue()[2]; tempOrientVec4[3] = _camOrientation->getVec4fValue()[3];
}
if (result)
{
myCamera->setPosition(tempPos);
SbRotation tempOrient;
tempOrient.setValue(SbVec3f(tempOrientVec4[0],tempOrientVec4[1],tempOrientVec4[2]),tempOrientVec4[3]);
myCamera->setOrientation(tempOrient);
SbVec3f lookDir = myCamera->getLookDir();
SbVec3f inverseLookDir = -1.0 * lookDir;
inverseLookDir.normalize();
//SphereCenter
float sphere_x, sphere_y, sphere_z, sphere_radius; int sphere_div;
m_calcVis.getSphereValues(sphere_x, sphere_y, sphere_z, sphere_radius, sphere_div);
SbVec3f spherePoint;
spherePoint[0] = sphere_x + inverseLookDir[0] * sphere_radius;
spherePoint[1] = sphere_y + inverseLookDir[1] * sphere_radius;
spherePoint[2] = sphere_z + inverseLookDir[2] * sphere_radius;
m_calcVis.clearStack(1);
m_calcVis.addPointRegionToStackField(1, spherePoint[0], spherePoint[1], spherePoint[2], 0.1);
SbVec3f similarPosition;
int posID = m_calcVis.getStackMaxPos(1, similarPosition[0], similarPosition[1], similarPosition[2]);
_similarPosition->setVec3fValue(vec3(similarPosition[0],similarPosition[1],similarPosition[2]));
//Alle Occluder an dieser Position für ObOfIn
std::vector<float> visValues;
m_calcVis.getMatrixValues(posID, _CurrentObject->getStringValue(), &visValues);
int objID = m_calcVis.findObjectId(_CurrentObject->getStringValue());
string occluName;
set<string> newFading;
for (int i=0; i<visValues.size()-3; i++)
{
if (visValues[i]!=0 && i!=objID)
{
occluName = m_calcVis.getObjectName(i);
newFading.insert(occluName);
//htNewFading.insert(occluName, occluName);
}
}
//std::cout << "newFading size = " << newFading.size() << std::endl;
//std::cout << "currentFading size = " << currentFading.size() << std::endl;
//Strukturen die neu hinzukommen finden
string objName = "";
Appearance oldValues;
set<string>::iterator iter = newFading.begin();
for (iter=newFading.begin(); iter!=newFading.end(); iter++)
{
objName = *iter;
//if (!htOldValues.find(objName))
if (!findInSet(currentFading, objName) && objName!="")
{
std::cout << "new:" << objName << std::endl;
//Get Old Values
myObjMgr->getObjAttributeFloat(objName,LAY_APPEARANCE, INF_TRANSPARENCY, oldValues.Transparency);
myObjMgr->getObjAttributeVec3f(objName,LAY_APPEARANCE, INF_COLOR, oldValues.Color);
myObjMgr->getObjAttributeVec3f(objName,LAY_APPEARANCE, INF_SILHOUETTECOLOR, oldValues.SilhouetteColor);
myObjMgr->getObjAttributeBool(objName,LAY_APPEARANCE, INF_SILHOUETTE, oldValues.SilhouetteVisible);
myObjMgr->getObjAttributeFloat(objName,LAY_APPEARANCE, INF_SILHOUETTEWIDTH, oldValues.SilhouetteWidth);
htOldValues.insert(objName, oldValues);
currentFading.insert(objName);
//Ausblenden
myObjMgr->setObjAttribute(objName,LAY_APPEARANCE, INF_TRANSPARENCY, new double(0.9), omINFOTYPE_DOUBLE, true, false);
myObjMgr->setObjAttribute(objName,LAY_APPEARANCE, INF_SILHOUETTEWIDTH, new double(2), omINFOTYPE_DOUBLE, true, false);
myObjMgr->setObjAttribute(objName,LAY_APPEARANCE, INF_SILHOUETTECOLOR, new vec3(0,0,0), omINFOTYPE_VEC3, true, false);
myObjMgr->setObjAttribute(objName,LAY_APPEARANCE, INF_SILHOUETTE, new bool(true), omINFOTYPE_BOOL, true, false);
}
}
//Alte Element aus currentFading wieder einblenden mit oldValues, die nicht in newFading drin sind
for (iter=currentFading.begin(); iter!=currentFading.end(); iter++)
{
objName = *iter;
if (!findInSet(newFading,objName) && objName!="")
{
std::cout << "Wiedereinblenden: " << objName << std::endl;
//.........这里部分代码省略.........