本文整理汇总了C++中GEO_Point::setPos方法的典型用法代码示例。如果您正苦于以下问题:C++ GEO_Point::setPos方法的具体用法?C++ GEO_Point::setPos怎么用?C++ GEO_Point::setPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GEO_Point
的用法示例。
在下文中一共展示了GEO_Point::setPos方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: instanceCube
/* ******************************************************************************
* Function Name : instanceCube()
*
* Description :
*
* Input Arguments : GU_Detail *inst_gdp, GU_Detail *mb_gdp
*
* Return Value : int
*
***************************************************************************** */
int VRAY_clusterThis::instanceCube(GU_Detail * inst_gdp, GU_Detail * mb_gdp)
{
#ifdef DEBUG
std::cout << "VRAY_clusterThis::instanceCube()" << std::endl;
#endif
GEO_Primitive * myCube;
GEO_Point * ppt;
UT_Matrix4 xform(1.0);
// UT_XformOrder xformOrder(UT_XformOrder::TRS, UT_XformOrder::XYZ);
UT_Matrix3 rot_xform(1.0);
// UT_Vector3 myDir = myPointAttributes.N;
UT_Vector3 myUp = UT_Vector3(0,1,0);
rot_xform.orient(myPointAttributes.N, myUp);
xform = rot_xform;
myCube = (GEO_Primitive *) inst_gdp->cube(
myPointAttributes.myNewPos[0] - ((mySize[0] * myPointAttributes.pscale) / 2),
myPointAttributes.myNewPos[0] + ((mySize[0] * myPointAttributes.pscale) / 2),
myPointAttributes.myNewPos[1] - ((mySize[1] * myPointAttributes.pscale) / 2),
myPointAttributes.myNewPos[1] + ((mySize[1] * myPointAttributes.pscale) / 2),
myPointAttributes.myNewPos[2] - ((mySize[2] * myPointAttributes.pscale) / 2),
myPointAttributes.myNewPos[2] + ((mySize[2] * myPointAttributes.pscale) / 2));
for(int i=0; i < myCube->getVertexCount(); i++) {
ppt = myCube->getVertexElement(i).getPt();
UT_Vector4 P = ppt->getPos();
P *= xform;
ppt->setPos(P);
}
VRAY_clusterThis::setInstanceAttributes(myCube);
if(myDoMotionBlur == CLUSTER_MB_DEFORMATION) {
myCube = (GEO_Primitive *) mb_gdp->cube(myPointAttributes.myMBPos[0] - ((mySize[0] * myPointAttributes.pscale) / 2),
myPointAttributes.myMBPos[0] + ((mySize[0] * myPointAttributes.pscale) / 2),
myPointAttributes.myMBPos[1] - ((mySize[1] * myPointAttributes.pscale) / 2),
myPointAttributes.myMBPos[1] + ((mySize[1] * myPointAttributes.pscale) / 2),
myPointAttributes.myMBPos[2] - ((mySize[2] * myPointAttributes.pscale) / 2),
myPointAttributes.myMBPos[2] + ((mySize[2] * myPointAttributes.pscale) / 2));
for(int i=0; i < myCube->getVertexCount(); i++) {
ppt = myCube->getVertexElement(i).getPt();
UT_Vector4 P = ppt->getPos();
P *= xform;
ppt->setPos(P);
}
VRAY_clusterThis::setInstanceAttributes(myCube);
}
if(myCVEX_Exec)
VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname, CLUSTER_CVEX_POINT);
if(myCVEX_Exec_prim)
VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname_prim, CLUSTER_CVEX_PRIM);
return 0;
}
示例2: instancePoint
/* ******************************************************************************
* Function Name : instancePoint()
*
* Description : Instance a point
*
* Input Arguments : GU_Detail *inst_gdp, GU_Detail *mb_gdp
*
* Return Value : int
*
***************************************************************************** */
int VRAY_clusterThis::instancePoint(GU_Detail * inst_gdp, GU_Detail * mb_gdp)
{
#ifdef DEBUG
std::cout << "VRAY_clusterThis::instancePoint()" << std::endl;
#endif
GEO_Point * ppt;
ppt = inst_gdp->appendPointElement();
ppt->setPos((float)myPointAttributes.myNewPos[0],
(float)myPointAttributes.myNewPos[1],
(float)myPointAttributes.myNewPos[2], 1.0);
VRAY_clusterThis::setPointInstanceAttributes(inst_gdp, ppt);
if(myDoMotionBlur == CLUSTER_MB_DEFORMATION) {
ppt = mb_gdp->appendPointElement();
ppt->setPos((float)myPointAttributes.myMBPos[0],
(float)myPointAttributes.myMBPos[1],
(float)myPointAttributes.myMBPos[2], 1.0);
VRAY_clusterThis::setPointInstanceAttributes(mb_gdp, ppt);
}
if(myCVEX_Exec)
VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname, CLUSTER_CVEX_POINT);
return 0;
}
示例3: instanceGrid
/* ******************************************************************************
* Function Name : instanceGrid()
*
* Description : Instance a grid
*
* Input Arguments : GU_Detail *inst_gdp, GU_Detail *mb_gdp
*
* Return Value : int
*
***************************************************************************** */
int VRAY_clusterThis::instanceGrid(GU_Detail * inst_gdp, GU_Detail * mb_gdp)
{
#ifdef DEBUG
std::cout << "VRAY_clusterThis::instanceGrid()" << std::endl;
#endif
GEO_Primitive * myGrid;
GU_GridParms grid_parms;
UT_XformOrder xformOrder(UT_XformOrder::TRS, UT_XformOrder::XYZ);
UT_Matrix4 xform(1.0);
xform.rotate(myPointAttributes.N[0], myPointAttributes.N[1], myPointAttributes.N[2], xformOrder);
grid_parms.rows = 2;
grid_parms.cols = 2;
grid_parms.xsize = mySize[0] * myPointAttributes.pscale;
grid_parms.ysize = mySize[1] * myPointAttributes.pscale;
grid_parms.xcenter = myPointAttributes.myNewPos[0];
grid_parms.ycenter = myPointAttributes.myNewPos[1];
grid_parms.zcenter = myPointAttributes.myNewPos[2];
grid_parms.plane = GU_PLANE_XY;
myGrid = inst_gdp->buildGrid(grid_parms, GU_GRID_POLY);
for(int i = 0; i < myGrid->getVertexCount(); i++) {
GEO_Point * ppt = myGrid->getVertexElement(i).getPt();
UT_Vector4 P = ppt->getPos();
P *= xform;
ppt->setPos(P);
}
VRAY_clusterThis::setInstanceAttributes(myGrid);
if(myDoMotionBlur == CLUSTER_MB_DEFORMATION) {
grid_parms.xcenter = myPointAttributes.myMBPos[0];
grid_parms.ycenter = myPointAttributes.myMBPos[1];
grid_parms.zcenter = myPointAttributes.myMBPos[2];
myGrid = mb_gdp->buildGrid(grid_parms, GU_GRID_POLY);
for(int i = 0; i < myGrid->getVertexCount(); i++) {
GEO_Point * ppt = myGrid->getVertexElement(i).getPt();
UT_Vector4 P = ppt->getPos();
P *= xform;
ppt->setPos(P);
}
VRAY_clusterThis::setInstanceAttributes(myGrid);
}
if(myCVEX_Exec)
VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname, CLUSTER_CVEX_POINT);
if(myCVEX_Exec_prim)
VRAY_clusterThis::runCVEX(inst_gdp, mb_gdp, myCVEXFname_prim, CLUSTER_CVEX_PRIM);
return 0;
}
示例4: instanceCurve
/* ******************************************************************************
* Function Name : instanceCurve()
*
* Description : Instance a curve
*
* Input Arguments : GU_Detail *inst_gdp, GU_Detail *mb_gdp
*
* Return Value : int
*
***************************************************************************** */
int VRAY_clusterThis::instanceCurve(GU_Detail * inst_gdp, GU_Detail * mb_gdp, fpreal theta, long int point_num)
{
#ifdef DEBUG
std::cout << "VRAY_clusterThis::instanceCurve()" << std::endl;
#endif
GEO_Point * ppt;
GU_PrimNURBCurve * myCurve, * myMBCurve;
uint32 num_vtx;
int myCurvePointNum = 0;
UT_Vector4 pt_pos;
GU_Detail * curve_gdp, * curve_mb_gdp;
curve_gdp = allocateGeometry();
GA_RWAttributeRef prim_Cd = curve_gdp->addDiffuseAttribute(GEO_PRIMITIVE_DICT);
GA_RWAttributeRef prim_Alpha = curve_gdp->addAlphaAttribute(GEO_PRIMITIVE_DICT);
GA_RWAttributeRef prim_v = curve_gdp->addVelocityAttribute(GEO_PRIMITIVE_DICT);
GA_RWAttributeRef prim_N = curve_gdp->addNormalAttribute(GEO_PRIMITIVE_DICT);
GA_RWAttributeRef prim_material = curve_gdp->addStringTuple(GEO_PRIMITIVE_DICT, "shop_materialpath", 1);
GA_RWAttributeRef pt_Cd = curve_gdp->addDiffuseAttribute(GEO_POINT_DICT);
GA_RWAttributeRef pt_Alpha = curve_gdp->addAlphaAttribute(GEO_POINT_DICT);
GA_RWAttributeRef pt_v = curve_gdp->addVelocityAttribute(GEO_POINT_DICT);
GA_RWAttributeRef pt_N = curve_gdp->addNormalAttribute(GEO_POINT_DICT);
GA_RWAttributeRef pt_pscale = curve_gdp->addFloatTuple(GA_ATTRIB_POINT, "pscale", 1);
GA_RWAttributeRef pt_width = curve_gdp->addFloatTuple(GA_ATTRIB_POINT, "width", 1);
GA_RWAttributeRef pt_id = curve_gdp->addIntTuple(GA_ATTRIB_POINT, "id", 1);
GA_RWAttributeRef pt_instId = curve_gdp->addIntTuple(GA_ATTRIB_POINT, "inst_id", 1);
GA_RWAttributeRef pt_material = curve_gdp->addStringTuple(GA_ATTRIB_POINT, "shop_materialpath", 1);
GA_RWAttributeRef pt_mb_Cd;
GA_RWAttributeRef pt_mb_Alpha;
GA_RWAttributeRef pt_mb_v;
GA_RWAttributeRef pt_mb_N;
GA_RWAttributeRef pt_mb_pscale;
GA_RWAttributeRef pt_mb_width;
GA_RWAttributeRef pt_mb_id;
GA_RWAttributeRef pt_mb_instId;
GA_RWAttributeRef pt_mb_material;
num_vtx = ((myNumCopies * myRecursion) > 4) ? (myNumCopies * myRecursion) : 4;
myCurve = (GU_PrimNURBCurve *)GU_PrimNURBCurve::build((GU_Detail *)curve_gdp, num_vtx, 4, 0, 1, 1);
myCurve->setValue<UT_Vector3>(prim_Cd, (const UT_Vector3)myPointAttributes.Cd);
myCurve->setValue<fpreal>(prim_Alpha, (const fpreal)myPointAttributes.Alpha);
myCurve->setString(prim_material, myPointAttributes.material);
// cout << "VRAY_clusterThis::instanceCurve() - num vertices: " << myCurve->getVertexCount() << endl;;
// cout << "id: " << myCurve->getPrimitiveId() << endl;
// cout << "breakCount: " << myCurve->breakCount() << endl;
if(myDoMotionBlur == CLUSTER_MB_DEFORMATION) {
curve_mb_gdp = allocateGeometry();
myMBCurve = (GU_PrimNURBCurve *)GU_PrimNURBCurve::build((GU_Detail *)curve_mb_gdp, num_vtx, 4, 0, 1, 1);
pt_mb_Cd = curve_gdp->addDiffuseAttribute(GEO_POINT_DICT);
pt_mb_Alpha = curve_gdp->addAlphaAttribute(GEO_POINT_DICT);
pt_mb_v = curve_gdp->addVelocityAttribute(GEO_POINT_DICT);
pt_mb_N = curve_gdp->addNormalAttribute(GEO_POINT_DICT);
pt_mb_pscale = curve_gdp->addFloatTuple(GA_ATTRIB_POINT, "pscale", 1);
pt_mb_width = curve_gdp->addFloatTuple(GA_ATTRIB_POINT, "width", 1);
pt_mb_id = curve_gdp->addIntTuple(GA_ATTRIB_POINT, "id", 1);
pt_mb_instId = curve_gdp->addIntTuple(GA_ATTRIB_POINT, "inst_id", 1);
pt_mb_material = curve_gdp->addStringTuple(GA_ATTRIB_POINT, "shop_materialpath", 1);
}
for(int copyNum = 0; copyNum < myNumCopies; copyNum++)
for(int recursionNum = 0; recursionNum < myRecursion; recursionNum++) {
VRAY_clusterThis::calculateNewPosition(theta, copyNum, recursionNum);
ppt = myCurve->getVertexElement(myCurvePointNum).getPt();
ppt->setPos((float)myPointAttributes.myNewPos[0],
(float)myPointAttributes.myNewPos[1],
(float)myPointAttributes.myNewPos[2], 1.0);
// Assign attributes to each point
ppt->setValue<UT_Vector3>(pt_Cd, (const UT_Vector3)myPointAttributes.Cd);
ppt->setValue<fpreal>(pt_Alpha, (const fpreal)myPointAttributes.Alpha);
ppt->setValue<UT_Vector3>(pt_v, (const UT_Vector3)myPointAttributes.v);
ppt->setValue<UT_Vector3>(pt_N, (const UT_Vector3)myPointAttributes.N);
ppt->setValue<fpreal>(pt_pscale, (const fpreal)myPointAttributes.pscale);
ppt->setValue<fpreal>(pt_width, (const fpreal)myPointAttributes.width);
ppt->setValue<int>(pt_id, (const int)myPointAttributes.id);
ppt->setValue<int>(pt_instId, (const int)myCurvePointNum);
ppt->setString(pt_material, myPointAttributes.material);
if(myDoMotionBlur == CLUSTER_MB_DEFORMATION) {
ppt = myMBCurve->getVertexElement(myCurvePointNum).getPt();
ppt->setPos((float)myPointAttributes.myNewPos[0],
//.........这里部分代码省略.........
示例5: sizeof
//.........这里部分代码省略.........
attribLut[i] = attr;
}
//The channel values for particle shapes are stored in blocks/tiles.
unsigned int absPtNum = 0;
//Get the block array for the positions channel
const em::block3_array3f& positionBlocks( pShape->constBlocks3f("position") );
unsigned int numBlocks = positionBlocks.block_count();
unsigned int bsize;
float dec_accumulator = 0.0f;
float dec = (1.0f - (_decimation)/100.0f);
LogInfo() << "Keeping decimation value: " << dec << std::endl;
for (int blockIndex = 0; blockIndex < numBlocks; blockIndex ++)
{
//if (ptNum % 100 == 0)
//Get a single block from the position blocks
const em::block3vec3f& posBlock = positionBlocks(blockIndex);
if ( blockIndex % 100 == 0 )
LogDebug() << "Block: " << blockIndex << "/" << numBlocks << std::endl;
//Iterate over all the points/particles in the position block
bsize = posBlock.size();
//Only process the point if the decimation accumulator is greater than one.
for (int ptNum = 0; ptNum < bsize; ptNum++, absPtNum++)
{
dec_accumulator += dec;
if (dec_accumulator < 1.0f)
//Skip this point
continue;
//Process this point, remove the dec_accumulator rollover.
dec_accumulator -= (int) dec_accumulator;
ppt = _gdp->appendPoint();
pParticle->appendParticle(ppt);
ppt->setPos( UT_Vector3( posBlock(ptNum)[0], posBlock(ptNum)[1], posBlock(ptNum)[2] ) );
//Loop over the channels and add the attributes
//This loop needs to be as fast as possible.
for (int channelIndex = 0; channelIndex < channelCount; channelIndex++)
{
pInfo = &(attribInfo[ channelIndex ]);
//If the attribute is not supported then skip it
if (!pInfo->supported)
{
continue;
}
attribLut[ channelIndex ].setElement( ppt );
switch ( pInfo->type )
{
case GB_ATTRIB_INT:
{
if (pInfo->use64)
{
const em::block3i64& channelData( pShape->constBlocks1i64(channelIndex)(blockIndex) );
//Get the Houdini point attribute using the name list we built earlier.
attribLut[channelIndex].setI( channelData(ptNum) );
}
else
{
const em::block3i& channelData( pShape->constBlocks1i(channelIndex)(blockIndex) );
//Get the Houdini point attribute using the name list we built earlier.
attribLut[channelIndex].setI( channelData(ptNum) );
}
}
break;
case GB_ATTRIB_FLOAT:
{
//TODO: Handle more that 1 entry here, if we ever get something like that ... although I doubt it would happen.
const em::block3f& channelData( pShape->constBlocks1f(channelIndex)(blockIndex) );
//Get the Houdini point attribute using the name list we built earlier.
attribLut[channelIndex].setF( channelData(ptNum) );
}
break;
case GB_ATTRIB_VECTOR:
{
const em::block3vec3f& channelData( pShape->constBlocks3f(channelIndex)(blockIndex) );
//Get the Houdini point attribute using the name list we built earlier.
attribLut[channelIndex].setV3( UT_Vector3( channelData(ptNum)[0], channelData(ptNum)[1], channelData(ptNum)[2] ) );
}
break;
default:
//not yet implemented.
continue;
break;
}
}
}
}
//std::cout << "all done. " << std::endl;
return EC_SUCCESS;
}
示例6: cookMySop
//.........这里部分代码省略.........
use_cull_cam = true;
cam_near = cam->getNEAR(now);
cam_far = cam->getFAR(now);
std::cerr << "near: " << cam_near << std::endl;
std::cerr << "far: " << cam_far << std::endl;
mRedraw = true;
}
}
std::cerr << "cull camera: " << cullCamera << std::endl;
std::cerr << nearDensity << ", " << farDensity << std::endl;
}
*/
// add data from our cached points to geometry
// based on display/output probability
srand(0);
float density_mult = 1.f;
while( pos_it!=cachePoints.end() )
{
/*
if ( use_cull_cam )
{
float dist = ((*pos_it)-cam_pos).length();
if ( dist<cam_near )
density_mult = nearDensity;
else if ( dist>cam_far )
density_mult = farDensity;
else
{
float normalize_dist =( dist - cam_near ) / ( cam_far - cam_near );
density_mult = 1.f - normalize_dist;
}
}
*/
if ( rand()/(float)RAND_MAX <
ptc_gdp->display_probability*density_mult )
{
if ( (!ptc_gdp->use_cull_bbox) ||
(ptc_gdp->use_cull_bbox &&
ptc_gdp->cull_bbox.isInside( *pos_it ) ) )
{
// add to our SOP geometry
GEO_Point *pt = ptc_gdp->appendPoint();
pt->setPos( *pos_it );
(*pt->castAttribData<UT_Vector3>(n_attrib)) = *norm_it;
(*pt->castAttribData<float>(r_attrib)) = *rad_it;
const float *data = &*data_it;
for ( unsigned int i=0; i<data_types.size(); ++i )
{
if ( onlyOutputDisplayChannel )
{
if ( i==displayChannel )
{
pt->set( data_attribs[0], data, data_size[i] );
}
data += data_size[i];
}
else
{
pt->set( data_attribs[i], data, data_size[i] );
data += data_size[i];
}
}
}
}
// increment our interators
pos_it++;
norm_it++;
rad_it++;
data_it+=ptc_gdp->datasize;
}
// delete our particle primitive
ptc_gdp->deletePrimitive(0,0);
// info in sop's message area
std::stringstream ss;
ss << "Name: " << ptc_gdp->path << std::endl;
ss << "Points: " << ptc_gdp->nPoints << " - [ " <<
ptc_gdp->nLoaded << " loaded ]" << std::endl;
ss << "Channels: " << ptc_gdp->nChannels << std::endl;
for ( unsigned int i=0; i<ptc_gdp->nChannels; ++i )
ss << " " << i << ": " << mChannelNames[i] << std::endl;
addMessage( SOP_MESSAGE, ss.str().c_str() );
// Tell the interrupt server that we've completed
boss->opEnd();
// force update?
ptc_gdp->redraw = mRedraw;
mRedraw = false;
}
// tidy up & go home
unlockInputs();
return error();
}
示例7: cookMySop
OP_ERROR SOP_CudaParticles::cookMySop(OP_Context &context) {
oldf = f;
f = context.getFrame();
GEO_ParticleVertex* pvtx;
double t = context.getTime();
particlesSystem->dt = 1/(OPgetDirector()->getChannelManager()->getSamplesPerSec() * SUBSTEPS(t));
particlesSystem->preview = PREVIEW(t);
particlesSystem->partsLife = LIFE(t);
particlesSystem->partsLifeVar = LIFEVAR(t);
particlesSystem->velDamp = VELDAMP(t);
particlesSystem->gravityStrength = GRAVITYSTR(t);
particlesSystem->gravityDir = cu::make_float3(GRAVITYX(t),GRAVITYY(t),GRAVITYZ(t));
particlesSystem->fluidStrength = FLUIDSTR(t);
particlesSystem->noiseAmp = cu::make_float3(NOISEAMP(t),NOISEAMP(t),NOISEAMP(t));
particlesSystem->noiseOct = NOISEOCT(t);
particlesSystem->noiseFreq = NOISEFREQ(t);
particlesSystem->noiseLac = NOISELACUN(t);
particlesSystem->noiseOffset = cu::make_float3(NOISEOFFSETX(t),NOISEOFFSETY(t),NOISEOFFSETZ(t));
particlesSystem->pointSize = POINTSIZE(t);
particlesSystem->opacity = OPACITY(t);
particlesSystem->startColor = cu::make_float3(STARTCOLORX(t),STARTCOLORY(t),STARTCOLORZ(t));
particlesSystem->endColor = cu::make_float3(ENDCOLORX(t),ENDCOLORY(t),ENDCOLORZ(t));
UT_Interrupt *boss;
OP_Node::flags().timeDep = 1;
if (error() < UT_ERROR_ABORT) {
boss = UTgetInterrupt();
// Start the interrupt server
if (boss->opStart("Building Particles")){
//gdp->clearAndDestroy();
static float zero = 0.0;
GB_AttributeRef partsAtt = gdp->addAttrib("cudaParticlesPreview", sizeof(int), GB_ATTRIB_INT, &zero);
gdp->attribs().getElement().setValue<int>(partsAtt, particlesSystem->preview);
GB_AttributeRef systemIdAtt = gdp->addAttrib("systemId", sizeof(int), GB_ATTRIB_INT, &zero);
gdp->attribs().getElement().setValue<int>(systemIdAtt, particlesSystem->id);
if (f < STARTFRAME(t)) {
gdp->clearAndDestroy();
particlesSystem->resetParticles();
} else if (f == STARTFRAME(t)) {
gdp->clearAndDestroy();
particlesSystem->resetParticles();
int maxParts = MAXPARTS(t);
if (particlesSystem->nParts!=maxParts)
particlesSystem->changeMaxParts(maxParts);
//hSystem = (GEO_PrimParticle *)gdp->appendPrimitive(GEOPRIMPART);
//hSystem->clearAndDestroy();
GB_AttributeRef hVelocity = gdp->addPointAttrib("v", sizeof(UT_Vector3),GB_ATTRIB_VECTOR, 0);
GB_AttributeRef hLife = gdp->addPointAttrib("life", sizeof(float)*2,GB_ATTRIB_FLOAT, 0);
if(particlesSystem->preview!=1) {
UT_Vector4 orig = UT_Vector4(0,0,0,1);
for (int i = 0; i<particlesSystem->nParts; i++) {
GEO_Point* newPoint = gdp->appendPoint();
newPoint->setPos(orig);
/*pvtx = hSystem->giveBirth();
GEO_Point* ppt = pvtx->getPt();
//ppt->getPos().assign(0,0,0,1);*/
hSystemInit = 1;
}
}
} else {
if(particlesSystem->nParts != -1) {
if(lockInputs(context) >= UT_ERROR_ABORT)
return error();
if(getInput(0)){
GU_Detail* emittersInput = (GU_Detail*)inputGeo(0, context);
//.........这里部分代码省略.........
示例8: preProcess
//.........这里部分代码省略.........
if(myPreVDBLaplacianFilter)
preProcessFilter.laplacian();
// if(myVDBReNormalizeFilter)
// float r = barFilter.renormalize(3, 0.1);
if(myPreVDBOffsetFilter)
preProcessFilter.offset(myPreVDBOffsetFilterAmount);
myGradientGrid = openvdb::VectorGrid::create();
// openvdb::VectorGrid::Ptr myGradientGrid = openvdb::VectorGrid::create();
myGradientGrid->setTransform(transform);
// myGradientGrid->setGridClass(openvdb::GRID_FOG_VOLUME );
myGradientGrid->setGridClass(openvdb::GRID_LEVEL_SET);
openvdb::tools::Gradient<openvdb::ScalarGrid> myGradient(*myGeoGrid);
myGradientGrid = myGradient.process();
openvdb::VectorTree& myGeoGradTree = myGradientGrid->treeRW();
gridNameStr = "ClusterGradientGrid";
myGradientGrid->insertMeta("vector type", openvdb::StringMetadata("covariant (gradient)"));
myGradientGrid->insertMeta("name", openvdb::StringMetadata((const char *)gridNameStr));
myGradientGrid->insertMeta("VoxelSize", openvdb::FloatMetadata(myPreVoxelSize));
myGradientGrid->insertMeta("background", openvdb::FloatMetadata(background));
GA_FOR_ALL_GPOINTS(gdp, ppt) {
// myCurrPtOff = ppt->getMapOffset();
// std::cout << "myCurrPtOff: " << myCurrPtOff << std::endl;
pos = ppt->getPos();
// Vec3d worldToIndex ( const Vec3d & xyz ) const
// openvdb::Vec3R theIndex =
// (openvdb::Vec3R(pos[0], pos[1], pos[2]));
openvdb::Vec3R theIndex =
myGeoGrid->worldToIndex(openvdb::Vec3R(pos[0], pos[1], pos[2]));
radius = static_cast<fpreal>(ppt->getValue<fpreal>(myInstAttrRefs.pointVDBRadius, 0));
// std::cout << "radius: " << radius << std::endl;
// static bool sample (const TreeT &inTree, const Vec3R &inCoord, typename TreeT::ValueType &sampleResult)
const openvdb::Vec3R inst_sample_pos(theIndex[0], theIndex[1], theIndex[2]);
bool success = myGeoSampler.sample(myGeoTree, inst_sample_pos, sampleResult);
geoGradSampler.sample(myGeoGradTree, inst_sample_pos, gradResult);
//
// std::cout << "success: " << success << "\tpos: " << pos
// << "\tinst_sample_pos: " << inst_sample_pos
// << "\tsampleResult: " << sampleResult << std::endl;
//ValueType sampleWorld (const Vec3R &pt) const
//ValueType sampleWorld (Real x, Real y, Real z) const
// if the instanced point is within the vdb volume
if(success) {
// std::cout << "pos: " << pos << " inst_sample_pos: "
// << inst_sample_pos << " sampleResult: " << sampleResult
// << " gradResult: " << gradResult << std::endl;
// float weight;
pointsFound++;
inst_vel_gah.setElement(ppt);
currVel = inst_vel_gah.getV3();
UT_Vector3 gradVect = UT_Vector3(gradResult[0], gradResult[1], gradResult[2]);
ppt->setPos(pos + (myPrePosInfluence *(sampleResult * gradVect)));
// ppt->setPos(pos + (sampleResult * myPosInfluence *(currVel / myFPS)));
// inst_vel_gah.setV3(currVel * ((1 / sampleResult) * radius));
inst_vel_gah.setV3(currVel + (myPreVelInfluence *(sampleResult * gradVect)));
// std::cout << "currVel: " << currVel << " sampleResult " << sampleResult
// << " new vel: " << currVel * sampleResult << std::endl;
inst_N_gah.setV3(inst_N_gah.getV3() + (myPreNormalInfluence *(sampleResult * gradVect)));
// inst_Cd_gah.setElement(ppt);
// inst_Cd_gah.setV3(inst_Cd_gah.getV3() * abs(sampleResult));
//
//
// inst_Alpha_gah.setElement(ppt);
// inst_Alpha_gah.setF(inst_Alpha_gah.getF() * abs(sampleResult));
} // if the instanced point is within the vdb volume
if(myVerbose == CLUSTER_MSG_DEBUG) {
pt_counter++;
if((long int)(pt_counter % (stat_interval * myNumCopies * myRecursion)) == 0) {
cout << "VRAY_clusterThis::preProcess() Number of points pre processed: " << pt_counter
<< "\t - Number of points found in vdb grid: " << pointsFound << std::endl;
}
}
}
示例9: error
//.........这里部分代码省略.........
float min = 0.0f;
float tol = 1e-1F;
// Rayhit objects:
GU_RayFindType itype = GU_FIND_ALL;
GU_RayIntersect intersect = GU_RayIntersect(gdp);
// Profile:
//Timer timer = Timer();
//float rayhit_time = 0;
//float vertex_time = 0;
// Here we determine which groups we have to work on.
if (error() < UT_ERROR_ABORT && cookInputGroups(context) < UT_ERROR_ABORT)
{
UT_AutoInterrupt progress("Checking for self-intersections...");
const GEO_Primitive *ppr;
FOR_ALL_GROUP_PRIMITIVES(gdp, myGroup, ppr)
{
// Check if user requested abort
if (progress.wasInterrupted())
break;
// Get rid of primitives smaller than primarea:
if ( ppr->calcArea() < primarea )
continue;
for (int j = 0; j < ppr->getVertexCount() - 1; j++)
{
// Get data;
// TODO: This is extremally inefficent.
// TODO: Why do we crash with uv vetrex attributes!?
const GEO_Vertex ppv1 = ppr->getVertex(j);
const GEO_Vertex ppv2 = ppr->getVertex(j+1);
const GEO_Point *ppt1 = ppv1.getPt();
const GEO_Point *ppt2 = ppv2.getPt();
// Vertices positions:
UT_Vector3 p1 = ppt1->getPos();
UT_Vector3 p2 = ppt2->getPos();
// Ray direction:
p2 = p2 - p1;
// Get rid of edges shorter than edgelength:
if (p2.length() < edgelength)
continue;
// hit info with max distance equal edge length:
GU_RayInfo hitinfo = GU_RayInfo(p2.length(), min, itype, tol);
p2.normalize();
// Send ray:
if (intersect.sendRay(p1, p2, hitinfo))
{
UT_RefArray<GU_RayInfoHit> hits = *(hitinfo.myHitList);
for(int j = 0; j < hits.entries(); j++)
{
const GEO_Primitive *prim = hits[j].prim;
const GEO_PrimPoly *poly = (const GEO_PrimPoly *) prim; //TODO: Prims only?
// We are interested only ff points are not part of prims...:
if (poly->find(*ppt1) == -1 && poly->find(*ppt2)== -1)
{
if (verbose)
printf("Edge: %i-%i intersects with prim:%d \n",ppt1->getNum(), ppt2->getNum(), prim->getNum());
// Save hit position as points:
if (generatepoints)
{
UT_Vector4 pos;
float u = hits[j].u;
float v = hits[j].v;
if (!prim->evaluateInteriorPoint(pos, u, v))
hitPoints.append(pos);
}
// TODO: Should I indicate penetration with red color on both ends of edge?:
cdH.setElement(ppt1);
cdH.setV3(UT_Vector3(1.0, 0.0, 0.0));
cdH.setElement(ppt2);
cdH.setV3(UT_Vector3(1.0, 0.0, 0.0));
}
}
}
}
}
if (generatepoints)
{
hitPointsGroup = gdp->newPointGroup("__self_penetrate", false);
for (int i = 0; i < hitPoints.entries(); i++)
{
GEO_Point *point;
point = gdp->appendPoint();
hitPointsGroup->add(point);
point->setPos(hitPoints(i));
}
}
}
示例10: cookMySop
//.........这里部分代码省略.........
}
float base = 0.0;
for(int i=0;i<totd;i++)
{
Daemon& d = daemons[i];
d.range[0]=base;
d.range[1] = base+d.weight/weights;
base=d.range[1];
};
int total = evalInt("count",0,now);
int degr = evalInt("degr",0,now);
total >>= degr;
GA_RWHandleI cntt(gdp->addIntTuple(GA_ATTRIB_POINT, "count", 4, GA_Defaults(1.0)));
GB_AttributeRef dt(gdp->addDiffuseAttribute(GEO_POINT_DICT));
gdp->addVariableName("Cd","Cd");
UT_Vector3 current(0,0,0);
float C[3] = { 0,0,0 };
float R=1.0f;
bool trackRadii = (evalInt("trackradii",0,now)!=0);
float rScale = evalFloat("radiiscale",0,now);
GB_AttributeRef rt;
if(trackRadii)
{
float one=1.0f;
rt = gdp->addPointAttrib("width",4,GB_ATTRIB_FLOAT,&one);
if(!GBisAttributeRefValid(rt)) trackRadii=false;
else gdp->addVariableName("width","WIDTH");
};
float zero=0.0f;
GB_AttributeRef pt = gdp->addPointAttrib("parameter",4,GB_ATTRIB_FLOAT,&zero);
if(GBisAttributeRefValid(pt)) gdp->addVariableName("parameter","PARAMETER");
float param=0.0f;
srand(0);
UT_Interrupt* boss = UTgetInterrupt();
boss->opStart("Computing...");
for(int i=-50;i<total;i++)
{
bool ok = false;
if (boss->opInterrupt()) break;
float w = double(rand())/double(RAND_MAX);
for(int j=0;j<totd;j++)
{
ok = daemons[j].Transform(w,current,C,R,param);
if(ok) break;
};
if(i<0) continue;
if(clip)
{
if(!bbox.isInside(current)) continue;
};
if(ok)
{
GEO_Point* p = gdp->appendPoint();
p->setPos(current);
float* Cd=p->castAttribData<float>(dt);
if(useRamp)
{
ramp.rampLookup(param,C);
}
memcpy(Cd,C,12);
if(trackRadii)
{
float* _R = p->castAttribData<float>(rt);
*_R=rScale*R;
};
if(GBisAttributeRefValid(pt))
{
float* _p = p->castAttribData<float>(pt);
*_p=param;
}
};
};
boss->opEnd();
delete [] daemons;
return error();
};
示例11: error
//.........这里部分代码省略.........
delete _ocean_context;
}
_ocean = new drw::Ocean(gridres,gridres,stepsize,stepsize,
V(0),L(0),1.0,W(0),1-DAMP(0),ALIGN(0),
DEPTH(0),SEED(0));
_ocean_scale = _ocean->get_height_normalize_factor();
_ocean_context = _ocean->new_context(true,do_chop,do_normals,do_jacobian);
_ocean_needs_rebuild = false;
// std::cout << "######### SOP, rebuilt ocean, norm_factor = " << _ocean_scale
// << " chop = " << do_chop
// << " norm = " << do_normals
// << " jacobian = " << do_jacobian
// << std::endl;
}
float chop_amount = CHOPAMOUNT(now);
// sum up the waves at this timestep
_ocean->update(TIME(now),*_ocean_context,true,do_chop,do_normals,do_jacobian,
_ocean_scale * SCALE(now),chop_amount);
bool linterp = ! INTERP(now);
// get our attribute indices
GA_RWAttributeRef normal_index;
GA_RWAttributeRef jminus_index;
GA_RWAttributeRef eminus_index;
if (do_normals)
{
normal_index = gdp->addNormalAttribute(GEO_POINT_DICT);
}
if (do_jacobian)
{
// jminus_index = gdp->addPointAttrib("mineigval",sizeof(float),GB_ATTRIB_FLOAT,0);
// eminus_index = gdp->addPointAttrib("mineigvec",sizeof(UT_Vector3),GB_ATTRIB_VECTOR,0);
jminus_index = gdp->addTuple(GA_STORE_REAL32,GA_ATTRIB_POINT,"mineigval",1,GA_Defaults(0));
eminus_index = gdp->addFloatTuple(GA_ATTRIB_POINT,"mineigvec",1,GA_Defaults(0));
}
// this is not that fast, can it be done quicker ???
GA_FOR_ALL_GPOINTS(gdp, ppt)
{
UT_Vector4 p = ppt->getPos();
if (linterp)
{
_ocean_context->eval_xz(p(0),p(2));
}
else
{
_ocean_context->eval2_xz(p(0),p(2));
}
if (do_chop)
{
p.assign( p(0) + _ocean_context->disp[0],
p(1) + _ocean_context->disp[1],
p(2) + _ocean_context->disp[2] );
}
else
{
// ppt->getPos()(1) += _ocean_context->disp[1];
UT_Vector4 tmp_p = ppt->getPos();
tmp_p(1) += _ocean_context->disp[1];
ppt->setPos(tmp_p);
}
if (do_normals)
{
/*
UT_Vector3* normal = (UT_Vector3*) ppt->castAttribData<UT_Vector3>(normal_index);
normal->assign(_ocean_context->normal[0],
_ocean_context->normal[1],
_ocean_context->normal[2]);
normal->normalize();
*/
ppt->getValue<UT_Vector3>(normal_index).assign(_ocean_context->normal[0],
_ocean_context->normal[1],
_ocean_context->normal[2]);
ppt->getValue<UT_Vector3>(normal_index).normalize();
}
if (do_jacobian)
{/*
float *js = (float*)ppt->castAttribData<float>(jminus_index);
*js = _ocean_context->Jminus;
UT_Vector3* eminus = (UT_Vector3*)ppt->castAttribData<UT_Vector3>(eminus_index);
eminus->assign(_ocean_context->Eminus[0],0,_ocean_context->Eminus[1]);
*/
ppt->setValue<float>(jminus_index,_ocean_context->Jminus);
ppt->getValue<UT_Vector3>(eminus_index).assign(_ocean_context->Eminus[0],0,_ocean_context->Eminus[1]);
}
ppt->setPos(p);
}
示例12: add_simple_mesh
void add_simple_mesh(GU_Detail& gdp,
const dgal::simple_mesh<Imath::V3f>& smesh,
const std::string& pointIDAttrib, const std::vector<int>* pointIDs,
const std::string& polyIDAttrib, const std::vector<int>* polyIDs,
const std::string& cellTypeAttrib, unsigned int cellType,
const std::string& cellIDAttrib, unsigned int cellID)
{
unsigned int first_point = gdp.points().entries();
unsigned int first_prim = gdp.primitives().entries();
// create dest points
for(std::vector<Imath::V3f>::const_iterator it=smesh.m_points.begin();
it!=smesh.m_points.end(); ++it)
{
GEO_Point* pt = gdp.appendPoint();
pt->setPos(it->x, it->y, it->z);
}
GEO_PointList& points = gdp.points();
GEO_PrimList& prims = gdp.primitives();
// create dest polys
for(unsigned int i=0; i<smesh.m_polys.size(); ++i)
{
const std::vector<unsigned int>& cpoly = smesh.m_polys[i];
GEO_PrimPoly* poly = GU_PrimPoly::build(&gdp, cpoly.size(), GU_POLY_CLOSED, 0);
for(unsigned int j=0; j<cpoly.size(); ++j)
poly->getVertex(j).setPt(points[cpoly[j] + first_point]);
}
// create cell-type attribute
if(!cellTypeAttrib.empty())
{
int defaultv = -1;
GB_AttributeRef aref = gdp.addAttribute(cellTypeAttrib.c_str(), sizeof(int),
GB_ATTRIB_INT, &defaultv, GEO_PRIMITIVE_DICT);
if(aref.isValid())
{
unsigned int npolys = prims.entries();
for(unsigned int i=first_prim; i<npolys; ++i)
prims[i]->setValue<int32>(aref, static_cast<int>(cellType));
}
}
// create cell-id attribute
if(!cellIDAttrib.empty())
{
int defaultv = -1;
GB_AttributeRef aref = gdp.addAttribute(cellIDAttrib.c_str(), sizeof(int),
GB_ATTRIB_INT, &defaultv, GEO_PRIMITIVE_DICT);
if(aref.isValid())
{
unsigned int npolys = prims.entries();
for(unsigned int i=first_prim; i<npolys; ++i)
prims[i]->setValue<int32>(aref, static_cast<int>(cellID));
}
}
// create point-id attribute
if(!pointIDAttrib.empty())
{
int defaultv = -1;
GB_AttributeRef aref = gdp.addAttribute(pointIDAttrib.c_str(), sizeof(int),
GB_ATTRIB_INT, &defaultv, GEO_POINT_DICT);
if(aref.isValid() && pointIDs)
{
unsigned int sz = std::min(points.entries()-first_point,
static_cast<unsigned int>(pointIDs->size()));
for(unsigned int i=0; i<sz; ++i)
points[i + first_point]->setValue<int32>(aref, (*pointIDs)[i]);
}
}
// create poly-id attribute
if(!polyIDAttrib.empty())
{
int defaultv = 0;
GB_AttributeRef aref = gdp.addAttribute(polyIDAttrib.c_str(), sizeof(int),
GB_ATTRIB_INT, &defaultv, GEO_PRIMITIVE_DICT);
if(aref.isValid() && polyIDs)
{
unsigned int sz = std::min(prims.entries()-first_prim,
static_cast<unsigned int>(polyIDs->size()));
for(unsigned int i=0; i<sz; ++i)
prims[i + first_prim]->setValue<int32>(aref, (*polyIDs)[i]);
}
}
}