コード例 #1
0
ファイル: ProxyVizNode.cpp プロジェクト: spinos/aphid
bool ProxyViz::loadInternal(MDataBlock& block)
{
	MDataHandle tmH = block.inputValue(aplantTransformCache);
	MFnPointArrayData tmFn(tmH.data());
	MPointArray plantTms = tmFn.array();
	if(plantTms.length() < 1) return false;
	
	MDataHandle idH = block.inputValue(aplantIdCache);
	MFnIntArrayData idFn(idH.data());
	MIntArray plantIds = idFn.array();
	if(plantIds.length() < 1) return false;
	
	MDataHandle triH = block.inputValue(aplantTriangleIdCache);
	MFnIntArrayData triFn(triH.data());
	MIntArray plantTris = triFn.array();
	if(plantTris.length() < 1) return false;
	
	MDataHandle crdH = block.inputValue(aplantTriangleCoordCache);
	MFnVectorArrayData crdFn(crdH.data());
	MVectorArray plantCoords = crdFn.array();
	if(plantCoords.length() < 1) return false;
	
	MDataHandle cotH = block.inputValue(aplantOffsetCache);
	MFnVectorArrayData cotFn(cotH.data());
	MVectorArray plantOffsets = cotFn.array();
		
	return loadPlants(plantTms, plantIds, plantTris, plantCoords, plantOffsets);
}
コード例 #2
0
ファイル: meshMapUtils.cpp プロジェクト: BigRoy/Maya-devkit
//
// Intersect the current face list with the one provided, keep only the common elements
// 
void meshMapUtils::intersectArrays( MIntArray& selection, MIntArray& moreFaces )
{
	int j = selection.length() - 1;
	while ( j >= 0 )
	{
		bool found = false;;

		// For each item in moreFaces, try find it in fSelectedFaces
		for( unsigned int i = 0 ; i < moreFaces.length(); i++ )
		{
			if( selection[j] == moreFaces[i] )
			{
				found = true;
				break;
			}
		}	

		if( !found )
		{
			selection.remove(j);
		}

		j--;
	}
}
コード例 #3
0
ファイル: maTranslator.cpp プロジェクト: 2asoft/xray
void   CXRayObjectExport:: CreateSMGEdgeAttrs		( MFnMesh& fnMesh )
{
	int numPolygons = fnMesh.numPolygons();
	 for ( int pid=0; pid<numPolygons; pid++ ) 
	 {
		MIntArray vertexList;
		fnMesh.getPolygonVertices( pid, vertexList );
		int vcount = vertexList.length();
		if(vcount!=3)
			Msg( "poly vertex count not equel 3(is not a tri) vertex count = %d", vcount );
		
		for ( int vid=0; vid<vcount;vid++ ) 
		{
			int a = vertexList[vid];
			int b = vertexList[ vid==(vcount-1) ? 0 : vid+1 ];

			SXREdgeInfoPtr elem = findEdgeInfo( a, b );

			if ( NULL != elem )
			{
				set_edge_smooth_flag( polySmoothingGroups[pid], vid, elem->smooth );
			}
		}
	 }
}
コード例 #4
0
ファイル: MG_poseReader.cpp プロジェクト: bungnoid/MG_Tools
MObject MG_poseReader::makePlane(const MVector& p1,const MVector& p2,const MVector& p3){

	MFnMesh meshFn;

	MPoint p1p (p1);
	MPoint p2p (p2);
	MPoint p3p (p3);
	MPointArray pArray;
	pArray.append(p1p);
	pArray.append(p2p);
	pArray.append(p3p);

	MIntArray polyCount;
	polyCount.append(3);
	MIntArray polyConnect;
	polyConnect.append(0);
	polyConnect.append(1);
	polyConnect.append(2);
	

	MFnMeshData data;
	MObject polyData = data.create();

	MStatus stat;
	meshFn.create(3,1,pArray,polyCount,polyConnect,polyData,&stat);
		


	
	return polyData;

}
コード例 #5
0
		void exportShadingInputs()
		{
			MObject proceduralNode = m_dagPath.node();
			MPlug nullPlug;
			
			MIteratorType filter;
			MIntArray filterTypes;
			filterTypes.append( MFn::kShadingEngine );
			filterTypes.append( MFn::kDisplacementShader );			
			filter.setFilterList( filterTypes );
			
			MItDependencyGraph itDG( proceduralNode, nullPlug, filter, MItDependencyGraph::kUpstream );
			while( !itDG.isDone() )
			{
				MObject node = itDG.currentItem();
				MFnDependencyNode fnNode( node );
				MPlug plug;
				if( fnNode.typeName() == "displacementShader" )
				{
					plug = fnNode.findPlug( "displacement" );
				}
				else
				{
					plug = fnNode.findPlug( "dsm" );
				}
				ExportNode( plug );
				itDG.next();
			}
		}
