public UWB_BoundingBox GetBounds(ref UWB_DrawHelper helper, bool bDraw) { UWB_BoundingBox box = new UWB_BoundingBox(); box.makeInvalid(); if (mPrimitive != null) { box.add(mPrimitive.getBoundingVolume(eLevelofDetail.lodLow)); } helper.pushModelTransform(); { mXFormInfo.setupModelStack(helper); //Draw the box for debugging if (bDraw) { box.Draw(ref helper); } Vector3 minPt = box.getMin(); Vector3 maxPt = box.getMax(); Vector3 pt1 = new Vector3(minPt.X, minPt.Y, minPt.Z); Vector3 pt2 = new Vector3(maxPt.X, minPt.Y, minPt.Z); Vector3 pt3 = new Vector3(maxPt.X, maxPt.Y, minPt.Z); Vector3 pt4 = new Vector3(minPt.X, maxPt.Y, minPt.Z); Vector3 pt5 = new Vector3(minPt.X, minPt.Y, maxPt.Z); Vector3 pt6 = new Vector3(maxPt.X, minPt.Y, maxPt.Z); Vector3 pt7 = new Vector3(maxPt.X, maxPt.Y, maxPt.Z); Vector3 pt8 = new Vector3(minPt.X, maxPt.Y, maxPt.Z); helper.transformPoint(ref pt1); helper.transformPoint(ref pt2); helper.transformPoint(ref pt3); helper.transformPoint(ref pt4); helper.transformPoint(ref pt5); helper.transformPoint(ref pt6); helper.transformPoint(ref pt7); helper.transformPoint(ref pt8); box.makeInvalid(); box.add(new UWB_BoundingBox(pt1, pt2)); box.add(new UWB_BoundingBox(pt3, pt4)); box.add(new UWB_BoundingBox(pt5, pt6)); box.add(new UWB_BoundingBox(pt7, pt8)); int count = mChildNodes.count(); for (int i = 0; i < count; i++) { box.add(mChildNodes.getItem(i).GetBounds(ref helper, bDraw)); } } helper.popModelTransform(); return(box); }
protected bool GetNodeBoundsHelper(ref UWB_SceneNode pSearchNode, ref UWB_BoundingBox box, ref UWB_DrawHelper helper, int level, bool bDraw) { bool found = false; if (Object.ReferenceEquals(this, pSearchNode)) { box = this.GetBounds(ref helper, bDraw); found = true; } else { helper.pushModelTransform(); { level++; this.getXFormInfo().setupModelStack(helper); int count = this.numChildren(); for (int i = 0; i < count; i++) { UWB_SceneNode pChildNode = this.getChildNode(i); if (pChildNode.GetNodeBoundsHelper(ref pSearchNode, ref box, ref helper, level, bDraw)) { found = true; break; } } level--; } helper.popModelTransform(); } if (0 == level && found && bDraw) { helper.resetAttributes(); helper.setColor1(new Color(0, 0, 255)); helper.setShadeMode(eShadeMode.smFlat); helper.setFillMode(eFillMode.fmWireframe); box.Draw(ref helper); } return(found); }
public UWB_BoundingBox GetBounds(ref UWB_DrawHelper helper, bool bDraw) { UWB_BoundingBox box = new UWB_BoundingBox(); box.makeInvalid(); if (mPrimitive != null) box.add(mPrimitive.getBoundingVolume(eLevelofDetail.lodLow)); helper.pushModelTransform(); { mXFormInfo.setupModelStack(helper); //Draw the box for debugging if (bDraw) box.Draw(ref helper); Vector3 minPt = box.getMin(); Vector3 maxPt = box.getMax(); Vector3 pt1 = new Vector3(minPt.X, minPt.Y, minPt.Z); Vector3 pt2 = new Vector3(maxPt.X, minPt.Y, minPt.Z); Vector3 pt3 = new Vector3(maxPt.X, maxPt.Y, minPt.Z); Vector3 pt4 = new Vector3(minPt.X, maxPt.Y, minPt.Z); Vector3 pt5 = new Vector3(minPt.X, minPt.Y, maxPt.Z); Vector3 pt6 = new Vector3(maxPt.X, minPt.Y, maxPt.Z); Vector3 pt7 = new Vector3(maxPt.X, maxPt.Y, maxPt.Z); Vector3 pt8 = new Vector3(minPt.X, maxPt.Y, maxPt.Z); helper.transformPoint(ref pt1); helper.transformPoint(ref pt2); helper.transformPoint(ref pt3); helper.transformPoint(ref pt4); helper.transformPoint(ref pt5); helper.transformPoint(ref pt6); helper.transformPoint(ref pt7); helper.transformPoint(ref pt8); box.makeInvalid(); box.add(new UWB_BoundingBox(pt1, pt2)); box.add(new UWB_BoundingBox(pt3, pt4)); box.add(new UWB_BoundingBox(pt5, pt6)); box.add(new UWB_BoundingBox(pt7, pt8)); int count = mChildNodes.count(); for (int i = 0; i < count; i++) box.add(mChildNodes.getItem(i).GetBounds(ref helper, bDraw)); } helper.popModelTransform(); return box; }
protected bool GetNodeBoundsHelper(ref UWB_SceneNode pSearchNode, ref UWB_BoundingBox box, ref UWB_DrawHelper helper, int level, bool bDraw) { bool found = false; if( Object.ReferenceEquals(this, pSearchNode)) { box = this.GetBounds( ref helper, bDraw ); found = true; } else { helper.pushModelTransform(); { level++; this.getXFormInfo().setupModelStack(helper); int count = this.numChildren(); for(int i=0; i<count; i++) { UWB_SceneNode pChildNode = this.getChildNode( i ); if( pChildNode.GetNodeBoundsHelper( ref pSearchNode, ref box, ref helper, level, bDraw ) ) { found = true; break; } } level--; } helper.popModelTransform(); } if (0 == level && found && bDraw) { helper.resetAttributes(); helper.setColor1(new Color(0,0,255)); helper.setShadeMode(eShadeMode.smFlat); helper.setFillMode(eFillMode.fmWireframe); box.Draw(ref helper); } return found; }