本文整理汇总了C++中SFMatrix类的典型用法代码示例。如果您正苦于以下问题:C++ SFMatrix类的具体用法?C++ SFMatrix怎么用?C++ SFMatrix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SFMatrix类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CyberX3D::UpdateBoundingBox(
Node *node,
BoundingBox *bbox)
{
if (node->isGeometry3DNode()) {
Geometry3DNode *gnode = (Geometry3DNode *)node;
gnode->recomputeBoundingBox();
float bboxCenter[3];
float bboxSize[3];
gnode->getBoundingBoxCenter(bboxCenter);
gnode->getBoundingBoxSize(bboxSize);
SFMatrix mx;
gnode->getTransformMatrix(&mx);
for (int n=0; n<8; n++) {
float point[3];
point[0] = (n < 4) ? bboxCenter[0] - bboxSize[0] : bboxCenter[0] + bboxSize[0];
point[1] = (n % 2) ? bboxCenter[1] - bboxSize[1] : bboxCenter[1] + bboxSize[1];
point[2] = ((n % 4) < 2) ? bboxCenter[2] - bboxSize[2] : bboxCenter[2] + bboxSize[2];
mx.multi(point);
bbox->addPoint(point);
}
}
for (Node *cnode=node->getChildNodes(); cnode; cnode=cnode->next())
UpdateBoundingBox(cnode, bbox);
}
示例2: recomputeBoundingBox
void SceneGraph::recomputeBoundingBox()
{
Node *node;
float center[3];
float size[3];
float m4[4][4];
SFMatrix mx;
BoundingBox bbox;
for (node=getNodes(); node; node=node->nextTraversal()) {
if (node->isBoundedGroupingNode()) {
BoundedGroupingNode *gnode = (BoundedGroupingNode *)node;
gnode->getBoundingBoxCenter(center);
gnode->getBoundingBoxSize(size);
// Thanks for Peter DeSantis (07/22/04)
gnode->getTransformMatrix(m4);
mx.setValue(m4);
bbox.addBoundingBox(&mx, center, size);
}
else if (node->isGeometry3DNode()) {
Geometry3DNode *gnode = (Geometry3DNode *)node;
gnode->getBoundingBoxCenter(center);
gnode->getBoundingBoxSize(size);
// Thanks for Peter DeSantis (07/22/04)
gnode->getTransformMatrix(m4);
mx.setValue(m4);
bbox.addBoundingBox(&mx, center, size);
}
}
setBoundingBox(&bbox);
}
示例3: rotation
void SFMatrix::setRotation(float x, float y, float z, float rot)
{
SFRotation rotation(x, y, z, rot);
SFMatrix matrix;
rotation.getSFMatrix(&matrix);
float value[4][4];
matrix.getValue(value);
setValue(value);
}
示例4: getPosition
void ViewpointNode::getTranslationMatrix(SFMatrix *matrix)
{
float position[3];
getPosition(position);
SFVec3f transView(position);
transView.invert();
SFMatrix mxTrans;
mxTrans.setTranslation(&transView);
matrix->init();
matrix->add(&mxTrans);
}
示例5: getTransformMatrix
void Node::getTransformMatrix(SFMatrix *mxOut) const
{
mxOut->init();
for (const Node *node=this; node; node=node->getParentNode()) {
if (node->isTransformNode() || node->isBillboardNode()) {
SFMatrix mxNode;
if (node->isTransformNode())
((TransformNode *)node)->getSFMatrix(&mxNode);
else
((BillboardNode *)node)->getSFMatrix(&mxNode);
mxNode.add(mxOut);
mxOut->setValue(&mxNode);
}
}
}
示例6: getTranslationMatrix
void Node::getTranslationMatrix(SFMatrix *mxOut) const
{
mxOut->init();
for (const Node *node=this; node; node=node->getParentNode()) {
if (node->isTransformNode() || node->isBillboardNode()) {
SFMatrix mxNode;
if (node->isTransformNode()) {
float translation[3];
TransformNode *transNode = (TransformNode *)node;
transNode->getTranslation(translation);
mxNode.setTranslation(translation);
}
mxNode.add(mxOut);
mxOut->setValue(&mxNode);
}
}
}
示例7: GetRotateMatrixFromNormal
static void GetRotateMatrixFromNormal(
float normal[3],
SFMatrix &matrix)
{
SFMatrix mx;
SFMatrix my;
float mxValue[4][4];
float myValue[4][4];
mx.getValue(mxValue);
my.getValue(myValue);
float d = (float)sqrt(normal[1]*normal[1] + normal[2]*normal[2]);
if (d) {
float cosa = normal[2] / d;
float sina = normal[1] / d;
mxValue[0][0] = 1.0;
mxValue[0][1] = 0.0;
mxValue[0][2] = 0.0;
mxValue[1][0] = 0.0;
mxValue[1][1] = cosa;
mxValue[1][2] = sina;
mxValue[2][0] = 0.0;
mxValue[2][1] = -sina;
mxValue[2][2] = cosa;
}
float cosb = d;
float sinb = normal[0];
myValue[0][0] = cosb;
myValue[0][1] = 0.0;
myValue[0][2] = sinb;
myValue[1][0] = 0.0;
myValue[1][1] = 1.0;
myValue[1][2] = 0.0;
myValue[2][0] = -sinb;
myValue[2][1] = 0.0;
myValue[2][2] = cosb;
mx.setValue(mxValue);
my.setValue(myValue);
matrix.init();
matrix.add(&my);
matrix.add(&mx);
}
示例8: setDirection
void SFMatrix::setDirection(float x, float y, float z) {
SFMatrix mx;
SFMatrix my;
float mxValue[4][4];
float myValue[4][4];
float normal[3];
mx.getValue(mxValue);
my.getValue(myValue);
normal[0] = x;
normal[1] = y;
normal[2] = z;
float d = (float)sqrt(normal[1]*normal[1] + normal[2]*normal[2]);
if (d) {
float cosa = normal[2] / d;
float sina = normal[1] / d;
mxValue[0][0] = 1.0;
mxValue[0][1] = 0.0;
mxValue[0][2] = 0.0;
mxValue[1][0] = 0.0;
mxValue[1][1] = cosa;
mxValue[1][2] = sina;
mxValue[2][0] = 0.0;
mxValue[2][1] = -sina;
mxValue[2][2] = cosa;
}
float cosb = d;
float sinb = normal[0];
myValue[0][0] = cosb;
myValue[0][1] = 0.0;
myValue[0][2] = sinb;
myValue[1][0] = 0.0;
myValue[1][1] = 1.0;
myValue[1][2] = 0.0;
myValue[2][0] = -sinb;
myValue[2][1] = 0.0;
myValue[2][2] = cosb;
mx.setValue(mxValue);
my.setValue(myValue);
init();
add(&my);
add(&mx);
}
示例9: getSFMatrix
void TransformNode::getSFMatrix(SFMatrix *mOut)
{
float center[3];
float rotation[4];
float scale[3];
float scaleOri[4];
float trans[3];
SFMatrix mSRI;
SFMatrix mSR;
SFMatrix mCI;
SFMatrix mC;
SFMatrix mT;
SFMatrix mR;
SFMatrix mS;
getTranslation(trans);
mT.setTranslation(trans);
getCenter(center);
mC.setTranslation(center);
getRotation(rotation);
mR.setRotation(rotation);
getScaleOrientation(scaleOri);
mSR.setRotation(scaleOri);
getScale(scale);
mS.setScaling(scale);
getScaleOrientation(scaleOri);
scaleOri[3] = -scaleOri[3];
mSRI.setRotation(scaleOri);
getCenter(center);
center[0] = -center[0];
center[1] = -center[1];
center[2] = -center[2];
mCI.setTranslation(center);
mOut->init();
mOut->add(&mT);
mOut->add(&mC);
mOut->add(&mR);
mOut->add(&mSR);
mOut->add(&mS);
mOut->add(&mSRI);
mOut->add(&mCI);
}
示例10: getTranslationMatrix
void ViewpointNode::getTranslationMatrix(float value[4][4])
{
SFMatrix mx;
getTranslationMatrix(&mx);
mx.getValue(value);
}
示例11: getTextureCoordinateNodes
bool IndexedFaceSetNode::generateTextureCoordinate()
{
TextureCoordinateNode *texCoord = getTextureCoordinateNodes();
if (texCoord)
return false;
CoordinateNode *coordinateNode = getCoordinateNodes();
if (!coordinateNode)
return false;
texCoord = new TextureCoordinateNode();
int nPolygon = getNPolygons();
if (nPolygon <= 0)
return false;
float (*normal)[3] = new float[nPolygon][3];
SFVec3f *center = new SFVec3f[nPolygon];
SFVec3f *maxExtents = new SFVec3f[nPolygon];
SFVec3f *minExtents = new SFVec3f[nPolygon];
bool bPolygonBegin;
int polyn;
float point[3][3];
float coord[3];
int vertexn = 0;
int n;
bPolygonBegin = true;
polyn = 0;
/*
int nColorIndexes = idxFaceSet->getNColorIndexes();
int nNormalIndexes = idxFaceSet->getNNormalIndexes();
int nTexCoordIndexes = idxFaceSet->getNTexCoordIndexes();
*/
int nCoordIndexes = getNCoordIndexes();
for (n=0; n<nCoordIndexes; n++) {
int coordIndex = getCoordIndex(n);
if (coordIndex != -1) {
if (vertexn < 3)
coordinateNode->getPoint(coordIndex, point[vertexn]);
float point[3];
coordinateNode->getPoint(coordIndex, point);
if (bPolygonBegin) {
maxExtents[polyn].setValue(point);
minExtents[polyn].setValue(point);
center[polyn].setValue(point);
bPolygonBegin = false;
}
else {
SetExtents(maxExtents[polyn], minExtents[polyn], point);
center[polyn].add(point);
}
vertexn++;
}
else {
GetNormalFromVertices(point, normal[polyn]);
center[polyn].scale(1.0f / (float)vertexn);
maxExtents[polyn].sub(center[polyn]);
minExtents[polyn].sub(center[polyn]);
vertexn = 0;
bPolygonBegin = true;
polyn++;
}
}
float minx, miny, maxx, maxy, xlength, ylength;
SFMatrix matrix;
bPolygonBegin = true;
polyn = 0;
for (n=0; n<nCoordIndexes; n++) {
int coordIndex = getCoordIndex(n);
if (coordIndex != -1) {
if (bPolygonBegin) {
GetRotateMatrixFromNormal(normal[polyn], matrix);
matrix.multi(&minExtents[polyn]);
matrix.multi(&maxExtents[polyn]);
minx = minExtents[polyn].getX();
miny = minExtents[polyn].getY();
maxx = maxExtents[polyn].getX();
maxy = maxExtents[polyn].getY();
xlength = (float)fabs(maxExtents[polyn].getX() - minExtents[polyn].getX());
ylength = (float)fabs(maxExtents[polyn].getY() - minExtents[polyn].getY());
if (xlength == 0.0f || ylength == 0.0f) {
delete texCoord;
delete []minExtents;
delete []maxExtents;
//.........这里部分代码省略.........
示例12: getSFMatrix
void SFRotation::multi(SFVec3f *vector)
{
SFMatrix m;
getSFMatrix(&m);
m.multi(vector);
}