コード例 #6
0
void EndChunck() // fonction pour écrire une longueur par rapport à position actuelle dans le fichier
{

	


		int temp = posfichier.length()-1;
		info = "end position : ";
		info += temp;
		
		
				info += " address : ";
		info += posfichier[temp];

	

		//EndChunck(posfichier[temp-1]);
			int pos_new = ::output.tellp();//retient la position actuelle
	int size = pos_new - posfichier[temp];// détermine la longueur
	size -= 4 ; // pour les 4 premiers octets
	::output.seekp(posfichier[temp]);// se place à la position indiqué
	write_int(size);// écrit la longueur
	::output.seekp(pos_new);// se repositionne à la position transmise
		
		info += " taille : ";
		info += size;

		//MGlobal::displayInfo(info);
		
		
		posfichier.remove(temp);

}
コード例 #7
0
ファイル: writeUtil.cpp プロジェクト: MWDD/USD
bool
PxrUsdMayaWriteUtil::ReadMayaAttribute(
        const MFnDependencyNode& depNode,
        const MString& name,
        VtIntArray* val)
{
    MStatus status;
    depNode.attribute(name, &status);

    if (status == MS::kSuccess) {
        MPlug plug = depNode.findPlug(name);
        MObject dataObj;

        if ( (plug.getValue(dataObj) == MS::kSuccess) &&
             (dataObj.hasFn(MFn::kIntArrayData)) ) {

            MFnIntArrayData dData(dataObj, &status);
            if (status == MS::kSuccess) {
                MIntArray arrayValues = dData.array();
                size_t numValues = arrayValues.length();
                val->resize(numValues);
                for (size_t i = 0; i < numValues; ++i) {
                    (*val)[i] = arrayValues[i];
                }
                return true;
            }
        }
    }

    return false;
}
コード例 #8
0
ファイル: utils.cpp プロジェクト: JT-a/USD
static
bool
_GetLightingParam(
        const MIntArray& intValues,
        const MFloatArray& floatValues,
        GfVec4f& paramValue)
{
    bool gotParamValue = false;

    if (intValues.length() >= 3) {
        paramValue[0] = intValues[0];
        paramValue[1] = intValues[1];
        paramValue[2] = intValues[2];
        if (intValues.length() > 3) {
            paramValue[3] = intValues[3];
        }
        gotParamValue = true;
    } else if (floatValues.length() >= 3) {
        paramValue[0] = floatValues[0];
        paramValue[1] = floatValues[1];
        paramValue[2] = floatValues[2];
        if (floatValues.length() > 3) {
            paramValue[3] = floatValues[3];
        }
        gotParamValue = true;
    }

    return gotParamValue;
}
コード例 #9
0
ファイル: common.cpp プロジェクト: chadmv/cvwrap
MStatus GetAdjacency(MDagPath& pathMesh, std::vector<std::set<int> >& adjacency) {
  MStatus status;
  // Get mesh adjacency.  The adjacency will be all vertex ids on the connected faces.
  MItMeshVertex itVert(pathMesh, MObject::kNullObj, &status);
  CHECK_MSTATUS_AND_RETURN_IT(status);
  MFnMesh fnMesh(pathMesh, &status);
  CHECK_MSTATUS_AND_RETURN_IT(status);
  adjacency.resize(itVert.count());
  for (; !itVert.isDone(); itVert.next()) {
    MIntArray faces;
    status = itVert.getConnectedFaces(faces);
    CHECK_MSTATUS_AND_RETURN_IT(status);
    adjacency[itVert.index()].clear();
    // Put the vertex ids in a set to avoid duplicates
    for (unsigned int j = 0; j < faces.length(); ++j) {
      MIntArray vertices;
      fnMesh.getPolygonVertices(faces[j], vertices);
      for (unsigned int k = 0; k < vertices.length(); ++k) {
        if (vertices[k] != itVert.index()) {
          adjacency[itVert.index()].insert(vertices[k]);
        }
      }
    }
  }
  return MS::kSuccess;
}
コード例 #10
0
ファイル: softBodyNode.cpp プロジェクト: benelot/dynamica
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];	
	} 	
}
コード例 #11
0
ファイル: retargetLocator.cpp プロジェクト: jonntd/mayadev-1
MPointArray* retargetLocator::getPolygonPoints( MFnMesh& inputMesh )
{
	polygonNum = inputMesh.numPolygons();

	MPointArray inputMeshPoints;
	inputMesh.getPoints( inputMeshPoints );

	MPointArray* polygonPoints = new MPointArray[ polygonNum ];

	MIntArray polyVertexIndies;

	for( int polygonId =0; polygonId < polygonNum; polygonId++ )
	{
		inputMesh.getPolygonVertices( polygonId, polyVertexIndies );

		int length = polyVertexIndies.length();

		polygonPoints[polygonId].setLength( length );
		for( int i=0; i < length; i++ )
		{
			polygonPoints[polygonId].set( inputMeshPoints[ polyVertexIndies[i] ], i );
		}
	}
	return polygonPoints;
}
コード例 #12
0
ファイル: componentConverter.cpp プロジェクト: Byron/bsuite
//---------------------------------------------------------------------------
void		componentConverter::getConnectedFaces(MIntArray& edgeIDs,
												  MIntArray& result		)
