本文整理汇总了C++中MatrixTransform::setStateSet方法的典型用法代码示例。如果您正苦于以下问题:C++ MatrixTransform::setStateSet方法的具体用法?C++ MatrixTransform::setStateSet怎么用?C++ MatrixTransform::setStateSet使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MatrixTransform
的用法示例。
在下文中一共展示了MatrixTransform::setStateSet方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createOSGAxes
osg::Node* Shape::createOSGAxes(const base::Dimension3& dim)
{
const Real s = 1.5;
Real d = Math::minimum(0.06,Math::minimum(dim.x,dim.y,dim.z)/16.0);
Group* g = NewObj Group;
g->setName("debug");
// color the axes X:red, Y:green and Z:blue, with white end cones
StateSet* red = NewObj StateSet();
osg::Material* rmat = NewObj osg::Material();
Vec4 cred(1,0,0,1);
// mat->setEmission( osg::Material::FRONT_AND_BACK, Vec4(0,0,0,0) );
//mat->setAmbient( osg::Material::FRONT_AND_BACK, col );
rmat->setDiffuse( osg::Material::FRONT_AND_BACK, cred );
rmat->setSpecular( osg::Material::FRONT_AND_BACK, Vec4(1,1,1,0) );
rmat->setShininess( osg::Material::FRONT_AND_BACK, 1.0);
red->setAttribute( rmat );
StateSet* green = NewObj StateSet();
osg::Material* gmat = NewObj osg::Material();
Vec4 cgreen(0,1,0,1);
// mat->setEmission( osg::Material::FRONT_AND_BACK, Vec4(0,0,0,0) );
//mat->setAmbient( osg::Material::FRONT_AND_BACK, col );
gmat->setDiffuse( osg::Material::FRONT_AND_BACK, cgreen );
gmat->setSpecular( osg::Material::FRONT_AND_BACK, Vec4(1,1,1,0) );
gmat->setShininess( osg::Material::FRONT_AND_BACK, 1.0);
green->setAttribute( gmat );
StateSet* blue = NewObj StateSet();
osg::Material* bmat = NewObj osg::Material();
Vec4 cblue(0,0,1,1);
// mat->setEmission( osg::Material::FRONT_AND_BACK, Vec4(0,0,0,0) );
//mat->setAmbient( osg::Material::FRONT_AND_BACK, col );
bmat->setDiffuse( osg::Material::FRONT_AND_BACK, cblue );
bmat->setSpecular( osg::Material::FRONT_AND_BACK, Vec4(1,1,1,0) );
bmat->setShininess( osg::Material::FRONT_AND_BACK, 1.0);
blue->setAttribute( bmat );
StateSet* white = NewObj StateSet();
osg::Material* wmat = NewObj osg::Material();
Vec4 cwhite(1,1,1,1);
// mat->setEmission( osg::Material::FRONT_AND_BACK, Vec4(0,0,0,0) );
//mat->setAmbient( osg::Material::FRONT_AND_BACK, col );
wmat->setDiffuse( osg::Material::FRONT_AND_BACK, cwhite );
wmat->setSpecular( osg::Material::FRONT_AND_BACK, Vec4(1,1,1,0) );
wmat->setShininess( osg::Material::FRONT_AND_BACK, 1.0);
white->setAttribute( wmat );
// a long Clyinder for the axis and a cone-like cylinder
// for the arrow head of each X,Y and Z.
MatrixTransform* xrot = NewObj MatrixTransform();
xrot->setMatrix(osg::Matrix::rotate(consts::Pi/2.0,Vec3(0,1,0)));
xrot->postMult(osg::Matrix::translate(s*dim.x/4.0,0,0));
g->addChild(xrot);
MatrixTransform* yrot = NewObj MatrixTransform();
yrot->setMatrix(osg::Matrix::rotate(consts::Pi/2.0,Vec3(-1,0,0)));
yrot->postMult(osg::Matrix::translate(0,s*dim.y/4.0,0));
g->addChild(yrot);
MatrixTransform* zrot = NewObj MatrixTransform();
zrot->setMatrix(osg::Matrix::translate(0,0,s*dim.z/4.0));
g->addChild(zrot);
// the cylinder axes
ref<Cylinder> xc(NewObj Cylinder(s*dim.x/2.0,d));
xrot->addChild(xc->createOSGVisual());
xrot->setStateSet(red);
ref<Cylinder> yc(NewObj Cylinder(s*dim.y/2.0,d));
yrot->addChild(yc->createOSGVisual());
yrot->setStateSet(green);
ref<Cylinder> zc(NewObj Cylinder(s*dim.z/2.0,d));
zrot->addChild(zc->createOSGVisual());
zrot->setStateSet(blue);
// Translate each axis cone to the end
MatrixTransform* xtrans = NewObj MatrixTransform();
xtrans->setMatrix(osg::Matrix::translate(0,0,s*dim.x/4.0+d));
xrot->addChild(xtrans);
MatrixTransform* ytrans = NewObj MatrixTransform();
ytrans->setMatrix(osg::Matrix::translate(0,0,s*dim.y/4.0+d));
yrot->addChild(ytrans);
MatrixTransform* ztrans = NewObj MatrixTransform();
ztrans->setMatrix(osg::Matrix::translate(0,0,s*dim.z/4.0+d));
zrot->addChild(ztrans);
// the end cones
ref<Cone> cone(NewObj Cone(4*d,2*d));
osg::Node* coneNode = cone->createOSGVisual();
coneNode->setStateSet(white);
xtrans->addChild(coneNode);
ytrans->addChild(coneNode);
//.........这里部分代码省略.........