本文整理汇总了C++中StateSet::ref方法的典型用法代码示例。如果您正苦于以下问题:C++ StateSet::ref方法的具体用法?C++ StateSet::ref怎么用?C++ StateSet::ref使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateSet
的用法示例。
在下文中一共展示了StateSet::ref方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Geode
PositionAttitudeTransform *VideoGeode::createVideoSphere(float size, bool texRepeat)
{
Geode *sphere = new Geode();
sphere->addDrawable(new ShapeDrawable(new Sphere(Vec3(0, 0, 4), size)));
// assign the material to the sphere
StateSet *sphereStateSet = sphere->getOrCreateStateSet();
sphereStateSet->ref();
sphereStateSet->setAttribute(_material);
try {
sphereStateSet->setTextureAttributeAndModes(0, createVideoTexture(texRepeat), StateAttribute::ON);
} catch (char *e) {
throw e;
}
PositionAttitudeTransform *sphereTransform = new PositionAttitudeTransform();
sphereTransform->addChild(sphere);
return sphereTransform;
}
示例2: DrawElementsUInt
PositionAttitudeTransform *VideoGeode::createVideoPlane(float sizeX, float sizeY, bool texRepeat)
{
// vertex array
Vec3Array *vertexArray = new Vec3Array();
sizeX /= 2.0;
sizeY /= 2.0;
vertexArray->push_back(Vec3(-sizeX, 0, -sizeY));
vertexArray->push_back(Vec3(sizeX, 0, -sizeY));
vertexArray->push_back(Vec3(sizeX, 0, sizeY));
vertexArray->push_back(Vec3(-sizeX, 0, sizeY));
/*vertexArray->push_back(Vec3(-sizeX, -sizeY, 0));
vertexArray->push_back(Vec3(sizeX, -sizeY, 0));
vertexArray->push_back(Vec3(sizeX, sizeY, 0));
vertexArray->push_back(Vec3(-sizeX, sizeY, 0));*/
// face array
DrawElementsUInt *faceArray = new DrawElementsUInt(PrimitiveSet::TRIANGLES, 0);
faceArray->push_back(0); // face 1
faceArray->push_back(1);
faceArray->push_back(2);
faceArray->push_back(2); // face 2
faceArray->push_back(3);
faceArray->push_back(0);
// normal array
Vec3Array *normalArray = new Vec3Array();
normalArray->push_back(Vec3(0, 0, 1));
// normal index
TemplateIndexArray<unsigned int, Array::UIntArrayType, 24, 4> *normalIndexArray;
normalIndexArray = new TemplateIndexArray<unsigned int, Array::UIntArrayType, 24, 4>();
normalIndexArray->push_back(0);
normalIndexArray->push_back(0);
normalIndexArray->push_back(0);
normalIndexArray->push_back(0);
// texture coordinates
Vec2Array *texCoords = new Vec2Array();
texCoords->push_back(Vec2(0.0f, 0.0f));
texCoords->push_back(Vec2(1.0f, 0.0f));
texCoords->push_back(Vec2(1.0f, 1.0f));
texCoords->push_back(Vec2(0.0f, 1.0f));
Geometry *geometry = new Geometry();
geometry->setVertexArray(vertexArray);
geometry->setNormalArray(normalArray);
geometry->setNormalIndices(normalIndexArray);
geometry->setNormalBinding(Geometry::BIND_PER_VERTEX);
geometry->setTexCoordArray(0, texCoords);
geometry->addPrimitiveSet(faceArray);
Geode *plane = new Geode();
plane->addDrawable(geometry);
// assign the material to the sphere
StateSet *planeStateSet = plane->getOrCreateStateSet();
planeStateSet->ref();
planeStateSet->setAttribute(_material);
try {
planeStateSet->setTextureAttributeAndModes(0, createVideoTexture(texRepeat), StateAttribute::ON);
} catch (char *e) {
throw e;
}
PositionAttitudeTransform *planeTransform = new PositionAttitudeTransform();
planeTransform->addChild(plane);
return planeTransform;
}