//---------------------------------------------------------------------------
{
	
	MItMeshEdge edgeIter(mesh);
	MIntArray connectedFaces;
	
	result.clear();
	
	unsigned int l = edgeIDs.length();


	for(unsigned int i = 0; i < l; i++)
	{
		edgeIter.setIndex(edgeIDs[i],tmp);
		edgeIter.getConnectedFaces(connectedFaces);
		
		for(unsigned int x = 0; x < connectedFaces.length();x++)
		{
			result.append(connectedFaces[x]);
		}		
	}

}
コード例 #13
0
ファイル: updateTCCDataCmd.cpp プロジェクト: dnkv/MayaTSubdiv
MStatus compute_halfedge_indices(MIntArray &nFV, MIntArray &F, MIntArray &selV, MIntArray &selF, MIntArray &selHE)
{
    MIntArray F2H(nFV.length(), 0);
    
    size_t cumsum = 0;
    for (size_t k=0; k<nFV.length(); k++)
    {
        F2H[k] = cumsum; 
        cumsum += nFV[k];
    }
    
    selHE.setLength(selF.length());
    for (size_t k=0; k<selF.length(); k++)
    {
        size_t cV = selV[k];
        size_t cF = selF[k];
        size_t cnFV = nFV[cF];
        size_t cF2H = F2H[cF];
        for (size_t kFV=0; kFV<cnFV; kFV++)
        {
            if (F[cF2H+kFV]==cV)
            {
                selHE[k] = cF2H + kFV; break;
            }
        }
    }
    
    return MS::kSuccess;
}
コード例 #14
0
ファイル: MVGMesh.cpp プロジェクト: jonntd/mayaMVG
MStatus MVGMesh::unsetAllBlindData() const
{
    MStatus status;

    // Get all vertices
    MItMeshVertex vIt(_dagpath, MObject::kNullObj, &status);
    vIt.updateSurface();
    vIt.geomChanged();
    MIntArray componentId;
    while(!vIt.isDone())
    {
        const int index = vIt.index(&status);
        componentId.append(index);
        vIt.next();
    }
    MVGEditCmd* cmd = new MVGEditCmd();
    if(cmd)
    {
        cmd->clearBD(_dagpath, componentId);
        MArgList args;
        if(cmd->doIt(args))
            cmd->finalize();
    }
    delete cmd;

    return status;
}
int SelectRingToolCmd2::navigateFace( 
	const MDagPath &dagPath, 
	const int faceIndex, 
	const int edgeIndex, 
	const Location loc )
{
	int prevIndex;
	
	MItMeshPolygon polyIter( dagPath );
	polyIter.setIndex( faceIndex, prevIndex );
	
	// Get the face's edges
	MIntArray edges;
	polyIter.getEdges( edges );
				
	// Find the edge in the current face
	unsigned int i;
	for( i=0; i < edges.length(); i++ )
	{
		if( edgeIndex == edges[i] )
		{
			int offset;
			if( loc == OPPOSITE )
				offset = edges.length() / 2;
			else
				offset = (loc == NEXT) ? 1 : -1;
			
			return edges[ (i + offset) % edges.length() ];
		}
	}
	
	return -1; // Should never reach here
}
コード例 #16
0
IECoreScene::PrimitiveVariable FromMayaMeshConverter::normals() const
{
	MFnMesh fnMesh;
	const MDagPath *d = dagPath( true );
	if( d )
	{
		fnMesh.setObject( *d );
	}
	else
	{
		fnMesh.setObject( object() );
	}

	V3fVectorDataPtr normalsData = new V3fVectorData;
	normalsData->setInterpretation( GeometricData::Normal );
	vector<V3f> &normals = normalsData->writable();
	normals.reserve( fnMesh.numFaceVertices() );

	int numPolygons = fnMesh.numPolygons();
	V3f blankVector;

	if( space() == MSpace::kObject )
	{
		const float* rawNormals = fnMesh.getRawNormals(0);
		MIntArray normalIds;
		for( int i=0; i<numPolygons; i++ )
		{
			fnMesh.getFaceNormalIds( i, normalIds );
			for( unsigned j=0; j < normalIds.length(); ++j )
			{
				const float* normalIt = rawNormals + 3 * normalIds[j];
				normals.push_back( blankVector );
				V3f& nn = normals.back();
				nn.x = *normalIt++;
				nn.y = *normalIt++;
				nn.z = *normalIt;
			}
		}
	}
	else
	{
		MFloatVectorArray faceNormals;
		for( int i=0; i<numPolygons; i++ )
		{
			fnMesh.getFaceVertexNormals( i, faceNormals, space() );
			for( unsigned j=0; j<faceNormals.length(); j++ )
			{
				MFloatVector& n = faceNormals[j];
				normals.push_back( blankVector );
				V3f& nn = normals.back();
				nn.x = n.x;
				nn.y = n.y;
				nn.z = n.z;
			}
		}
	}

	return PrimitiveVariable( PrimitiveVariable::FaceVarying, normalsData );
}
コード例 #17
0
ファイル: mengercmd.cpp プロジェクト: skurmedel/mayamenger
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);
}
コード例 #18
0
ファイル: n_remap.cpp プロジェクト: sonictk/arrayNodes
MStatus RemapArrayValuesNode::compute(const MPlug& plug, MDataBlock& data)
{
    if (plug != aOutput)
        return MS::kUnknownParameter;

    MStatus status;

    MFnDoubleArrayData input(data.inputValue(aInput).data());
    float inputMin = float(data.inputValue(aInputMin).asDouble());
    float inputMax = float(data.inputValue(aInputMax).asDouble());
    float outputMin = float(data.inputValue(aOutputMin).asDouble());
    float outputMax = float(data.inputValue(aOutputMax).asDouble());

    int size = input.length();
    MDoubleArray outputArray(size);
    
    MRampAttribute ramp(thisMObject(), aRamp, &status);
    CHECK_MSTATUS_AND_RETURN_IT(status);

    MFloatArray positions;
    MFloatArray values;
    MIntArray interps;
    MIntArray indices;

    ramp.getEntries(indices, positions, values, interps);

    int numIndices = indices.length();

    float inValue = 0.0;
    float outValue = 0.0;

    for (int i = 0; i < size; i++)
    {
        inValue = float(input[i]);
        
        inValue = remapValue(inValue, inputMin, inputMax);

        if (numIndices > 0)
        {
            ramp.getValueAtPosition(inValue, outValue, &status);
            CHECK_MSTATUS_AND_RETURN_IT(status);
        } else {
            outValue = inValue;
        }

        outValue = remapValue(outValue, 0.0, 1.0, outputMin, outputMax);

        outputArray.set(double(outValue), i);
    }

    MDataHandle outputHandle = data.outputValue(aOutput);
    MFnDoubleArrayData output;
    MObject outputData = output.create(outputArray);

    outputHandle.setMObject(outputData);
    outputHandle.setClean();

    return MS::kSuccess;
}
コード例 #19
0
void ParameterisedHolderModificationCmd::restoreClassParameterStates( const IECore::CompoundData *classes, IECore::Parameter *parameter, const std::string &parentParameterPath )
{
	std::string parameterPath = parentParameterPath;
	if( parentParameterPath.size() )
	{
		parameterPath += ".";
	}
	parameterPath += parameter->name();
		
	if( parameter->isInstanceOf( "ClassParameter" ) )
	{				
		const CompoundData *c = classes->member<const CompoundData>( parameterPath );
		if( c )
		{
			ClassParameterHandler::setClass(
				parameter,
				c->member<const IECore::StringData>( "className" )->readable().c_str(),
				c->member<const IECore::IntData>( "classVersion" )->readable(),
				c->member<const IECore::StringData>( "searchPathEnvVar" )->readable().c_str()
			);
		}
	}
	else if( parameter->isInstanceOf( "ClassVectorParameter" ) )
	{		
		const CompoundData *c = classes->member<const CompoundData>( parameterPath );
		if( c )
		{
			IECore::ConstStringVectorDataPtr parameterNames = c->member<const IECore::StringVectorData>( "parameterNames" );
			IECore::ConstStringVectorDataPtr classNames = c->member<const IECore::StringVectorData>( "classNames" );
			IECore::ConstIntVectorDataPtr classVersions = c->member<const IECore::IntVectorData>( "classVersions" );
			MStringArray mParameterNames;
			MStringArray mClassNames;
			MIntArray mClassVersions;
			int numClasses = parameterNames->readable().size();
			for( int i=0; i<numClasses; i++ )
			{
				mParameterNames.append( parameterNames->readable()[i].c_str() );
				mClassNames.append( classNames->readable()[i].c_str() );
				mClassVersions.append( classVersions->readable()[i] );
			}
			ClassVectorParameterHandler::setClasses( parameter, mParameterNames, mClassNames, mClassVersions );
		}
	}
	
	if( parameter->isInstanceOf( IECore::CompoundParameter::staticTypeId() ) )
	{
		CompoundParameter *compoundParameter = static_cast<CompoundParameter *>( parameter );
		const CompoundParameter::ParameterVector &childParameters = compoundParameter->orderedParameters();
		for( CompoundParameter::ParameterVector::const_iterator it = childParameters.begin(); it!=childParameters.end(); it++ )
		{
			restoreClassParameterStates( classes, it->get(), parameterPath );
		}
	}
}
コード例 #20
0
MStatus LSSolverNode::buildOutputMesh(MFnMesh& inputMesh, float* vertices, MObject &outputMesh)
{
	MStatus stat;
	MPointArray points;

	unsigned vIndex = 0;
	int numVertices = inputMesh.numVertices();
	for(int i=0; i<numVertices;i++)
	{
		double x = vertices[vIndex++];
		double y = vertices[vIndex++];
		double z = vertices[vIndex++];
		//std::cout<<"("<<x<<","<<y<<","<<z<<")"<<endl;
		MPoint point(x,y,z);
		points.append(point);
	}
	
	const int numFaces = inputMesh.numPolygons();
	int *face_counts = new int[numFaces];
	for(int i = 0 ; i < numFaces ; i++)
	{
		face_counts[i] = 3;
	}

	MIntArray faceCounts( face_counts, numFaces );

	// Set up and array to assign vertices from points to each face 
	int numFaceConnects = numFaces * 3;
	int *face_connects = new int[numFaceConnects];

	int faceConnectsIdx = 0;
	for ( int i=0; i<numFaces; i++ )
	{
		MIntArray polyVerts;
		inputMesh.getPolygonVertices( i, polyVerts );
		int pvc = polyVerts.length();

		face_connects[faceConnectsIdx++] = polyVerts[0];
		face_connects[faceConnectsIdx++]= polyVerts[1];
		face_connects[faceConnectsIdx++] = polyVerts[2];
	}

	MIntArray faceConnects( face_connects, numFaceConnects );
	
	MFnMesh meshFS;
	MObject newMesh = meshFS.create(numVertices, numFaces,
									points, faceCounts, faceConnects,
									outputMesh, &stat);

	return stat;

}
コード例 #21
0
ファイル: MVGMesh.cpp プロジェクト: jonntd/mayaMVG
MStatus MVGMesh::setPoints(const MIntArray& verticesIds, const MPointArray& points) const
{
    MStatus status;
    assert(verticesIds.length() == points.length());
    assert(_dagpath.isValid());
    MFnMesh fnMesh(_dagpath, &status);
    for(int i = 0; i < verticesIds.length(); ++i)
    {
        status = fnMesh.setPoint(verticesIds[i], points[i], MSpace::kWorld);
        CHECK_RETURN_STATUS(status);
    }
    fnMesh.syncObject();
    return status;
}
コード例 #22
0
bool HesperisPolygonalMeshIO::CreateMeshData(APolygonalMesh * data, const MDagPath & path)
{
    MGlobal::displayInfo(MString("todo poly mesh write ")+path.fullPathName());
    MStatus stat;
    MFnMesh fmesh(path.node(), &stat);
    if(!stat) {
        MGlobal::displayInfo(MString(" not a mesh ") + path.fullPathName());
        return false;
    }
    
    unsigned np = fmesh.numVertices();
    unsigned nf = fmesh.numPolygons();
    unsigned ni = fmesh.numFaceVertices();
    
    data->create(np, ni, nf);
    Vector3F * pnts = data->points();
	unsigned * inds = data->indices();
    unsigned * cnts = data->faceCounts();
    
    MPointArray ps;
    MPoint wp;
	MMatrix worldTm;
    
    worldTm = GetWorldTransform(path);
    fmesh.getPoints(ps, MSpace::kObject);
	
    unsigned i = 0;
    for(;i<np;i++) {
        wp  = ps[i] * worldTm;
        pnts[i].set((float)wp.x, (float)wp.y, (float)wp.z);
    }
    
    unsigned j;
    unsigned acc = 0;
    MIntArray vertices;
    MItMeshPolygon faceIt(path);
    for(i=0; !faceIt.isDone(); faceIt.next(), i++) {
        cnts[i] = faceIt.polygonVertexCount();
        faceIt.getVertices(vertices);
        for(j = 0; j < vertices.length(); j++) {
            inds[acc] = vertices[j];
            acc++;
        }
    }
    
    data->computeFaceDrift();
    return true;
}
コード例 #23
0
ファイル: MayaExport.cpp プロジェクト: 2asoft/xray
//-----------------------------------------------------------------------------------------
LPCSTR CXRayObjectExport::getMaterialName(MDagPath & mdagPath, int cid, int objectIdx)
{
    MStatus stat;
	
    int i, length;
	MIntArray * currentMaterials = new MIntArray();
	MStringArray mArray;


	for ( i=0; i<numSets; i++ )	{
		if ( lookup(mdagPath,i,cid) ) {
			MFnSet fnSet( (*sets)[i] );
			if ( MFnSet::kRenderableOnly == fnSet.restriction(&stat) ) {
				currentMaterials->append( i );
				mArray.append( fnSet.name() );
			}
		}
	}

	// Test for equivalent materials
	//
	bool materialsEqual = false;
	if ((lastMaterials != NULL) && (lastMaterials->length() == currentMaterials->length())){
		materialsEqual = true;
		length = lastMaterials->length();
		for (i=0; i<length; i++){
			if ((*lastMaterials)[i]!=(*currentMaterials)[i]){
				materialsEqual = false;
				break;
			}
		}			
	}

	if (!materialsEqual){
		if (lastMaterials!=NULL) xr_delete(lastMaterials);

		lastMaterials = currentMaterials;

		int mLength = mArray.length(); 
		if (mLength==0) xrDebug::Fatal(DEBUG_INFO,"Object '%s' has polygon '%d' without material.",0,cid);
		if (mLength>1){
			xrDebug::Fatal(DEBUG_INFO,"Object '%s' has polygon '%d' with more than one material.",0,cid);
		}
	}else{
		xr_delete(currentMaterials);
	}
	return mArray[0].asChar();
}
コード例 #24
0
ファイル: TCCNode.cpp プロジェクト: dnkv/MayaTSubdiv
// uScale and vScale switched because first edge pointing in v direction
void copy_patch_uvs(int &kV, int &kHE, MFloatArray &u_src, MFloatArray &v_src, MIntArray &uvIdx_src, MFloatArray &u_dst, MFloatArray &v_dst, float vScale, float uScale, MFloatArray &sc_u_dst, MFloatArray &sc_v_dst, MIntArray &uvIdx_dst, float lineThickness)
{
    int nHE = uvIdx_src.length();
    for (int k=0; k<nHE; k++)
    {
        uvIdx_dst[kHE] = kV + uvIdx_src[k]; // offset by beginning of this block of UVs
        
        kHE++;
    }
    
//    float offset_u = (uScale - 1) * 0.5*lineThickness;
//    float offset_v = (vScale - 1) * 0.5*lineThickness;
    
    lineThickness = 0.5 * lineThickness; 
    
    float offset_u = lineThickness * (uScale - 1.0)/(uScale - 2*lineThickness);
    float offset_v = lineThickness * (vScale - 1.0)/(vScale - 2*lineThickness);

    int nV = u_src.length();
    for (int k=0; k<nV; k++)
    {
        u_dst[kV] = u_src[k] * (1.0 - 2.0*offset_u) + offset_u;
        v_dst[kV] = v_src[k] * (1.0 - 2.0*offset_v) + offset_v;
        
        sc_u_dst[kV] = uScale * u_src[k];
        sc_v_dst[kV] = vScale * v_src[k];
        
        kV++;
    }
}
コード例 #25
0
ファイル: sweptEmitter.cpp プロジェクト: DimondTheCat/xray
MStatus sweptEmitter::emitCountPerPoint
	(
		const MPlug &plug,
		MDataBlock &block,
		int length,					// length of emitCountPP
		MIntArray &emitCountPP		// output: emitCount for each point
	)
