本文整理汇总了C++中PatchMesh::setVec方法的典型用法代码示例。如果您正苦于以下问题:C++ PatchMesh::setVec方法的具体用法?C++ PatchMesh::setVec怎么用?C++ PatchMesh::setVec使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PatchMesh
的用法示例。
在下文中一共展示了PatchMesh::setVec方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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)
//.........这里部分代码省略.........
示例2: BuildPatchFromShape
//.........这里部分代码省略.........
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);
p = spline->InterpBezier3D(seg, 0.666666f);
pmesh.setVec(vec++, p + offset);
}
}
}
// Now, the vectors between the levels
int baseVec = vec;
for(level = 0; level < levels; ++level) {
Point3 offsetA = Point3(0.0f, 0.0f, baseZ + (float)level / (float)levels * zSize);
Point3 offsetB = Point3(0.0f, 0.0f, baseZ + (float)(level + 1) / (float)levels * zSize);
Point3 offset1 = offsetA + (offsetB - offsetA) * 0.333333333f;
Point3 offset2 = offsetA + (offsetB - offsetA) * 0.666666666f;
for(knot = 0; knot < knots; ++knot) {
Point3 p = spline->GetKnotPoint(knot);
pmesh.setVec(vec++, p + offset1);
pmesh.setVec(vec++, p + offset2);
}
}
}
// Create the patches!
int np = 0;
int baseVert = 0;
int baseVec = 0;
for(poly = 0; poly < polys; ++poly) {
Spline3D *spline = bShape.splines[poly];