public static void CreateBoxes() { msgScene scene = msgScene.GetScene(); scene.Clear(); Utils.AddFloorInScene(7.0, 7.0, 1.0, 1.0, -0.3); msgBox bx1 = msgBox.Create(1, 2, 2.1); scene.AttachObject(bx1); bx1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 8); msgBox bx2 = msgBox.Create(1, 1, 1); msgVectorStruct transV = new msgVectorStruct(); transV.x = 1.5; transV.y = 0.0; transV.z = 0.0; bx2.InitTempMatrix().Translate(transV); bx2.ApplyTempMatrix(); bx2.DestroyTempMatrix(); bx2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 0); bx2.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_THICKNESS, 1); bx2.SetAttribute(msgObjectAttrEnum.SG_OA_LINE_TYPE, 1); scene.AttachObject(bx2); }
public static void CreateIntersection() { msgScene scene = msgScene.GetScene(); scene.Clear(); msgTorus tor1 = msgTorus.Create(2, 1, 24, 24); msgTorus tor2 = msgTorus.Create(2, 0.3, 24, 24); msgVectorStruct transV1 = new msgVectorStruct(1, 1, 0); tor2.InitTempMatrix().Translate(transV1); tor2.ApplyTempMatrix(); tor2.DestroyTempMatrix(); scene.AttachObject(tor1); tor1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 5); scene.AttachObject(tor2); tor2.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 45); msgVectorStruct transV2 = new msgVectorStruct(0, 0, 1.5); msgGroup bool1 = msgBoolean.Intersection(tor1, tor2); int ChCnt = bool1.GetChildrenList().GetCount(); msgObject[] allChilds = null; bool1.BreakGroup(ref allChilds); msgObject.DeleteObject(bool1); for (ushort i = 0; i < ChCnt; i++) { allChilds[i].InitTempMatrix().Translate(transV2); allChilds[i].ApplyTempMatrix(); allChilds[i].DestroyTempMatrix(); scene.AttachObject(allChilds[i]); allChilds[i].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, (ushort)(10 + i)); } msgBox bx1 = msgBox.Create(2, 2, 1); msgSphere sp1 = msgSphere.Create(1, 24, 24); msgVectorStruct transV4 = new msgVectorStruct(3, 3, 0); bx1.InitTempMatrix().Translate(transV4); bx1.ApplyTempMatrix(); bx1.DestroyTempMatrix(); scene.AttachObject(bx1); bx1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 55); msgVectorStruct transV5 = new msgVectorStruct(3, 4, 0); sp1.InitTempMatrix().Translate(transV5); sp1.ApplyTempMatrix(); sp1.DestroyTempMatrix(); scene.AttachObject(sp1); sp1.SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, 75); msgGroup bool2 = msgBoolean.Intersection(sp1, bx1); ChCnt = bool2.GetChildrenList().GetCount(); bool2.BreakGroup(ref allChilds); msgObject.DeleteObject(bool2); for (ushort i = 0; i < ChCnt; i++) { allChilds[i].InitTempMatrix().Translate(transV2); allChilds[i].ApplyTempMatrix(); allChilds[i].DestroyTempMatrix(); scene.AttachObject(allChilds[i]); allChilds[i].SetAttribute(msgObjectAttrEnum.SG_OA_COLOR, (ushort)(10 + i)); } }