예제 #1
0
        /// <summary>
        /// Initializes new wrapper object for native mesh.
        /// </summary>
        /// <param name="obj">Static object that hosts the mesh.</param>
        public NativeMesh(StaticObject obj)
        {
            if (obj.Disposed)
            {
                throw new ObjectDisposedException("Cannot acquire mesh data from static" +
                                                  " object that has been disposed of.");
            }
            MeshHandles handles = StaticObjectInterop.GetMeshHandles(obj.Handle);

            if (handles.IndexedMeshHandle == IntPtr.Zero || handles.MeshHandle == IntPtr.Zero)
            {
                throw new Exception("Unable to acquire mesh handles for the static object.");
            }
            this.CMeshHandle       = handles.MeshHandle;
            this.IndexedMeshHandle = handles.IndexedMeshHandle;
            this.StaticObject      = obj;

            this.colors0   = new NativeVertexColor0Collection(this);
            this.colors1   = new NativeVertexColor1Collection(this);
            this.faces     = new NativeFaceCollection(this.CMeshHandle);
            this.indices   = new NativeIndicesCollection(this);
            this.positions = new NativeVertexPositionCollection(this);
            this.normals   = new NativeVertexNormalCollection(this);
            this.tangents  = new NativeVertexTangentCollection(this);
            this.qTangents = new NativeVertexQTangentCollection(this);
            this.texCoords = new NativeVertexTextureCoordinatesCollection(this);
        }
예제 #2
0
 /// <summary>
 /// Performs disposal of this instance.
 /// </summary>
 /// <param name="disposeManagedResources">
 /// Indicates whether all resources allocated in managed environment must be freed.
 /// </param>
 protected void Dispose(bool disposeManagedResources)
 {
     if (this.Disposed)
     {
         return;
     }
     StaticObjectInterop.ReleaseStaticObject(this.Handle);
     this.Disposed = true;
 }
예제 #3
0
 /// <summary>
 /// Creates a new empty static object.
 /// </summary>
 /// <remarks>
 /// This constructor invokes I3DEngine-&gt;CreateStatObj() method that initializes empty
 /// instance of IStatObj, that does not contain any mesh data.
 ///
 /// This means that you should use this constructor when you need to create a mesh object
 /// from scratch.
 ///
 /// Failure to create new object will mark this wrapper as disposed.
 /// </remarks>
 public StaticObject()
 {
     this.Handle   = StaticObjectInterop.CreateStaticObject();
     this.Disposed = this.Handle == IntPtr.Zero;
 }