//
//	Descriptions:
//		Compute emitCount for each point where new particles come from.
//
{
	MStatus status;

	int plugIndex = plug.logicalIndex( &status );
	McheckErr(status, "ERROR in emitCountPerPoint: when plug.logicalIndex.\n");

	// Get rate and delta time.
	//
	double rate = rateValue( block );
	MTime dt = deltaTimeValue( plugIndex, block );

	// Compute emitCount for each point.
	//
	double dblCount = rate * dt.as( MTime::kSeconds );

	int intCount = (int)dblCount;
	for( int i = 0; i < length; i++ )
	{
		emitCountPP.append( intCount );
	}

	return( MS::kSuccess );
}
コード例 #26
0
int Triangulation(
	MFnMesh &mfnMesh,
	MIntArray &triangleCount, MIntArray &triangleList, MIntArray &triangleNList, MIntArray &triangleUVList,
	MIntArray &vertexCount, MIntArray &vertexList, MIntArray &normalList, MIntArray &uvIds)
{
	int poly_idx_offset = 0;
	int tri_idx_offset = 0;
	for (int i = 0; i < mfnMesh.numPolygons(); ++i)
	{
		for (int j = 0; j < triangleCount[i]; ++j)
		{
			for (unsigned int k = 0; k < 3; ++k)
			{
				int v_idx = triangleList[tri_idx_offset + j * 3 + k];
				int match = -1;
				int l = 0;
				while (match < 0 && l < vertexCount[i])
				{
					if (vertexList[poly_idx_offset + l] == v_idx)
						match = l;
					++l;
				}
				triangleNList[tri_idx_offset + j * 3 + k] = normalList[poly_idx_offset + match];
				int id = 0;
				if (uvIds.length() != 0)
					mfnMesh.getPolygonUVid(i, match, id);
				triangleUVList[tri_idx_offset + j * 3 + k] = id;
			}
		}
		poly_idx_offset += vertexCount[i];
		tri_idx_offset += 3 * triangleCount[i];
	}
	return tri_idx_offset;
}
コード例 #27
0
ファイル: blendshape.cpp プロジェクト: MrLobo/El-Rayo-de-Zeus
	// Load blend shape deformer from Maya
	MStatus BlendShape::load(MObject &blendShapeObj)
	{
		// Create a Fn for relative Maya blend shape deformer
		m_pBlendShapeFn = new MFnBlendShapeDeformer(blendShapeObj);
		// Save original envelope value for the deformer
		m_origEnvelope = m_pBlendShapeFn->envelope();
		// Save original target weights
		m_origWeights.clear();
		MIntArray indexList;
		m_pBlendShapeFn->weightIndexList(indexList);
		for (int i=0; i<indexList.length(); i++)
		{
			m_origWeights.push_back(m_pBlendShapeFn->weight(indexList[i]));
		}
		return MS::kSuccess;
	}
