本文整理汇总了C++中GeoPositions3fPtr类的典型用法代码示例。如果您正苦于以下问题:C++ GeoPositions3fPtr类的具体用法?C++ GeoPositions3fPtr怎么用?C++ GeoPositions3fPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GeoPositions3fPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initWave
static void initWave(void)
{
_size = (int) sqrt((float) _geo->getPositions()->getSize());
_surf.resize(_size);
for(UInt32 i=0;i<_size;++i)
_surf[i].resize(_size);
_force.resize(_size);
for(UInt32 i=0;i<_size;++i)
_force[i].resize(_size);
_veloc.resize(_size);
for(UInt32 i=0;i<_size;++i)
_veloc[i].resize(_size);
_surfo.resize(_size);
for(UInt32 i=0;i<_size;++i)
_surfo[i].resize(_size);
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(_geo->getPositions());
MFPnt3f *p = pos->getFieldPtr();
beginEditCP(pos);
{
int c = 0;
for(int i=0;i<_size;i++)
{
for(int j=0;j<_size;j++)
_surfo[i][j] = (*p)[c++][2];
}
}
endEditCP(pos);
}
示例2: display
void display(void)
{
Real32 time = glutGet(GLUT_ELAPSED_TIME);
updateMesh(time);
// we extract the core out of the root node
// as we now this is a geometry node
GeometryPtr geo = GeometryPtr::dcast(scene->getChild(0)->getCore());
//now modify it's content
// first we need a pointer to the position data field
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(geo->getPositions());
//get the data field the pointer is pointing at
GeoPositions3f::StoredFieldType *posfield = pos->getFieldPtr();
//get some iterators
GeoPositions3f::StoredFieldType::iterator last, it;
// set the iterator to the first data
it = posfield->begin();
beginEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
//now simply run over all entires in the array
for (int x = 0; x < N; x++)
for (int z = 0; z < N; z++){
(*it) = Pnt3f(x, wMesh[x][z], z);
it++;
}
endEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
mgr->redraw();
}
示例3: makePolygon
OSG::NodePtr makePolygon(double pntData[][3], int numPoints) {
OSG::GeometryPtr geoPtr = OSG::Geometry::create();
OSG::NodePtr nodePtr = OSG::Node::create();
GeoPositions3fPtr pnts = GeoPositions3f::create();
GeoNormals3fPtr norms = GeoNormals3f::create();
GeoTexCoords2fPtr tex = GeoTexCoords2f::create();
GeoIndicesUI32Ptr indices = GeoIndicesUI32::create();
GeoPLengthsUI32Ptr lens = GeoPLengthsUI32::create();
GeoPTypesUI8Ptr types = GeoPTypesUI8::create();
//Set up the properties according to the geometry defined above
beginEditCP(pnts);
beginEditCP(norms);
for(int i = 0; i < numPoints; i++)
{
pnts->push_back(Pnt3f(pntData[i][0],
pntData[i][1],
pntData[i][2]));
indices->push_back(2*i);
norms->push_back(Vec3f(0.0, 0.0, pntData[i][2]));
indices->push_back(2*i + 1);
}
endEditCP(pnts);
endEditCP(norms);
beginEditCP(types);
beginEditCP(lens);
types->push_back(GL_POLYGON);
lens->push_back(numPoints);
endEditCP(types);
endEditCP(lens);
beginEditCP(geoPtr);
geoPtr->setMaterial(getDefaultMaterial());
geoPtr->setPositions(pnts);
geoPtr->setNormals(norms);
geoPtr->setIndices(indices);
geoPtr->editMFIndexMapping()->push_back(Geometry::MapPosition |
Geometry::MapNormal);
geoPtr->setTypes(types);
geoPtr->setLengths(lens);
endEditCP(geoPtr);
nodePtr->setCore(geoPtr);
return nodePtr;
}
示例4: updateGeometry
static void updateGeometry(GeometryPtr geo)
{
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(geo->getPositions());
// p->setValue() is faster than pos->setValue()
MFPnt3f *p = pos->getFieldPtr();
beginEditCP(pos);
int c = 0;
for(int i=0;i<_size;++i)
{
for(int j=0;j<_size;++j)
{
Pnt3f &pp = (*p)[c++];
pp[2] = _surfo[i][j] + _surf[i][j];
}
}
endEditCP(pos);
}
示例5: getTXFNVertices
bool Text::fillTXFGeo(Geometry &mesh, bool isNew,
std::vector<std::string> &lineVec)
{
Int32 numVerts;
GeoPositions3fPtr pos;
GeoTexCoords2fPtr tex;
numVerts = getTXFNVertices(lineVec);
if(isNew)
{
GeoNormals3fPtr normals = GeoNormals3f::create();
GeoPTypesUI8Ptr ftypes = GeoPTypesUI8::create();
pos = GeoPositions3f::create();
tex = GeoTexCoords2f::create();
ftypes->addValue(GL_QUADS);
normals->addValue(Vec3f(0.0, 0.0, -1.0));
mesh.setPositions(pos);
mesh.setTexCoords(tex);
mesh.setNormals(normals);
mesh.setTypes(ftypes);
}
else
{
pos = GeoPositions3fPtr::dcast(mesh.getPositions());
tex = GeoTexCoords2fPtr::dcast(mesh.getTexCoords());
}
pos->resize(numVerts);
tex->resize(numVerts);
fillTXFArrays(lineVec, &pos->editField()[0], &tex->editField()[0]);
return true;
}
示例6: display
void display(void)
{
Real32 time = glutGet(GLUT_ELAPSED_TIME);
updateMesh(time);
// we extract the core out of the root node
// as we now this is a geometry node
GeometryPtr geo = GeometryPtr::dcast(scene->getCore());
//now modify it's content
// first we need a pointer to the position data field
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(geo->getPositions());
//this loop is similar to when we generted the data during createScenegraph()
beginEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
// here they all come
for (int x = 0; x < N; x++)
for (int z = 0; z < N; z++)
pos->setValue(Pnt3f(x, wMesh[x][z], z), N*x+z);
endEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
mgr->redraw();
}
示例7: if
//.........这里部分代码省略.........
// double rotation[3];
_actor->GetPosition(translation);
_actor->GetScale(scaling);
//_actor->GetRotation(rotation[0], rotation[1], rotation[2]);
if (_verbose)
std::cout << "set scaling: " << scaling[0] << " " << scaling[1] << " " <<
scaling[2] << std::endl;
osg::Matrix m;
m.setIdentity();
m.setTranslate(translation[0], translation[1], translation[2]);
m.setScale(scaling[0], scaling[1], scaling[2]);
// TODO QUATERNION m.setRotate(rotation[0], rotation[1], rotation[2])
beginEditCP(_osgTransform);
_osgTransform->setMatrix(m);
endEditCP(_osgTransform);
//pm->Update();
// Get the converted OpenSG node
NodePtr osgGeomNode = Node::create();
GeometryPtr osgGeometry = Geometry::create();
beginEditCP(osgGeomNode);
osgGeomNode->setCore(osgGeometry);
endEditCP(osgGeomNode);
bool osgConversionSuccess = false;
GeoPTypesPtr osgTypes = GeoPTypesUI8::create();
GeoPLengthsPtr osgLengths = GeoPLengthsUI32::create();
GeoIndicesUI32Ptr osgIndices = GeoIndicesUI32::create();
GeoPositions3fPtr osgPoints = GeoPositions3f::create();
GeoNormals3fPtr osgNormals = GeoNormals3f::create();
GeoColors3fPtr osgColors = GeoColors3f::create();
GeoTexCoords2dPtr osgTexCoords = GeoTexCoords2d::create();
//Rendering with OpenSG simple indexed geometry
if (((m_iNormalType == PER_VERTEX) || (m_iNormalType == NOT_GIVEN)) &&
((m_iColorType == PER_VERTEX) || (m_iColorType == NOT_GIVEN)))
{
if (_verbose)
std::cout << "Start ProcessGeometryNormalsAndColorsPerVertex()" << std::endl;
//getting the vertices:
beginEditCP(osgPoints);
{
for (int i = 0; i < m_iNumPoints; i++)
{
double* aVertex = pd->GetPoint(i);
osgPoints->addValue(Vec3f(aVertex[0], aVertex[1], aVertex[2]));
}
} endEditCP(osgPoints);
//possibly getting the normals
if (m_iNormalType == PER_VERTEX)
{
vtkIdType iNumNormals = vtkNormals->GetNumberOfTuples();
beginEditCP(osgNormals);
{
double* aNormal;
for (int i = 0; i < iNumNormals; i++)
{
aNormal = vtkNormals->GetTuple(i);
osgNormals->addValue(Vec3f(aNormal[0], aNormal[1], aNormal[2]));
示例8: createCoordinateCross
// Create the coordinate cross
NodePtr createCoordinateCross()
{
GeometryPtr geoPtr = Geometry::create();
beginEditCP(geoPtr);
{
GeoPTypesUI8Ptr typesPtr = GeoPTypesUI8::create();
typesPtr->push_back(GL_LINES);
geoPtr->setTypes(typesPtr);
GeoPLengthsUI32Ptr lensPtr = GeoPLengthsUI32::create();
lensPtr->push_back(6);
geoPtr->setLengths(lensPtr);
GeoPositions3fPtr posPtr = GeoPositions3f::create();
posPtr->push_back(Vec3f(-0.1f, 0.f, 0.f));
posPtr->push_back(Vec3f(1.f, 0.f, 0.f));
posPtr->push_back(Vec3f(0.f, -0.1f, 0.f));
posPtr->push_back(Vec3f(0.f, 1.f, 0.f));
posPtr->push_back(Vec3f(0.f, 0.f, -0.1f));
posPtr->push_back(Vec3f(0.f, 0.f, 1.f));
geoPtr->setPositions(posPtr);
GeoColors3fPtr colorsPtr = GeoColors3f::create();
colorsPtr->push_back(Color3f(1.f, 0.f, 0.f));
colorsPtr->push_back(Color3f(0.f, 1.f, 0.f));
colorsPtr->push_back(Color3f(0.f, 0.f, 1.f));
geoPtr->setColors(colorsPtr);
GeoIndicesUI32Ptr indicesPtr = GeoIndicesUI32::create();
// X Axis
indicesPtr->push_back(0);
indicesPtr->push_back(0);
indicesPtr->push_back(1);
indicesPtr->push_back(0);
// Y Axis
indicesPtr->push_back(2);
indicesPtr->push_back(1);
indicesPtr->push_back(3);
indicesPtr->push_back(1);
// Z Axis
indicesPtr->push_back(4);
indicesPtr->push_back(2);
indicesPtr->push_back(5);
indicesPtr->push_back(2);
geoPtr->setIndices(indicesPtr);
geoPtr->editMFIndexMapping()->clear();
geoPtr->editMFIndexMapping()->push_back(Geometry::MapPosition);
geoPtr->editMFIndexMapping()->push_back(Geometry::MapColor);
SimpleMaterialPtr matPtr = SimpleMaterial::create();
geoPtr->setMaterial(matPtr);
}
endEditCP(geoPtr);
NodePtr nodePtr = Node::create();
beginEditCP(nodePtr, Node::CoreFieldMask);
{
nodePtr->setCore(geoPtr);
}
endEditCP(nodePtr, Node::CoreFieldMask);
return nodePtr;
}
示例9: createMetrics
// Create the metrics
NodePtr createMetrics(TextFace *face, Real32 scale, const TextLayoutParam &layoutParam,
const TextLayoutResult &layoutResult)
{
GeometryPtr geoPtr = Geometry::create();
beginEditCP(geoPtr);
{
GeoPTypesUI8Ptr typesPtr = GeoPTypesUI8::create();
geoPtr->setTypes(typesPtr);
GeoPLengthsUI32Ptr lensPtr = GeoPLengthsUI32::create();
geoPtr->setLengths(lensPtr);
GeoPositions3fPtr posPtr = GeoPositions3f::create();
geoPtr->setPositions(posPtr);
GeoColors3fPtr colorsPtr = GeoColors3f::create();
colorsPtr->push_back(Color3f(0.f, 0.f, 1.f));
colorsPtr->push_back(Color3f(1.f, 0.f, 0.f));
colorsPtr->push_back(Color3f(0.f, 1.f, 0.f));
colorsPtr->push_back(Color3f(1.f, 1.f, 0.f));
geoPtr->setColors(colorsPtr);
GeoIndicesUI32Ptr indicesPtr = GeoIndicesUI32::create();
geoPtr->setIndices(indicesPtr);
UInt32 i, numGlyphs = layoutResult.getNumGlyphs();
for (i = 0; i < numGlyphs; ++i)
{
const TextGlyph &glyph = face->getGlyph(layoutResult.indices[i]);
typesPtr->push_back(GL_LINE_LOOP);
lensPtr->push_back(4);
const Vec2f &pos = layoutResult.positions[i];
Real32 left = pos.x() * scale;
Real32 right = (pos.x() + glyph.getWidth()) * scale;
Real32 top = pos.y() * scale;
Real32 bottom = (pos.y() - glyph.getHeight()) * scale;
UInt32 posOffset = posPtr->size();
posPtr->push_back(Vec3f(left, bottom, 0.f));
posPtr->push_back(Vec3f(right, bottom, 0.f));
posPtr->push_back(Vec3f(right, top, 0.f));
posPtr->push_back(Vec3f(left, top, 0.f));
indicesPtr->push_back(posOffset);
indicesPtr->push_back(0);
indicesPtr->push_back(posOffset + 1);
indicesPtr->push_back(0);
indicesPtr->push_back(posOffset + 2);
indicesPtr->push_back(0);
indicesPtr->push_back(posOffset + 3);
indicesPtr->push_back(0);
}
// Bounding box
Vec2f lowerLeft, upperRight;
face->calculateBoundingBox(layoutResult, lowerLeft, upperRight);
typesPtr->push_back(GL_LINE_LOOP);
lensPtr->push_back(4);
Real32 left = lowerLeft.x() * scale;
Real32 right = upperRight.x() * scale;
Real32 top = upperRight.y() * scale;
Real32 bottom = lowerLeft.y() * scale;
UInt32 posOffset = posPtr->size();
posPtr->push_back(Vec3f(left, bottom, 0.f));
posPtr->push_back(Vec3f(right, bottom, 0.f));
posPtr->push_back(Vec3f(right, top, 0.f));
posPtr->push_back(Vec3f(left, top, 0.f));
indicesPtr->push_back(posOffset);
indicesPtr->push_back(1);
indicesPtr->push_back(posOffset + 1);
indicesPtr->push_back(1);
indicesPtr->push_back(posOffset + 2);
indicesPtr->push_back(1);
indicesPtr->push_back(posOffset + 3);
indicesPtr->push_back(1);
// Text bounds & Line bounds
Vec2f pos, textPos, offset;
if (layoutParam.horizontal == true)
{
Real32 lineHeight = face->getHoriAscent() - face->getHoriDescent();
Real32 spacing = layoutParam.spacing * lineHeight;
if (layoutParam.topToBottom == true)
{
switch (layoutParam.minorAlignment)
{
case TextLayoutParam::ALIGN_BEGIN:
break;
case TextLayoutParam::ALIGN_FIRST:
pos[1] = textPos[1] = face->getHoriAscent();
break;
case TextLayoutParam::ALIGN_MIDDLE:
pos[1] = textPos[1] = (spacing * (layoutResult.lineBounds.size() - 1) + lineHeight) / 2.f;
break;
case TextLayoutParam::ALIGN_END:
pos[1] = textPos[1] = spacing * (layoutResult.lineBounds.size() - 1) + lineHeight;
break;
}
offset.setValues(0.f, -spacing);
}
else
//.........这里部分代码省略.........
示例10: calcVertexNormals
static void calcVertexNormals(GeometryPtr geo)
{
GeoNormals3fPtr norms = GeoNormals3fPtr::dcast(geo->getNormals());
GeoPositions3fPtr pos = GeoPositions3fPtr::dcast(geo->getPositions());
MFPnt3f *p = pos->getFieldPtr();
MFVec3f *n = norms->getFieldPtr();
beginEditCP(norms);
Vec3f a, b, c;
int l = 0;
for(int i=0; i<_size; ++i)
{
for(int j=0; j<_size; ++j)
{
int m = i*_size+j;
if (i!=_size-1 && j!=_size-1)
{
a = (*p)[l+m+1] - (*p)[l+m];
b = (*p)[l+m+_size] - (*p)[l+m];
}
else
{
a = (*p)[l+m-1] - (*p)[l+m];
int index = l+m-_size;
if(index < 0)
index += norms->getSize();
b = (*p)[index] - (*p)[l+m];
}
c = a.cross(b);
c.normalize();
if (i==0 && j==_size-1)
{
a = (*p)[l+m-1] - (*p)[l+m];
b = (*p)[l+m+_size] - (*p)[l+m];
c = a.cross(b);
c.normalize();
c.negate();
}
if (i==_size-1 && j==0)
{
a = (*p)[l+m-_size] - (*p)[l+m];
b = (*p)[l+m+1] - (*p)[l+m];
c = a.cross(b);
c.normalize();
}
(*n)[l+m] = c;
}
}
l += _size*_size;
endEditCP(norms);
}
示例11: main
int main(int argc, char **argv)
{
// OSG init
osgInit(argc,argv);
// Set up Window
TutorialWindowEventProducer = createDefaultWindowEventProducer();
WindowPtr MainWindow = TutorialWindowEventProducer->initWindow();
TutorialWindowEventProducer->setDisplayCallback(display);
TutorialWindowEventProducer->setReshapeCallback(reshape);
TutorialUpdateListener TheTutorialUpdateListener;
TutorialWindowEventProducer->addUpdateListener(&TheTutorialUpdateListener);
//Add Window Listener
TutorialKeyListener TheKeyListener;
TutorialWindowEventProducer->addKeyListener(&TheKeyListener);
TutorialMouseListener TheTutorialMouseListener;
TutorialMouseMotionListener TheTutorialMouseMotionListener;
TutorialWindowEventProducer->addMouseListener(&TheTutorialMouseListener);
TutorialWindowEventProducer->addMouseMotionListener(&TheTutorialMouseMotionListener);
// Create the SimpleSceneManager helper
mgr = new SimpleSceneManager;
// Tell the Manager what to manage
mgr->setWindow(MainWindow);
//Print key command info
std::cout << "\n\nKEY COMMANDS:" << std::endl;
std::cout << "space Play/Pause the animation" << std::endl;
std::cout << "G Show/Hide the grid" << std::endl;
std::cout << "A Show/Hide the axes" << std::endl;
std::cout << "B Show/Hide the bind pose skeleton" << std::endl;
std::cout << "SHIFT-B Show/Hide the bind pose mesh" << std::endl;
std::cout << "P Show/Hide the current pose skeleton" << std::endl;
std::cout << "SHIFT-P Show/Hide the current pose mesh" << std::endl;
std::cout << "CTRL-Q Exit\n\n" << std::endl;
//Setup axes
LineChunkPtr AxesLineChunk = LineChunk::create();
beginEditCP(AxesLineChunk);
AxesLineChunk->setWidth(0.0f);
AxesLineChunk->setSmooth(true);
endEditCP(AxesLineChunk);
//Axes material
ChunkMaterialPtr AxesMaterial = ChunkMaterial::create();
beginEditCP(AxesMaterial, ChunkMaterial::ChunksFieldMask);
AxesMaterial->addChunk(AxesLineChunk);
endEditCP(AxesMaterial, ChunkMaterial::ChunksFieldMask);
//Grid material
ChunkMaterialPtr gridMaterial = ChunkMaterial::create();
beginEditCP(gridMaterial, ChunkMaterial::ChunksFieldMask);
gridMaterial->addChunk(AxesLineChunk);
endEditCP(gridMaterial, ChunkMaterial::ChunksFieldMask);
//Axes should render as lines
GeoPTypesPtr axesType = GeoPTypesUI8::create();
beginEditCP(axesType, GeoPTypesUI8::GeoPropDataFieldMask);
{
axesType->addValue(GL_LINES);
}
endEditCP (axesType, GeoPTypesUI8::GeoPropDataFieldMask);
//Grid type
GeoPTypesPtr gridType = GeoPTypesUI8::create();
beginEditCP(gridType, GeoPTypesUI8::GeoPropDataFieldMask);
{
gridType->addValue(GL_LINES);
}
endEditCP (gridType, GeoPTypesUI8::GeoPropDataFieldMask);
//Axes lens
GeoPLengthsPtr axesLens = GeoPLengthsUI32::create();
beginEditCP(axesLens, GeoPLengthsUI32::GeoPropDataFieldMask);
{
axesLens->addValue(6);
}
endEditCP (axesLens, GeoPLengthsUI32::GeoPropDataFieldMask);
//Grid lens
GeoPLengthsPtr gridLens = GeoPLengthsUI32::create();
beginEditCP(gridLens, GeoPLengthsUI32::GeoPropDataFieldMask);
{
gridLens->addValue(84);
}
endEditCP (gridLens, GeoPLengthsUI32::GeoPropDataFieldMask);
//Axes points
GeoPositions3fPtr axesPnts = GeoPositions3f::create();
beginEditCP(axesPnts, GeoPositions3f::GeoPropDataFieldMask);
{
// X-Axis
//.........这里部分代码省略.........
示例12: createScenegraph
NodePtr createScenegraph(){
// the scene must be created here
for (int x = 0; x < N; x++)
for (int z = 0; z < N; z++)
wMesh[x][z] = 0;
// GeoPTypes will define the types of primitives to be used
GeoPTypesPtr type = GeoPTypesUI8::create();
beginEditCP(type, GeoPTypesUI8::GeoPropDataFieldMask);
// we want to use quads ONLY
type->addValue(GL_QUADS);
endEditCP(type, GeoPTypesUI8::GeoPropDataFieldMask);
// GeoPLength will define the number of vertices of
// the used primitives
GeoPLengthsPtr length = GeoPLengthsUI32::create();
beginEditCP(length, GeoPLengthsUI32::GeoPropDataFieldMask);
// the length of our quads is four ;-)
length->addValue((N-1)*(N-1)*4);
endEditCP(length, GeoPLengthsUI32::GeoPropDataFieldMask);
// GeoPositions3f stores the positions of all vertices used in
// this specific geometry core
GeoPositions3fPtr pos = GeoPositions3f::create();
beginEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
// here they all come
for (int x = 0; x < N; x++)
for (int z = 0; z < N; z++)
pos->addValue(Pnt3f(x, wMesh[x][z], z));
endEditCP(pos, GeoPositions3f::GeoPropDataFieldMask);
//GeoColors3f stores all color values that will be used
GeoColors3fPtr colors = GeoColors3f::create();
beginEditCP(colors, GeoColors3f::GeoPropDataFieldMask);
for (int x = 0; x < N; x++)
for (int z = 0; z < N; z++)
colors->addValue(Color3f(0,0,1));
endEditCP(colors, GeoColors3f::GeoPropDataFieldMask);
GeoNormals3fPtr norms = GeoNormals3f::create();
beginEditCP(norms, GeoNormals3f::GeoPropDataFieldMask);
for (int x = 0; x < N; x++)
for (int z = 0; z < N; z++)
// As initially all heights are set to zero thus yielding a plane,
// we set all normals to (0,1,0) parallel to the y-axis
norms->addValue(Vec3f(0,1,0));
endEditCP(norms, GeoNormals3f::GeoPropDataFieldMask);
SimpleMaterialPtr mat = SimpleMaterial::create();
beginEditCP(mat);
mat->setDiffuse(Color3f(0,0,1));
endEditCP(mat);
// GeoIndicesUI32 points to all relevant data used by the
// provided primitives
GeoIndicesUI32Ptr indices = GeoIndicesUI32::create();
beginEditCP(indices, GeoIndicesUI32::GeoPropDataFieldMask);
for (int x = 0; x < N-1; x++)
for (int z = 0; z < N-1; z++){
// points to four vertices that will
// define a single quad
indices->addValue(z*N+x);
indices->addValue((z+1)*N+x);
indices->addValue((z+1)*N+x+1);
indices->addValue(z*N+x+1);
}
endEditCP(indices, GeoIndicesUI32::GeoPropDataFieldMask);
GeometryPtr geo = Geometry::create();
beginEditCP(geo,
Geometry::TypesFieldMask |
Geometry::LengthsFieldMask |
Geometry::IndicesFieldMask |
Geometry::PositionsFieldMask |
Geometry::NormalsFieldMask |
Geometry::MaterialFieldMask |
Geometry::ColorsFieldMask |
Geometry::DlistCacheFieldMask
);
geo->setTypes(type);
geo->setLengths(length);
geo->setIndices(indices);
geo->setPositions(pos);
geo->setNormals(norms);
geo->setMaterial(mat);
//geo->setColors(colors);
geo->setDlistCache(false);
endEditCP(geo,
Geometry::TypesFieldMask |
Geometry::LengthsFieldMask |
Geometry::IndicesFieldMask |
Geometry::PositionsFieldMask |
Geometry::NormalsFieldMask |
Geometry::MaterialFieldMask |
Geometry::ColorsFieldMask |
Geometry::DlistCacheFieldMask
);
//.........这里部分代码省略.........
示例13: triIt
void
updateRayGeo(void)
{
Line &ray = testRays[uiCurrentRay];
IntersectResult &res = resultsP[uiCurrentRay];
Pnt3f startPnt = ray.getPosition();
Pnt3f endPnt = startPnt + (rayLength * ray.getDirection());
beginEditCP(pPoints);
pPoints->setValue(startPnt, 0);
pPoints->setValue(endPnt, 1);
if(res._hit == true)
{
TriangleIterator triIt(res._pObj);
Matrix matrix;
Pnt3f point;
triIt.seek(res._tri);
res._pObj->getToWorld(matrix);
point = triIt.getPosition(0);
matrix.mult(point, point);
pPoints->setValue(point, 2);
point = triIt.getPosition(1);
matrix.mult(point, point);
pPoints->setValue(point, 3);
point = triIt.getPosition(2);
matrix.mult(point, point);
pPoints->setValue(point, 4);
}
else
{
pPoints->setValue(Pnt3f(0.0, 0.0, 0.0), 2);
pPoints->setValue(Pnt3f(0.0, 0.0, 0.0), 3);
pPoints->setValue(Pnt3f(0.0, 0.0, 0.0), 4);
}
endEditCP (pPoints);
}
示例14: main
int main(int argc, char *argv[])
{
osgLogP->setLogLevel(LOG_NOTICE);
osgInit(argc, argv);
int winid = setupGLUT(&argc, argv);
// create a GLUT window
GLUTWindowPtr gwin = GLUTWindow::create();
gwin->setId(winid);
gwin->init();
osgLogP->setLogLevel(LOG_DEBUG);
// build the test scene
NodePtr pRoot = Node ::create();
GroupPtr pRootCore = Group::create();
NodePtr pRayGeo = Node ::create();
NodePtr pScene = buildGraph();
GroupPtr pSceneCore = Group::create();
Time tStart;
Time tStop;
Time tDFTotal = 0.0;
Time tDFSTotal = 0.0;
Time tPTotal = 0.0;
Time tOTotal = 0.0;
StatCollector statP;
StatCollector statDF;
StatCollector statDFS;
beginEditCP(pRoot, Node::CoreFieldId | Node::ChildrenFieldId);
pRoot->setCore (pRootCore );
pRoot->addChild(pScene );
pRoot->addChild(pRayGeo );
endEditCP (pRoot, Node::CoreFieldId | Node::ChildrenFieldId);
createRays(uiNumRays, testRays);
// build the geometry to visualize the rays
pPoints = GeoPositions3f::create();
beginEditCP(pPoints);
pPoints->addValue(Pnt3f(0.0, 0.0, 0.0));
pPoints->addValue(Pnt3f(0.0, 0.0, 0.0));
pPoints->addValue(Pnt3f(0.0, 0.0, 0.0));
pPoints->addValue(Pnt3f(0.0, 0.0, 0.0));
pPoints->addValue(Pnt3f(0.0, 0.0, 0.0));
endEditCP (pPoints);
GeoIndicesUI32Ptr pIndices = GeoIndicesUI32::create();
beginEditCP(pIndices);
pIndices->addValue(0);
pIndices->addValue(1);
pIndices->addValue(2);
pIndices->addValue(3);
pIndices->addValue(4);
endEditCP (pIndices);
GeoPLengthsPtr pLengths = GeoPLengthsUI32::create();
beginEditCP(pLengths);
pLengths->addValue(2);
pLengths->addValue(3);
endEditCP (pLengths);
GeoPTypesPtr pTypes = GeoPTypesUI8::create();
beginEditCP(pTypes);
pTypes->addValue(GL_LINES );
pTypes->addValue(GL_TRIANGLES);
endEditCP (pTypes);
GeoColors3fPtr pColors = GeoColors3f::create();
beginEditCP(pColors);
pColors->addValue(Color3f(1.0, 1.0, 1.0));
pColors->addValue(Color3f(1.0, 0.0, 0.0));
pColors->addValue(Color3f(1.0, 0.0, 0.0));
pColors->addValue(Color3f(1.0, 0.0, 0.0));
pColors->addValue(Color3f(1.0, 0.0, 0.0));
endEditCP (pColors);
SimpleMaterialPtr pMaterial = SimpleMaterial::create();
beginEditCP(pMaterial);
pMaterial->setLit(false);
endEditCP (pMaterial);
GeometryPtr pRayGeoCore = Geometry::create();
beginEditCP(pRayGeoCore);
pRayGeoCore->setPositions(pPoints );
pRayGeoCore->setIndices (pIndices );
pRayGeoCore->setLengths (pLengths );
pRayGeoCore->setTypes (pTypes );
pRayGeoCore->setColors (pColors );
pRayGeoCore->setMaterial (pMaterial);
endEditCP (pRayGeoCore);
beginEditCP(pRayGeo, Node::CoreFieldId);
pRayGeo->setCore(pRayGeoCore);
endEditCP (pRayGeo, Node::CoreFieldId);
//.........这里部分代码省略.........
示例15: main
int main(int argc, char **argv)
{
// enableFPE();
#ifdef __sgi
signal(SIGSEGV, (void (*)(int))sighand);
signal(SIGTRAP, (void (*)(int))sighand);
signal(SIGBUS, (void (*)(int))sighand);
#endif
// OSG init
osgInit(argc,argv);
if (argc > 1 && ! strcmp(argv[1],"-bench"))
{
runBench = true;
argc--;
argv++;
glutInitWindowPosition(0,0);
glutInitWindowSize(600,600);
}
if (argc > 1 && ! strcmp(argv[1],"-test"))
{
testSet = true;
doMotion = false;
argc--;
argv++;
}
// GLUT init
int winid = setupGLUT(&argc, argv);
// the connection between GLUT and OpenSG
GLUTWindowPtr gwin= GLUTWindow::create();
gwin->setId(winid);
gwin->init();
// create the scene
NodePtr scene = Node::create();
NodePtr pnode = Node::create();
ComponentTransformPtr trans = ComponentTransform::create();
beginEditCP(scene);
scene->setCore(trans);
scene->addChild(pnode);
endEditCP(scene);
beginEditCP(trans);
trans->setTranslation(Vec3f(2,0,0));
trans->setRotation(Quaternion(Vec3f(0,1,0),Pi/2));
trans->setScale(Vec3f(2,2,2));
endEditCP(trans);
particles = Particles::create();
beginEditCP(pnode);
pnode->setCore(particles);
endEditCP(pnode);
numParticles = 100;
if (argc > 1)
{
numParticles=atoi(argv[1]);
}
beginEditCP(particles);
pnts=GeoPositions3f::create();
secpnts=GeoPositions3f::create();
addRefCP(pnts);
addRefCP(secpnts);
GeoColors3fPtr cols = GeoColors3f::create();
GeoNormals3fPtr norms = GeoNormals3f::create();
MFPnt3f* p=pnts->editFieldPtr();
MFPnt3f* sp=secpnts->editFieldPtr();
MFVec3f *size=particles->editMFSizes();
indices = particles->editMFIndices();
velocities=new Vec3f [numParticles];
beginEditCP(pnts);
beginEditCP(secpnts);
beginEditCP(cols);
if(!testSet)
{
for(UInt32 i=0; i < numParticles; ++i)
{
Pnt3f pnt(osgrand(),osgrand(),osgrand());
indices->push_back(i);
p->push_back(pnt);
sp->push_back(pnt);
velocities[i].setValues(osgrand()/30.f/2, osgrand()/30.f/2, osgrand()/30.f/2);
cols->editFieldPtr()->push_back(
Color3f(osgrand()/2.f + .5f,osgrand()/2.f + .5f,osgrand()/2.f + .5f) );
//.........这里部分代码省略.........