static void AddObjectsForJoinTests(NURBSSet &nset, int &c1, int &c2, int &s1, int &s2) { NURBSIndependentPoint pt; NURBSPointCurve *c = new NURBSPointCurve(); c->SetName(GetString(IDS_J_PT_CRV1)); c->SetNumPts(3); pt.SetPosition(0, Point3(100, 0, -100)); c->SetPoint(0, pt); pt.SetPosition(0, Point3(200, 0, -100)); c->SetPoint(1, pt); pt.SetPosition(0, Point3(200, 100, -100)); c->SetPoint(2, pt); c1 = nset.AppendObject(c); c = new NURBSPointCurve(); c->SetName(GetString(IDS_J_PT_CRV2)); c->SetNumPts(3); pt.SetPosition(0, Point3(210, 110, -100)); c->SetPoint(0, pt); pt.SetPosition(0, Point3(300, 200, -100)); c->SetPoint(1, pt); pt.SetPosition(0, Point3(300, 100, -100)); c->SetPoint(2, pt); c2 = nset.AppendObject(c); NURBSPointSurface *s = new NURBSPointSurface(); s->SetName(GetString(IDS_J_PT_SRF1)); s->SetNumPts(2, 2); pt.SetPosition(0, Point3(200, 0, -100)); s->SetPoint(0, 0, pt); pt.SetPosition(0, Point3(200, 100, -100)); s->SetPoint(0, 1, pt); pt.SetPosition(0, Point3(300, 0, -100)); s->SetPoint(1, 0, pt); pt.SetPosition(0, Point3(300, 100, -100)); s->SetPoint(1, 1, pt); s1 = nset.AppendObject(s); s = new NURBSPointSurface(); s->SetName(GetString(IDS_J_PT_SRF2)); s->SetNumPts(2, 2); pt.SetPosition(0, Point3(310, 0, -100)); s->SetPoint(0, 0, pt); pt.SetPosition(0, Point3(310, 100, -100)); s->SetPoint(0, 1, pt); pt.SetPosition(0, Point3(400, 0, -100)); s->SetPoint(1, 0, pt); pt.SetPosition(0, Point3(400, 100, -100)); s->SetPoint(1, 1, pt); s2 = nset.AppendObject(s); }
static void AddObjectsForBreakTests(NURBSSet &nset, int &c1, int &s1) { NURBSCVCurve *c = new NURBSCVCurve(); c->SetName(GetString(IDS_BREAK_CURVE)); c->SetNumCVs(4); c->SetOrder(4); c->SetNumKnots(8); for (int k = 0; k < 4; k++) { c->SetKnot(k, 0.0); c->SetKnot(k+4, 1.0); } NURBSControlVertex cv; cv.SetPosition(0, Point3(200, 0, 50)); c->SetCV(0, cv); cv.SetPosition(0, Point3(300, 0, 50)); c->SetCV(1, cv); cv.SetPosition(0, Point3(300, -100, 50)); c->SetCV(2, cv); cv.SetPosition(0, Point3(200, -100, 50)); c->SetCV(3, cv); c1 = nset.AppendObject(c); NURBSCVSurface *s = new NURBSCVSurface(); s->SetName(GetString(IDS_BREAK_SURFACE)); s->SetNumCVs(4, 4); s->SetUOrder(4); s->SetVOrder(4); s->SetNumUKnots(8); s->SetNumVKnots(8); for (k = 0; k < 4; k++) { s->SetUKnot(k, 0.0); s->SetVKnot(k, 0.0); s->SetUKnot(k+4, 1.0); s->SetVKnot(k+4, 1.0); } for (int u = 0; u < 4; u++) { float up = 100.0f * ((float)u/3.0f); for (int v = 0; v < 4; v++) { float vp = 100.0f * ((float)v/3.0f); cv.SetPosition(0, Point3(-150.0f + up, -100.0f + vp, -200.0f)); s->SetCV(u, v, cv); } } s1 = nset.AppendObject(s); }
int APITestUtil::MakeTestUVLoftSurface(NURBSSet &nset) { Matrix3 scale = ScaleMatrix(Point3(50, 50, 50)); Matrix3 rotate = RotateZMatrix(PI/2.0f); int cu0 = P1Curve(nset, scale * TransMatrix(Point3(0, 0, 0))); int cu1 = P1Curve(nset, scale * TransMatrix(Point3(0, 0, 20))); int cu2 = P1Curve(nset, scale * TransMatrix(Point3(0, 0, 40))); int cv0 = P2Curve(nset, TransMatrix(Point3(50, 50, 0))); int cv1 = P2Curve(nset, TransMatrix(Point3(-50, 50, 0))); int cv2 = P2Curve(nset, TransMatrix(Point3(-50, -50, 0))); int cv3 = P2Curve(nset, TransMatrix(Point3(50, -50, 0))); NURBSUVLoftSurface *s = new NURBSUVLoftSurface(); s->SetName(GetString(IDS_UVLOFT_SURFACE)); s->SetNSet(&nset); s->AppendUCurve(cu0); s->AppendUCurve(cu1); s->AppendUCurve(cu2); s->AppendVCurve(cv0); s->AppendVCurve(cv1); s->AppendVCurve(cv2); s->AppendVCurve(cv3); return nset.AppendObject(s); }
int APITestUtil::MakeTestCVSurface(NURBSSet &nset, Matrix3 mat, BOOL rigid) { NURBSCVSurface *s = new NURBSCVSurface(); s->SetRigid(rigid); s->SetName(GetString(IDS_CV_SURFACE)); s->SetNumCVs(4, 4); s->SetUOrder(4); s->SetVOrder(4); s->SetNumUKnots(8); s->SetNumVKnots(8); for (int k = 0; k < 4; k++) { s->SetUKnot(k, 0.0); s->SetVKnot(k, 0.0); s->SetUKnot(k+4, 1.0); s->SetVKnot(k+4, 1.0); } NURBSControlVertex cv; for (int u = 0; u < 4; u++) { float up = 100.0f * ((float)u/3.0f); for (int v = 0; v < 4; v++) { float vp = 100.0f * ((float)v/3.0f); cv.SetPosition(0, mat * Point3(-150.0f + up, -100.0f + vp, 0.0f)); TCHAR name[20]; _stprintf(name, _T("%s[%d,%d]"), GetString(IDS_CV), u, v); cv.SetName(name); s->SetCV(u, v, cv); } } return nset.AppendObject(s); }
int APITestUtil::MakeTestPointSurface(NURBSSet &nset, Matrix3 mat) { NURBSPointSurface *s = new NURBSPointSurface(); s->SetName(GetString(IDS_POINT_SURFACE)); s->SetNumPts(2, 2); NURBSIndependentPoint pt; pt.SetPosition(0, mat * Point3(20, 0, 0)); TCHAR name[32]; _stprintf(name, _T("%s [%d,%d]"), GetString(IDS_POINT), 0, 0); pt.SetName(name); s->SetPoint(0, 0, pt); pt.SetPosition(0, mat * Point3(20, 0, 100)); _stprintf(name, _T("%s [%d,%d]"), GetString(IDS_POINT), 0, 1); pt.SetName(name); s->SetPoint(0, 1, pt); pt.SetPosition(0, mat * Point3(120, 0, 0)); _stprintf(name, _T("%s [%d,%d]"), GetString(IDS_POINT), 1, 0); pt.SetName(name); s->SetPoint(1, 0, pt); pt.SetPosition(0, mat * Point3(120, 0, 100)); _stprintf(name, _T("%s [%d,%d]"), GetString(IDS_POINT), 1, 1); pt.SetName(name); s->SetPoint(1, 1, pt); return nset.AppendObject(s); }
int APITestUtil::MakeTestPoint(NURBSSet &nset) { NURBSIndependentPoint *p = new NURBSIndependentPoint(); p->SetName(GetString(IDS_POINT)); p->SetPosition(0, Point3(75, -75, 0)); return nset.AppendObject(p); }
int APITestUtil::MakeTestOffsetSurface(NURBSSet &nset, int p) { NURBSOffsetSurface *s = new NURBSOffsetSurface(); s->SetName(GetString(IDS_OFFSET_SURFACE)); s->SetNSet(&nset); s->SetParent(p); s->SetDistance(0, 20.0); return nset.AppendObject(s); }
int APITestUtil::MakeTestPointCPoint(NURBSSet &nset, int p1) { NURBSPointConstPoint *p = new NURBSPointConstPoint(); p->SetName(GetString(IDS_POINT_CONST_POINT)); p->SetParent(p1); p->SetPointType(kNConstOffset); p->SetOffset(0, Point3(20, -20, 20)); return nset.AppendObject(p); }
int APITestUtil::MakeTestCurveCPoint(NURBSSet &nset, int p1) { NURBSCurveConstPoint *p = new NURBSCurveConstPoint(); p->SetName(GetString(IDS_CURVE_CONST_POINT)); p->SetParent(p1); p->SetUParam(0, 0.5); p->SetPointType(kNConstNormal); p->SetNormal(0, 15.0f); return nset.AppendObject(p); }
static int AddTestIsoCurve(NURBSSet &nset, NURBSId id) { NURBSIsoCurve *c = new NURBSIsoCurve(); c->SetName(GetString(IDS_ADDED_ISO_CURVE)); c->SetNSet(&nset); c->SetParentId(id); c->SetParam(0, 0.6); c->SetDirection(FALSE); // not U return nset.AppendObject(c); }
int APITestUtil::MakeTestExtrudeSurface(NURBSSet &nset, int p1) { NURBSExtrudeSurface *s = new NURBSExtrudeSurface(); s->SetName(GetString(IDS_EXTRUDE_SURFACE)); s->SetNSet(&nset); s->SetParent(p1); s->SetDistance(0, 50); s->FlipNormals(TRUE); return nset.AppendObject(s); }
int APITestUtil::MakeTestULoftSurface(NURBSSet &nset, int p1, int p2, int p3) { NURBSULoftSurface *s = new NURBSULoftSurface(); s->SetName(GetString(IDS_ULOFT_SURFACE)); s->SetNSet(&nset); s->AppendCurve(p1, FALSE); s->AppendCurve(p2, FALSE); s->AppendCurve(p3, FALSE); s->FlipNormals(TRUE); return nset.AppendObject(s); }
int APITestUtil::MakeTestRuledSurface(NURBSSet &nset, int p1, int p2) { NURBSRuledSurface *s = new NURBSRuledSurface(); s->SetName(GetString(IDS_RULED_SURFACE)); s->SetNSet(&nset); s->SetParent(0, p1); s->SetParent(1, p2); s->SetFlip(0, FALSE); s->SetFlip(1, FALSE); return nset.AppendObject(s); }
int APITestUtil::MakeTestBlendSurface(NURBSSet &nset, int p1, int p2) { NURBSBlendSurface *s = new NURBSBlendSurface(); s->SetName(GetString(IDS_BLEND_SURFACE)); s->SetNSet(&nset); s->SetParent(0, p1); s->SetParent(1, p2); s->SetEdge(0, 1); // make it the High U edge return nset.AppendObject(s); }
int APITestUtil::MakeTestXFormSurface(NURBSSet &nset, int p) { NURBSXFormSurface *s = new NURBSXFormSurface(); s->SetName(GetString(IDS_XFORM_SURFACE)); s->SetNSet(&nset); s->SetParent(p); Matrix3 mat; mat.IdentityMatrix(); mat.SetTrans(Point3(-150, 150, 0)); s->SetXForm(0, mat); return nset.AppendObject(s); }
int APITestUtil::MakeTestCurveSurface(NURBSSet &nset, int p1, int p2) { NURBSCurveSurfaceIntersectionPoint *p = new NURBSCurveSurfaceIntersectionPoint(); p->SetName(GetString(IDS_CURV_SURF_INT_POINT)); p->SetNSet(&nset); p->SetParent(0, p1); p->SetParent(1, p2); p->SetSeed(0.5); return nset.AppendObject(p); }
int APITestUtil::MakeTestSurfCPoint(NURBSSet &nset, int p1) { NURBSSurfConstPoint *p = new NURBSSurfConstPoint(); p->SetName(GetString(IDS_SURF_CONST_POINT)); p->SetParent(p1); p->SetUParam(0, 0.5); p->SetVParam(0, 0.6); p->SetPointType(kNConstTangent); p->SetUTangent(0, 15.0f); p->SetVTangent(0, 25.0f); return nset.AppendObject(p); }
int APITestUtil::MakeTestCurveCurve(NURBSSet &nset, int p1, int p2, BOOL trim) { NURBSCurveCurveIntersectionPoint *p = new NURBSCurveCurveIntersectionPoint(); p->SetName(GetString(IDS_CURVE_CURVE_POINT)); p->SetNSet(&nset); p->SetParent(0, p1); p->SetParent(1, p2); p->SetCurveParam(0, 0.0); p->SetCurveParam(1, 0.0); p->SetTrimCurve(1, trim); return nset.AppendObject(p); }
int APITestUtil::MakeTestMirrorSurface(NURBSSet &nset, int p) { NURBSMirrorSurface *s = new NURBSMirrorSurface(); s->SetName(GetString(IDS_MIRROR_SURFACE)); s->SetNSet(&nset); s->SetParent(p); Matrix3 mat; mat.IdentityMatrix(); s->SetXForm(0, mat); s->SetAxis(kMirrorZ); s->SetDistance(0, 100.0); s->FlipNormals(TRUE); return nset.AppendObject(s); }
static int MakeCurveToLathe(NURBSSet &nset) { NURBSPointCurve *c = new NURBSPointCurve(); c->SetName(GetString(IDS_POINT_CURVE)); c->SetNumPts(3); NURBSIndependentPoint pt; pt.SetPosition(0, Point3(200, 200, 0)); c->SetPoint(0, pt); pt.SetPosition(0, Point3(250, 200, 100)); c->SetPoint(1, pt); pt.SetPosition(0, Point3(200, 200, 150)); c->SetPoint(2, pt); return nset.AppendObject(c); }
int APITestUtil::MakeTestLatheSurface(NURBSSet &nset) { int p = MakeCurveToLathe(nset); NURBSLatheSurface *s = new NURBSLatheSurface(); s->SetName(GetString(IDS_LATHE_SURFACE)); s->SetNSet(&nset); s->SetParent(p); Matrix3 mat = TransMatrix(Point3(200, 200, 0)); s->SetAxis(0, mat); s->FlipNormals(TRUE); return nset.AppendObject(s); }
static int P2Curve(NURBSSet &nset, Matrix3 mat) { NURBSPointCurve *c = new NURBSPointCurve(); c->SetName(GetString(IDS_POINT_CURVE)); c->SetNumPts(3); NURBSIndependentPoint pt; pt.SetPosition(0, mat * Point3(0, 0, 0)); c->SetPoint(0, pt); pt.SetPosition(0, mat * Point3(0, 0, 20)); c->SetPoint(1, pt); pt.SetPosition(0, mat * Point3(0, 0, 40)); c->SetPoint(2, pt); return nset.AppendObject(c); }
int APITestUtil::MakeTest1RailSweepSurface(NURBSSet &nset) { int rail = P1Curve(nset, ScaleMatrix(Point3(50, 50, 50))); int cross = P1Curve(nset, ScaleMatrix(Point3(5, 5, 5)) * RotateYMatrix(PI/2.0f) * TransMatrix(Point3(50, 50, 0))); NURBS1RailSweepSurface *s = new NURBS1RailSweepSurface(); s->SetName(GetString(IDS_1RAIL_SURFACE)); s->SetNSet(&nset); s->SetParentRail(rail); s->AppendCurve(cross, FALSE); s->SetParallel(FALSE); s->FlipNormals(TRUE); return nset.AppendObject(s); }
int APITestUtil::MakeTest2RailSweepSurface(NURBSSet &nset) { int rail1 = P1Curve(nset, ScaleMatrix(Point3(70, 70, 70))); int rail2 = P1Curve(nset, ScaleMatrix(Point3(90, 90, 90))); int cross = P1Curve(nset, ScaleMatrix(Point3(5, 5, 5)) * RotateYMatrix(PI/2.0f) * TransMatrix(Point3(70, 70, 0))); NURBS2RailSweepSurface *s = new NURBS2RailSweepSurface(); s->SetName(GetString(IDS_2RAIL_SURFACE)); s->SetNSet(&nset); s->SetRailParent(0, rail1); s->SetRailParent(1, rail2); s->AppendCurve(cross, FALSE); return nset.AppendObject(s); }
static int AddTestPointSurface(NURBSSet &nset) { NURBSPointSurface *s = new NURBSPointSurface(); s->SetName(GetString(IDS_ADDED_POINT_SURF)); s->SetNumPts(2, 2); NURBSIndependentPoint pt; pt.SetPosition(0, Point3(20, 0, -100)); s->SetPoint(0, 0, pt); pt.SetPosition(0, Point3(20, 0, -200)); s->SetPoint(0, 1, pt); pt.SetPosition(0, Point3(120, 0, -100)); s->SetPoint(1, 0, pt); pt.SetPosition(0, Point3(120, 0, -200)); s->SetPoint(1, 1, pt); s->FlipNormals(TRUE); return nset.AppendObject(s); }
static int COS2(NURBSSet &nset, int p1) { NURBSPointCurveOnSurface *c = new NURBSPointCurveOnSurface(); c->SetName(GetString(IDS_POINT_COS_CURVE)); c->SetNSet(&nset); c->SetParent(p1); c->SetNumPts(3); NURBSIndependentPoint pt; pt.SetPosition(0, Point3(0.1, 0.1, 0.0)); c->SetPoint(0, pt); pt.SetPosition(0, Point3(0.75, 0.25, 0.0)); c->SetPoint(1, pt); pt.SetPosition(0, Point3(0.9, 0.9, 0.0)); c->SetPoint(2, pt); return nset.AppendObject(c); }
int APITestUtil::MakeTestMultiCurveTrimSurface(NURBSSet &nset) { int srf = MakeTestCVSurface(nset, TransMatrix(Point3(100, 100, 150))); int cos1 = COS1(nset, srf); int cos2 = COS2(nset, srf); NURBSMultiCurveTrimSurface *s = new NURBSMultiCurveTrimSurface(); s->SetName(GetString(IDS_MULTI_TRIM_SURFACE)); s->SetNSet(&nset); s->SetSurfaceParent(srf); s->AppendCurve(cos1); s->AppendCurve(cos2); // Tell the surface to flip the orientation of the trim. s->SetFlipTrim(TRUE); return nset.AppendObject(s); }
Object* BuildNURBSPrism(float side1, float side2, float side3, float height, int genUVs) { float s13len=side1*side3; float theta = (float)acos((side2*side2 - side1*side1 - side3*side3)/(-2.0f*s13len)); int prism_faces[5][4] = {{0, 1, 2, 2}, // bottom {1, 0, 4, 3}, // front {2, 1, 5, 4}, // left {0, 2, 3, 5}, // right {4, 3, 5, 5}};// top Point3 prism_verts[6] ={Point3(0.0f, 0.0f, 0.0f), Point3(side1, 0.0f, 0.0f), Point3(side3*(float)cos(theta), side3*(float)sin(theta), 0.0f), Point3(0.0f, 0.0f, height), Point3(side1, 0.0f, height), Point3(side3*(float)cos(theta), side3*(float)sin(theta), height)}; NURBSSet nset; for (int face = 0; face < 5; face++) { Point3 bl = prism_verts[prism_faces[face][0]]; Point3 br = prism_verts[prism_faces[face][1]]; Point3 tl = prism_verts[prism_faces[face][2]]; Point3 tr = prism_verts[prism_faces[face][3]]; NURBSCVSurface *surf = new NURBSCVSurface(); nset.AppendObject(surf); surf->SetUOrder(4); surf->SetVOrder(4); surf->SetNumCVs(4, 4); surf->SetNumUKnots(8); surf->SetNumVKnots(8); Point3 top, bot; for (int r = 0; r < 4; r++) { top = tl + (((float)r/3.0f) * (tr - tl)); bot = bl + (((float)r/3.0f) * (br - bl)); for (int c = 0; c < 4; c++) { NURBSControlVertex ncv; ncv.SetPosition(0, bot + (((float)c/3.0f) * (top - bot))); ncv.SetWeight(0, 1.0f); surf->SetCV(r, c, ncv); } } for (int k = 0; k < 4; k++) { surf->SetUKnot(k, 0.0); surf->SetVKnot(k, 0.0); surf->SetUKnot(k + 4, 1.0); surf->SetVKnot(k + 4, 1.0); } surf->Renderable(TRUE); surf->SetGenerateUVs(genUVs); if (height > 0.0f) surf->FlipNormals(TRUE); else surf->FlipNormals(FALSE); float sum = side1 + side2 + side3; float s1 = side1/sum; float s3 = 1.0f - side3/sum; switch(face) { case 0: surf->SetTextureUVs(0, 0, Point2(0.5f, 0.0f)); surf->SetTextureUVs(0, 1, Point2(0.5f, 0.0f)); surf->SetTextureUVs(0, 2, Point2(1.0f, 1.0f)); surf->SetTextureUVs(0, 3, Point2(0.0f, 1.0f)); break; case 1: surf->SetTextureUVs(0, 0, Point2(s1, 1.0f)); surf->SetTextureUVs(0, 1, Point2(0.0f, 1.0f)); surf->SetTextureUVs(0, 2, Point2(s1, 0.0f)); surf->SetTextureUVs(0, 3, Point2(0.0f, 0.0f)); break; case 2: surf->SetTextureUVs(0, 0, Point2(s3, 1.0f)); surf->SetTextureUVs(0, 1, Point2(s1, 1.0f)); surf->SetTextureUVs(0, 2, Point2(s3, 0.0f)); surf->SetTextureUVs(0, 3, Point2(s1, 0.0f)); break; case 3: surf->SetTextureUVs(0, 0, Point2(1.0f, 1.0f)); surf->SetTextureUVs(0, 1, Point2(s3, 1.0f)); surf->SetTextureUVs(0, 2, Point2(1.0f, 0.0f)); surf->SetTextureUVs(0, 3, Point2(s3, 0.0f)); break; case 4: surf->SetTextureUVs(0, 0, Point2(0.5f, 1.0f)); surf->SetTextureUVs(0, 1, Point2(0.5f, 1.0f)); surf->SetTextureUVs(0, 2, Point2(1.0f, 0.0f)); surf->SetTextureUVs(0, 3, Point2(0.0f, 0.0f)); break; } TCHAR bname[80]; _stprintf(bname, _T("%s%02d"), GetString(IDS_CT_SURF), face); surf->SetName(bname); } #define F(s1, s2, s1r, s1c, s2r, s2c) \ fuse.mSurf1 = (s1); \ fuse.mSurf2 = (s2); \ fuse.mRow1 = (s1r); \ fuse.mCol1 = (s1c); \ fuse.mRow2 = (s2r); \ fuse.mCol2 = (s2c); \ nset.mSurfFuse.Append(1, &fuse); NURBSFuseSurfaceCV fuse; // Bottom(0) to Front (1) F(0, 1, 3, 0, 0, 0); F(0, 1, 2, 0, 1, 0); F(0, 1, 1, 0, 2, 0); F(0, 1, 0, 0, 3, 0); // Bottom(0) to Left (2) F(0, 2, 3, 0, 3, 0); F(0, 2, 3, 1, 2, 0); F(0, 2, 3, 2, 1, 0); F(0, 2, 3, 3, 0, 0); // Bottom(0) to Right (3) F(0, 3, 0, 0, 0, 0); F(0, 3, 0, 1, 1, 0); F(0, 3, 0, 2, 2, 0); F(0, 3, 0, 3, 3, 0); // Top(4) to Front (1) F(4, 1, 3, 0, 3, 3); F(4, 1, 2, 0, 2, 3); F(4, 1, 1, 0, 1, 3); F(4, 1, 0, 0, 0, 3); // Top(4) to Left (2) F(4, 2, 0, 0, 3, 3); F(4, 2, 0, 1, 2, 3); F(4, 2, 0, 2, 1, 3); F(4, 2, 0, 3, 0, 3); // Top(4) to Right (3) F(4, 3, 3, 0, 0, 3); F(4, 3, 3, 1, 1, 3); F(4, 3, 3, 2, 2, 3); F(4, 3, 3, 3, 3, 3); // Front(1) to Left (2) F(1, 2, 0, 1, 3, 1); F(1, 2, 0, 2, 3, 2); // Left(2) to Right (3) F(2, 3, 0, 1, 3, 1); F(2, 3, 0, 2, 3, 2); // Right(3) to Front (1) F(3, 1, 0, 1, 3, 1); F(3, 1, 0, 2, 3, 2); // Fuse the triangles together for (int i = 1; i < 4; i++) { F(0, 0, 0, 3, i, 3); F(4, 4, 0, 3, i, 3); } Matrix3 mat; mat.IdentityMatrix(); Object *obj = CreateNURBSObject(NULL, &nset, mat); return obj; }
void APITestUtil::CombinedTests() { // now let's build a test object NURBSSet nset; Matrix3 mat; mat.IdentityMatrix(); // build an independent point int indPnt = MakeTestPoint(nset); // now a constrained point int ptPnt = MakeTestPointCPoint(nset, indPnt); // build a cv curve int cvCrv = MakeTestCVCurve(nset, mat); // and a constrained point on that curve int crvPnt = MakeTestCurveCPoint(nset, cvCrv); // now a point curve int ptCrv = MakeTestPointCurve(nset, mat); // Blend the two curves int blendCrv = MakeTestBlendCurve(nset, cvCrv, ptCrv); // make an offset of the CV curve int offCrv = MakeTestOffsetCurve(nset, cvCrv); // make a Transform curve of the point curve int xformCrv = MakeTestXFormCurve(nset, ptCrv); // make a mirror of the blend int mirCrv = MakeTestMirrorCurve(nset, blendCrv); // make a fillet curve (It makes it's own point curves to fillet) int fltCrv = MakeTestFilletCurve(nset); // make a chamfer curve (It makes it's own point curves to fillet) int chmCrv = MakeTestChamferCurve(nset); // build a cv surface int cvSurf = MakeTestCVSurface(nset, mat); // and a constrained point on that surface int srfPnt = MakeTestSurfCPoint(nset, cvSurf); // Curve Surface intersection point. int cvCrv2 = MakeTestCVCurve(nset, RotateXMatrix(PI/2.0f) * TransMatrix(Point3(0, 0, -175))); int srfIntPoint = MakeTestCurveSurface(nset, cvSurf, cvCrv2); // Now an Iso Curve on the CV surface int isoCrv1 = MakeTestIsoCurveU(nset, cvSurf); // Now an Iso Curve on the CV surface int isoCrv2 = MakeTestIsoCurveV(nset, cvSurf); // Now a Surface Edge Curve on the CV surface int surfEdgeCrv = MakeTestSurfaceEdgeCurve(nset, cvSurf); // build a CV Curve on Surface int cvCOS = MakeTestCurveOnSurface(nset, cvSurf); // build a Point Curve on Surface int pntCOS = MakeTestPointCurveOnSurface(nset, cvSurf); // build a Surface Normal Offset Curve int cnoCrf = MakeTestSurfaceNormalCurve(nset, cvCOS); // Make a curve-curve intersection point int curveCurve = MakeTestCurveCurve(nset, isoCrv1, isoCrv2, TRUE); // build a point surface int ptSurf = MakeTestPointSurface(nset, mat); // Blend the two surfaces int blendSurf = MakeTestBlendSurface(nset, cvSurf, ptSurf); // Offset of the blend int offSurf = MakeTestOffsetSurface(nset, blendSurf); // Transform of the Offset int xformSurf = MakeTestXFormSurface(nset, offSurf); // Mirror of the transform surface int mirSurf = MakeTestMirrorSurface(nset, xformSurf); // Make a Ruled surface between two curves int rulSurf = MakeTestRuledSurface(nset, cvCrv, ptCrv); // Make a ULoft surface int uLoftSurf = MakeTestULoftSurface(nset, ptCrv, offCrv, xformCrv); // Make a Extrude surface int extSurf = MakeTestExtrudeSurface(nset, xformCrv); // Make a lathe int lthSurf = MakeTestLatheSurface(nset); // these will build their own curves to work with // UV Loft int uvLoftSurf = MakeTestUVLoftSurface(nset); // 1 Rail Sweep int oneRailSurf = MakeTest1RailSweepSurface(nset); // 2 Rail Sweep int twoRailSurf = MakeTest2RailSweepSurface(nset); // MultiCurveTrim Surface int multiTrimSurf = MakeTestMultiCurveTrimSurface(nset); // Now make the curves and surfaces that we'll use later for the join tests int jc1, jc2, js1, js2; AddObjectsForJoinTests(nset, jc1, jc2, js1, js2); int bc, bs; AddObjectsForBreakTests(nset, bc, bs); Object *obj = CreateNURBSObject(mpIp, &nset, mat); INode *node = mpIp->CreateObjectNode(obj); node->SetName(GetString(IDS_TEST_OBJECT)); NURBSSet addNset; // build a point surface int addptSurf = AddTestPointSurface(addNset); // add an iso curve to the previously created CV Surface NURBSId id = nset.GetNURBSObject(cvSurf)->GetId(); int addIsoCrv = AddTestIsoCurve(addNset, id); AddNURBSObjects(obj, mpIp, &addNset); // now test some changing functionality // Let's change the name of the CVSurface NURBSObject* nObj = nset.GetNURBSObject(cvSurf); nObj->SetName(_T("New CVSurf Name")); // testing only, no need to localize // now let's change the position of one of the points in the point curve NURBSPointCurve* ptCrvObj = (NURBSPointCurve*)nset.GetNURBSObject(ptCrv); ptCrvObj->GetPoint(0)->SetPosition(0, Point3(10, 160, 0)); // moved from 0,150,0 // now let's change the position and weight of one of the CVs // in the CV Surface NURBSCVSurface* cvSurfObj = (NURBSCVSurface*)nset.GetNURBSObject(cvSurf); cvSurfObj->GetCV(0, 0)->SetPosition(0, Point3(-150.0, -100.0, 20.0)); // moved from 0,0,0 cvSurfObj->GetCV(0, 0)->SetWeight(0, 2.0); // from 1.0 // now let's do a transform of a curve. NURBSIdTab xfmTab; NURBSId nid = nset.GetNURBSObject(jc1)->GetId(); xfmTab.Append(1, &nid); Matrix3 xfmMat; xfmMat = TransMatrix(Point3(10, 10, -10)); SetXFormPacket xPack(xfmMat); NURBSResult res = Transform(obj, xfmTab, xPack, xfmMat, 0); // Now let's Join two curves NURBSId jc1id = nset.GetNURBSObject(jc1)->GetId(), jc2id = nset.GetNURBSObject(jc2)->GetId(); JoinCurves(obj, jc1id, jc2id, FALSE, TRUE, 20.0, 1.0f, 1.0f, 0); // Now let's Join two surfaces NURBSId js1id = nset.GetNURBSObject(js1)->GetId(), js2id = nset.GetNURBSObject(js2)->GetId(); JoinSurfaces(obj, js1id, js2id, 1, 0, 20.0, 1.0f, 1.0f, 0); // Break a Curve NURBSId bcid = nset.GetNURBSObject(bc)->GetId(); BreakCurve(obj, bcid, .5, 0); // Break a Surface NURBSId bsid = nset.GetNURBSObject(bs)->GetId(); BreakSurface(obj, bsid, TRUE, .5, 0); mpIp->RedrawViews(mpIp->GetTime()); nset.DeleteObjects(); addNset.DeleteObjects(); // now do a detach NURBSSet detset; Matrix3 detmat; detmat.IdentityMatrix(); // build a cv curve int detcvCrv = MakeTestCVCurve(detset, detmat); // now a point curve int detptCrv = MakeTestPointCurve(detset, detmat); // Blend the two curves int detblendCrv = MakeTestBlendCurve(detset, detcvCrv, detptCrv); Object *detobj = CreateNURBSObject(mpIp, &detset, detmat); INode *detnode = mpIp->CreateObjectNode(detobj); detnode->SetName("Detach From"); BOOL copy = TRUE; BOOL relational = TRUE; NURBSIdList detlist; NURBSId oid = detset.GetNURBSObject(detblendCrv)->GetId(); detlist.Append(1, &oid); DetachObjects(GetCOREInterface()->GetTime(), detnode, detobj, detlist, "Detach Test", copy, relational); mpIp->RedrawViews(mpIp->GetTime()); }
Object * BuildNURBSTorus(float radius, float radius2, BOOL sliceon, float pie1, float pie2, BOOL genUVs) { NURBSSet nset; Point3 origin(0,0,0); Point3 symAxis(0,0,1); Point3 refAxis(0,1,0); float startAngle = 0.0f; float endAngle = TWOPI; if (sliceon && pie1 != pie2) { float sweep = pie2-pie1; if (sweep <= 0.0f) sweep += TWOPI; refAxis = Point3(Point3(0,1,0) * RotateZMatrix(pie1)); endAngle = sweep; } // first the main surface NURBSCVSurface *surf = new NURBSCVSurface(); nset.AppendObject(surf); surf->SetGenerateUVs(genUVs); surf->SetTextureUVs(0, 0, Point2(0.0f, 0.0f)); surf->SetTextureUVs(0, 1, Point2(0.0f, 1.0f)); surf->SetTextureUVs(0, 2, Point2(1.0f, 0.0f)); surf->SetTextureUVs(0, 3, Point2(1.0f, 1.0f)); surf->FlipNormals(TRUE); surf->Renderable(TRUE); TCHAR bname[80]; TCHAR sname[80]; _tcscpy(bname, GetString(IDS_RB_TORUS)); _stprintf(sname, _T("%s%s"), bname, GetString(IDS_CT_SURF)); surf->SetName(sname); if (sliceon && pie1 != pie2) { GenNURBSTorusSurface(radius, radius2, origin, symAxis, refAxis, startAngle, endAngle, -PI, PI, TRUE, *surf); // now create caps on the ends NURBSCapSurface *cap0 = new NURBSCapSurface(); nset.AppendObject(cap0); cap0->SetGenerateUVs(genUVs); cap0->SetParent(0); cap0->SetEdge(2); cap0->FlipNormals(FALSE); cap0->Renderable(TRUE); TCHAR sname[80]; _stprintf(sname, _T("%s%s%02d"), bname, GetString(IDS_CT_CAP), 0); cap0->SetName(sname); NURBSCapSurface *cap1 = new NURBSCapSurface(); nset.AppendObject(cap1); cap1->SetGenerateUVs(genUVs); cap1->SetParent(0); cap1->SetEdge(3); cap1->FlipNormals(TRUE); cap1->Renderable(TRUE); _stprintf(sname, _T("%s%s%02d"), bname, GetString(IDS_CT_CAP), 1); cap1->SetName(sname); } else { GenNURBSTorusSurface(radius, radius2, origin, symAxis, refAxis, startAngle, endAngle, -PI, PI, FALSE, *surf); } Matrix3 mat; mat.IdentityMatrix(); Object *ob = CreateNURBSObject(NULL, &nset, mat); return ob; }