コード例 #28
0
void vixo_hairCacheExport::initBasicStepInfo(int vid,MObject & staticMesh,map<int,inVertexBasicInfo>& inVIDMapInVertexDataBase)
{

	inVertexBasicInfo ele;
	inVIDMapInVertexDataBase.insert(pair<int,inVertexBasicInfo>(vid,ele));
	map<int,inVertexBasicInfo>::iterator iter=inVIDMapInVertexDataBase.find(vid);
	iter->second.stepVertex.resize(MAXSTEP);

	forInVertexBasicInfo subele;
	subele.vertexID=vid;
	subele.distance=0;
	iter->second.stepVertex[0].insert(subele);

	MItMeshVertex iterVertex4Record(staticMesh);
	MIntArray tempConnectedVertex;
	int prevIndex;

	MFnMesh fnMesh(staticMesh);
	MPointArray allPoints;
	fnMesh.getPoints(allPoints,MSpace::kObject);

	set<int> checkedVertex;
	checkedVertex.insert(vid);

	set<forInVertexBasicInfo>::iterator lastStepSetIter;
	for(int step=1;step<MAXSTEP;step++)
	{
		for(lastStepSetIter=iter->second.stepVertex[step-1].begin();lastStepSetIter!=iter->second.stepVertex[step-1].end();lastStepSetIter++)
		{
			iterVertex4Record.setIndex(lastStepSetIter->vertexID,prevIndex);
			iterVertex4Record.getConnectedVertices(tempConnectedVertex);
			for(int j=0;j<tempConnectedVertex.length();j++)
			{
				if(checkedVertex.count(tempConnectedVertex[j])<=0)
				{
					forInVertexBasicInfo subeleTemp;
					subeleTemp.vertexID=tempConnectedVertex[j];
					subeleTemp.distance=allPoints[vid].distanceTo(allPoints[subeleTemp.vertexID]);
					iter->second.stepVertex[step].insert(subeleTemp);
					checkedVertex.insert(tempConnectedVertex[j]);
				}
			}
		}
	}

}
コード例 #29
0
void StartChunck(){
	int tempo;
	int temp = ::output.tellp();
	posfichier.append(temp);
		
		info = " start position: ";
		tempo = posfichier.length()-1;
		info += tempo;
	
		
		
		info += " rec adress : ";
		info += temp;
		//MGlobal::displayInfo(info);

		write_int(1); // écriture d'une valeur quelconque
}
コード例 #30
0
ファイル: splitUVCmd.cpp プロジェクト: BigRoy/Maya-devkit
MStatus splitUV::pruneUVs( MIntArray& validUVIndices )
//
// Description:
//
//		This method will remove any invalid UVIds from the component list and UVId array.
//		The benefit of this is to reduce the amount of extra processing that the node would
//		have to perform. It will result in less iterations through the mesh as there are
//		less UVs to search for.
//
{
	MStatus status;

	unsigned i;
	MIntArray validUVIds;

	for( i = 0; i < validUVIndices.length(); i++ )
	{
		int uvIndex = validUVIndices[i];
		validUVIds.append( fSelUVs[uvIndex] );
	}

	// Replace the local int array of UVIds
	//
	fSelUVs.clear();
	fSelUVs = validUVIds;

	// Build the list of valid components
	//
	MFnSingleIndexedComponent compFn;
	compFn.create( MFn::kMeshMapComponent, &status );
	MCheckStatus( status, "compFn.create( MFn::kMeshMapComponent )" );
	status = compFn.addElements( validUVIds );
	MCheckStatus( status, "compFn.addElements( validUVIds )" );
	MObject component = compFn.object();

	// Replace the component list
	//
	MFnComponentListData compListFn;
	compListFn.create();
	status = compListFn.add( component );
	MCheckStatus( status, "compListFn.add( component )" );

	fComponentList = compListFn.object();

	return status;
}