当前位置: 首页>>代码示例>>C++>>正文


C++ MDoubleArray类代码示例

本文整理汇总了C++中MDoubleArray的典型用法代码示例。如果您正苦于以下问题:C++ MDoubleArray类的具体用法?C++ MDoubleArray怎么用?C++ MDoubleArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MDoubleArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getCreaseVertices

// Reference: OSD shape_utils.h:: applyTags() "corner"
static float
getCreaseVertices( MFnMesh const & inMeshFn, Descriptor & outDesc) {

    MUintArray tVertexIds;
    MDoubleArray tCreaseData;
    float maxCreaseValue = 0.0f;

    if ( inMeshFn.getCreaseVertices(tVertexIds, tCreaseData) ) {

        assert( tVertexIds.length() == tCreaseData.length() );

        int    ncorners = tVertexIds.length();
        int *     verts = new int[ncorners*2];
        float * weights = new float[ncorners];

        // Has crease vertices
        for (unsigned int j=0; j < tVertexIds.length(); j++) {

            assert( tCreaseData[j] >= 0.0 );

            verts[j] = tVertexIds[j];
            weights[j] = float(tCreaseData[j]);

            maxCreaseValue = std::max(float(tCreaseData[j]), maxCreaseValue);
        }

        outDesc.numCorners = ncorners;
        outDesc.cornerVertexIndices = verts;
        outDesc.cornerWeights = weights;
    }
    return maxCreaseValue;
}
开发者ID:AiYong,项目名称:OpenSubdiv,代码行数:33,代码来源:mayaPolySmooth.cpp

示例2: jMakeCurve

/*
-----------------------------------------

	Make a degree 1 curve from the given CVs.

-----------------------------------------
*/
static void jMakeCurve( MPointArray cvs )
{
	MStatus stat;
	unsigned int deg = 1;
	MDoubleArray knots;

	unsigned int i;
	for ( i = 0; i < cvs.length(); i++ )
		knots.append( (double) i );

    // Now create the curve
    //
    MFnNurbsCurve curveFn;

    curveFn.create( cvs,
				    knots, deg,
				    MFnNurbsCurve::kOpen,
				    false, false,
				    MObject::kNullObj,
				    &stat );

    if ( MS::kSuccess != stat )
		cout<<"Error creating curve."<<endl;

}
开发者ID:DimondTheCat,项目名称:xray,代码行数:32,代码来源:motionTraceCmd.cpp

示例3: MPoint

bool HesperisCurveCreator::CreateACurve(Vector3F * pos, unsigned nv, MObject &target)
{
	MPointArray vertexArray;
    unsigned i=0;
	for(; i<nv; i++)
		vertexArray.append( MPoint( pos[i].x, pos[i].y, pos[i].z ) );
	const int degree = 2;
    const int spans = nv - degree;
	const int nknots = spans + 2 * degree - 1;
    MDoubleArray knotSequences;
	knotSequences.append(0.0);
	for(i = 0; i < nknots-2; i++)
		knotSequences.append( (double)i );
	knotSequences.append(nknots-3);
    
    MFnNurbsCurve curveFn;
	MStatus stat;
	curveFn.create(vertexArray,
					knotSequences, degree, 
					MFnNurbsCurve::kOpen, 
					false, false, 
					target, 
					&stat );
					
	return stat == MS::kSuccess;
}
开发者ID:kkaushalp,项目名称:aphid,代码行数:26,代码来源:HesperisCurveIO.cpp

示例4:

bool ToMayaMatrixVectorDataConverter<F>::doConversion( IECore::ConstObjectPtr from, MObject &to, IECore::ConstCompoundObjectPtr operands ) const
{
	MStatus s;

	typename F::ConstPtr data = IECore::runTimeCast<const F>( from );
	if( !data )
	{
		return false;
	}

	MFnDoubleArrayData fnData;
	
	const typename F::ValueType &v = data->readable();
	
	MDoubleArray array;
	array.setLength( v.size() * 16 );

	for ( unsigned i=0; i < v.size(); i++ )
	{
		for ( unsigned j=0; j < 4; j++ )
		{
			for ( unsigned k=0; k < 4; k++ )
			{
				array[ i*16 + j*4 + k ] = (double)v[i][j][k];
			}
		}
	}

	to = fnData.create( array, &s );
	
	return s;
}
开发者ID:AtomicFiction,项目名称:cortex,代码行数:32,代码来源:ToMayaMatrixVectorDataConverter.cpp

