本文整理汇总了C++中MDataHandle::setFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ MDataHandle::setFloat方法的具体用法?C++ MDataHandle::setFloat怎么用?C++ MDataHandle::setFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MDataHandle
的用法示例。
在下文中一共展示了MDataHandle::setFloat方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compute
//.........这里部分代码省略.........
//finds min and max z-coordinate values to determine middle point (choice of z-axis was ours)
for (int i = 0; i < magNumPoints; i++) {
min = magVerts[i].z < min ? magVerts[i].z : min;
max = magVerts[i].z > max ? magVerts[i].z : max;
}
double middle = (min + max) / 2;
double polarity[magNumPoints];
//assigns polarity based on middle point of mesh
for (int i = 0; i < magNumPoints; i++) {
polarity[i] = magVerts[i].z > middle ? max / magVerts[i].z : -min / magVerts[i].z;
}
double* objdVerts = (double *)malloc(sizeof(double) * objNumPoints * 3);
double* magdVerts = (double *)malloc(sizeof(double) * magNumPoints * 3);
//creates handles to use attribute data
MDataHandle vecX = data.inputValue(transX, &status);
MDataHandle vecY = data.inputValue(transY, &status);
MDataHandle vecZ = data.inputValue(transZ, &status);
//gathers previously stored coordinates of the center of the object
double moveX = vecX.asFloat();
double moveY = vecY.asFloat();
double moveZ = vecZ.asFloat();
//translates object based on the position stored in the attribute values
for (int i=0; i<objNumPoints; i++) {
objdVerts[i * 3] = tempverts[i].x + moveX;
objdVerts[i * 3 + 1] = tempverts[i].y + moveY;
objdVerts[i * 3 + 2] = tempverts[i].z + moveZ;
}
for (int i=0; i<magNumPoints; i++) {
magdVerts[i * 3] = magVerts[i].x;
magdVerts[i * 3 + 1] = magVerts[i].y;
magdVerts[i * 3 + 2] = magVerts[i].z;
}
double teslaData = data.inputValue(tesla, &status).asDouble();
MDataHandle posiData = data.inputValue(positivelycharged, &status);
double pivot[6] = {DBL_MAX, -DBL_MAX, DBL_MAX, -DBL_MAX, DBL_MAX, -DBL_MAX};
//finds the pivot point of the object in world space prior to being affected by the magnet
for (int i = 0; i < tempverts.length(); i++) {
pivot[0] = tempverts[i].x < pivot[0] ? tempverts[i].x : pivot[0];
pivot[1] = tempverts[i].x > pivot[1] ? tempverts[i].x : pivot[1];
pivot[2] = tempverts[i].y < pivot[2] ? tempverts[i].y : pivot[2];
pivot[3] = tempverts[i].y > pivot[3] ? tempverts[i].y : pivot[3];
pivot[4] = tempverts[i].z < pivot[4] ? tempverts[i].z : pivot[4];
pivot[5] = tempverts[i].z > pivot[5] ? tempverts[i].z : pivot[5];
}
MTimer timer; timer.beginTimer();
//main function call
magnetForce(magNumPoints, objNumPoints, teslaData, magdVerts,
objdVerts, polarity, posiData.asBool(), offloadData.asBool());
timer.endTimer(); printf("Runtime for threaded loop %f\n", timer.elapsedTime());
for (int i=0; i<objNumPoints; i++) {
objVerts[i].x = objdVerts[i * 3 + 0];
objVerts[i].y = objdVerts[i * 3 + 1];
objVerts[i].z = objdVerts[i * 3 + 2];
}
//finds the pivot point of object in world space after being affected by the magnet
double objCenter[6] = {DBL_MAX, -DBL_MAX, DBL_MAX, -DBL_MAX, DBL_MAX, -DBL_MAX};
for (int i = 0; i < tempverts.length(); i++) {
objCenter[0] = objVerts[i].x < objCenter[0] ? objVerts[i].x : objCenter[0];
objCenter[1] = objVerts[i].x > objCenter[1] ? objVerts[i].x : objCenter[1];
objCenter[2] = objVerts[i].y < objCenter[2] ? objVerts[i].y : objCenter[2];
objCenter[3] = objVerts[i].y > objCenter[3] ? objVerts[i].y : objCenter[3];
objCenter[4] = objVerts[i].z < objCenter[4] ? objVerts[i].z : objCenter[4];
objCenter[5] = objVerts[i].z > objCenter[5] ? objVerts[i].z : objCenter[5];
}
//creates vector based on the two calculated pivot points
moveX = (objCenter[0] + objCenter[1]) / 2 - (pivot[0] + pivot[1]) / 2;
moveY = (objCenter[2] + objCenter[3]) / 2 - (pivot[2] + pivot[3]) / 2;
moveZ = (objCenter[4] + objCenter[5]) / 2 - (pivot[4] + pivot[5]) / 2;
//stores pivot vector for next computation
if (teslaData) {
vecX.setFloat(moveX);
vecY.setFloat(moveY);
vecZ.setFloat(moveZ);
}
// write values back onto output using fast set method on iterator
iter.setAllPositions(objVerts, MSpace::kWorld);
free(objdVerts);
free(magdVerts);
return status;
}