GetCentroid
Syntax
public const string EngineDLL = @"engine.dll";[DllImport(EngineDLL, EntryPoint = "GetCentroid")] public static extern double GetCentroid(Int64 owlInstance, ref float vertices, ref Int32 indices, out double centroid); [DllImport(EngineDLL, EntryPoint = "GetCentroid")] public static extern double GetCentroid(Int64 owlInstance, ref float vertices, ref Int64 indices, out double centroid); [DllImport(EngineDLL, EntryPoint = "GetCentroid")] public static extern double GetCentroid(Int64 owlInstance, ref double vertices, ref Int32 indices, out double centroid); [DllImport(EngineDLL, EntryPoint = "GetCentroid")] public static extern double GetCentroid(Int64 owlInstance, ref double vertices, ref Int64 indices, out double centroid); [DllImport(EngineDLL, EntryPoint = "GetCentroid")] public static extern double GetCentroid(Int64 owlInstance, IntPtr vertices, IntPtr indices, out double centroid);
Property owlInstance
Size: 64 bit / 8 byte (value)Property vertices
Size: 64 bit / 8 byte (reference)Property indices
Size: 64 bit / 8 byte (reference)Property centroid
Size: 64 bit / 8 byte (reference)
Example
Here you can find code snippits that show how the API call GetCentroid can be used.
using Engine; ... static void Main(string[] args) { Int64 model = Engine.x86_64.CreateModel(); if (model != 0) { // // Classes // Int64 classBox = Engine.x86_64.GetClassByName(model, "Box"); // // Datatype Properties (attributes) // Int64 propertyLength = Engine.x86_64.GetPropertyByName(model, "length"), propertyWidth = Engine.x86_64.GetPropertyByName(model, "width"), propertyHeight = Engine.x86_64.GetPropertyByName(model, "height"); // // Instances (creating) // Int64 instanceBox = Engine.x86_64.CreateInstance(classBox, (string) null); double length = 2.8, width = 1.3, height = 1.4; Engine.x86_64.SetDatatypeProperty(instanceBox, propertyLength, ref length, 1); Engine.x86_64.SetDatatypeProperty(instanceBox, propertyWidth, ref width, 1); Engine.x86_64.SetDatatypeProperty(instanceBox, propertyHeight, ref height, 1); // // Simple use of the derived information functions // double[] centroid = new double[3]; double volume = Engine.x86_64.GetCentroid(instanceBox, (IntPtr) 0, (IntPtr) 0, out centroid[0]); Int64 vertexBufferSize = 0, indexBufferSize = 0; Engine.x86_64.CalculateInstance(instanceBox, out vertexBufferSize, out indexBufferSize, (IntPtr) 0); if (vertexBufferSize != 0 && indexBufferSize != 0) { float[] vertexBuffer = new float[6 * vertexBufferSize]; Engine.x86_64.UpdateInstanceVertexBuffer(instanceBox, ref vertexBuffer[0]); Int32[] indexBuffer = new Int32[indexBufferSize]; Engine.x86_64.UpdateInstanceIndexBuffer(instanceBox, ref indexBuffer[0]); // // Reuse knowledge to improve performance (in case of single precision, with less accuracy) // volume = Engine.x86_64.GetCentroid(instanceBox, ref vertexBuffer[0], ref indexBuffer[0], out centroid[0]); } // // The resulting model can be viewed in 3D-Editor.exe // Engine.x86_64.SaveModel(model, "c:\\created\\myFile.bin"); Engine.x86_64.CloseModel(model); } }