本文整理汇总了C++中BoundingBox::extent方法的典型用法代码示例。如果您正苦于以下问题:C++ BoundingBox::extent方法的具体用法?C++ BoundingBox::extent怎么用?C++ BoundingBox::extent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoundingBox
的用法示例。
在下文中一共展示了BoundingBox::extent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onKeyPressEvent
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PointSprites::onKeyPressEvent(KeyEvent* keyEvent)
{
char character = keyEvent->character();
if (character == '+' || character == L'-')
{
if (character == '+') m_fovScale += 0.1;
else m_fovScale -= 0.1;
m_fovScale = Math::clamp(m_fovScale, 0.1, 4.0);
}
if (character == ',' || character == L'.')
{
if (character == ',') m_nearPlane += 0.5;
else m_nearPlane -= 0.5;
m_nearPlane = Math::clamp(m_nearPlane, 0.0001, 200.0);
}
if (m_usePerspective)
{
double fovDeg = m_fovScale*40.0;
m_camera->setProjectionAsPerspective(fovDeg, m_nearPlane, m_camera->farPlane());
Trace::show("Perspective: FOV set to %.1f NEAR set to %.1f", fovDeg, m_nearPlane);
}
else
{
BoundingBox bb = m_renderSequence->boundingBox();
double height = m_fovScale*bb.extent().length();
m_camera->setProjectionAsOrtho(height, m_nearPlane, m_camera->farPlane());
Trace::show("Ortho: HEIGHT set to %.1f NEAR set to %.1f", height, m_nearPlane);
}
keyEvent->setRequestedAction(REDRAW);
}
示例2: onInitialize
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool SingleBox::onInitialize()
{
ref<DrawableGeo> geo1 = new DrawableGeo;
{
GeometryBuilderFaceList builder;
GeometryUtils::createBox(Vec3f(0,0,0), 2.0, 2.0, 2.0, &builder);
ref<Vec3fArray> vertices = builder.vertices();
ref<UIntArray> faceList = builder.faceList();
geo1->setVertexArray(vertices.p());
geo1->setFromFaceList(*faceList);
geo1->computeNormals();
}
ref<Part> part1 = new Part;
part1->setDrawable(geo1.p());
ref<Effect> eff1 = new Effect;
eff1->setRenderState(new RenderStateMaterial_FF(Color3f(1, 0, 0)));
part1->setEffect(eff1.p());
ref<ModelBasicList> myModel = new ModelBasicList;
myModel->addPart(part1.p());
myModel->updateBoundingBoxesRecursive();
// BoundingBox b = myModel->boundingBox();
// Trace::show("%f %f %f %f %f %f", b.min().x(), b.min().y(), b.min().z(), b.max().x(), b.max().y(), b.max().z());
m_renderSequence->rendering(0)->scene()->addModel(myModel.p());
BoundingBox bb = m_renderSequence->boundingBox();
if (bb.isValid())
{
m_camera->setProjectionAsOrtho(bb.extent().length(), m_camera->nearPlane(), m_camera->farPlane());
}
m_camera->setFromLookAt(Vec3d(0,0,5), Vec3d(0,0,0), Vec3d(0,1,0));
return true;
}
示例3: onInitialize
//.........这里部分代码省略.........
}
ref<Part> part = new Part;
part->setDrawable(geo.p());
part->setEffect(eff.p());
model->addPart(part.p());
}
{
ref<Vec3fArray> vertices = new Vec3fArray;
vertices->reserve(10);
vertices->add(Vec3f(0, 0, 0));
vertices->add(Vec3f(-3, 0, 0));
vertices->add(Vec3f(3, 0, 0));
ref<UIntArray> indices = new UIntArray(vertices->size());
indices->setConsecutive(0);
ref<PrimitiveSetIndexedUInt> primSet = new PrimitiveSetIndexedUInt(PT_POINTS);
primSet->setIndices(indices.p());
ref<DrawableGeo> geo = new DrawableGeo;
geo->setVertexArray(vertices.p());
geo->addPrimitiveSet(primSet.p());
ref<Effect> eff = new Effect;
if (useShaders)
{
bool useTextureSprite = true;
cvf::ShaderProgramGenerator gen("PointSprites", cvf::ShaderSourceProvider::instance());
gen.addVertexCode(ShaderSourceRepository::vs_DistanceScaledPoints);
if (useTextureSprite) gen.addFragmentCode(ShaderSourceRepository::src_TextureFromPointCoord);
else gen.addFragmentCode(ShaderSourceRepository::src_Color);
gen.addFragmentCode(ShaderSourceRepository::fs_CenterLitSpherePoints);
ref<cvf::ShaderProgram> prog = gen.generate();
eff->setShaderProgram(prog.p());
eff->setUniform(new UniformFloat("u_pointRadius", 1.0f));
if (useTextureSprite)
{
ref<Texture> tex = createTexture();
ref<Sampler> sampler = new Sampler;
sampler->setMinFilter(Sampler::LINEAR);
sampler->setMagFilter(Sampler::NEAREST);
sampler->setWrapModeS(Sampler::REPEAT);
sampler->setWrapModeT(Sampler::REPEAT);
ref<RenderStateTextureBindings> texBind = new RenderStateTextureBindings(tex.p(), sampler.p(), "u_texture2D");
eff->setRenderState(texBind.p());
}
else
{
eff->setUniform(new UniformFloat("u_color", Color4f(Color3::RED)));
}
ref<RenderStatePoint> point = new RenderStatePoint(RenderStatePoint::PROGRAM_SIZE);
point->enablePointSprite(true);
eff->setRenderState(point.p());
}
else
{
eff->setRenderState(new RenderStateLighting_FF(false));
eff->setRenderState(new RenderStateMaterial_FF(RenderStateMaterial_FF::PURE_MAGENTA));
ref<RenderStatePoint> point = new RenderStatePoint(RenderStatePoint::FIXED_SIZE);
point->enablePointSprite(true);
point->setSize(600.0f);
eff->setRenderState(point.p());
}
ref<Part> part = new Part;
part->setDrawable(geo.p());
part->setEffect(eff.p());
model->addPart(part.p());
}
model->updateBoundingBoxesRecursive();
m_renderSequence->firstRendering()->scene()->addModel(model.p());
BoundingBox bb = model->boundingBox();
if (bb.isValid())
{
m_camera->fitView(bb, -Vec3d::Z_AXIS, Vec3d::Y_AXIS);
if (m_usePerspective)
{
m_camera->setProjectionAsPerspective(m_fovScale*40.0, m_nearPlane, m_camera->farPlane());
}
else
{
m_camera->setProjectionAsOrtho(m_fovScale*bb.extent().length(), m_nearPlane, m_camera->farPlane());
}
}
return true;
}