public static void CreatePrimitiveMesh(Content.Geometry geometry, PrimitiveInitInfo info) { Debug.Assert(geometry != null); using var sceneData = new SceneData(); try { CreatePrimitiveMesh(sceneData, info); Debug.Assert(sceneData.Data != IntPtr.Zero && sceneData.DataSize > 0); var data = new byte[sceneData.DataSize]; Marshal.Copy(sceneData.Data, data, 0, sceneData.DataSize); geometry.FromRawData(data); } catch (Exception ex) { Logger.Log(MessageType.Error, $"failed to create {info.Type} primitive mesh."); Debug.WriteLine(ex.Message); } }
private void UpdatePrimitive() { if (!IsInitialized) { return; } var primitiveType = (PrimitiveMeshType)primTypeComboBox.SelectedItem; var info = new PrimitiveInitInfo() { Type = primitiveType }; switch (primitiveType) { case PrimitiveMeshType.Plane: { info.SegmentX = (int)xSliderPlane.Value; info.SegmentZ = (int)zSliderPlane.Value; info.Size.X = Value(WidthScalarBoxPlane, 0.001f); info.Size.Z = Value(LengthScalarBoxPlane, 0.001f); } break; case PrimitiveMeshType.Cube: break; case PrimitiveMeshType.UvSphere: break; case PrimitiveMeshType.IcoSphere: break; case PrimitiveMeshType.Cylinder: break; case PrimitiveMeshType.Capsule: break; } var geometry = new Geometry(); ContentToolsAPI.CreatePrimitiveMesh(geometry, info); }
private static extern void CreatePrimitiveMesh([In, Out] SceneData data, PrimitiveInitInfo info);