[PXCDD-commit] SF.net SVN: pxcdd: [405] trunk/client/c4d/pxcdd-turntable.cof
Status: Alpha
Brought to you by:
tangentsoft
From: <ric...@us...> - 2006-07-20 04:13:24
|
Revision: 405 Author: ricknroll Date: 2006-07-19 21:13:11 -0700 (Wed, 19 Jul 2006) ViewCVS: http://svn.sourceforge.net/pxcdd/?rev=405&view=rev Log Message: ----------- Now properly getting scene and object extents - I think Modified Paths: -------------- trunk/client/c4d/pxcdd-turntable.cof Modified: trunk/client/c4d/pxcdd-turntable.cof =================================================================== --- trunk/client/c4d/pxcdd-turntable.cof 2006-07-20 04:04:23 UTC (rev 404) +++ trunk/client/c4d/pxcdd-turntable.cof 2006-07-20 04:13:11 UTC (rev 405) @@ -70,17 +70,20 @@ PXCDDTurntablePlugin::GetObjectBounds(op) { - var vec_min = vector(0,0,0); - var vec_max = vector(0,0,0); + var vec_min; + var vec_max; var vec_pnt; var arr = op->GetPoints(); if(instanceof(op, PointObject)) { + + vec_pnt = op->GetMg()->GetV0() + op->GetPoint(0); + vec_min = vec_pnt; + vec_max = vec_pnt; var p; for(p = 0; p < op->GetPointCount(); p++) { - println(arr[p]); - vec_pnt = op->GetPoint(p); + vec_pnt = op->GetMg()->GetV0() + 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; @@ -92,9 +95,22 @@ } var vec_ctr = (vec_min + vec_max) / 2; - var vec_siz = abs(vec_min) + abs(vec_max); + var vec_siz = vec_max - vec_min; - println(op->GetName(), "::", vec_min, "//", vec_max, "//", vec_ctr, "//", vec_siz); + var mtx = new(Matrix); + mtx->SetV0(vec_ctr); + mtx->SetV1(vec_siz); + mtx->SetV2(vec_min); + mtx->SetV3(vec_max); + + println("OBJECT BOUNDS [", op->GetName(), "] :: "); + println("-- Center (V0): ", vec_ctr); + println("-- Size (V1): ", vec_siz); + println("-- Minimum (V2): ", vec_min); + println("-- Maximum (V2): ", vec_max); + + return mtx; + } //// GetSceneBounds /////////////////////////////////////////////////// @@ -105,13 +121,20 @@ PXCDDTurntablePlugin::GetSceneBounds(doc) { + var mtx_objBound; + var vec_min; + var vec_max; + var vec_obj_min; + var vec_obj_max; + // Start Undo Step so we can undo all the MakeEditables doc->StartUndo(); var op = doc->GetFirstObject(); while(op) { - println(op->GetName()); - println(getclass(op)); + + mtx_objBound = NULL; + switch( getclass(op) ) { case LightObject: @@ -127,28 +150,64 @@ case PointObject: case PolygonObject: // Get the Object Extents - println("Point"); - GetObjectBounds(op); + mtx_objBound = GetObjectBounds(op); break; default: // Make the object editable + println("Making ", op->GetName(), " editable"); if(MakeEditable(doc, op)) { + if(op) println("Now referencing ", op->GetName()); op = GetActiveObject(doc); + if(op) println("Got Reference ", op->GetName()); }; + if(instanceof(op, PointObject)) { - GetObjectBounds(op); - } - + mtx_objBound = GetObjectBounds(op); + } } + if(op) println("has Reference ", op->GetName()); + + if(mtx_objBound) { + + if(!vec_min) vec_min = mtx_objBound->GetV2(); + if(!vec_max) vec_max = mtx_objBound->GetV3(); + vec_obj_min = mtx_objBound->GetV2(); + vec_obj_max = mtx_objBound->GetV3(); + + if(vec_obj_min.x < vec_min.x) vec_min.x = vec_obj_min.x; + if(vec_obj_min.y < vec_min.y) vec_min.y = vec_obj_min.y; + if(vec_obj_min.z < vec_min.z) vec_min.z = vec_obj_min.z; + if(vec_obj_max.x > vec_max.x) vec_max.x = vec_obj_max.x; + if(vec_obj_max.y > vec_max.y) vec_max.y = vec_obj_max.y; + if(vec_obj_max.z > vec_max.z) vec_max.z = vec_obj_max.z; + + } + op = GetNextHierarchyObject(op, NULL); } // End the Undo Step, and undo the MakeEditables doc->EndUndo(); - //doc->DoUndo(); + doc->DoUndo(); + + var vec_ctr = (vec_min + vec_max) / 2; + var vec_siz = vec_max - vec_min; + println("SCENE BOUNDS :: "); + println("-- Center (V0): ", vec_ctr); + println("-- Size (V1): ", vec_siz); + println("-- Minimum (V2): ", vec_min); + println("-- Maximum (V2): ", vec_max); + + var mtx = new(Matrix); + mtx->SetV0(vec_ctr); + mtx->SetV1(vec_siz); + mtx->SetV2(vec_min); + mtx->SetV3(vec_max); + + return mtx; } //// Execute /////////////////////////////////////////////////////////// @@ -180,9 +239,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. |