本文整理汇总了C++中ParamSet::AddPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ ParamSet::AddPoint方法的具体用法?C++ ParamSet::AddPoint怎么用?C++ ParamSet::AddPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParamSet
的用法示例。
在下文中一共展示了ParamSet::AddPoint方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createAreaLightMesh
void LuxRenderer::createAreaLightMesh(mtlu_MayaObject *obj)
{
MString meshName("");
MFnDependencyNode depFn(obj->mobject);
MObject otherSideObj = getOtherSideNode(MString("mtlu_areaLight_geo"), obj->mobject);
if( otherSideObj != MObject::kNullObj)
{
}else{
int indices[6] = {0,1,2,2,3,0};
float floatPointArray[12] = {-1, -1, 0,
-1, 1, 0,
1, 1, 0,
1, -1, 0};
float floatNormalArray[12] = {0,0,-1,
0,0,-1,
0,0,-1,
0,0,-1};
ParamSet triParams = CreateParamSet();
triParams->AddInt("indices", indices, 6);
triParams->AddPoint("P", floatPointArray, 4);
triParams->AddNormal("N", floatNormalArray, 4);
lux->transformBegin();
float fm[16];
MMatrix tm = obj->transformMatrices[0];
setZUp(tm, fm);
this->lux->transform(fm);
this->lux->shape("trianglemesh", boost::get_pointer(triParams));
lux->transformEnd();
}
}
示例2: Refine
void Heightfield::Refine(vector<Reference<Shape> > &refined) const {
int ntris = 2*(nx-1)*(ny-1);
refined.reserve(ntris);
int *verts = new int[3*ntris];
Point *P = new Point[nx*ny];
float *uvs = new float[2*nx*ny];
int nverts = nx*ny;
int x, y;
// Compute heightfield vertex positions
int pos = 0;
for (y = 0; y < ny; ++y) {
for (x = 0; x < nx; ++x) {
P[pos].x = uvs[2*pos] = (float)x / (float)(nx-1);
P[pos].y = uvs[2*pos+1] = (float)y / (float)(ny-1);
P[pos].z = z[pos];
++pos;
}
}
// Fill in heightfield vertex offset array
int *vp = verts;
for (y = 0; y < ny-1; ++y) {
for (x = 0; x < nx-1; ++x) {
#define VERT(x,y) ((x)+(y)*nx)
*vp++ = VERT(x, y);
*vp++ = VERT(x+1, y);
*vp++ = VERT(x+1, y+1);
*vp++ = VERT(x, y);
*vp++ = VERT(x+1, y+1);
*vp++ = VERT(x, y+1);
}
#undef VERT
}
ParamSet paramSet;
paramSet.AddInt("indices", verts, 3*ntris);
paramSet.AddFloat("uv", uvs, 2 * nverts);
paramSet.AddPoint("P", P, nverts);
refined.push_back(CreateTriangleMeshShape(ObjectToWorld, WorldToObject, ReverseOrientation, paramSet));
delete[] P;
delete[] uvs;
delete[] verts;
}
示例3: defineTriangleMesh
//.........这里部分代码省略.........
floatNormalArray[vtxCount * 3] = normals[normalId2].x;
floatNormalArray[vtxCount * 3 + 1] = normals[normalId2].y;
floatNormalArray[vtxCount * 3 + 2] = normals[normalId2].z;
floatUvArray[vtxCount * 2] = uArray[uvId2];
floatUvArray[vtxCount * 2 + 1] = vArray[uvId2];
vtxCount++;
//logger.debug(MString("Vertex count: ") + vtxCount + " maxId " + ((vtxCount - 1) * 3 + 2) + " ptArrayLen " + (numTriangles * 3 * 3));
triangelVtxIdList[triCount * 3] = triCount * 3;
triangelVtxIdList[triCount * 3 + 1] = triCount * 3 + 1;
triangelVtxIdList[triCount * 3 + 2] = triCount * 3 + 2;
triCount++;
}
}
//generatetangents bool Generate tangent space using miktspace, useful if mesh has a normal map that was also baked using miktspace (such as blender or xnormal) false
//subdivscheme string Subdivision algorithm, options are "loop" and "microdisplacement" "loop"
//displacementmap string Name of the texture used for the displacement. Subdivscheme parameter must always be provided, as load-time displacement is handled by the loop-subdivision code. none - optional. (loop subdiv can be used without displacement, microdisplacement will not affect the mesh without a displacement map specified)
//dmscale float Scale of the displacement (for an LDR map, this is the maximum height of the displacement in meter) 0.1
//dmoffset float Offset of the displacement. 0
//dmnormalsmooth bool Smoothing of the normals of the subdivided faces. Only valid for loop subdivision. true
//dmnormalsplit bool Force the mesh to split along breaks in the normal. If a mesh has no normals (flat-shaded) it will rip open on all edges. Only valid for loop subdivision. false
//dmsharpboundary bool Try to preserve mesh boundaries during subdivision. Only valid for loop subdivision. false
//nsubdivlevels integer Number of subdivision levels. This is only recursive for loop subdivision, microdisplacement will need much larger values (such as 50). 0
bool generatetangents = false;
getBool(MString("mtlu_mesh_generatetangents"), meshFn, generatetangents);
int subdivscheme = 0;
const char *subdAlgos[] = {"loop", "microdisplacement"};
getInt(MString("mtlu_mesh_subAlgo"), meshFn, subdivscheme);
const char *subdalgo = subdAlgos[subdivscheme];
float dmscale;
getFloat(MString("mtlu_mesh_dmscale"), meshFn, dmscale);
float dmoffset;
getFloat(MString("mtlu_mesh_dmoffset"), meshFn, dmoffset);
MString displacementmap;
getString(MString("mtlu_mesh_displacementMap"), meshFn, displacementmap);
const char *displacemap = displacementmap.asChar();
bool dmnormalsmooth = true;
getBool(MString("mtlu_mesh_dmnormalsmooth"), meshFn, dmnormalsmooth);
bool dmnormalsplit = false;
getBool(MString("mtlu_mesh_dmnormalsplit"), meshFn, dmnormalsplit);
bool dmsharpboundary = false;
getBool(MString("mtlu_mesh_dmsharpboundary"), meshFn, dmsharpboundary);
int nsubdivlevels = 0;
getInt(MString("mtlu_mesh_subdivlevel"), meshFn, nsubdivlevels);
// a displacment map needs its own texture defintion
MString displacementTextureName = "";
if(displacementmap.length() > 0)
{
ParamSet dmParams = CreateParamSet();
dmParams->AddString("filename", &displacemap);
displacementTextureName = meshFn.name() + "_displacementMap";
this->lux->texture(displacementTextureName.asChar(), "float", "imagemap", boost::get_pointer(dmParams));
}
ParamSet triParams = CreateParamSet();
int numPointValues = numTriangles * 3;
int numUvValues = numTriangles * 3 * 2;
clock_t startTime = clock();
logger.info(MString("Adding mesh values to params."));
triParams->AddInt("indices", triangelVtxIdList, numTriangles * 3);
triParams->AddPoint("P", floatPointArray, numPointValues);
triParams->AddNormal("N", floatNormalArray, numPointValues);
triParams->AddFloat("uv", floatUvArray, numUvValues);
if( nsubdivlevels > 0)
triParams->AddInt("nsubdivlevels", &nsubdivlevels, 1);
triParams->AddBool("generatetangents", &generatetangents, 1);
triParams->AddString("subdivscheme", &subdalgo , 1);
if(displacementmap.length() > 0)
{
triParams->AddFloat("dmoffset", &dmoffset, 1);
triParams->AddFloat("dmscale", &dmscale, 1);
const char *dmft = displacementTextureName.asChar();
triParams->AddString("displacementmap", &dmft);
}
triParams->AddBool("dmnormalsmooth", &dmnormalsmooth, 1);
triParams->AddBool("dmnormalsplit", &dmnormalsplit, 1);
triParams->AddBool("dmsharpboundary", &dmsharpboundary, 1);
clock_t pTime = clock();
if(!noObjectDef)
this->lux->objectBegin(meshFullName.asChar());
this->lux->shape("trianglemesh", boost::get_pointer(triParams));
if(!noObjectDef)
this->lux->objectEnd();
clock_t eTime = clock();
logger.info(MString("Timing: Parameters: ") + ((pTime - startTime)/CLOCKS_PER_SEC) + " objTime " + ((eTime - pTime)/CLOCKS_PER_SEC) + " all " + ((eTime - startTime)/CLOCKS_PER_SEC));
return;
}
示例4: Refine
//.........这里部分代码省略.........
f2 ? f2->children[f2->vnum(face->v[k])] : NULL;
f2 = face->f[PREV(k)];
face->children[k]->f[PREV(k)] =
f2 ? f2->children[f2->vnum(face->v[k])] : NULL;
}
}
// Update face vertex pointers
for (uint32_t j = 0; j < f.size(); ++j) {
SDFace *face = f[j];
for (int k = 0; k < 3; ++k) {
// Update child vertex pointer to new even vertex
face->children[k]->v[k] = face->v[k]->child;
// Update child vertex pointer to new odd vertex
SDVertex *vert = edgeVerts[SDEdge(face->v[k], face->v[NEXT(k)])];
face->children[k]->v[NEXT(k)] = vert;
face->children[NEXT(k)]->v[k] = vert;
face->children[3]->v[k] = vert;
}
}
// Prepare for next level of subdivision
f = newFaces;
v = newVertices;
}
// Push vertices to limit surface
PbrtPoint *Plimit = new PbrtPoint[v.size()];
for (uint32_t i = 0; i < v.size(); ++i) {
if (v[i]->boundary)
Plimit[i] = weightBoundary(v[i], 1.f/5.f);
else
Plimit[i] = weightOneRing(v[i], gamma(v[i]->valence()));
}
for (uint32_t i = 0; i < v.size(); ++i)
v[i]->P = Plimit[i];
// Compute vertex tangents on limit surface
vector<Normal> Ns;
Ns.reserve(v.size());
vector<PbrtPoint> Pring(16, PbrtPoint());
for (uint32_t i = 0; i < v.size(); ++i) {
SDVertex *vert = v[i];
Vector S(0,0,0), T(0,0,0);
int valence = vert->valence();
if (valence > (int)Pring.size())
Pring.resize(valence);
vert->oneRing(&Pring[0]);
if (!vert->boundary) {
// Compute tangents of interior face
for (int k = 0; k < valence; ++k) {
S += cosf(2.f*M_PI*k/valence) * Vector(Pring[k]);
T += sinf(2.f*M_PI*k/valence) * Vector(Pring[k]);
}
} else {
// Compute tangents of boundary face
S = Pring[valence-1] - Pring[0];
if (valence == 2)
T = Vector(Pring[0] + Pring[1] - 2 * vert->P);
else if (valence == 3)
T = Pring[1] - vert->P;
else if (valence == 4) // regular
T = Vector(-1*Pring[0] + 2*Pring[1] + 2*Pring[2] +
-1*Pring[3] + -2*vert->P);
else {
float theta = M_PI / float(valence-1);
T = Vector(sinf(theta) * (Pring[0] + Pring[valence-1]));
for (int k = 1; k < valence-1; ++k) {
float wt = (2*cosf(theta) - 2) * sinf((k) * theta);
T += Vector(wt * Pring[k]);
}
T = -T;
}
}
Ns.push_back(Normal(Cross(S, T)));
}
// Create _TriangleMesh_ from subdivision mesh
uint32_t ntris = uint32_t(f.size());
int *verts = new int[3*ntris];
int *vp = verts;
uint32_t totVerts = uint32_t(v.size());
map<SDVertex *, int> usedVerts;
for (uint32_t i = 0; i < totVerts; ++i)
usedVerts[v[i]] = i;
for (uint32_t i = 0; i < ntris; ++i) {
for (int j = 0; j < 3; ++j) {
*vp = usedVerts[f[i]->v[j]];
++vp;
}
}
ParamSet paramSet;
paramSet.AddInt("indices", verts, 3*ntris);
paramSet.AddPoint("P", Plimit, totVerts);
paramSet.AddNormal("N", &Ns[0], int(Ns.size()));
refined.push_back(CreateTriangleMeshShape(ObjectToWorld,
WorldToObject, ReverseOrientation, paramSet));
delete[] verts;
delete[] Plimit;
}
示例5: wi
MedianCutEnvironmentLight::MedianCutEnvironmentLight(const Transform &light2world,
const Spectrum &L, int ns_, const string &texmap)
: Light(light2world, ns_), impl(new MedCutEnvImpl {nullptr, nullptr, ns_}) {
int width = 0, height = 0;
RGBSpectrum *texels = NULL;
// Read texel data from _texmap_ into _texels_
if (texmap != "") {
texels = ReadImage(texmap, &width, &height);
if (texels)
for (int i = 0; i < width * height; ++i)
texels[i] *= L.ToRGBSpectrum();
}
if (!texels) {
width = height = 1;
texels = new RGBSpectrum[1];
texels[0] = L.ToRGBSpectrum();
}
impl->radianceMap = new MIPMap<RGBSpectrum>(width, height, texels);
impl->width = width;
impl->inv_w = 1.0f/(width-1);
impl->height = height;
impl->inv_h = 1.0f/(height-1);
impl->createDistantLight = [this](const RGBSpectrum& s, float cy, float cx) {
ParamSet p;
float rgb[3];
s.ToRGB(rgb);
p.AddRGBSpectrum("L", rgb, 3);
const float theta = impl->inv_h*cy * M_PI
, phi = impl->inv_w*cx * 2.f * M_PI;
const float costheta = cosf(theta), sintheta = sinf(theta);
const float sinphi = sinf(phi), cosphi = cosf(phi);
const Point wi(-sintheta*cosphi, -sintheta*sinphi, -costheta);
p.AddPoint(string("to"), &wi, 1);
#if DEBUG >= 1
fprintf(stderr, "rgb (%f,%f,%f)\n", rgb[0], rgb[1], rgb[2]);
#endif
return CreateDistantLight(this->LightToWorld, p);
};
impl->solid_angle = ((2.f * M_PI) / (width - 1)) * (M_PI / (1.f * (height - 1)));
#if DEBUG >= 1
fprintf(stderr, "solid_angle = %f\n", impl->solid_angle);
#endif
for (int y = 0; y < height; ++y) {
float sinTheta = sinf(M_PI * float(y + 0.5f)/height);
for (int x = 0; x < width; ++x)
texels[y*width + x] *= impl->solid_angle * sinTheta;
}
// Initialize energy sum array; the array is shifted for (1,1)
// i.e. (0,*) and (*,0) are inserted 0-boundaries
fprintf(stderr, "[+] [%10.2f] Initializing sum array\n", clock()*1.0/CLOCKS_PER_SEC);
#if DEBUG >= 3
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
fprintf(stderr, "%.2f ", texels[y*width+x].y());
}
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
#endif
vector<vector<float>> acc(height+1, vector<float>(width+1));
for (int y = 0; y < height; ++y)
for (int x = 0; x < width; ++x)
acc[y+1][x+1] = acc[y+1][x] + texels[y*width + x].y();
#if DEBUG >= 3
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
fprintf(stderr, "%.2f ", acc[y][x]);
}
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
#endif
for (int x = 1; x <= width; ++x)
for (int y = 1; y <= height; ++y)
acc[y][x] += acc[y-1][x];
#if DEBUG >= 3
for (int y = 0; y < 5; ++y) {
for (int x = 0; x < 5; ++x) {
fprintf(stderr, "%.2f ", acc[y][x]);
}
fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
#endif
// initialize median cut
//.........这里部分代码省略.........
示例6: Refine
void NURBS::Refine(vector<Reference<Shape> > &refined) const {
// Compute NURBS dicing rates
int diceu = 30, dicev = 30;
float *ueval = new float[diceu];
float *veval = new float[dicev];
Point *evalPs = new Point[diceu*dicev];
Normal *evalNs = new Normal[diceu*dicev];
int i;
for (i = 0; i < diceu; ++i)
ueval[i] = Lerp((float)i / (float)(diceu-1), umin, umax);
for (i = 0; i < dicev; ++i)
veval[i] = Lerp((float)i / (float)(dicev-1), vmin, vmax);
// Evaluate NURBS over grid of points
memset(evalPs, 0, diceu*dicev*sizeof(Point));
memset(evalNs, 0, diceu*dicev*sizeof(Point));
float *uvs = new float[2*diceu*dicev];
// Turn NURBS into triangles
Homogeneous3 *Pw = (Homogeneous3 *)P;
if (!isHomogeneous) {
Pw = (Homogeneous3 *)alloca(nu*nv*sizeof(Homogeneous3));
for (int i = 0; i < nu*nv; ++i) {
Pw[i].x = P[3*i];
Pw[i].y = P[3*i+1];
Pw[i].z = P[3*i+2];
Pw[i].w = 1.;
}
}
for (int v = 0; v < dicev; ++v) {
for (int u = 0; u < diceu; ++u) {
uvs[2*(v*diceu+u)] = ueval[u];
uvs[2*(v*diceu+u)+1] = veval[v];
Vector dPdu, dPdv;
Point pt = NURBSEvaluateSurface(uorder, uknot, nu, ueval[u],
vorder, vknot, nv, veval[v], Pw, &dPdu, &dPdv);
evalPs[v*diceu + u].x = pt.x;
evalPs[v*diceu + u].y = pt.y;
evalPs[v*diceu + u].z = pt.z;
evalNs[v*diceu + u] = Normal(Normalize(Cross(dPdu, dPdv)));
}
}
// Generate points-polygons mesh
int nTris = 2*(diceu-1)*(dicev-1);
int *vertices = new int[3 * nTris];
int *vertp = vertices;
// Compute the vertex offset numbers for the triangles
for (int v = 0; v < dicev-1; ++v) {
for (int u = 0; u < diceu-1; ++u) {
#define VN(u,v) ((v)*diceu+(u))
*vertp++ = VN(u, v);
*vertp++ = VN(u+1, v);
*vertp++ = VN(u+1, v+1);
*vertp++ = VN(u, v);
*vertp++ = VN(u+1, v+1);
*vertp++ = VN(u, v+1);
#undef VN
}
}
int nVerts = diceu*dicev;
ParamSet paramSet;
paramSet.AddInt("indices", vertices, 3*nTris);
paramSet.AddPoint("P", evalPs, nVerts);
paramSet.AddFloat("uv", uvs, 2 * nVerts);
paramSet.AddNormal("N", evalNs, nVerts);
refined.push_back(MakeShape("trianglemesh", ObjectToWorld,
reverseOrientation, paramSet));
// Cleanup from NURBS refinement
delete[] uvs;
delete[] ueval;
delete[] veval;
delete[] evalPs;
delete[] evalNs;
delete[] vertices;
}