本文整理汇总了C++中Geode::setName方法的典型用法代码示例。如果您正苦于以下问题:C++ Geode::setName方法的具体用法?C++ Geode::setName怎么用?C++ Geode::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Geode
的用法示例。
在下文中一共展示了Geode::setName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawArrayLengths
Geode *ClipPlanePlugin::loadPlane()
{
// *5---*6---*7
// | | |
// *3--------*4
// | | |
// *0---*1---*2
float w = cover->getSceneSize() * 0.1; // width of plane
Vec3Array *lineCoords = new Vec3Array(12);
(*lineCoords)[0].set(-w, -0.01, -w);
(*lineCoords)[1].set(w, -0.01, -w);
(*lineCoords)[2].set(-w, -0.01, 0.0f);
(*lineCoords)[3].set(w, -0.01, 0.0f);
(*lineCoords)[4].set(-w, -0.01, w);
(*lineCoords)[5].set(w, -0.01, w);
(*lineCoords)[6].set(-w, -0.01, -w);
(*lineCoords)[7].set(-w, -0.01, w);
(*lineCoords)[8].set(0.0f, -0.01, -w);
(*lineCoords)[9].set(0.0f, -0.01, w);
(*lineCoords)[10].set(w, -0.01, -w);
(*lineCoords)[11].set(w, -0.01, w);
DrawArrayLengths *primitives = new DrawArrayLengths(PrimitiveSet::LINE_STRIP);
for (int i = 0; i < 6; i++)
{
primitives->push_back(2);
}
Vec3Array *lineColors = new Vec3Array(12);
for (int i = 0; i < 12; i++)
{
(*lineColors)[i].set(Vec3(1.0f, 1.0f, 1.0f));
}
Geometry *geoset = new Geometry();
geoset->setVertexArray(lineCoords);
geoset->addPrimitiveSet(primitives);
geoset->setColorArray(lineColors);
Material *mtl = new Material;
mtl->setColorMode(Material::AMBIENT_AND_DIFFUSE);
mtl->setAmbient(Material::FRONT_AND_BACK, Vec4(0.2f, 0.2f, 0.2f, 1.0f));
mtl->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.0f));
mtl->setSpecular(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.0f));
mtl->setEmission(Material::FRONT_AND_BACK, Vec4(0.0f, 0.0f, 0.0f, 1.0f));
mtl->setShininess(Material::FRONT_AND_BACK, 16.0f);
Geode *geode = new Geode;
geode->setName("ClipPlane");
geode->addDrawable(geoset);
StateSet *geostate = geode->getOrCreateStateSet();
geostate->setAttributeAndModes(mtl, StateAttribute::ON);
geostate->setMode(GL_LIGHTING, StateAttribute::OFF);
LineWidth *lineWidth = new LineWidth(3.0);
geostate->setAttributeAndModes(lineWidth, StateAttribute::ON);
geode->setStateSet(geostate);
return geode;
}
示例2: if
osg::Node *JTOpenPlugin::createShape(JtkShape *partShape, const char *objName)
{
//cout << "JtkSHAPE\n";
Geode *geode = new Geode();
ref_ptr<Geometry> geom = new Geometry();
StateSet *geoState = geode->getOrCreateStateSet();
Vec3Array *vert = new Vec3Array;
Vec3Array *normalArray = new Vec3Array();
Vec3Array *colorArray = new Vec3Array();
Vec2Array *tcArray = new Vec2Array();
DrawArrayLengths *primitives = NULL;
if (partShape->typeID() == JtkEntity::JtkPOLYGONSET)
{
primitives = new DrawArrayLengths(PrimitiveSet::POLYGON);
}
else if (partShape->typeID() == JtkEntity::JtkLINESTRIPSET)
{
primitives = new DrawArrayLengths(PrimitiveSet::LINE_STRIP);
}
else if (partShape->typeID() == JtkEntity::JtkTRISTRIPSET)
{
primitives = new DrawArrayLengths(PrimitiveSet::TRIANGLE_STRIP);
}
else
{
cerr << "unknown partShape->typeID " << partShape->typeID() << endl;
}
geode->setName(objName);
if (primitives)
{
for (int set = 0; set < partShape->numOfSets(); set++)
{
float *vertex = NULL,
*normal = NULL,
*color = NULL,
*texture = NULL;
int vertexCount = -1,
normCount = -1,
colorCount = -1,
textCount = -1;
partShape->getInternal(vertex, vertexCount, normal, normCount,
color, colorCount, texture, textCount, set);
primitives->push_back(vertexCount);
// backFaceCulling nur dann, wenn es im CoviseConfig enabled ist
/*if(backFaceCulling && (mask & Viewer::MASK_SOLID))
{
CullFace *cullFace = new CullFace(); // da viele Modelle backface Culling nicht vertragen (nicht richtig modelliert sind)
cullFace->setMode(CullFace::BACK);
geoState->setAttributeAndModes(cullFace, StateAttribute::ON);
}
// already done in updateMaterial()
#if 0
if(Blended)
{
BlendFunc *blendFunc = new BlendFunc();
blendFunc->setFunction(BlendFunc::SRC_ALPHA, BlendFunc::ONE_MINUS_SRC_ALPHA);
geoState->setAttributeAndModes(blendFunc, StateAttribute::ON);
#if 1
AlphaFunc *alphaFunc = new AlphaFunc();
alphaFunc->setFunction(AlphaFunc::ALWAYS,1.0);
geoState->setAttributeAndModes(alphaFunc, StateAttribute::OFF);
#endif
}
#endif
#ifdef HAVE_OSGNV
if((strncmp(d_currentObject->node->name(),"combineTextures",15)==0)||(strncmp(objName,"combineTextures",15)==0))
{
geoState->setAttributeAndModes(combineTextures.get(), StateAttribute::ON);
}
if((strncmp(d_currentObject->node->name(),"combineEnvTextures",15)==0)||(strncmp(objName,"combineEnvTextures",15)==0))
{
geoState->setAttributeAndModes(combineEnvTextures.get(), StateAttribute::ON);
}
#endif*/
if (vertex && (vertexCount > 0))
{
for (int elems = 0; elems < vertexCount; elems++)
{
vert->push_back(Vec3(vertex[elems * 3 + 0], vertex[elems * 3 + 1], vertex[elems * 3 + 2]));
}
JtkEntityFactory::deleteMemory(vertex);
}
if (normal && (normCount > 0))
{
for (int elems = 0; elems < normCount; elems++)
{
normalArray->push_back(Vec3(normal[elems * 3 + 0], normal[elems * 3 + 1], normal[elems * 3 + 2]));
}
if (normCount == vertexCount)
{
}
else
//.........这里部分代码省略.........
示例3: sizeof
//.........这里部分代码省略.........
{ 0.0, 0.0, 0.15 },
{ 0.0, 0.0, 0.15 },
{ 0.4, 0.4, 0.7 },
{ 0.2, 0.2, 0.6 },
{ 0.1, 0.1, 0.6 },
{ 0.1, 0.1, 0.6 },
{ 0.1, 0.1, 0.6 },
};
float x, y, z;
float alpha, theta;
float radius = 20.0f;
int nlev = sizeof( lev )/sizeof(float);
Geometry *geom = new Geometry;
Vec3Array& coords = *(new Vec3Array(19*nlev));
Vec4Array& colors = *(new Vec4Array(19*nlev));
Vec2Array& tcoords = *(new Vec2Array(19*nlev));
int ci = 0;
for( i = 0; i < nlev; i++ )
{
for( j = 0; j <= 18; j++ )
{
alpha = osg::DegreesToRadians(lev[i]);
theta = osg::DegreesToRadians((float)(j*20));
x = radius * cosf( alpha ) * cosf( theta );
y = radius * cosf( alpha ) * -sinf( theta );
z = radius * sinf( alpha );
coords[ci][0] = x;
coords[ci][1] = y;
coords[ci][2] = z;
colors[ci][0] = cc[i][0];
colors[ci][1] = cc[i][1];
colors[ci][2] = cc[i][2];
colors[ci][3] = 1.0;
tcoords[ci][0] = (float)j/18.0;
tcoords[ci][1] = (float)i/(float)(nlev-1);
ci++;
}
}
for( i = 0; i < nlev-1; i++ )
{
DrawElementsUShort* drawElements = new DrawElementsUShort(PrimitiveSet::TRIANGLE_STRIP);
drawElements->reserve(38);
for( j = 0; j <= 18; j++ )
{
drawElements->push_back((i+1)*19+j);
drawElements->push_back((i+0)*19+j);
}
geom->addPrimitiveSet(drawElements);
}
geom->setVertexArray( &coords );
geom->setTexCoordArray( 0, &tcoords );
geom->setColorArray( &colors );
geom->setColorBinding( Geometry::BIND_PER_VERTEX );
Texture2D *tex = new Texture2D;
tex->setImage(osgDB::readImageFile("Images/white.rgb"));
StateSet *dstate = new StateSet;
dstate->setTextureAttributeAndModes(0, tex, StateAttribute::OFF );
dstate->setTextureAttribute(0, new TexEnv );
dstate->setMode( GL_LIGHTING, StateAttribute::OFF );
dstate->setMode( GL_CULL_FACE, StateAttribute::ON );
// clear the depth to the far plane.
osg::Depth* depth = new osg::Depth;
depth->setFunction(osg::Depth::ALWAYS);
depth->setRange(1.0,1.0);
dstate->setAttributeAndModes(depth,StateAttribute::ON );
dstate->setRenderBinDetails(-2,"RenderBin");
geom->setStateSet( dstate );
Geode *geode = new Geode;
geode->addDrawable( geom );
geode->setName( "Sky" );
return geode;
}