public void CancelDraw() { if (primitive != null) { primitive.Destroy(); primitive = null; } }
public void EndDraw() { // store undo/redo record for new primitive PrimitiveSO primSO = primitive.BuildSO(scene, scene.DefaultSOMaterial); scene.History.PushChange( new AddSOChange() { scene = scene, so = primSO, bKeepWorldPosition = false }); scene.History.PushInteractionCheckpoint(); primitive.Destroy(); primitive = null; }
void CreateNewPrimitive() { SOType activePrimType = scene.DefaultPrimitiveType; if (activePrimType == SOTypes.Sphere) { eActiveType = SupportedTypes.Sphere; } else if (activePrimType == SOTypes.Box) { eActiveType = SupportedTypes.Box; } else { eActiveType = SupportedTypes.Cylinder; } float fScale = scene.GetSceneScale(); if (eActiveType == SupportedTypes.Cylinder) { primitive = new MeshPrimitivePreview(); primitive.Type = MeshPrimitivePreview.PrimType.Cylinder; primitive.Center = CenterModes.Base; primitive.Create(scene.NewSOMaterial, scene.RootGameObject, MinDimension * fScale); } else if (eActiveType == SupportedTypes.Sphere) { primitive = new MeshPrimitivePreview(); primitive.Type = MeshPrimitivePreview.PrimType.Sphere; primitive.Center = CenterModes.Origin; primitive.Create(scene.NewSOMaterial, scene.RootGameObject, MinDimension * fScale); } else if (eActiveType == SupportedTypes.Box) { primitive = new MeshPrimitivePreview(); primitive.Type = MeshPrimitivePreview.PrimType.Box; primitive.Center = CenterModes.Corner; primitive.Create(scene.NewSOMaterial, scene.RootGameObject, MinDimension * fScale); } else { throw new NotImplementedException("SnapDrawPrimitivesTool.Create: unsupported type"); } }