本文整理汇总了C++中Vec3Array类的典型用法代码示例。如果您正苦于以下问题:C++ Vec3Array类的具体用法?C++ Vec3Array怎么用?C++ Vec3Array使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Vec3Array类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: createTextureQuad
Geode* createTextureQuad(Texture2D *texture)
{
Vec3Array *vertices = new Vec3Array;
vertices->push_back(Vec3(-1.0, -1.0, 0.0));
vertices->push_back(Vec3(1.0, -1.0, 0.0));
vertices->push_back(Vec3(1.0, 1.0, 0.0));
vertices->push_back(Vec3(-1.0, 1.0, 0.0));
Vec2Array *texcoord = new Vec2Array;
texcoord->push_back(Vec2(0.0, 0.0));
texcoord->push_back(Vec2(1.0, 0.0));
texcoord->push_back(Vec2(1.0, 1.0));
texcoord->push_back(Vec2(0.0, 1.0));
Geometry *geom = new Geometry;
geom->setVertexArray(vertices);
geom->setTexCoordArray(0, texcoord);
geom->addPrimitiveSet(new DrawArrays(GL_QUADS, 0, 4));
Geode *geode = new Geode;
geode->addDrawable(geom);
geode->getOrCreateStateSet()->setTextureAttributeAndModes(0, texture, StateAttribute::ON);
return geode;
}
开发者ID:AndreyIstomin,项目名称:osg,代码行数:25,代码来源:osgfpdepth.cpp
示例2: Geometry
/** This creates the wireframe PickBox around the widget.
Volume vertex names:
<PRE>
4____ 7 y
/___ /| |
0| 3| | |___x
| 5 | /6 /
|/___|/ z
1 2
</PRE>
*/
Geometry *PickBox::createWireframe(const Vec4 &color)
{
Geometry *geom = new Geometry();
updateVertices(geom);
// Set colors:
Vec4Array *colors = new Vec4Array();
colors->push_back(color);
geom->setColorArray(colors);
geom->setColorBinding(Geometry::BIND_OVERALL);
// Set normals:
Vec3Array *normals = new Vec3Array();
normals->push_back(Vec3(0.0f, 0.0f, 1.0f));
geom->setNormalArray(normals);
geom->setNormalBinding(Geometry::BIND_OVERALL);
// This time we simply use primitive, and hardwire the number of coords
// to use since we know up front:
geom->addPrimitiveSet(new DrawArrays(PrimitiveSet::LINES, 0, 24));
geom->setUseDisplayList(false); // allow dynamic changes
return geom;
}
开发者ID:nixz,项目名称:covise,代码行数:37,代码来源:PickBox.cpp
示例3: initBaseGeometry
/***************************************************************
* Function: initBaseGeometry()
***************************************************************/
void CAVEGeodeSnapWireframeCone::initBaseGeometry()
{
Vec3Array* vertices = new Vec3Array;
float rad = 1.0f, height = 1.0f, intvl = M_PI * 2 / gMinFanSegments;
// BaseGeometry contains (gMinFanSegments * 2) vertices
for (int i = 0; i < gMinFanSegments; i++)
{
vertices->push_back(Vec3(rad * cos(i * intvl), rad * sin(i * intvl), height));
}
for (int i = 0; i < gMinFanSegments; i++)
{
vertices->push_back(Vec3(rad * cos(i * intvl), rad * sin(i * intvl), 0));
}
mBaseGeometry->setVertexArray(vertices);
DrawElementsUInt* topEdges = new DrawElementsUInt(PrimitiveSet::LINE_STRIP, 0);
DrawElementsUInt* bottomEdges = new DrawElementsUInt(PrimitiveSet::LINE_STRIP, 0);
DrawElementsUInt* sideEdges = new DrawElementsUInt(PrimitiveSet::LINES, 0);
for (int i = 0; i < gMinFanSegments; i++)
{
topEdges->push_back(i);
bottomEdges->push_back(i + gMinFanSegments);
sideEdges->push_back(i);
sideEdges->push_back(i + gMinFanSegments);
}
topEdges->push_back(0);
bottomEdges->push_back(gMinFanSegments);
mBaseGeometry->addPrimitiveSet(topEdges);
mBaseGeometry->addPrimitiveSet(bottomEdges);
mBaseGeometry->addPrimitiveSet(sideEdges);
}
开发者ID:CalVR,项目名称:calvr_plugins,代码行数:36,代码来源:CAVEGeodeSnapWireframe.cpp
示例4: getNumDrawables
bool Object3D::findNearestVertex(Vec3f point, std::pair<unsigned int, Vec3f>& foundVertex)
{
bool found = false;
unsigned int nbDrawables = getNumDrawables();
Vec3Array *vertexArray = NULL;
double distMin = 100.0;
double dist;
for(unsigned int i=0; i<nbDrawables; i++)
{
vertexArray = getVertexList(i);
if(vertexArray)
{
std::vector<Vec3>::iterator itr;
for (itr=vertexArray->begin(); itr != vertexArray->end(); ++itr)
{
dist = Util::computeDist(*itr, point);
if(dist < distMin)
{
distMin = dist;
foundVertex = std::make_pair(i, *itr);
found = true;
}
}
}
}
return found;
}
开发者ID:ConfusedReality,项目名称:pkg_augmented-reality_polAR,代码行数:29,代码来源:Object3D.cpp
示例5: Vec3Array
Geode* ChessUtils::createRectangleWithTexture(Vec3 centerPosition, Image* image, int width, int height, Vec4 color) {
int halfWidth = width / 2;
int halfHeight = height / 2;
Vec3Array* vertices = new Vec3Array();
vertices->push_back(Vec3(centerPosition.x() - halfWidth, centerPosition.y() - halfHeight, centerPosition.z()));
vertices->push_back(Vec3(centerPosition.x() + halfWidth, centerPosition.y() - halfHeight, centerPosition.z()));
vertices->push_back(Vec3(centerPosition.x() + halfWidth, centerPosition.y() + halfHeight, centerPosition.z()));
vertices->push_back(Vec3(centerPosition.x() - halfWidth, centerPosition.y() + halfHeight, centerPosition.z()));
Vec3Array* normals = new Vec3Array();
normals->push_back(Vec3(0.0f, 0.0f, 1.0f));
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));
Vec4Array* colors = new Vec4Array();
colors->push_back(color);
Geometry* quad = new Geometry();
quad->setVertexArray(vertices);
quad->setNormalArray(normals);
quad->setNormalBinding(osg::Geometry::BIND_OVERALL);
quad->setColorArray(colors);
quad->setColorBinding(osg::Geometry::BIND_OVERALL);
quad->setTexCoordArray(0, texcoords);
quad->addPrimitiveSet(new osg::DrawArrays(GL_QUADS, 0, 4));
Texture2D* texture = new Texture2D();
if (image != NULL) {
texture->setImage(image);
}
Geode* geode = new Geode();
geode->addDrawable(quad);
osg::BlendFunc* blendFunc = new osg::BlendFunc();
blendFunc->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
osg::TexEnv* blendTexEnv = new osg::TexEnv();
blendTexEnv->setMode(osg::TexEnv::BLEND);
osg::StateSet* geodeStateset = geode->getOrCreateStateSet();
geodeStateset->setAttributeAndModes(blendFunc);
geodeStateset->setTextureAttribute(0, blendTexEnv);
geodeStateset->setTextureAttributeAndModes(0, texture);
geodeStateset->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
return geode;
}
开发者ID:carlosmccosta,项目名称:AR-Chess,代码行数:53,代码来源:ChessUtils.cpp
示例6: gl
void DragonBustNode::genBezierSubdivide(Vec3Array g, uint depth, Vec3Array& points)
{
/*
* Based on code from "Curved Surfaces Using Bézier Patches"
* http://www.gamasutra.com/view/feature/131755/curved_surfaces_using_bzier_.php?page=6
* See: Bibliography.
*/
if (depth == 0)
{
points.push_back(g[0]);
points.push_back(g[2]);
return;
}
Vec3Array gl(3);
Vec3Array gr(3);
gl[0] = g[0];
gl[1] = (g[0] + g[1]) * 0.5f;
gr[1] = (g[1] + g[2]) * 0.5f;
gl[2] = gr[0] = (gl[1] + gr[1]) * 0.5f;
gr[2] = g[2];
genBezierSubdivide(gl, --depth, points);
genBezierSubdivide(gr, depth, points);
}
开发者ID:mattmw,项目名称:charsim,代码行数:27,代码来源:DragonBustNode.cpp
示例7: CPPUNIT_ASSERT
void SWWReaderTest::testBedslopeNormalArray()
{
CPPUNIT_ASSERT( _sww->isValid() );
osg::ref_ptr<osg::Vec3Array> actual = _sww->getBedslopeNormalArray();
CPPUNIT_ASSERT( actual );
// expected number of bedslope normals
const size_t nvertices = 24;
CPPUNIT_ASSERT_EQUAL( actual->size(), nvertices );
// hard-coded values (bedslope is flat plane)
using osg::Vec3;
using osg::Vec3Array;
Vec3Array *expected = new Vec3Array;
expected->assign(24, Vec3( 0.301511, -0.301511, 0.904534 ) );
for (size_t i=0; i<nvertices; i++)
CPPUNIT_ASSERT_VEC3_EQUAL( actual->at(i), expected->at(i) );
}
开发者ID:stoiver,项目名称:anuga-viewer,代码行数:20,代码来源:swwreadertest.cpp
示例8: setGlows
Hyperspace::Hyperspace()
{
setGlows(false);
//start by creating a bunch of "stars"
int stars = 2500;
osg::Geode* geode = new Geode();
Geometry* geom = new Geometry;
geode->addDrawable(geom);
Vec4Array* colors = new Vec4Array();
colors->push_back(Vec4(1, 1, 1, 1));
geom->setColorArray(colors);
geom->setColorBinding(Geometry::BIND_OVERALL);
Vec3Array* verts = new Vec3Array();
geom->setVertexArray(verts);
geom->addPrimitiveSet(new DrawArrays(PrimitiveSet::TRIANGLES, 0, stars*3));
geom->getOrCreateStateSet()->setMode(GL_LIGHTING, false);
for(int i = 0; i < stars; i++)
{
float radius = Util::random(10, 150);
float theta = 6.28 * Util::loggedRandom("Hyperspace theta") / RAND_MAX;
float s = cosf(theta);
float c = sinf(theta);
Vec3 localUp(-s, c, 0);
float width = Util::random(0.1, 0.25) * radius / 25;;
float length = Util::random(10, 30) * radius / 20;
float z = 0;
Vec3 basePos(c*radius, s*radius, z+length*0.5);
Vec3 zDir(0, 0, 1);
verts->push_back(basePos + zDir * length * 0.5 + localUp * width * 0);
// verts->push_back(basePos + zDir * length * 0.5 - localUp * width * 0.5);
verts->push_back(basePos - zDir * length * 0.5 - localUp * width * 0.5);
verts->push_back(basePos - zDir * length * 0.5 + localUp * width * 0.5);
}
mPat->setPosition(Vec3(0, 0, -250));
mPat->addChild(geode);
mHSTime = -1;
update(0);
}
开发者ID:allegrocm,项目名称:Falcon,代码行数:39,代码来源:Hyperspace.cpp
示例9: Vec3Array
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;
}
开发者ID:jim-normand,项目名称:NAM,代码行数:75,代码来源:videogeometry.cpp
示例10: Geode
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
//.........这里部分代码省略.........
开发者ID:nixz,项目名称:covise,代码行数:101,代码来源:JTOpenPlugin.cpp
示例11: v
void Normals::MakeNormalsVisitor::apply( Geode &geode )
{
for( unsigned int i = 0; i < geode.getNumDrawables(); i++ )
{
Geometry *geom = dynamic_cast<Geometry *>(geode.getDrawable(i));
if( geom )
{
if (geom->containsDeprecatedData()) geom->fixDeprecatedData();
Vec3Array *coords = dynamic_cast<Vec3Array*>(geom->getVertexArray());
if( coords == 0L )
continue;
Vec3Array *normals = dynamic_cast<Vec3Array*>(geom->getNormalArray());
if( normals == 0L )
continue;
Geometry::AttributeBinding binding = geom->getNormalBinding();
if( binding == Geometry::BIND_OFF )
continue;
if( binding == Geometry::BIND_OVERALL )
{
Vec3 v(0,0,0);
Vec3 n = normals->front();
Vec3Array::iterator coord_index = coords->begin();
while( coord_index != coords->end() )
v += *(coord_index++) * _mat;
v /= (float)(coords->size());
n *= _normal_scale;
_local_coords->push_back( v );
_local_coords->push_back( (v + n));
}
else // BIND_PER_PRIMITIVE_SET, BIND_PER_VERTEX
{
Geometry::PrimitiveSetList& primitiveSets = geom->getPrimitiveSetList();
Geometry::PrimitiveSetList::iterator itr;
Vec3Array::iterator coord_index = coords->begin();
Vec3Array::iterator normals_index = normals->begin();
for(itr=primitiveSets.begin(); itr!=primitiveSets.end(); ++itr)
{
#ifdef DEBUG
_printPrimitiveType( (*itr).get() );
#endif
if( binding == Geometry::BIND_PER_PRIMITIVE_SET )
{
Vec3 v(0,0,0);
Vec3 n = *(normals_index++);
int ni = (*itr)->getNumIndices();
for( int i = 0; i < ni; i++ )
v += *(coord_index++) * _mat;
v /= (float)(ni);
n *= _normal_scale;
_local_coords->push_back( v );
_local_coords->push_back( (v + n));
}
else
{
switch((*itr)->getMode())
{
case(PrimitiveSet::TRIANGLES):
{
for( unsigned int j = 0; j < (*itr)->getNumPrimitives(); j++ )
{
_processPrimitive( 3, coord_index, normals_index, binding );
coord_index += 3;
normals_index+=3;
}
break;
}
case(PrimitiveSet::TRIANGLE_STRIP):
{
for( unsigned int j = 0; j < (*itr)->getNumIndices()-2; j++ )
{
_processPrimitive( 3, coord_index, normals_index, binding );
coord_index++;
normals_index++;
}
coord_index += 2;
if( binding == Geometry::BIND_PER_VERTEX )
normals_index += 2;
break;
}
case(PrimitiveSet::TRIANGLE_FAN):
break;
case(PrimitiveSet::QUADS):
{
for( unsigned int j = 0; j < (*itr)->getNumPrimitives(); j++ )
{
_processPrimitive( 4, coord_index, normals_index, binding );
coord_index += 4;
normals_index +=4;
}
break;
//.........这里部分代码省略.........
开发者ID:amhagan,项目名称:osg,代码行数:101,代码来源:Normals.cpp
示例12: sqrt
/***************************************************************
* Function: resize()
***************************************************************/
void CAVEGeodeSnapWireframeCone::resize(osg::Vec3 &gridVect)
{
// calculate rounded vector
float height = mScaleVect.z(),
rad = sqrt(mScaleVect.x() * mScaleVect.x() + mScaleVect.y() * mScaleVect.y());
int hSeg, radSeg, fanSeg, hDir = 1;
if (height < 0)
{
height = -height;
hDir = -1;
}
hSeg = (int)(abs((int)(height / mSnappingUnitDist)) + 0.5);
radSeg = (int)(abs((int)(rad / mSnappingUnitDist)) + 0.5);
fanSeg = (int)(abs((int)(rad * M_PI * 2 / mSnappingUnitDist)) + 0.5);
if (fanSeg < gMinFanSegments)
fanSeg = gMinFanSegments;
float intvl = M_PI * 2 / fanSeg;
height = hSeg * mSnappingUnitDist;
rad = radSeg * mSnappingUnitDist;
gridVect = Vec3(radSeg, 0, hSeg * hDir);
mDiagonalVect = Vec3(rad, rad, height * hDir);
gCurFanSegments = 10;//fanSeg; // update number of fan segment, this parameter is passed to 'CAVEGeodeShape'
// update 'mSnapwireGeometry' geometry, do not use 'mBaseGeometry' anymore
if (mBaseGeometry)
{
removeDrawable(mBaseGeometry);
mBaseGeometry = NULL;
}
if (mSnapwireGeometry)
removeDrawable(mSnapwireGeometry);
mSnapwireGeometry = new Geometry();
Vec3Array* snapvertices = new Vec3Array;
int vertoffset = 0;
// create vertical edges, cap radiating edges and ring strips on side surface
for (int i = 0; i <= hSeg; i++)
{
for (int j = 0; j < fanSeg; j++)
{
float theta = j * intvl;
snapvertices->push_back(mInitPosition + Vec3(rad * cos(theta), rad * sin(theta), i * mSnappingUnitDist * hDir));
}
}
snapvertices->push_back(mInitPosition);
snapvertices->push_back(mInitPosition + Vec3(0, 0, height * hDir));
for (int i = 0; i <= hSeg; i++)
{
DrawElementsUInt* sideRingStrip = new DrawElementsUInt(PrimitiveSet::LINE_STRIP, 0);
for (int j = 0; j < fanSeg; j++)
{
sideRingStrip->push_back(vertoffset + i * fanSeg + j);
}
sideRingStrip->push_back(vertoffset + i * fanSeg);
mSnapwireGeometry->addPrimitiveSet(sideRingStrip);
}
DrawElementsUInt* sideVerticalEdges = new DrawElementsUInt(PrimitiveSet::LINES, 0);
DrawElementsUInt* capRadiatingEdges = new DrawElementsUInt(PrimitiveSet::LINES, 0);
for (int j = 0; j < fanSeg; j++)
{
sideVerticalEdges->push_back(vertoffset + j);
sideVerticalEdges->push_back(vertoffset + j + fanSeg * hSeg);
capRadiatingEdges->push_back((hSeg + 1) * fanSeg);
capRadiatingEdges->push_back(vertoffset + j);
capRadiatingEdges->push_back((hSeg + 1) * fanSeg + 1);
capRadiatingEdges->push_back(vertoffset + j + fanSeg * hSeg);
}
mSnapwireGeometry->addPrimitiveSet(sideVerticalEdges);
mSnapwireGeometry->addPrimitiveSet(capRadiatingEdges);
vertoffset += (hSeg + 1) * fanSeg + 2;
// create ring strips on two caps
for (int i = 1; i < radSeg; i++)
{
float r = i * mSnappingUnitDist;
for (int j = 0; j < fanSeg; j++)
{
float theta = j * intvl;
snapvertices->push_back(mInitPosition + Vec3(r * cos(theta), r * sin(theta), height * hDir));
snapvertices->push_back(mInitPosition + Vec3(r * cos(theta), r * sin(theta), 0));
}
}
for (int i = 1; i < radSeg; i++)
{
DrawElementsUInt* topRingStrip = new DrawElementsUInt(PrimitiveSet::LINE_STRIP, 0);
DrawElementsUInt* bottomRingStrip = new DrawElementsUInt(PrimitiveSet::LINE_STRIP, 0);
//.........这里部分代码省略.........
开发者ID:CalVR,项目名称:calvr_plugins,代码行数:101,代码来源:CAVEGeodeSnapWireframe.cpp
示例13: createFloorplanGeometry
/***************************************************************
* Function: createFloorplanGeometry()
***************************************************************/
void VirtualScenicHandler::createFloorplanGeometry(const int numPages,
CAVEAnimationModeler::ANIMPageEntry **pageEntryArray)
{
if (numPages <= 0)
{
return;
}
for (int i = 0; i < numPages; i++)
{
// create floorplan geometry
float length = pageEntryArray[i]->mLength;
float width = pageEntryArray[i]->mWidth;
float altitude = pageEntryArray[i]->mAlti;
Geode *floorplanGeode = new Geode;
Geometry *floorplanGeometry = new Geometry;
Vec3Array* vertices = new Vec3Array;
Vec3Array* normals = new Vec3Array;
Vec2Array* texcoords = new Vec2Array(4);
vertices->push_back(Vec3(-length / 2, width / 2, altitude)); (*texcoords)[0].set(0, 1);
vertices->push_back(Vec3(-length / 2, -width / 2, altitude)); (*texcoords)[1].set(0, 0);
vertices->push_back(Vec3( length / 2, -width / 2, altitude)); (*texcoords)[2].set(1, 0);
vertices->push_back(Vec3( length / 2, width / 2, altitude)); (*texcoords)[3].set(1, 1);
for (int k = 0; k < 4; k++)
{
normals->push_back(Vec3(0, 0, 1));
}
DrawElementsUInt* rectangle = new DrawElementsUInt(PrimitiveSet::POLYGON, 0);
rectangle->push_back(0); rectangle->push_back(1);
rectangle->push_back(2); rectangle->push_back(3);
floorplanGeometry->addPrimitiveSet(rectangle);
floorplanGeometry->setVertexArray(vertices);
floorplanGeometry->setNormalArray(normals);
floorplanGeometry->setTexCoordArray(0, texcoords);
floorplanGeometry->setNormalBinding(Geometry::BIND_PER_VERTEX);
floorplanGeode->addDrawable(floorplanGeometry);
mFloorplanSwitch->addChild(floorplanGeode);
/* load floorplan images */
Material *transmaterial = new Material;
transmaterial->setDiffuse(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
transmaterial->setAlpha(Material::FRONT_AND_BACK, 1.0f);
Image* imgFloorplan = osgDB::readImageFile(pageEntryArray[i]->mTexFilename);
Texture2D* texFloorplan = new Texture2D(imgFloorplan);
StateSet *floorplanStateSet = floorplanGeode->getOrCreateStateSet();
floorplanStateSet->setTextureAttributeAndModes(0, texFloorplan, StateAttribute::ON);
floorplanStateSet->setMode(GL_BLEND, StateAttribute::OVERRIDE | StateAttribute::ON );
floorplanStateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
floorplanStateSet->setAttributeAndModes(transmaterial, StateAttribute::OVERRIDE | StateAttribute::ON);
}
}
开发者ID:Peachychan,项目名称:calvr_plugins,代码行数:64,代码来源:VirtualScenicHandler.cpp
示例14: Vec4
/***************************************************************
* Function: resize()
***************************************************************/
void CAVEGeodeSnapWireframeLine::resize(osg::Vec3 &gridVect)
{
/*
Material* material = new Material;
material->setAmbient(Material::FRONT_AND_BACK, Vec4(0.0, 1.0, 0.0, 1.0));
material->setDiffuse(Material::FRONT_AND_BACK, Vec4(1.0, 1.0, 0.0, 1.0));
material->setSpecular(Material::FRONT_AND_BACK, osg::Vec4( 1.f, 1.f, 1.f, 1.0f));
material->setAlpha(Material::FRONT_AND_BACK, 1.f);
StateSet* stateset = new StateSet();
stateset->setAttributeAndModes(material, StateAttribute::OVERRIDE | StateAttribute::ON);
setStateSet(stateset);
*/
// calculate grid vector
float snapUnitX, snapUnitY, snapUnitZ;
snapUnitX = snapUnitY = snapUnitZ = mSnappingUnitDist;
if (mScaleVect.x() < 0)
snapUnitX = -mSnappingUnitDist;
if (mScaleVect.y() < 0)
snapUnitY = -mSnappingUnitDist;
if (mScaleVect.z() < 0)
snapUnitZ = -mSnappingUnitDist;
int xSeg = (int)(abs((int)((mScaleVect.x() + 0.5 * snapUnitX) / mSnappingUnitDist)));
int ySeg = (int)(abs((int)((mScaleVect.y() + 0.5 * snapUnitY) / mSnappingUnitDist)));
int zSeg = (int)(abs((int)((mScaleVect.z() + 0.5 * snapUnitZ) / mSnappingUnitDist)));
Vec3 roundedVect;
roundedVect.x() = xSeg * snapUnitX; gridVect.x() = roundedVect.x() / mSnappingUnitDist;
roundedVect.y() = ySeg * snapUnitY; gridVect.y() = roundedVect.y() / mSnappingUnitDist;
roundedVect.z() = zSeg * snapUnitZ; gridVect.z() = roundedVect.z() / mSnappingUnitDist;
mDiagonalVect = roundedVect;
// update box corners in 'mBaseGeometry'
float xMin, yMin, zMin, xMax, yMax, zMax;
xMin = mInitPosition.x(); xMax = xMin + roundedVect.x();
yMin = mInitPosition.y(); yMax = yMin + roundedVect.y();
zMin = mInitPosition.z(); zMax = zMin + roundedVect.z();
Array* baseVertArray = mBaseGeometry->getVertexArray();
if (baseVertArray->getType() == Array::Vec3ArrayType)
{
Vec3* vertexArrayDataPtr = (Vec3*) (baseVertArray->getDataPointer());
vertexArrayDataPtr[0] = Vec3(xMax, yMax, zMax);
vertexArrayDataPtr[1] = Vec3(xMin, yMax, zMax);
vertexArrayDataPtr[2] = Vec3(xMin, yMin, zMax);
vertexArrayDataPtr[3] = Vec3(xMax, yMin, zMax);
vertexArrayDataPtr[4] = Vec3(xMax, yMax, zMin);
vertexArrayDataPtr[5] = Vec3(xMin, yMax, zMin);
vertexArrayDataPtr[6] = Vec3(xMin, yMin, zMin);
vertexArrayDataPtr[7] = Vec3(xMax, yMin, zMin);
}
mBaseGeometry->dirtyDisplayList();
mBaseGeometry->dirtyBound();
// update snapping wire geometry
if (mSnapwireGeometry)
removeDrawable(mSnapwireGeometry);
mSnapwireGeometry = new Geometry();
Vec3Array* snapvertices = new Vec3Array;
int vertoffset = 0;
if (xSeg > 1) // (xSeg - 1) * 4 vertices
{
for (int i = 1; i <= xSeg - 1; i++)
{
snapvertices->push_back(Vec3(xMin + i * snapUnitX, yMin, zMin));
snapvertices->push_back(Vec3(xMin + i * snapUnitX, yMax, zMin));
snapvertices->push_back(Vec3(xMin + i * snapUnitX, yMax, zMax));
snapvertices->push_back(Vec3(xMin + i * snapUnitX, yMin, zMax));
DrawElementsUInt* edges = new DrawElementsUInt(PrimitiveSet::LINE_STRIP, 0);
edges->push_back(vertoffset + (i-1)*4);
edges->push_back(vertoffset + (i-1)*4 + 1);
edges->push_back(vertoffset + (i-1)*4 + 2);
edges->push_back(vertoffset + (i-1)*4 + 3);
edges->push_back(vertoffset + (i-1)*4);
mSnapwireGeometry->addPrimitiveSet(edges);
}
vertoffset += (xSeg - 1) * 4;
}
if (ySeg > 1) // (ySeg - 1) * 4 vertices
{
for (int i = 1; i <= ySeg - 1; i++)
{
snapvertices->push_back(Vec3(xMin, yMin + i * snapUnitY, zMin));
snapvertices->push_back(Vec3(xMax, yMin + i * snapUnitY, zMin));
snapvertices->push_back(Vec3(xMax, yMin + i * snapUnitY, zMax));
snapvertices->push_back(Vec3(xMin, yMin + i * snapUnitY, zMax));
DrawElementsUInt* edges = new DrawElementsUInt(PrimitiveSet::LINE_STRIP, 0);
edges->push_back(vertoffset + (i-1)*4);
edges->push_back(vertoffset + (i-1)*4 + 1);
edges->push_back(vertoffset + (i-1)*4 + 2);
edges->push_back(vertoffset + (i-1)*4 + 3);
edges->push_back(vertoffset + (i-1)*4);
mSnapwireGeometry->addPrimitiveSet(edges);
//.........这里部分代码省略.........
开发者ID:CalVR,项目名称:calvr_plugins,代码行数:101,代码来源:CAVEGeodeSnapWireframe.cpp
示例15: V_RETURN
//.........这里部分代码省略.........
GLuint *pIndices = QSE_NEW GLuint[m_sides * 2 * 3];
GLuint *current = pIndices;
for (DWORD i = 0; i<m_sides; i++)
{
// Triangle #1 ACB
*(current) = GLuint(i * 4);
*(current + 1) = GLuint(i * 4 + 2);
*(current + 2) = GLuint(i * 4 + 1);
// Triangle #2 BCD
*(current + 3) = GLuint(i * 4 + 1);
*(current + 4) = GLuint(i * 4 + 2);
*(current + 5) = GLuint(i * 4 + 3);
current += 6;
}
data.mIndices = GLUFArrToVec(pIndices, m_sides * 2 * 3);
//now the indicies
/*glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_IndexBuffer);
glBufferStorage(GL_ELEMENT_ARRAY_BUFFER, m_sides * 2 * 3 * sizeof(GLfloat), m_IndexBufferData.data(), GL_STATIC_DRAW);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
SAFE_DELETE_ARRAY(pIndices);
//buffer the data
m_pVertexArray.BufferData(mPositionLoc, data.mPositions.size(), &data.mPositions[0]);
m_pVertexArray.BufferData(mUVLoc, data.mUVCoords.size(), &data.mPositions[0]);
m_pVertexArray.BufferIndices(pIndices, m_sides * 2 * 3);
*/
Vec3Array verts;
float val = 1.0f;
float depth = val;
m_sides = 6;
//float N = 1.0f / sqrt(3.0f);
//north
/*verts.push_back(glm::vec3(-val, -val, depth));
verts.push_back(glm::vec3(val, -val, depth));
verts.push_back(glm::vec3(val, val, depth));
verts.push_back(glm::vec3(-val, val, depth));
//uvws.push_back(glm::vec3(-N, -N, N));
//uvws.push_back(glm::vec3(N, -N, N));
//uvws.push_back(glm::vec3(N, N, N));
//uvws.push_back(glm::vec3(-N, N, N));
//south
verts.push_back(glm::vec3(val, -val, -depth));
verts.push_back(glm::vec3(-val, -val, -depth));
verts.push_back(glm::vec3(-val, val, -depth));
verts.push_back(glm::vec3(val, val, -depth));
//uvws.push_back(glm::vec3(N, -N, -N));
//uvws.push_back(glm::vec3(-N, -N, -N));
//uvws.push_back(glm::vec3(-N, N, -N));
//uvws.push_back(glm::vec3(N, N, -N));
//east
开发者ID:KevinMackenzie,项目名称:AmberRabbit,代码行数:67,代码来源:Sky.cpp
示例16: g
void DragonBustNode::genBezierIKMatrices()
{
/* Copy translation values to bezier chain for bezier-based IK solving. */
for (uint i = 0; i < _nBones; i++)
{
_bezierIKChain[i]._length = _globalIKChain[i]._length;
_bezierIKChain[i]._pose._localPoseTranslation = _globalIKChain[i]._pose._localPoseTranslation;
}
/* Generate segments along bezier curve. */
/* DEBUG: armature rendering. */
Vec3Array points;
_renderer->setWorldTransformation(_W);
Vec3Array g(3);
g[0] = Vec3(0, 0, 0);
g[1] = Vec3(0, 10.0, -1.0);
g[2] = Vec3(0, 5, 6);
/* Tuning for cursor-following. */
if (_input->isEntered)
{
g[1].x = -(_input->x-0.5f)*2.5f;
g[2].x = 10.0f*(_input->x-0.5f);
g[2].y = -(5.0f*(_input->y-1.75));
}
else
{
g[2].y = 6.25f;
}
_target = g[2];
/* Apply acceleration to points. */
float fac;
float d;
Vec3 lookAtTargetDir;
Vec3 vel;
Vec3 lookAtTarget;
lookAtTarget = g[1] - _lookAtPosG1;
if (lookAtTarget != Vec3(0,0,0))
{
d = glm::length(lookAtTarget);
fac = (d*2);
lookAtTargetDir = glm::normalize(lookAtTarget);
vel = 2.0f * fac * lookAtTargetDir;
_lookAtPosG1 += vel * *_tDelta;
g[1] = _lookAtPosG1;
}
lookAtTarget = g[2] - _lookAtPosG2;
d = glm::length(lookAtTarget);
fac = (d*2);
lookAtTargetDir = glm::normalize(lookAtTarget);
vel = 2.0f * fac * lookAtTargetDir;
_lookAtPosG2 += vel * *_tDelta;
g[2] = _lookAtPosG2;
points.push_back(g[0]);
points.push_back(g[1]);
points.push_back(g[1]);
points.push_back(g[2]);
_renderer->renderDebug(points, 5.0f);
Vec3Array bezPoints;
genBezierSubdivide(g, 3, bezPoints);
uint segmentCount = 8;
_renderer->renderDebug(bezPoints, 5.0f);
/* Compact list of points for intersection testing. */
Vec3Array segmentPoints;
for (uint i = 0; i < bezPoints.size(); i+=2)
{
segmentPoints.push_back(bezPoints[i]);
}
segmentPoints.push_back(bezPoints[bezPoints.size()-1]);
/* Match armature _ik_global_chain[i] to curve. */
Vec3 p1; /* Start delimiter of line segment. */
Vec3 p2; /* End delimiter of line segment. */
Vec3 p3; /* Location of sphere centre. */
Vec3 p; /* Location of intersection. */
Vec3 t; /* Translation vector for realignment of child joints. */
float r; /* Sphere radius. */
int segmentIndex = -1;
/* For each bone. */
for (uint i = 0; i < _nBones-1; i++)
{
/*
* Get radius of sphere defined by all possible rotations of the
* current bone "vector".
*/
r = _bezierIKChain[i]._length;
/* Get location of sphere's centre. */
p3 = _bezierIKChain[i]._pose._localPoseTranslation;
//.........这里部分代码省略.........
开发者ID:mattmw,项目名称:charsim,代码行数:101,代码来源:DragonBustNode.cpp
示例17: ANIMCreateSinglePageGeodeAnimation
/***************************************************************
* Function: ANIMCreateSinglePageGeodeAnimation()
***************************************************************/
void ANIMCreateSinglePageGeodeAnimation(const string& texfilename, Geode **flipUpGeode, Geode **flipDownGeode,
AnimationPathCallback **flipUpCallback, AnimationPathCallback **flipDownCallback)
{
/* coordinates of page object */
Vec3 topleft = Vec3(-0.19, 0, 0);
Vec3 bottomleft = Vec3(-0.19, 0, -0.28);
Vec3 bottomright = Vec3( 0.19, 0, -0.28);
Vec3 topright = Vec3( 0.19, 0, 0);
Vec3 start = Vec3(0, -0.004, 0);
Vec3 end = Vec3(0, 0.008, 0);
float pageH = 0.28, pageW = 0.38;
/* create page pain geometry */
*flipUpGeode = new Geode;
*flipDownGeode = new Geode;
Geometry *pageGeometry = new Geometry();
Vec3Array* vertices = new Vec3Array;
Vec2Array* texcoords = new Vec2Array(4);
Vec3Array* normals = new Vec3Array;
vertices->push_back(topleft); (*texcoords)[0].set(0, 1);
vertices->push_back(bottomleft); (*texcoords)[1].set(0, 0);
vertices->push_back(bottomright); (*texcoords)[2].set(1, 0);
vertices->push_back(topright); (*texcoords)[3].set(1, 1);
for (int i = 0; i < 4; i++)
{
normals->push_back(Vec3(0, -1, 0));
}
DrawElementsUInt* rectangle = new DrawElementsUInt(PrimitiveSet::POLYGON, 0);
rectangle->push_back(0); rectangle->push_back(1);
rectangle->push_back(2); rectangle->push_back(3);
pageGeometry->addPrimitiveSet(rectangle);
pageGeometry->setVertexArray(vertices);
pageGeometry->setTexCoordArray(0, texcoords);
pageGeometry->setNormalArray(normals);
pageGeometry->setNormalBinding(Geometry::BIND_PER_VERTEX);
(*flipUpGeode)->addDrawable(pageGeometry);
(*flipDownGeode)->addDrawable(pageGeometry);
/* apply image textures to page geodes */
Image* imgFloorplan = osgDB::readImageFile(texfilename);
int imgW = imgFloorplan->s();
int imgH = imgFloorplan->t();
Texture2D* texFloorplan = new Texture2D(imgFloorplan);
texFloorplan->setWrap(Texture::WRAP_S, Texture::CLAMP);
texFloorplan->setWrap(Texture::WRAP_T, Texture::CLAMP);
float imgRatio = (float) imgW / imgH;
float pageRatio = pageW / pageH;
if (imgRatio <= pageRatio)
{
(*texcoords)[0].set((1.0 - pageRatio / imgRatio) * 0.5, 1);
(*texcoords)[1].set((1.0 - pageRatio / imgRatio) * 0.5, 0);
(*texcoords)[2].set((1.0 + pageRatio / imgRatio) * 0.5, 0);
(*texcoords)[3].set((1.0 + pageRatio / imgRatio) * 0.5, 1);
}
else
{
(*texcoords)[0].set(0, (1.0 + imgRatio / pageRatio) * 0.5);
(*texcoords)[1].set(0, (1.0 - imgRatio / pageRatio) * 0.5);
(*texcoords)[2].set(1, (1.0 - imgRatio / pageRatio) * 0.5);
(*texcoords)[3].set(1, (1.0 + imgRatio / pageRatio) * 0.5);
}
Material *transmaterial = new Material;
transmaterial->setDiffuse(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
transmaterial->setAlpha(Material::FRONT_AND_BACK, 0.8f);
Material *solidmaterial = new Material;
solidmaterial->setDiffuse(Material::FRONT_AND_BACK, Vec4(1, 1, 1, 1));
solidmaterial->setAlpha(Material::FRONT_AND_BACK, 1.0f);
StateSet *flipUpStateSet = (*flipUpGeode)->getOrCreateStateSet();
flipUpStateSet->setTextureAttributeAndModes(0, texFloorplan, StateAttribute::ON);
flipUpStateSet->setMode(GL_BLEND, StateAttribute::OVERRIDE | StateAttribute::ON );
flipUpStateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
flipUpStateSet->setAttributeAndModes(transmaterial, StateAttribute::OVERRIDE | StateAttribute::ON);
StateSet *flipDownStateSet = (*flipDownGeode)->getOrCreateStateSet();
flipDownStateSet->setTextureAttributeAndModes(0, texFloorplan, StateAttribute::ON);
flipDownStateSet->setMode(GL_BLEND, StateAttribute::OVERRIDE | StateAttribute::ON );
flipDownStateSet->setRenderingHint(StateSet::TRANSPARENT_BIN);
flipDownStateSet->setAttributeAndModes(solidmaterial, StateAttribute::OVERRIDE | StateAttribute::ON);
/* create page flipping animation call backs */
AnimationPath* animationPathFlipUp = new AnimationPath;
AnimationPath* animationPathFlipDown = new AnimationPath;
animationPathFlipUp->setLoopMode(AnimationPath::NO_LOOPING);
animati
|
请发表评论