本文整理汇总了C++中PatchMesh::setTVert方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchMesh::setTVert方法的具体用法?C++ PatchMesh::setTVert怎么用?C++ PatchMesh::setTVert使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchMesh
的用法示例。
在下文中一共展示了PatchMesh::setTVert方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakePatchCapTexture
static void MakePatchCapTexture(PatchMesh &pmesh, Matrix3 &itm, int pstart, int pend, BOOL usePhysUVs) {
if(pstart == pend)
return;
// Find out which verts are used by the cap
BitArray capVerts(pmesh.numVerts);
capVerts.ClearAll();
for(int i = pstart; i < pend; ++i) {
Patch &p = pmesh.patches[i];
capVerts.Set(p.v[0]);
capVerts.Set(p.v[1]);
capVerts.Set(p.v[2]);
if(p.type == PATCH_QUAD)
capVerts.Set(p.v[3]);
}
// Minmax the verts involved in X/Y axis and total them
Box3 bounds;
int numCapVerts = 0;
int numCapPatches = pend - pstart;
IntTab capIndexes;
capIndexes.SetCount(pmesh.numVerts);
int baseTVert = pmesh.getNumTVerts();
for(int i = 0; i < pmesh.numVerts; ++i) {
if(capVerts[i]) {
capIndexes[i] = baseTVert + numCapVerts++;
bounds += pmesh.verts[i].p * itm;
}
}
pmesh.setNumTVerts(baseTVert + numCapVerts, TRUE);
Point3 s;
if (usePhysUVs)
s = Point3(1.0f, 1.0f, 0.0f);
else
s = Point3(1.0f / bounds.Width().x, 1.0f / bounds.Width().y, 0.0f);
Point3 t(-bounds.Min().x, -bounds.Min().y, 0.0f);
// Do the TVerts
for(int i = 0; i < pmesh.numVerts; ++i) {
if(capVerts[i])
pmesh.setTVert(baseTVert++, ((pmesh.verts[i].p * itm) + t) * s);
}
// Do the TVPatches
for(int i = pstart; i < pend; ++i) {
Patch &p = pmesh.patches[i];
TVPatch &tp = pmesh.getTVPatch(i);
if(p.type == PATCH_TRI)
tp.setTVerts(capIndexes[p.v[0]], capIndexes[p.v[1]], capIndexes[p.v[2]]);
else
tp.setTVerts(capIndexes[p.v[0]], capIndexes[p.v[1]], capIndexes[p.v[2]], capIndexes[p.v[3]]);
}
}
示例2: BuildPatch
void TriPatchObject::BuildPatch(TimeValue t,PatchMesh& amesh)
{
int nverts = 4;
int nvecs = 16;
float l, w;
int tex;
// Start the validity interval at forever and whittle it down.
ivalid = FOREVER;
pblock->GetValue( PB_LENGTH, t, l, ivalid );
pblock->GetValue( PB_WIDTH, t, w, ivalid );
pblock->GetValue( PB_TEXTURE, t, tex, ivalid );
amesh.setNumVerts(nverts);
amesh.setNumTVerts(tex ? nverts : 0);
amesh.setNumVecs(nvecs);
amesh.setNumPatches(2);
amesh.setNumTVPatches(tex ? 2 : 0);
Point3 v0 = Point3(-w, -l, 0.0f) / 2.0f;
Point3 v1 = v0 + Point3(w, 0.0f, 0.0f);
Point3 v2 = v0 + Point3(w, l, 0.0f);
Point3 v3 = v0 + Point3(0.0f, l, 0.0f);
// Create the vertices.
amesh.verts[0].flags = PVERT_COPLANAR;
amesh.verts[1].flags = PVERT_COPLANAR;
amesh.verts[2].flags = PVERT_COPLANAR;
amesh.verts[3].flags = PVERT_COPLANAR;
if(tex) {
amesh.setTVert(0, UVVert(0,0,0));
amesh.setTVert(1, UVVert(1,0,0));
amesh.setTVert(2, UVVert(1,1,0));
amesh.setTVert(3, UVVert(0,1,0));
}
amesh.setVert(0, v0);
amesh.setVert(1, v1);
amesh.setVert(2, v2);
amesh.setVert(3, v3);
// Create the vectors
MAKEVEC(0, v0, v1);
MAKEVEC(2, v1, v2);
MAKEVEC(4, v2, v3);
MAKEVEC(6, v3, v0);
MAKEVEC(8, v3, v1);
// Create patches.
amesh.MakeTriPatch(0, 0, 0, 1, 1, 9, 8, 3, 6, 7, 10, 11, 12, 1);
amesh.MakeTriPatch(1, 1, 2, 3, 2, 4, 5, 3, 8, 9, 13, 14, 15, 1);
Patch &p1 = amesh.patches[0];
Patch &p2 = amesh.patches[1];
if(tex) {
amesh.getTVPatch(0).setTVerts(0,1,3);
amesh.getTVPatch(1).setTVerts(1,2,3);
}
// Finish up patch internal linkages (and bail out if it fails!)
assert(amesh.buildLinkages());
// Calculate the interior bezier points on the PatchMesh's patches
amesh.computeInteriors();
amesh.InvalidateGeomCache();
// Tell the PatchMesh it just got changed
amesh.InvalidateMesh();
}
示例3: BuildTorusPatch
void BuildTorusPatch(
TimeValue t, PatchMesh &patch,
float radius1, float radius2, int genUVs, BOOL usePhysUVs)
{
int segs = 8, sides = 4;
int nverts = segs * sides;
int nvecs = segs*sides*8;
int npatches = segs * sides;
patch.setNumVerts(nverts);
patch.setNumTVerts(genUVs ? (segs + 1) * (sides + 1) : 0);
patch.setNumVecs(nvecs);
patch.setNumPatches(npatches);
patch.setNumTVPatches(genUVs ? npatches : 0);
int ix=0, jx=0, kx=sides*segs*4, i, j;
float ang1 = 0.0f, delta1 = TWOPI/float(segs);
float ang2 = 0.0f, delta2 = TWOPI/float(sides);
float circleLenIn = CIRCLE_FACT8*(radius1-radius2);
float circleLenOut = CIRCLE_FACT8*(radius1+radius2);
float circleLenMid = CIRCLE_FACT4*radius2;
float circleLen;
float sinang1, cosang1, sinang2, cosang2, rt, u;
Point3 p, v;
DWORD a, b, c, d;
for (i=0; i<segs; i++) {
sinang1 = (float)sin(ang1);
cosang1 = (float)cos(ang1);
ang2 = 0.0f;
for (j=0; j<sides; j++) {
sinang2 = (float)sin(ang2);
cosang2 = (float)cos(ang2);
rt = radius1+radius2*cosang2;
// Vertex
p.x = rt*cosang1;
p.y = rt*sinang1;
p.z = radius2*sinang2;
patch.setVert(ix, p);
// Tangents
u = (cosang2+1.0f)/2.0f;
circleLen = u*circleLenOut + (1.0f-u)*circleLenIn;
v.x = -sinang1*circleLen;
v.y = cosang1*circleLen;
v.z = 0.0f;
patch.setVec(jx++,patch.verts[ix] + v);
v.x = sinang1*circleLen;
v.y = -cosang1*circleLen;
v.z = 0.0f;
patch.setVec(jx++,patch.verts[ix] + v);
v.x = -sinang2*cosang1*circleLenMid;
v.y = -sinang2*sinang1*circleLenMid;
v.z = cosang2*circleLenMid;
patch.setVec(jx++,patch.verts[ix] + v);
v.x = sinang2*cosang1*circleLenMid;
v.y = sinang2*sinang1*circleLenMid;
v.z = -cosang2*circleLenMid;
patch.setVec(jx++,patch.verts[ix] + v);
// Build the patch
a = ((i+1)%segs)*sides + (j+1)%sides;
b = i*sides + (j+1)%sides;
c = i*sides + j;
d = ((i+1)%segs)*sides + j;
patch.patches[ix].SetType(PATCH_QUAD);
patch.patches[ix].setVerts(a, b, c, d);
patch.patches[ix].setVecs(
Tang(a,1),Tang(b,0),Tang(b,3),Tang(c,2),
Tang(c,0),Tang(d,1),Tang(d,2),Tang(a,3));
patch.patches[ix].setInteriors(kx, kx+1, kx+2, kx+3);
patch.patches[ix].smGroup = 1;
kx += 4;
ix++;
ang2 += delta2;
}
ang1 += delta1;
}
if(genUVs) {
int tv = 0;
int tvp = 0;
float fsegs = (float)segs;
float fsides = (float)sides;
float uScale = usePhysUVs ? ((float) 2.0f * PI * radius1) : 1.0f;
float vScale = usePhysUVs ? ((float) 2.0f * PI * radius2) : 1.0f;
for (i=0; i<=segs; i++) {
float u = (float)i / (fsegs-1);
for (j=0; j<=sides; j++,++tv) {
float v = (float)j / (fsides-1);
if (usePhysUVs)
patch.setTVert(tv, UVVert(vScale*v, uScale*u, 0.0f));
else
patch.setTVert(tv, UVVert(uScale*(1.0f-u), vScale*v, 0.0f));
if(j < sides && i < segs)
//.........这里部分代码省略.........
示例4: BuildPatchFromShape
//.........这里部分代码省略.........
// Maybe create the texture vertices
if(texturing) {
int tvert = 0;
int level;
for(poly = 0; poly < polys; ++poly) {
Spline3D *spline = bShape.splines[poly];
if(!spline->KnotCount())
continue;
// Make it a polyline
PolyLine pline;
spline->MakePolyLine(pline, 10);
int knots = spline->KnotCount();
for(level = 0; level < TVlevels; ++level) {
float tV = (float)level / (float)(TVlevels - 1);
float vScale = usePhysUVs ? amount : 1.0f;
int lverts = pline.numPts;
int tp = 0;
int texPts = spline->Segments() + 1;
float cumLen = 0.0f;
float totLen = pline.CurveLength();
float uScale = usePhysUVs ? totLen : 1.0f;
Point3 prevPt = pline.pts[0].p;
int plix = 0;
while(tp < texPts) {
Point3 &pt = pline[plix].p;
cumLen += Length(pt - prevPt);
prevPt = pt;
if(pline[plix].flags & POLYPT_KNOT) {
float tU;
if(tp == (texPts - 1))
tU = 1.0f;
else
tU = cumLen / totLen;
pmesh.setTVert(tvert++, UVVert(uScale*tU, vScale*tV, 0.0f));
tp++;
}
plix = (plix + 1) % pline.numPts;
}
}
}
assert(tvert == ntverts);
}
// Create the vectors!
int seg;
int vec = 0;
for(poly = 0; poly < polys; ++poly) {
Spline3D *spline = bShape.splines[poly];
if(!spline->KnotCount())
continue;
int segs = spline->Segments();
int knots = spline->KnotCount();
// First, the vectors on each level
for(level = 0; level <= levels; ++level) {
Point3 offset = Point3(0.0f, 0.0f, baseZ + (float)level / (float)levels * zSize);
for(seg = 0; seg < segs; ++seg) {
int seg2 = (seg + 1) % knots;
if(spline->GetLineType(seg) == LTYPE_CURVE) {
Point3 p = spline->GetOutVec(seg);
pmesh.setVec(vec++, p + offset);
p = spline->GetInVec(seg2);
pmesh.setVec(vec++, p + offset);
}
else {
Point3 p = spline->InterpBezier3D(seg, 0.333333f);
pmesh.setVec(vec++, p + offset);