本文整理汇总了C++中GeoPnt3fPropertyRecPtr::size方法的典型用法代码示例。如果您正苦于以下问题:C++ GeoPnt3fPropertyRecPtr::size方法的具体用法?C++ GeoPnt3fPropertyRecPtr::size怎么用?C++ GeoPnt3fPropertyRecPtr::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GeoPnt3fPropertyRecPtr
的用法示例。
在下文中一共展示了GeoPnt3fPropertyRecPtr::size方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getGeometricCenter
/** Returns the geometric center of the mesh **/
Vec3f VRGeometry::getGeometricCenter() {
if (!meshSet) return Vec3f(0,0,0);
GeoPnt3fPropertyRecPtr pos = dynamic_cast<GeoPnt3fProperty*>(mesh->getPositions());
Vec3f center = Vec3f(0,0,0);
for (uint i=0;i<pos->size();i++)
center += Vec3f(pos->getValue(i));
center *= 1./pos->size();
return center;
}
示例2: readSharedMemory
void VRGeometry::readSharedMemory(string segment, string object) {
VRSharedMemory sm(segment, false);
int sm_state = sm.getObject<int>(object+"_state");
while (sm.getObject<int>(object+"_state") == sm_state) {
cout << "VRGeometry::readSharedMemory: waiting for data: " << sm_state << endl;
sleep(1);
}
// read buffer
auto sm_types = sm.getVector<int>(object+"_types");
auto sm_lengths = sm.getVector<int>(object+"_lengths");
auto sm_pos = sm.getVector<float>(object+"_pos");
auto sm_norms = sm.getVector<float>(object+"_norms");
auto sm_inds = sm.getVector<int>(object+"_inds");
auto sm_cols = sm.getVector<float>(object+"_cols");
GeoPnt3fPropertyRecPtr pos = GeoPnt3fProperty::create();
GeoVec3fPropertyRecPtr norms = GeoVec3fProperty::create();
GeoUInt32PropertyRecPtr inds = GeoUInt32Property::create();
GeoUInt32PropertyRecPtr types = GeoUInt32Property::create();
GeoUInt32PropertyRecPtr lengths = GeoUInt32Property::create();
GeoVec4fPropertyRecPtr cols = GeoVec4fProperty::create();
cout << "SM mesh read: " << sm_types.size() << " " << sm_lengths.size() << " " << sm_pos.size() << " " << sm_norms.size() << " " << sm_inds.size() << " " << sm_cols.size() << endl;
if (sm_types.size() > 0) for (auto& t : sm_types) types->addValue(t);
if (sm_lengths.size() > 0) for (auto& l : sm_lengths) lengths->addValue(l);
for (auto& i : sm_inds) inds->addValue(i);
if (sm_pos.size() > 0) for (int i=0; i<sm_pos.size()-2; i+=3) pos->addValue(Pnt3f(sm_pos[i], sm_pos[i+1], sm_pos[i+2]));
if (sm_norms.size() > 0) for (int i=0; i<sm_norms.size()-2; i+=3) norms->addValue(Vec3f(sm_norms[i], sm_norms[i+1], sm_norms[i+2]));
if (sm_cols.size() > 0) for (int i=0; i<sm_cols.size()-2; i+=3) cols->addValue(Pnt3f(sm_cols[i], sm_cols[i+1], sm_cols[i+2]));
cout << "osg mesh data: " << types->size() << " " << lengths->size() << " " << pos->size() << " " << norms->size() << " " << inds->size() << " " << cols->size() << endl;
int N = pos->size();
if (N == 0) return;
setTypes(types);
setLengths(lengths);
setPositions(pos);
if (norms->size() == N) setNormals(norms);
if (cols->size() == N) setColors(cols);
setIndices(inds);
}
示例3: setRandomColors
void VRGeometry::setRandomColors() {
GeoPnt3fPropertyRecPtr pos = dynamic_cast<GeoPnt3fProperty*>(mesh->getPositions());
int N = pos->size();
GeoVec4fPropertyRecPtr cols = GeoVec4fProperty::create();
for (int i=0; i<N; i++) {
Color4f c; c.setRandom();
cols->addValue( c );
}
setColors(cols);
}
示例4: getMin
/** Returns the minimum position on the x, y || z axis **/
float VRGeometry::getMin(int axis) {
if (!meshSet) return 0;
if (axis != 0 && axis != 1 && axis != 2) return 0;
GeoPnt3fPropertyRecPtr pos = dynamic_cast<GeoPnt3fProperty*>(mesh->getPositions());
float min = pos->getValue(0)[axis];
for (uint i=0;i<pos->size();i++) {
if (min > pos->getValue(i)[axis]) min = pos->getValue(i)[axis];
}
return min;
}
示例5: strokeProfile
void VRStroke::strokeProfile(vector<Vec3f> profile, bool closed, bool lit) {
mode = 0;
this->profile = profile;
this->closed = closed;
this->lit = lit;
GeoUInt8PropertyRecPtr Type = GeoUInt8Property::create();
GeoUInt32PropertyRecPtr Length = GeoUInt32Property::create();
GeoPnt3fPropertyRecPtr Pos = GeoPnt3fProperty::create();
GeoVec3fPropertyRecPtr Norms = GeoVec3fProperty::create();
GeoVec3fPropertyRecPtr Colors = GeoVec3fProperty::create();
GeoUInt32PropertyRecPtr Indices = GeoUInt32Property::create();
bool doCaps = closed && profile.size() > 1;
Vec3f z = Vec3f(0,0,1);
if (profile.size() == 1) Type->addValue(GL_LINES);
else Type->addValue(GL_QUADS);
clearChildren();
for (uint i=0; i<paths.size(); i++) {
vector<Vec3f> pnts = paths[i]->getPositions();
vector<Vec3f> directions = paths[i]->getDirections();
vector<Vec3f> up_vectors = paths[i]->getUpvectors();
vector<Vec3f> cols = paths[i]->getColors();
Vec3f _p;
for (uint j=0; j<pnts.size(); j++) {
Vec3f p = pnts[j];
Vec3f n = directions[j];
Vec3f u = up_vectors[j];
Vec3f c = cols[j];
Matrix m;
MatrixLookAt(m, Vec3f(0,0,0), n, u);
// add new profile points && normals
for (uint k=0; k<profile.size(); k++) {
Vec3f tmp = profile[k];
m.mult(tmp, tmp);
Pos->addValue(p+tmp);
tmp.normalize();
Norms->addValue(tmp);
Colors->addValue(c);
}
if (j==0 && profile.size() > 1) continue;
// add line
if (profile.size() == 1) {
int N = Pos->size();
Indices->addValue(N-2);
Indices->addValue(N-1);
} else {
// add quad
for (uint k=0; k<profile.size()-1; k++) {
int N1 = Pos->size() - 2*profile.size() + k;
int N2 = Pos->size() - profile.size() + k;
Indices->addValue(N1);
Indices->addValue(N2);
Indices->addValue(N2+1);
Indices->addValue(N1+1);
//cout << "\nN1N2 " << N1 << " " << N2 << " " << N2+1 << " " << N1+1 << flush;
}
if (closed) {
int N0 = Pos->size() - 2*profile.size();
int N1 = Pos->size() - profile.size() - 1;
int N2 = Pos->size() - 1;
Indices->addValue(N1);
Indices->addValue(N2);
Indices->addValue(N1+1);
Indices->addValue(N0);
//cout << "\nN1N2 " << N1 << " " << N2 << " " << N1+1 << " " << N0 << flush;
}
}
}
}
Length->addValue(Indices->size());
// caps
if (doCaps) {
int Nt = 0;
for (uint i=0; i<paths.size(); i++) {
vector<Vec3f> pnts = paths[i]->getPositions();
vector<Vec3f> directions = paths[i]->getDirections();
vector<Vec3f> up_vectors = paths[i]->getUpvectors();
vector<Vec3f> cols = paths[i]->getColors();
Matrix m;
// first cap
Vec3f p = pnts[0];
Vec3f n = directions[0];
Vec3f u = up_vectors[0];
Vec3f c = cols[0];
//.........这里部分代码省略.........
示例6: strokeProfile
void VRStroke::strokeProfile(vector<Vec3f> profile, bool closed, bool lit) {
mode = 0;
this->profile = profile;
this->closed = closed;
this->lit = lit;
GeoUInt8PropertyRecPtr Type = GeoUInt8Property::create();
GeoUInt32PropertyRefPtr Length = GeoUInt32Property::create();
GeoPnt3fPropertyRecPtr Pos = GeoPnt3fProperty::create();
GeoVec3fPropertyRefPtr Norms = GeoVec3fProperty::create();
GeoVec3fPropertyRefPtr Colors = GeoVec3fProperty::create();
GeoUInt32PropertyRefPtr Indices = GeoUInt32Property::create();
Vec3f z = Vec3f(0,0,1);
if (profile.size() == 1) Type->addValue(GL_LINES);
else Type->addValue(GL_QUADS);
clearChildren();
for (uint i=0; i<paths.size(); i++) {
vector<Vec3f> pnts = paths[i]->get();
vector<Vec3f> norms = paths[i]->getNormals();
vector<Vec3f> cols = paths[i]->getColors();
Vec3f _p;
for (uint j=0; j<pnts.size(); j++) {
Vec3f p = pnts[j];
Vec3f n = norms[j];
Vec3f c = cols[j];
//float ca = n.dot(z);
Matrix m;
//MatrixLookAt(m, Vec3f(0,0,0), n, z.cross(n));
MatrixLookAt(m, Vec3f(0,0,0), n, Vec3f(0,1,0));
// add new profile points and normals
for (uint k=0; k<profile.size(); k++) {
Vec3f tmp = profile[k];
m.mult(tmp, tmp);
Pos->addValue(p+tmp);
tmp.normalize();
Norms->addValue(tmp);
Colors->addValue(c);
}
if (j==0 and profile.size() > 1) continue;
// add line
if (profile.size() == 1) {
int N = Pos->size();
Indices->addValue(N-2);
Indices->addValue(N-1);
} else {
// add quad
for (uint k=0; k<profile.size()-1; k++) {
int N1 = Pos->size() - 2*profile.size() + k;
int N2 = Pos->size() - profile.size() + k;
Indices->addValue(N1);
Indices->addValue(N2);
Indices->addValue(N2+1);
Indices->addValue(N1+1);
//cout << "\nN1N2 " << N1 << " " << N2 << " " << N2+1 << " " << N1+1 << flush;
}
if (closed) {
int N0 = Pos->size() - 2*profile.size();
int N1 = Pos->size() - profile.size() - 1;
int N2 = Pos->size() - 1;
Indices->addValue(N1);
Indices->addValue(N2);
Indices->addValue(N1+1);
Indices->addValue(N0);
//cout << "\nN1N2 " << N1 << " " << N2 << " " << N1+1 << " " << N0 << flush;
}
}
}
}
Length->addValue(Indices->size());
SimpleMaterialRecPtr Mat = SimpleMaterial::create();
GeometryRecPtr g = Geometry::create();
g->setTypes(Type);
g->setLengths(Length);
g->setPositions(Pos);
g->setNormals(Norms);
g->setColors(Colors);
g->setIndices(Indices);
g->setMaterial(Mat);
Mat->setLit(lit);
VRGeometry* geo = new VRGeometry("stroke");
geo->setMesh(g);
addChild(geo);
}