Object* TriPatchObject::ConvertToType(TimeValue t, Class_ID obtype) { if(obtype == patchObjectClassID || obtype == defObjectClassID || obtype == mapObjectClassID) { PatchObject *ob; UpdatePatchMesh(t); ob = new PatchObject(); ob->patch = patch; ob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t)); ob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t)); return ob; } if(obtype == triObjectClassID) { TriObject *ob = CreateNewTriObject(); PrepareMesh(t); ob->GetMesh() = patch.GetMesh(); ob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t)); ob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t)); return ob; } #ifndef NO_NURBS if (obtype==EDITABLE_SURF_CLASS_ID) { PatchObject *pob; UpdatePatchMesh(t); pob = new PatchObject(); pob->patch = patch; Object *ob = BuildEMObjectFromPatchObject(pob); delete pob; ob->SetChannelValidity(TOPO_CHAN_NUM, ObjectValidity(t)); ob->SetChannelValidity(GEOM_CHAN_NUM, ObjectValidity(t)); return ob; } #endif if (Object::CanConvertToType (obtype)) return Object::ConvertToType (t, obtype); if (CanConvertPatchObject (obtype)) { PatchObject *ob; UpdatePatchMesh(t); ob = new PatchObject(); ob->patch = patch; ob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t)); ob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t)); Object *ret = ob->ConvertToType (t, obtype); ob->DeleteThis (); return ret; } return NULL; }
Object* TriObject::ConvertToType(TimeValue t, Class_ID cid) { if (cid==defObjectClassID) return this; if (cid==mapObjectClassID) return this; if (cid==triObjectClassID) return this; #ifndef NO_PATCHES if (cid==patchObjectClassID) { PatchObject *patchob = new PatchObject(); patchob->patch = mesh; patchob->SetChannelValidity(TOPO_CHAN_NUM,ChannelValidity (t, TOPO_CHAN_NUM)); patchob->SetChannelValidity(GEOM_CHAN_NUM,ChannelValidity (t, GEOM_CHAN_NUM)); patchob->SetChannelValidity(TEXMAP_CHAN_NUM,ChannelValidity (t, TEXMAP_CHAN_NUM)); patchob->SetChannelValidity(VERT_COLOR_CHAN_NUM,ChannelValidity (t, VERT_COLOR_CHAN_NUM)); return patchob; } #endif #ifdef DESIGN_VER if (cid == GENERIC_AMSOLID_CLASS_ID) { Object* solid = (Object*)CreateInstance(GEOMOBJECT_CLASS_ID, GENERIC_AMSOLID_CLASS_ID); assert(solid); if(solid) { IGeomImp* cacheptr = (IGeomImp*)(solid->GetInterface(I_GEOMIMP)); assert(cacheptr); if(cacheptr) { // bool res = cacheptr->createConvexHull(mesh.verts, mesh.getNumVerts()); cacheptr->Init((void*)&mesh, MAX_MESH_ID); bool res = !cacheptr->isNull(); solid->ReleaseInterface(I_GEOMIMP, cacheptr); solid->SetChannelValidity(TOPO_CHAN_NUM,ChannelValidity (t, TOPO_CHAN_NUM)); solid->SetChannelValidity(GEOM_CHAN_NUM,ChannelValidity (t, GEOM_CHAN_NUM)); solid->SetChannelValidity(TEXMAP_CHAN_NUM,ChannelValidity (t, TEXMAP_CHAN_NUM)); solid->SetChannelValidity(VERT_COLOR_CHAN_NUM,ChannelValidity (t, VERT_COLOR_CHAN_NUM)); if(res) { return solid; } } } } #endif return Object::ConvertToType (t, cid); }
Object* SimpleObject::ConvertToType(TimeValue t, Class_ID obtype) { if (obtype==defObjectClassID||obtype==triObjectClassID||obtype==mapObjectClassID) { TriObject *triob; UpdateMesh(t); triob = CreateNewTriObject(); triob->GetMesh() = mesh; triob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t)); triob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t)); return triob; } else if (obtype == patchObjectClassID) { UpdateMesh(t); PatchObject *patchob = new PatchObject(); patchob->patch = mesh; // Handy Mesh->PatchMesh conversion patchob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t)); patchob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t)); return patchob; } return Object::ConvertToType(t,obtype); }
Object* SimpleObject::ConvertToType(TimeValue t, Class_ID obtype) { if (obtype==defObjectClassID||obtype==triObjectClassID||obtype==mapObjectClassID) { TriObject *triob; UpdateMesh(t); triob = CreateNewTriObject(); triob->GetMesh() = mesh; triob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t)); triob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t)); return triob; } #ifndef NO_PATCHES if (obtype == patchObjectClassID) { UpdateMesh(t); PatchObject *patchob = new PatchObject(); patchob->patch = mesh; // Handy Mesh->PatchMesh conversion patchob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t)); patchob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t)); return patchob; } #endif if (Object::CanConvertToType (obtype)) { UpdateMesh (t); return Object::ConvertToType(t,obtype); } if (CanConvertTriObject(obtype)) { UpdateMesh (t); TriObject *triob = CreateNewTriObject (); triob->GetMesh() = mesh; triob->SetChannelValidity(TOPO_CHAN_NUM,ObjectValidity(t)); triob->SetChannelValidity(GEOM_CHAN_NUM,ObjectValidity(t)); Object *ob = triob->ConvertToType (t, obtype); if (ob != triob) triob->DeleteThis (); // (ob should never = tob.) return ob; } return NULL; }
Object* TorusObject::ConvertToType(TimeValue t, Class_ID obtype) { #ifndef NO_PATCHES if (obtype == patchObjectClassID) { Interval valid = FOREVER; float radius1, radius2; int genUVs; pblock->GetValue(PB_RADIUS,t,radius1,valid); pblock->GetValue(PB_RADIUS2,t,radius2,valid); pblock->GetValue(PB_GENUVS,t,genUVs,valid); PatchObject *ob = new PatchObject(); BuildTorusPatch(t,ob->patch,radius1,radius2,genUVs, GetUsePhysicalScaleUVs()); ob->SetChannelValidity(TOPO_CHAN_NUM,valid); ob->SetChannelValidity(GEOM_CHAN_NUM,valid); ob->UnlockObject(); return ob; } #endif #ifndef NO_NURBS if (obtype == EDITABLE_SURF_CLASS_ID) { Interval valid = FOREVER; float radius, radius2, pie1, pie2; int sliceon, genUVs; pblock->GetValue(PB_RADIUS,t,radius,valid); pblock->GetValue(PB_RADIUS2,t,radius2,valid); pblock->GetValue(PB_PIESLICE1,t,pie1,valid); pblock->GetValue(PB_PIESLICE2,t,pie2,valid); pblock->GetValue(PB_SLICEON,t,sliceon,valid); pblock->GetValue(PB_GENUVS,t,genUVs,valid); Object *ob = BuildNURBSTorus(radius, radius2, sliceon, pie1, pie2, genUVs); ob->SetChannelValidity(TOPO_CHAN_NUM,valid); ob->SetChannelValidity(GEOM_CHAN_NUM,valid); ob->UnlockObject(); return ob; } #endif #ifdef DESIGN_VER if (obtype == GENERIC_AMSOLID_CLASS_ID) { Interval valid = FOREVER; float radius1, radius2, pie1, pie2; int sliceon, genUVs, sides, segs; pblock->GetValue(PB_RADIUS,t,radius1,valid); pblock->GetValue(PB_RADIUS2,t,radius2,valid); pblock->GetValue(PB_PIESLICE1,t,pie1,valid); pblock->GetValue(PB_PIESLICE2,t,pie2,valid); pblock->GetValue(PB_SLICEON,t,sliceon,valid); pblock->GetValue(PB_GENUVS,t,genUVs,valid); pblock->GetValue(PB_SIDES,t,sides,valid); pblock->GetValue(PB_SEGMENTS,t,segs,valid); int smooth; pblock->GetValue(PB_SMOOTH,t,smooth,valid); if (radius1 < 0.0f) radius1 = 0.0f; if (radius2 < 0.0f) radius2 = 0.0f; Object* solid = (Object*)CreateInstance(GEOMOBJECT_CLASS_ID, GENERIC_AMSOLID_CLASS_ID); assert(solid); if(solid) { IGeomImp* cacheptr = (IGeomImp*)(solid->GetInterface(I_GEOMIMP)); assert(cacheptr); if(cacheptr) { bool res = cacheptr->createTorus(radius1, radius2, sides, segs, smooth); solid->ReleaseInterface(I_GEOMIMP, cacheptr); if(res) return solid; else { solid->DeleteMe(); } } } return NULL; } #endif return SimpleObject::ConvertToType(t,obtype); }
void ExtrudeMod::ModifyObject(TimeValue t, ModContext &mc, ObjectState * os, INode *node) { //DebugPrint(_T("Extrude modifying object\n")); // Get our personal validity interval... Interval valid = GetValidity(t); // and intersect it with the channels we use as input (see ChannelsUsed) valid &= os->obj->ChannelValidity(t,TOPO_CHAN_NUM); valid &= os->obj->ChannelValidity(t,GEOM_CHAN_NUM); int output; pblock->GetValue(PB_OUTPUT, TimeValue(0), output, FOREVER); switch (output) { case NURBS_OUTPUT: #ifndef NO_NURBS { // Here is where all the fun stuff happens -- GenerateExtrudeSurface fills in the EM, // then we stuff the EditableSurface into the pipeline. ShapeObject *shape = (ShapeObject *)os->obj; float amount; BOOL texturing, genMatIds, useShapeIDs; pblock->GetValue(PB_MAPPING, TimeValue(0), texturing, FOREVER); pblock->GetValue(PB_GEN_MATIDS, TimeValue(0), genMatIds, FOREVER); pblock->GetValue(PB_USE_SHAPEIDS, TimeValue(0), useShapeIDs, FOREVER); int levels,capStart,capEnd,capType; pblock->GetValue(PB_SEGS,t,levels,FOREVER); if (levels<1) levels = 1; pblock->GetValue(PB_CAPSTART,t,capStart,FOREVER); pblock->GetValue(PB_CAPEND,t,capEnd,FOREVER); pblock->GetValue(PB_CAPTYPE,t,capType,FOREVER); pblock->GetValue(PB_AMOUNT,t,amount,FOREVER); LimitValue(amount, -1000000.0f, 1000000.0f); BOOL suspended = FALSE; if (theHold.Holding()) { theHold.Suspend(); suspended = TRUE; } Object *nobj = CreateNURBSExtrudeShape(ip, GetString(IDS_RB_EXTRUDE), t, shape, amount, capStart, capEnd, capType, texturing, genMatIds, useShapeIDs); if (suspended) { theHold.Resume(); } // We only set geom validity because we preserve animation on clone // and copying other cahnnels causes problems -- SCM 9/2/97 nobj->SetChannelValidity(GEOM_CHAN_NUM, valid); os->obj = nobj; break;} #endif #ifndef NO_PATCHES case PATCH_OUTPUT: { // Here is where all the fun stuff happens -- BuildPatchFromShape fills in the PatchObject's patch mesh, // then we stuff the PatchObject into the pipeline. PatchObject *pat = new PatchObject; BuildPatchFromShape(t, mc, os, pat->patch); pat->SetChannelValidity(TOPO_CHAN_NUM, valid); pat->SetChannelValidity(GEOM_CHAN_NUM, valid); pat->SetChannelValidity(TEXMAP_CHAN_NUM, valid); pat->SetChannelValidity(MTL_CHAN_NUM, valid); pat->SetChannelValidity(SELECT_CHAN_NUM, valid); pat->SetChannelValidity(SUBSEL_TYPE_CHAN_NUM, valid); pat->SetChannelValidity(DISP_ATTRIB_CHAN_NUM, valid); os->obj = pat; break;} #endif // NO_PATCHES case MESH_OUTPUT: { // Here is where all the fun stuff happens -- BuildMeshFromShape fills in the TriObject's mesh, // then we stuff the TriObj into the pipeline. TriObject *tri = CreateNewTriObject(); BuildMeshFromShape(t, mc, os, tri->GetMesh()); tri->SetChannelValidity(TOPO_CHAN_NUM, valid); tri->SetChannelValidity(GEOM_CHAN_NUM, valid); tri->SetChannelValidity(TEXMAP_CHAN_NUM, valid); tri->SetChannelValidity(MTL_CHAN_NUM, valid); tri->SetChannelValidity(SELECT_CHAN_NUM, valid); tri->SetChannelValidity(SUBSEL_TYPE_CHAN_NUM, valid); tri->SetChannelValidity(DISP_ATTRIB_CHAN_NUM, valid); os->obj = tri; break; } #ifdef XXDESIGN_VER case AMSOLID_OUTPUT: { //Create an extrusion solid using Facet Modeler Object* solid = (Object*)CreateInstance(GEOMOBJECT_CLASS_ID, GENERIC_AMSOLID_CLASS_ID); assert(solid); if(solid) { IGeomImp* cacheptr = (IGeomImp*)(solid->GetInterface(I_GEOMIMP)); assert(cacheptr); if(cacheptr) { bool res = BuildAMSolidFromShape(t, mc, os, cacheptr); solid->ReleaseInterface(I_GEOMIMP, cacheptr); if(!res) { valid.SetInstant(t); // assert(!cacheptr->isNull()); } for(int i=0; i<NUM_OBJ_CHANS;i++) solid->SetChannelValidity(i, valid); os->obj = solid; } } break; } #endif } os->obj->UnlockObject(); }