示例5: dData

bool
PxrUsdMayaWriteUtil::ReadMayaAttribute(
        const MFnDependencyNode& depNode,
        const MString& name,
        VtFloatArray* 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::kDoubleArrayData)) ) {

            MFnDoubleArrayData dData(dataObj, &status);
            if (status == MS::kSuccess) {
                MDoubleArray 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;
}
开发者ID:MWDD,项目名称:USD,代码行数:31,代码来源:writeUtil.cpp

示例6: getCreaseEdges

// Reference: OSD shape_utils.h:: applyTags() "crease"
static float
getCreaseEdges(MFnMesh const & inMeshFn, Descriptor & outDesc) {

    MUintArray tEdgeIds;
    MDoubleArray tCreaseData;
    float maxCreaseValue = 0.0f;

    if (inMeshFn.getCreaseEdges(tEdgeIds, tCreaseData)) {

        assert( tEdgeIds.length() == tCreaseData.length() );

        int    ncreases = tEdgeIds.length();
        int * vertPairs = new int[ncreases*2];
        float * weights = new float[ncreases];

        int2 edgeVerts;
        for (unsigned int j=0; j < tEdgeIds.length(); j++) {

            assert( tCreaseData[j] >= 0.0 );
            inMeshFn.getEdgeVertices(tEdgeIds[j], edgeVerts);

            vertPairs[j*2  ] = edgeVerts[0];
            vertPairs[j*2+1] = edgeVerts[1];
            weights[j] = float(tCreaseData[j]);
            maxCreaseValue = std::max(float(tCreaseData[j]), maxCreaseValue);
        }

        outDesc.numCreases = ncreases;
        outDesc.creaseVertexIndexPairs = vertPairs;
        outDesc.creaseWeights = weights;
    }
    return maxCreaseValue;
}
开发者ID:AiYong,项目名称:OpenSubdiv,代码行数:34,代码来源:mayaPolySmooth.cpp

示例7: applyCreaseVertices

// Reference: OSD shape_utils.h:: applyTags() "corner"
float
applyCreaseVertices( MFnMesh const & inMeshFn, HMesh * hbrMesh ) {

    MUintArray tVertexIds;
    MDoubleArray tCreaseData;
    float maxCreaseValue = 0.0f;

    if ( inMeshFn.getCreaseVertices(tVertexIds, tCreaseData) ) {

        assert( tVertexIds.length() == tCreaseData.length() );

        // Has crease vertices
        for (unsigned int j=0; j < tVertexIds.length(); j++) {

            // Assumption: The OSD vert ids are identical to those of the Maya mesh

            HVertex * v = hbrMesh->GetVertex( tVertexIds[j] );
            if(v) {

                assert( tCreaseData[j] >= 0.0 );

                v->SetSharpness( (float)tCreaseData[j] );

                maxCreaseValue = std::max(float(tCreaseData[j]), maxCreaseValue);
            } else {
                fprintf(stderr,
                    "warning: cannot find vertex for corner tag (%d)\n",
                        tVertexIds[j] );
           }
        }
    }
    return maxCreaseValue;
}
开发者ID:janba,项目名称:OpenSubdiv,代码行数:34,代码来源:osdPolySmooth.cpp

示例8: makeSurf

MStatus makeSurf()
{
	cout << ">>>> Start creation of test surface <<<<" << endl;

	// Set up knots
	//
	MDoubleArray knotArray;
	int i;
    // Add extra starting knots so that the first CV matches the curve start point
	//
	knotArray.append( 0.0 );
	knotArray.append( 0.0 );
	for ( i = 0; i <= NUM_SPANS; i++ ) {
		knotArray.append( (double)i );
	}
	// Add extra ending knots so that the last CV matches the curve end point
	//
	knotArray.append( (double)i );
	knotArray.append( (double)i );
 
	// Now, Set up CVs
	//
	MPointArray cvArray;
	
	// We need a 2D array of CVs with NUM_SPANS + 3 CVs on a side
	//
	int last = NUM_SPANS + 3;
	for ( i = 0; i < last; i++ ) {
		for ( int j = 0; j < last; j++ ) {
			MPoint cv;
			cv.x = (((double)(j))/((double)(NUM_SPANS + 3)) * WIDTH) 
				- (WIDTH/2.0);
			cv.z = (((double)(i))/((double)(NUM_SPANS + 3)) * WIDTH) 
				- (WIDTH/2.0);
			double dist = sqrt( cv.x*cv.x + cv.z*cv.z );
			cv.y = cos( dist ) * VERTICAL_SCALING;
			cvArray.append( cv );
		}
	}

	// Create the surface
	// 
	MFnNurbsSurface mfnNurbsSurf;

	MStatus stat;
	mfnNurbsSurf.create( cvArray, knotArray, knotArray, 3, 3, 
						 MFnNurbsSurface::kOpen, MFnNurbsSurface::kOpen,
						 true, MObject::kNullObj, &stat );
 
	if ( stat ) {
		cout << ">>>> Test Surface Creation Successfull <<<<\n";
	} else {
		stat.perror("MFnNurbsSurface::create");
		cout << ">>>> Test Surface Creation Failed <<<<\n";
	}

	return stat;
}
开发者ID:DimondTheCat,项目名称:xray,代码行数:58,代码来源:surfaceCreate.cpp

示例9: if

MStatus helix::doIt( const MArgList& args )
{
	MStatus stat;

	const unsigned	deg 	= 3;			// Curve Degree
	const unsigned	ncvs 	= 20;			// Number of CVs
	const unsigned	spans 	= ncvs - deg;	// Number of spans
	const unsigned	nknots	= spans+2*deg-1;// Number of knots
	double	radius			= 4.0;			// Helix radius
	double	pitch 			= 0.5;			// Helix pitch
	unsigned	i;

	// Parse the arguments.
	for ( i = 0; i < args.length(); i++ )
		if ( MString( "-p" ) == args.asString( i, &stat )
				&& MS::kSuccess == stat)
		{
			double tmp = args.asDouble( ++i, &stat );
			if ( MS::kSuccess == stat )
				pitch = tmp;
		}
		else if ( MString( "-r" ) == args.asString( i, &stat )
				&& MS::kSuccess == stat)
		{
			double tmp = args.asDouble( ++i, &stat );
			if ( MS::kSuccess == stat )
				radius = tmp;
		}

	MPointArray	 controlVertices;
	MDoubleArray knotSequences;

	// Set up cvs and knots for the helix
	//
	for (i = 0; i < ncvs; i++)
		controlVertices.append( MPoint( radius * cos( (double)i ),
			pitch * (double)i, radius * sin( (double)i ) ) );

	for (i = 0; i < nknots; i++)
		knotSequences.append( (double)i );

	// Now create the curve
	//
	MFnNurbsCurve curveFn;

	curveFn.create( controlVertices,
					knotSequences, deg, 
					MFnNurbsCurve::kOpen, 
					false, false, 
					MObject::kNullObj, 
					&stat );

	if ( MS::kSuccess != stat )
		cout<<"Error creating curve."<<endl;

	return stat;
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:57,代码来源:helixCmd.cpp

示例10: getBulletVectorAttribute

MDoubleArray boingRbCmd::getBulletVectorAttribute(MString &name, MString &attr) {
    
    MVector vec;
    MDoubleArray result;
    
    shared_ptr<bSolverNode> b_solv = bSolverNode::get_bsolver_node();
    MStringArray nodes;
    if (name == "*") {
        nodes = b_solv->get_all_keys();
    } else {
        nodes.append(name);
    }
    
    //std::cout<<"nodes : "<<nodes<<std::endl;
    //std::cout<<"nodes.length() : "<<nodes.length()<<std::endl;
    
    for (int i=0; i<nodes.length(); i++) {
        
        std::cout<<"trying to get rb...."<<std::endl;
        rigid_body_t::pointer rb = b_solv->getdata(nodes[i])->m_rigid_body;
        std::cout<<"got rb : "<<b_solv->getdata(nodes[i])->name<<std::endl;
        
        //rigid_body_t::pointer rb = getPointerFromName(name);
        
        if (rb != 0) {
            float mass = rb->get_mass();
            bool active = (mass>0.f);
            if(active) {
                if (attr=="velocity") {
                    vec3f vel;
                    rb->get_linear_velocity(vel);
                    vec = MVector((double)vel[0], (double)vel[1], (double)vel[2]);
                } else if (attr=="position") {
                    vec3f pos;
                    quatf rot;
                    rb->get_transform(pos, rot);
                    vec = MVector((double)pos[0], (double)pos[1], (double)pos[2]);
                } else if (attr=="angularVelocity") {
                    vec3f av;
                    rb->get_angular_velocity(av);
                    vec = MVector((double)av[0], (double)av[1], (double)av[2]);
                } /*else {
                   boing *b = static_cast<boing*>( rb->impl()->body()->getUserPointer() );
                   MString vecStr = b->get_data(attr);
                   MStringArray vecArray = parseArguments(vecStr, ",");
                   vec = MVector(vecArray[0].asDouble(), vecArray[1].asDouble(), vecArray[2].asDouble());
                   }*/
            }
        }
        for (int j=0; j<3; j++) {
            //std::cout<<"vec["<<j<<"] : "<<vec[j]<<std::endl;
            result.append(vec[j]);
        }
    }
    return result;
    
}
开发者ID:ristopuukko,项目名称:boing,代码行数:57,代码来源:boingRBCmds.cpp

示例11: CreateNodeOnMesh

void
VertexPolyColourCommand::WriteColoursToNode(MDagPath& dagPath, MColorArray& colors, bool isSource)
{
	MStatus status;

	// Try to find the colour node attached to the mesh
	// If it's not found, create it
	MObject ourNode;
	if (!FindNodeOnMesh(dagPath,ourNode))
	{
		CreateNodeOnMesh(dagPath, ourNode);
	}

	// Send the selection to the node
	{
		// Pass the component list down to the node.
		// To do so, we create/retrieve the current plug
		// from the uvList attribute on the node and simply
		// set the value to our component list.
		//

		MDoubleArray dcols;
		dcols.setLength(colors.length()*4);
		int idx = 0;
		for (unsigned int i=0; i<colors.length(); i++)
		{
			dcols[idx] = (double)colors[i].r; idx++;
			dcols[idx] = (double)colors[i].g; idx++;
			dcols[idx] = (double)colors[i].b; idx++;
			dcols[idx] = (double)colors[i].a; idx++;
		}
		MFnDoubleArrayData wrapper;
		wrapper.create(dcols,&status);

		MPlug* colourPlug = NULL;
		if (isSource)
		{
			colourPlug = new MPlug(ourNode, PolyColourNode::m_colors);
		}
		else
		{
			colourPlug = new MPlug(ourNode, PolyColourNode::m_colorsDest);
		}

		// Warning, we have to do this as GCC doesn't like to pass by temporary reference
		MObject wrapperObjRef = wrapper.object();
		status = colourPlug->setValue(wrapperObjRef);
		delete colourPlug;
	}
}
开发者ID:jonntd,项目名称:MayaPlugin-VertexChameleon,代码行数:50,代码来源:VertexPolyColourCommand_Node.cpp

示例12: apply

void dynExprField::apply(
MDataBlock         &block,
int                 receptorSize,
const MDoubleArray &magnitudeArray,
const MDoubleArray &magnitudeOwnerArray,
const MVectorArray &directionArray,
const MVectorArray &directionOwnerArray,
MVectorArray       &outputForce
)
//
//      Compute output force for each particle.  If there exists the 
//      corresponding per particle attribute, use the data passed from
//      particle shape (stored in magnitudeArray and directionArray).  
//      Otherwise, use the attribute value from the field.
//
{
        // get the default values
	MVector defaultDir = direction(block);
	double  defaultMag = magnitude(block);
	int magArraySize = magnitudeArray.length();
	int dirArraySize = directionArray.length();
	int magOwnerArraySize = magnitudeOwnerArray.length();
	int dirOwnerArraySize = directionOwnerArray.length();
	int numOfOwner = magOwnerArraySize;
	if( dirOwnerArraySize > numOfOwner )
	    numOfOwner = dirOwnerArraySize;

	double  magnitude = defaultMag;
	MVector direction = defaultDir;

	for (int ptIndex = 0; ptIndex < receptorSize; ptIndex ++ ) {
	    if(receptorSize == magArraySize)
	        magnitude = magnitudeArray[ptIndex];
	    if(receptorSize == dirArraySize)
	        direction = directionArray[ptIndex];
	    if( numOfOwner > 0) {
	        for( int nthOwner = 0; nthOwner < numOfOwner; nthOwner++ ) {
		    if(magOwnerArraySize == numOfOwner)
		        magnitude = magnitudeOwnerArray[nthOwner];
		    if(dirOwnerArraySize == numOfOwner)
		        direction = directionOwnerArray[nthOwner];
		    outputForce.append( direction * magnitude );
		}
	    } else {
	        outputForce.append( direction * magnitude );
	    }
	}
}
开发者ID:BigRoy,项目名称:Maya-devkit,代码行数:48,代码来源:dynExprField.cpp

示例13: useOgawa

AlembicWriteJob::AlembicWriteJob(const MString &in_FileName,
                                 const MObjectArray &in_Selection,
                                 const MDoubleArray &in_Frames, bool use_ogawa,
                                 const std::vector<std::string> &in_prefixFilters,
                                 const std::set<std::string> &in_attributes,
                                 const std::vector<std::string> &in_userPrefixFilters,
                                 const std::set<std::string> &in_userAttributes)
    : useOgawa(use_ogawa),
    mPrefixFilters(in_prefixFilters),
    mAttributes(in_attributes),
    mUserPrefixFilters(in_userPrefixFilters),
    mUserAttributes(in_userAttributes)
{
  // ensure to clear the isRefAnimated cache
  clearIsRefAnimatedCache();

  mFileName = in_FileName;
  for (unsigned int i = 0; i < in_Selection.length(); i++) {
    mSelection.append(in_Selection[i]);
  }

  for (unsigned int i = 0; i < in_Frames.length(); i++) {
    mFrames.push_back(in_Frames[i]);
  }
}
开发者ID:BlackGinger,项目名称:ExocortexCrate,代码行数:25,代码来源:AlembicWriteJob.cpp

示例14: applyCreaseEdges

// Reference: OSD shape_utils.h:: applyTags() "crease"
float
applyCreaseEdges(MFnMesh const & inMeshFn, HMesh * hbrMesh) {

    MStatus returnStatus;
    MUintArray tEdgeIds;
    MDoubleArray tCreaseData;
    float maxCreaseValue = 0.0f;

    if (inMeshFn.getCreaseEdges(tEdgeIds, tCreaseData)) {

        assert( tEdgeIds.length() == tCreaseData.length() );

        // Has crease edges
        int2 edgeVerts;
        for (unsigned int j=0; j < tEdgeIds.length(); j++) {

            // Get vert ids from maya edge
            int edgeId = tEdgeIds[j];
            returnStatus = inMeshFn.getEdgeVertices(edgeId, edgeVerts);

            // Assumption: The OSD vert ids are identical to those of the Maya mesh
            HVertex const * v = hbrMesh->GetVertex( edgeVerts[0] ),
                          * w = hbrMesh->GetVertex( edgeVerts[1] );

            HHalfedge * e = 0;
            if( v and w ) {

                if( (e = v->GetEdge(w)) == 0) {
                    e = w->GetEdge(v);
                }

                if(e) {
                    assert( tCreaseData[j] >= 0.0 );
                    e->SetSharpness( (float)tCreaseData[j] );

                    maxCreaseValue = std::max(float(tCreaseData[j]), maxCreaseValue);
                } else {
                    fprintf(stderr,
                        "warning: cannot find edge for crease tag (%d,%d)\n",
                            edgeVerts[0], edgeVerts[1] );
                }
            }
        }
    }
    return maxCreaseValue;
}
开发者ID:janba,项目名称:OpenSubdiv,代码行数:47,代码来源:osdPolySmooth.cpp

示例15: createHelix

void HelixButton::createHelix()
{
    MStatus st;
    const unsigned deg = 3;             // Curve Degree
    const unsigned ncvs = 20;            // Number of CVs
    const unsigned spans = ncvs - deg;    // Number of spans
    const unsigned nknots = spans + 2 * deg - 1; // Number of knots
    double         radius = 4.0;           // Helix radius
    double         pitch = 0.5;           // Helix pitch
    unsigned       i;
    MPointArray controlVertices;
    MDoubleArray knotSequences;
    // Set up cvs and knots for the helix
    for (i = 0; i < ncvs; i++) {
        controlVertices.append(
            MPoint(
                radius * cos((double)i),
                pitch * (double)i,
                radius * sin((double)i)
                )
            );
    }
    for (i = 0; i < nknots; i++)
        knotSequences.append((double)i);
    // Now create the curve
    MFnNurbsCurve curveFn;
    MObject curve = curveFn.create(
        controlVertices,
        knotSequences,
        deg,
        MFnNurbsCurve::kOpen,
        false,
        false,
        MObject::kNullObj,
        &st
        );
    MGlobal::displayInfo("Helix curve created!");

    if (!st) {
        MGlobal::displayError(
            HelixQtCmd::commandName + " - could not create helix: "
            + st.errorString()
            );
    }
}
开发者ID:EmreTekinalp,项目名称:Qt,代码行数:45,代码来源:helixCmd.cpp


注:本文中的MDoubleArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。