本文整理汇总了C++中MFloatPointArray类的典型用法代码示例。如果您正苦于以下问题:C++ MFloatPointArray类的具体用法?C++ MFloatPointArray怎么用?C++ MFloatPointArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MFloatPointArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createHalfRope
MFloatPointArray ropeGenerator::createHalfRope( int pointsCount, float radius )
{
MFloatPointArray points;
MPoint baseVector( 1,0,0 );
baseVector = baseVector * radius;
points.append( MFloatPoint( baseVector.x, baseVector.y, baseVector.z, 1.0 ) );
float fbaseAngle = 180.0 / float( pointsCount );
for (int d = 1; d < pointsCount; d++)
{
if (d == 1)
{
MAngle baseAngle((fbaseAngle * 0.25), MAngle::kDegrees );
MVector vVector( baseVector );
vVector = vVector.rotateBy( MVector::kYaxis, baseAngle.asRadians() );
points.append( MFloatPoint( vVector.x, vVector.y, vVector.z, 1.0 ) );
}
MAngle baseAngle((fbaseAngle * float( d ) ), MAngle::kDegrees );
MVector vVector( baseVector );
vVector = vVector.rotateBy( MVector::kYaxis, baseAngle.asRadians() );
points.append( MFloatPoint( vVector.x, vVector.y, vVector.z, 1.0 ) );
if ( d == pointsCount - 1 )
{
MAngle baseAngle((fbaseAngle * ( d + 0.75 )), MAngle::kDegrees );
MVector vVector( baseVector );
vVector = vVector.rotateBy( MVector::kYaxis, baseAngle.asRadians() );
points.append( MFloatPoint( vVector.x, vVector.y, vVector.z, 1.0 ) );
}
}
return points;
}
示例2: createHelperMesh
void SoftBodyNode::createHelperMesh(MFnMesh &mayaMesh, std::vector<int> &triIndices, std::vector<float> &triVertices, MSpace::Space space)
{
MFloatPointArray ptArray;
mayaMesh.getPoints(ptArray, space);
// append vertex locations (x, y, z) into "flattened array"
for(int i = 0; i < ptArray.length(); i++)
{
MFloatPoint pt;
pt = ptArray[i];
pt.cartesianize();
triVertices.push_back(pt.x);
triVertices.push_back(pt.y);
triVertices.push_back(pt.z);
}
std::cout << std::endl;
// create vector of triangle indices
MIntArray tCounts;
MIntArray tVerts;
mayaMesh.getTriangles(tCounts, tVerts);
triIndices.resize(tVerts.length());
for(int i = 0; i < tVerts.length(); i ++)
{
triIndices[i] = tVerts[i];
}
}
示例3: createMesh
MObject animCube::createMesh(const MTime& time,
MObject& outData,
MStatus& stat)
{
int numVertices, frame;
float cubeSize;
MFloatPointArray points;
MFnMesh meshFS;
// Scale the cube on the frame number, wrap every 10 frames.
frame = (int)time.as( MTime::kFilm );
if (frame == 0)
frame = 1;
cubeSize = 0.5f * (float)( frame % 10);
const int numFaces = 6;
numVertices = 8;
const int numFaceConnects = 24;
MFloatPoint vtx_1( -cubeSize, -cubeSize, -cubeSize );
MFloatPoint vtx_2( cubeSize, -cubeSize, -cubeSize );
MFloatPoint vtx_3( cubeSize, -cubeSize, cubeSize );
MFloatPoint vtx_4( -cubeSize, -cubeSize, cubeSize );
MFloatPoint vtx_5( -cubeSize, cubeSize, -cubeSize );
MFloatPoint vtx_6( -cubeSize, cubeSize, cubeSize );
MFloatPoint vtx_7( cubeSize, cubeSize, cubeSize );
MFloatPoint vtx_8( cubeSize, cubeSize, -cubeSize );
points.append( vtx_1 );
points.append( vtx_2 );
points.append( vtx_3 );
points.append( vtx_4 );
points.append( vtx_5 );
points.append( vtx_6 );
points.append( vtx_7 );
points.append( vtx_8 );
// Set up an array containing the number of vertices
// for each of the 6 cube faces (4 verticies per face)
//
int face_counts[numFaces] = { 4, 4, 4, 4, 4, 4 };
MIntArray faceCounts( face_counts, numFaces );
// Set up and array to assign vertices from points to each face
//
int face_connects[ numFaceConnects ] = { 0, 1, 2, 3,
4, 5, 6, 7,
3, 2, 6, 5,
0, 3, 5, 4,
0, 4, 7, 1,
1, 7, 6, 2 };
MIntArray faceConnects( face_connects, numFaceConnects );
MObject newMesh = meshFS.create(numVertices, numFaces,
points, faceCounts, faceConnects,
outData, &stat);
return newMesh;
}
示例4: create_shape
MStatus metro_model_translator::create_shape( const m2033::mesh_ptr m )
{
MFloatPointArray v;
MVectorArray norm;
MIntArray p;
MIntArray idx;
MFnTransform transform_fn;
MObject transform_obj = transform_fn.create( MObject::kNullObj );
transform_fn.setName( m->get_name().c_str() );
m2033::mesh::vertices mv = m->get_vertices();
m2033::mesh::indices mi = m->get_indices();
m2033::mesh::texcoords mt = m->get_tex_coords();
m2033::mesh::normals mn = m->get_normals();
for( unsigned i = 0; i < mv.size(); i++ ) {
v.append( -mv[i].x, mv[i].y, mv[i].z );
norm.append( MVector( -mn[i].x, mn[i].y, mn[i].z ) );
}
for( unsigned i = 0; i < mi.size() / 3; i++ ) {
idx.append( mi[i*3+2] );
idx.append( mi[i*3+1] );
idx.append( mi[i*3] );
p.append( 3 );
}
MFloatArray u_values, v_values;
for( unsigned i = 0; i < mt.size(); i++ ) {
u_values.append( mt[i].x );
v_values.append( -mt[i].y );
}
MFnMesh meshFn;
MObject mesh = meshFn.create( v.length(), p.length(), v, p, idx, u_values, v_values, transform_obj );
MString name = m->get_name().c_str();
meshFn.setName( name + MString("_shape") );
MStatus s = meshFn.assignUVs( p, idx, 0 );
if( !s ) {
return s;
}
s = meshFn.unlockVertexNormals( idx );
if( !s ) {
return s;
}
meshFn.setVertexNormals( norm, idx );
MObject mat = create_material( m->get_texture_name(), &s );
if( !s ) {
return s;
}
MFnSet mat_fn(mat);
mat_fn.addMember(mesh);
return MS::kSuccess;
}
示例5: makeCubes
static void makeCubes(std::vector<cube> &cubes, MString &name, MStatus *stat)
{
MFnMesh fnMesh;
MObject result;
MFloatPointArray points;
MIntArray faceCounts;
MIntArray faceConnects;
int index_offset = 0;
for (std::vector<cube>::iterator cit = cubes.begin(); cit != cubes.end(); ++cit)
{
point3 diag = cit->diagonal();
float scale = diag.x;
point3 pos = cit->start + (diag * .5f);
MFloatVector mpos(pos.x, pos.y, pos.z);
addCube(scale, mpos, index_offset * (8), points, faceCounts, faceConnects);
index_offset += 1;
}
unsigned int vtx_cnt = points.length();
unsigned int face_cnt = faceCounts.length();
MObject newMesh =
fnMesh.create(
/* numVertices */ vtx_cnt,
/* numFaces */ face_cnt,
points,
faceCounts,
faceConnects,
MObject::kNullObj,
stat);
/* Harden all edges. */
int n_edges = fnMesh.numEdges(stat);
for (int i = 0; i < n_edges; ++i)
{
fnMesh.setEdgeSmoothing(i, false);
}
fnMesh.cleanupEdgeSmoothing(); /* Must be called after editing edges. */
fnMesh.updateSurface();
/* Assign Shader. */
MSelectionList sel_list;
if (!MFAIL(sel_list.add("initialShadingGroup")))
{
MObject set_obj;
sel_list.getDependNode(0, set_obj);
MFnSet set(set_obj);
set.addMember(newMesh);
}
/* Give it a swanky name. */
MFnDagNode parent(fnMesh.parent(0));
name = parent.setName("polyMengerSponge", false, stat);
}
示例6: inputNData
MStatus testNucleusNode::compute(const MPlug &plug, MDataBlock &data)
{
MStatus stat;
if ( plug == nextState )
{
//get the value of the currentTime
MTime currTime = data.inputValue(currentTime).asTime();
MObject inputData;
//pull on start state or current state depending on the current time.
if(currTime.value() <= 0.0) {
MArrayDataHandle multiDataHandle = data.inputArrayValue(startState);
multiDataHandle.jumpToElement(0);
inputData =multiDataHandle.inputValue().data();
}
else {
MArrayDataHandle multiDataHandle = data.inputArrayValue(currentState);
multiDataHandle.jumpToElement(0);
inputData =multiDataHandle.inputValue().data();
}
MFnNObjectData inputNData(inputData);
MnCloth * nObj = NULL;
inputNData.getObjectPtr(nObj);
MFloatPointArray points;
nObj->getPositions(points);
unsigned int ii;
for(ii=0;ii<points.length();ii++) {
points[ii].y = (float) sin(points[ii].x + currTime.value()*4.0f*(3.1415f/180.0f));
}
nObj->setPositions(points);
delete nObj;
data.setClean(plug);
}
else if ( plug == currentState )
{
data.setClean(plug);
}
else if (plug == startState) {
data.setClean(plug);
}
else {
stat = MS::kUnknownParameter;
}
return stat;
}
示例7: readFrame
MObject AniMesh::readFrame(const MTime& time,MObject& outData,MStatus& stat)
{
MFloatPointArray points;
MFnMesh meshFS;
int frame = (int)time.as( MTime::kFilm );
if (frame == 0)
frame = 1;
vector<size_t> face_v;
vector<double> points_v;
char cfilename[256];
sprintf(cfilename, "%s%d.vrml",import_prefix.c_str(),frame);
//sprintf(cfilename, "%s%d.vrml",import_prefix.c_str(),0);
string filename = string(cfilename);
fstream fp;
fp.open(filename,ios::in);
if (fp)
{
ImportVrml2 (filename, face_v, points_v);
}else{
sprintf(cfilename, "%s%d.vrml",import_prefix.c_str(),0);
string filename = string(cfilename);
ImportVrml2(filename,face_v,points_v);
}
size_t numVertices = points_v.size()/3;
size_t numFaces = face_v.size()/3;
for(vector<double>::const_iterator it = points_v.begin();it != points_v.end();it+=3) {
MFloatPoint vtx(*it,*(it+1),*(it+2));
points.append(vtx);
}
vector<int> face_count;
for(int i=0;i<numFaces;i++) {
face_count.push_back(3);
}
MIntArray faceCounts(&face_count[0],numFaces);
vector<int> face_connects;
face_connects.resize(face_v.size());
for(int i=0;i<face_v.size();++i)
{
face_connects[i] = face_v[i];
}
MIntArray faceConnects( &face_connects[0], face_connects.size() );
MObject newMesh=meshFS.create(numVertices, numFaces,points, faceCounts, faceConnects,outData,&stat);
return newMesh;
}
示例8: getPoints
bool kgLocator::getPoints( MFloatPointArray &pts )
{
MFloatPoint pt;
pt.x = -0.5f; pt.y = 0.0f; pt.z = 0.0f;
pts.append( pt );
pt.x = 0.5f; pt.y = 0.0f; pt.z = 0.0f;
pts.append( pt );
pt.x = 0.0f; pt.y = 0.0f; pt.z = -0.5f;
pts.append( pt );
pt.x = 0.0f; pt.y = 0.0f; pt.z = 0.5f;
pts.append( pt );
assert( pts.length() == 4 );
return true;
}
示例9: createCriclePoints
void ropeGenerator::createCriclePoints( int pointsCount, MMatrix bMatrix, MFloatPointArray &points, float radius )
{
MPoint baseVector2( radius,0,0 );
baseVector2 = baseVector2 * bMatrix;
points.append( MFloatPoint( baseVector2.x, baseVector2.y, baseVector2.z, 1.0 ) );
float baseAngle = 360.0f / float( pointsCount );
for (int d = 1; d < pointsCount; d++ )
{
MVector vVector( radius,0,0 );
vVector = vVector.rotateBy( MVector::kYaxis,
MAngle( baseAngle * float( d ),MAngle::kDegrees).asRadians() );
MPoint point( vVector.x, vVector.y, vVector.z );
point = point * bMatrix;
points.append( MFloatPoint( point.x, point.y, point.z, 1.0 ));
}
}
示例10: meshFn
void MayaGeoAttribute::transferValueFromMaya(MPlug &plug, MDataBlock &data){
MDataHandle dataHandle = data.inputValue(plug);
MFnMesh meshFn(dataHandle.asMesh());
MFloatPointArray mayaPoints;
meshFn.getPoints(mayaPoints);
// collect points
std::vector<Imath::V3f> coralPoints;
for(int i = 0; i < mayaPoints.length(); ++i){
MFloatPoint* mayaPoint = &mayaPoints[i];
coralPoints.push_back(Imath::V3f(mayaPoint->x, mayaPoint->y, mayaPoint->z));
}
// collect faces
int numPolys = meshFn.numPolygons();
std::vector<std::vector<int> > coralFaces(numPolys);
for(int polyId = 0; polyId < numPolys; ++polyId){
MIntArray mayaVertexList;
meshFn.getPolygonVertices(polyId, mayaVertexList);
int polyPoints = mayaVertexList.length();
std::vector<int> coralFace(polyPoints);
for(int i = 0; i < polyPoints; ++i){
int pointId = mayaVertexList[i];
coralFace[i] = pointId;
}
coralFaces[polyId] = coralFace;
}
// create coral geo
coral::Geo *coralGeo = outValue();
if(coralGeo->hasSameTopology(coralFaces)){
coralGeo->setPoints(coralPoints);
}
else{
coralGeo->build(coralPoints, coralFaces);
}
valueChanged();
}
示例11: value
void MayaGeoAttribute::transferValueToMaya(MPlug &plug, MDataBlock &data){
coral::Geo *coralGeo = value();
const std::vector<Imath::V3f> &coralPoints = coralGeo->points();
// transfer points
MFloatPointArray mayaPoints;
for(int i = 0; i < coralPoints.size(); ++i){
const Imath::V3f *coralPoint = &coralPoints[i];
mayaPoints.append(MFloatPoint(coralPoint->x, coralPoint->y, coralPoint->z));
}
// transfer faces
MIntArray mayaFaceCount;
MIntArray mayaFaceVertices;
const std::vector<std::vector<int> > coralFaces = coralGeo->rawFaces();
for(int polyId = 0; polyId < coralFaces.size(); ++polyId){
const std::vector<int> *coralFace = &coralFaces[polyId];
int faceVertexCount = coralFace->size();
mayaFaceCount.append(faceVertexCount);
for(int i = 0; i < faceVertexCount; ++i){
mayaFaceVertices.append(coralFace->at(i));
}
}
// create maya mesh
MDataHandle dataHandle = data.outputValue(plug);
MFnMeshData dataCreator;
MObject newOutputData = dataCreator.create();
MFnMesh newMesh;
newMesh.create(mayaPoints.length(), coralFaces.size(), mayaPoints, mayaFaceCount, mayaFaceVertices, newOutputData);
dataHandle.set(newOutputData);
}
示例12: store_in_hds
void store_in_hds(HDS &hds, MFloatPointArray &points, MIntArray &nFV, MIntArray &F)
{
size_t nV = points.length();
hds.V.setDims(3, nV);
for (size_t k=0; k<nV; k++)
{
hds.V[3*k+0] = points[k](0);
hds.V[3*k+1] = points[k](1);
hds.V[3*k+2] = points[k](2);
}
hds.nFV.setDims(1,nFV.length());
for (size_t k=0; k<nFV.length(); k++) hds.nFV[k] = nFV[k];
hds.tip.setDims(1,F.length());
for (size_t k=0; k<F.length(); k++) hds.tip[k] = F[k];
}
示例13: boundingBox
MBoundingBox BasicLocator::boundingBox() const
{
MBoundingBox bbox;
MFloatPointArray points;
points.clear();
points.setSizeIncrement(4);
points.append(-1.0, 0.0, 0.0);
points.append(1.0, 0.0, 0.0);
points.append(0.0, 0.0, 1.0);
points.append(0.0, 0.0, -1.0);
for (unsigned int i = 0; i < points.length(); i++)
bbox.expand(points[i]);
return bbox;
}
示例14: load_from_hds
void load_from_hds(HDS &hds, MFloatPointArray &points, MIntArray &nFV, MIntArray &F)
{
size_t nV = hds.nV();
size_t nF = hds.nF();
size_t nIHE = hds.nIHE();
points.setLength(nV);
for (size_t k=0; k<nV; k++)
{
points[k](0) = hds.V[3*k+0];
points[k](1) = hds.V[3*k+1];
points[k](2) = hds.V[3*k+2];
}
nFV.setLength(nF);
for (size_t k=0; k<nF; k++) nFV[k] = hds.nFV[k];
F.setLength(nIHE);
for (size_t k=0; k<nIHE; k++) F[k] = hds.tip[k];
}
示例15: angle
void ropeGenerator::createRopesRings( int ropesCount, MMatrix bMatrix, MFloatPointArray &points, int pointsCount, float ropeStrength, float radius )
{
MAngle angle( (180.0/ ropesCount ), MAngle::kDegrees );
float distanceToMoveRope = cos( angle.asRadians() );
float singleRopeRadius = sin( angle.asRadians() );
float baseAngle = 360.0f / float( ropesCount );
for ( int d = 1; d < ropesCount + 1; d++)
{
MFloatPointArray ropePoints( createHalfRope( pointsCount, singleRopeRadius ) );
for ( int ropP = 0; ropP < ropePoints.length(); ropP++)
{
MFloatPoint ropPoint( ropePoints[ropP] );
MVector ropV( ropPoint.x, ropPoint.y, ropPoint.z * ropeStrength );
ropV = ropV + MVector( 0,0,-distanceToMoveRope );
ropV = ropV.rotateBy( MVector::kYaxis, MAngle( baseAngle * float( d ), MAngle::kDegrees).asRadians() );
MPoint ropFinalPoint( ropV * radius );
ropFinalPoint = ropFinalPoint * bMatrix;
points.append( MFloatPoint( ropFinalPoint.x, ropFinalPoint.y, ropFinalPoint.z ) );
}
}
}