本文整理汇总了C++中SbMatrix::multDirMatrix方法的典型用法代码示例。如果您正苦于以下问题:C++ SbMatrix::multDirMatrix方法的具体用法?C++ SbMatrix::multDirMatrix怎么用?C++ SbMatrix::multDirMatrix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SbMatrix
的用法示例。
在下文中一共展示了SbMatrix::multDirMatrix方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: InventorTriangleCB
/**
* This method extracts the triangle given by \p v1, \p v2, \p v3 and stores
* it in the TriMeshModel instance passed in through \p data by calling
* TriMeshModel::addTriangleWithFace() with the extracted triangle.
*/
void CoinVisualizationNode::InventorTriangleCB(void* data, SoCallbackAction* action,
const SoPrimitiveVertex* v1,
const SoPrimitiveVertex* v2,
const SoPrimitiveVertex* v3)
{
TriMeshModel* triangleMeshModel = static_cast<TriMeshModel*>(data);
if (!triangleMeshModel)
{
VR_INFO << ": Internal error, NULL data" << endl;
return;
}
SbMatrix mm = action->getModelMatrix();
SbMatrix scale;
scale.setScale(1000.0f); // simox operates in mm, coin3d in m
mm = mm.multRight(scale);
SbVec3f triangle[3];
mm.multVecMatrix(v1->getPoint(), triangle[0]);
mm.multVecMatrix(v2->getPoint(), triangle[1]);
mm.multVecMatrix(v3->getPoint(), triangle[2]);
SbVec3f normal[3];
/*mm.multVecMatrix(v1->getNormal(), normal[0]);
mm.multVecMatrix(v2->getNormal(), normal[1]);
mm.multVecMatrix(v3->getNormal(), normal[2]);*/
mm.multDirMatrix(v1->getNormal(), normal[0]);
mm.multDirMatrix(v2->getNormal(), normal[1]);
mm.multDirMatrix(v3->getNormal(), normal[2]);
normal[0] = (normal[0] + normal[1] + normal[2]) / 3.0f;
// read out vertices
Eigen::Vector3f a, b, c, n;
a << triangle[0][0], triangle[0][1], triangle[0][2];
b << triangle[1][0], triangle[1][1], triangle[1][2];
c << triangle[2][0], triangle[2][1], triangle[2][2];
n << normal[0][0], normal[0][1], normal[0][2];
// add new triangle to the model
triangleMeshModel->addTriangleWithFace(a, b, c, n);
}
示例3:
const SbVec4f &
SoTextureCoordinateEnvironment::valueCallback(void *action,
const SbVec3f &point,
const SbVec3f &normal)
//
////////////////////////////////////////////////////////////////////////
{
SoAction *a = (SoAction *)action;
//
// See the glTexGen() man page for the math here.
//
// First, map normal and point into eye space:
const SbMatrix &mm = SoModelMatrixElement::get(a->getState());
const SbMatrix &vm = SoViewingMatrixElement::get(a->getState());
// Compute the matrix that transforms normals from object-space to
// eye-space; use the inverse transpose to scale correctly
SbVec3f normalE;
SbMatrix nm = (vm * mm).inverse().transpose();
nm.multDirMatrix(normal, normalE);
SbVec3f pointE;
mm.multVecMatrix(point, pointE); // Gives world-space point
vm.multVecMatrix(pointE, pointE); // ... to eye-space.
// Get the normalized vector from the eye (which is conveniently
// at 0,0,0 in eye space) to the point.
pointE.normalize();
// Now, figure out reflection vector, from formula:
// R = P - 2 (N . N) pointE
SbVec3f reflection = pointE - 2.0 * normalE.dot(normalE) * pointE;
// Finally, compute s/t coordinates...
reflection[2] += 1.0;
float magnitude = reflection.length();
// This is static so we can return a reference to it
static SbVec4f result;
result.setValue(reflection[0] / magnitude + 0.5,
reflection[1] / magnitude + 0.5,
0.0, 1.0);
return result;
}
示例4: doClipping
void doClipping(SbVec3f trans, SbRotation rot)
{
SbMatrix mat;
SbVec3f normal;
mat.setTransform(trans, rot, SbVec3f(1,1,1));
mat.multDirMatrix(SbVec3f(0, -1, 0), normal);
SbPlane plane(normal, trans);
const float coords[][3] = {
{-5,-5,-5},
{5,-5,-5},
{5,5,-5},
{-5,5,-5},
{-5,-5,5},
{5,-5,5},
{5,5,5},
{-5,5,5}
};
const int indices[] = {
0,3,2,1,-1,
0,1,5,4,-1,
2,6,5,1,-1,
3,7,6,2,-1,
3,0,4,7,-1,
7,4,5,6,-1
};
// Clip box against plane
SbClip clip;
SoMFVec3f * globalVerts =
(SoMFVec3f *)SoDB::getGlobalField(SbName("globalVerts"));
SoMFVec3f * globalTVerts =
(SoMFVec3f *)SoDB::getGlobalField(SbName("globalTVerts"));
SoMFInt32 * globalnv =
(SoMFInt32 *)SoDB::getGlobalField(SbName("globalnv"));
globalVerts->startEditing();
globalVerts->setNum(0);
globalTVerts->startEditing();
globalTVerts->setNum(0);
globalnv->startEditing();
globalnv->setNum(0);
int i;
for (i = 0;i<6*5;i++) {
if (indices[i] == -1) {
clip.clip(plane);
int numVerts = clip.getNumVertices();
if (numVerts > 0) {
for (int j = 0;j<numVerts;j++) {
SbVec3f v;
clip.getVertex(j, v);
globalVerts->set1Value(globalVerts->getNum(), v);
v += SbVec3f(5, 5, 5);
v /= 10.0;
globalTVerts->set1Value(globalTVerts->getNum(), v);
}
globalnv->set1Value(globalnv->getNum(), numVerts);
}
clip.reset();
}
else clip.addVertex(coords[indices[i]]);
}
globalVerts->finishEditing();
globalTVerts->finishEditing();
globalnv->finishEditing();
// Close hole in clipped box by clipping against all 6 planes
const SbVec3f planecoords[] = {
SbVec3f(-10,0,-10),
SbVec3f(10,0,-10),
SbVec3f(10,0,10),
SbVec3f(-10,0,10)
};
clip.reset();
for (i = 0;i<4;i++) {
SbVec3f v;
mat.multVecMatrix(planecoords[i], v);
clip.addVertex(v);
}
for (i = 0;i<6*5;i+=5) {
SbPlane p(coords[indices[i+2]],
coords[indices[i+1]],
coords[indices[i]]);
clip.clip(p);
}
int numVerts = clip.getNumVertices();
SoMFVec3f * planeVerts =
(SoMFVec3f *)SoDB::getGlobalField(SbName("planeVerts"));
SoMFVec3f * planeTVerts =
(SoMFVec3f *)SoDB::getGlobalField(SbName("planeTVerts"));
planeVerts->startEditing();
planeVerts->setNum(0);
planeTVerts->startEditing();
planeTVerts->setNum(0);
for (i = 0;i<numVerts;i++) {
SbVec3f v;
//.........这里部分代码省略.........