[PXCDD-commit] SF.net SVN: pxcdd: [399] trunk/client/c4d/pxcdd-turntable.cof
Status: Alpha
Brought to you by:
tangentsoft
From: <ric...@us...> - 2006-07-17 02:44:42
|
Revision: 399 Author: ricknroll Date: 2006-07-16 19:44:37 -0700 (Sun, 16 Jul 2006) ViewCVS: http://svn.sourceforge.net/pxcdd/?rev=399&view=rev Log Message: ----------- Added code to determine scene extents. It's not working, but I wanted to checkin my progress. Modified Paths: -------------- trunk/client/c4d/pxcdd-turntable.cof Modified: trunk/client/c4d/pxcdd-turntable.cof =================================================================== --- trunk/client/c4d/pxcdd-turntable.cof 2006-07-15 21:03:39 UTC (rev 398) +++ trunk/client/c4d/pxcdd-turntable.cof 2006-07-17 02:44:37 UTC (rev 399) @@ -16,6 +16,9 @@ public: // ctor PXCDDTurntablePlugin(); + + GetSceneBounds(doc); + GetObjectBounds(op); // Parent class overrides Execute(doc); @@ -28,10 +31,126 @@ private: + GetNextHierarchyObject(obj, stopAt); + MakeEditable(doc, obj); +} +PXCDDTurntablePlugin::GetNextHierarchyObject(obj, stopAt) +{ + // This function by Mikael Sterner + // From plugincafe.com + + if (!obj) return NULL; + + var next; + if (next = obj->GetDown()) return next; + if (next = obj->GetNext()) return next; + + var up = obj; + while (up = up->GetUp()) { + if (up == stopAt) return NULL; + if (next = up->GetNext()) return next; + } } +PXCDDTurntablePlugin::MakeEditable(doc, obj) +{ + var bc = new(BaseContainer); + doc->AddUndo(UNDO_OBJECT_REC, obj); + return SendModelingCommand(MCOMMAND_MAKEeditable, doc, obj, bc, MODIFY_ALL); +} + +//// GetObjectBounds /////////////////////////////////////////////////// +// Loop through object points and return matrix with: +// -- Negative extents +// -- Positive extents +// -- Center point +// -- Total size + +PXCDDTurntablePlugin::GetObjectBounds(op) +{ + var vec_min = vector(0,0,0); + var vec_max = vector(0,0,0); + var vec_pnt; + + var arr = op->GetPoints(); + + if(instanceof(op, PointObject)) { + + var p; for(p = 0; p < op->GetPointCount(); p++) { + println(arr[p]); + vec_pnt = op->GetPoint(p); + if(vec_pnt.x < vec_min.x) vec_min.x = vec_pnt.x; + if(vec_pnt.y < vec_min.y) vec_min.y = vec_pnt.y; + if(vec_pnt.z < vec_min.z) vec_min.z = vec_pnt.z; + if(vec_pnt.x > vec_max.x) vec_max.x = vec_pnt.x; + if(vec_pnt.y > vec_max.y) vec_max.y = vec_pnt.y; + if(vec_pnt.z > vec_max.z) vec_max.z = vec_pnt.z; + } + + } + + var vec_ctr = (vec_min + vec_max) / 2; + var vec_siz = abs(vec_min) + abs(vec_max); + + println(op->GetName(), "::", vec_min, "//", vec_max, "//", vec_ctr, "//", vec_siz); +} + +//// GetSceneBounds /////////////////////////////////////////////////// +// Loop through scene and return matrix with: +// -- Negative extents +// -- Positive extents +// -- Center point + +PXCDDTurntablePlugin::GetSceneBounds(doc) +{ + // Start Undo Step so we can undo all the MakeEditables + doc->StartUndo(); + + var op = doc->GetFirstObject(); + while(op) { + println(op->GetName()); + println(getclass(op)); + switch( getclass(op) ) { + + case LightObject: + case CameraObject: + case FloorObject: + case SkyObject: + case EnvironmentObject: + case ForegroundObject: + case BackgroundObject: + // Skip any processing + break; + + case PointObject: + case PolygonObject: + // Get the Object Extents + println("Point"); + GetObjectBounds(op); + break; + + default: + // Make the object editable + if(MakeEditable(doc, op)) { + op = GetActiveObject(doc); + }; + if(instanceof(op, PointObject)) { + GetObjectBounds(op); + } + + } + op = GetNextHierarchyObject(op, NULL); + + } + + // End the Undo Step, and undo the MakeEditables + doc->EndUndo(); + //doc->DoUndo(); + +} + //// Execute /////////////////////////////////////////////////////////// // The main event...run the plugin on the document. @@ -61,7 +180,9 @@ } */ - + println("Here"); + GetSceneBounds(doc); + println("there"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |