本文整理汇总了C++中LSystem::setDefaultAngle方法的典型用法代码示例。如果您正苦于以下问题:C++ LSystem::setDefaultAngle方法的具体用法?C++ LSystem::setDefaultAngle怎么用?C++ LSystem::setDefaultAngle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LSystem
的用法示例。
在下文中一共展示了LSystem::setDefaultAngle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMesh
MObject LSystemNode::createMesh(const double & angle, const double & step, const MString & grammar,
const MTime& time, MObject& outData, MStatus& stat)
{
//int numVertices, frame;
//float cubeSize;
//MFloatPointArray points;
MPointArray points;
MIntArray faceCounts;
MIntArray faceConnects;
MFnMesh meshFS;
LSystem lsys;
lsys.setDefaultAngle(angle); //angle
lsys.setDefaultStep(step); //step size
string gram = grammar.asChar(); //grammar
lsys.loadProgramFromString(gram);
std::vector<LSystem::Branch> branches;
lsys.process((int)time.value(),branches);
CylinderMesh*cm;
for(int j = 0;j<branches.size();j++)
{
vec3 Bstart = branches[j].first;
vec3 Bend = branches[j].second;
MPoint b_start(Bstart[0],Bstart[1],Bstart[2]);
MPoint b_end(Bend[0],Bend[1],Bend[2]);
cm = new CylinderMesh(b_start,b_end);
cm->appendToMesh(points,faceCounts,faceConnects);
}
/*
// 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;*/
MObject newMesh = meshFS.create(points.length()
,faceCounts.length(),points,faceCounts
,faceConnects,outData,&stat);
return newMesh;
}
示例2: compute
MStatus LSystemNode::compute(const MPlug& plug, MDataBlock& data)
{
MStatus returnStatus;
if (plug == outputMesh) {
/* Get time */
MDataHandle timeData = data.inputValue( time, &returnStatus );
McheckErr(returnStatus, "Error getting time data handle\n");
MTime time = timeData.asTime();
MDataHandle angleData = data.inputValue( angle, &returnStatus );
McheckErr(returnStatus, "Error getting time data handle\n");
double angle_value = angleData.asDouble();
MDataHandle stepsData = data.inputValue( steps, &returnStatus );
McheckErr(returnStatus, "Error getting time data handle\n");
double steps_value = stepsData.asDouble();
MDataHandle grammarData = data.inputValue( grammar, &returnStatus );
McheckErr(returnStatus, "Error getting time data handle\n");
MString grammar_value = grammarData.asString();
/* Get output object */
MDataHandle outputHandle = data.outputValue(outputMesh, &returnStatus);
McheckErr(returnStatus, "ERROR getting polygon data handle\n");
MFnMeshData dataCreator;
MObject newOutputData = dataCreator.create(&returnStatus);
McheckErr(returnStatus, "ERROR creating outputData");
MFnMesh myMesh;
MPointArray points;
MIntArray faceCounts;
MIntArray faceConnects;
//MString grammar = ("F\\nF->F[+F]F[-F]F");
CylinderMesh *cm;
LSystem system;
system.loadProgramFromString(grammar_value.asChar());
system.setDefaultAngle(angle_value);
system.setDefaultStep(steps_value);
std::vector<LSystem::Branch> branches;
system.process(time.value(), branches);
int k = branches.size();
for(int j = 0; j < branches.size(); j++)
{
//1. find the position for start and end point of current branch
//2. generate a cylinder
MPoint start(branches[j].first[0],branches[j].first[1],branches[j].first[2]);
MPoint end(branches[j].second[0],branches[j].second[1],branches[j].second[2]);
cm = new CylinderMesh(start, end);
cm->appendToMesh(points, faceCounts, faceConnects);
}
MObject newMesh = myMesh.create(points.length(), faceCounts.length(),
points, faceCounts, faceConnects,
newOutputData, &returnStatus);
McheckErr(returnStatus, "ERROR creating new mesh");
outputHandle.set(newOutputData);
data.setClean( plug );
} else
return MS::kUnknownParameter;
return MS::kSuccess;
}