Static methods

@:value({ normalize : false })staticcomputeTangents(vertices:Array<Float>, uvtData:Array<Float>, normals:Array<Float>, indices:Array<Int>, normalize:Bool = false):Array<Float>

Calculates tangents for a set of mesh data.

Tangents are used along normals for accurate lighting effects using normal maps.

Note: The output returns a 4-component array. This is XYZ = Tangent and W = Binormal handedness.

This method is based on a simplified version of the MikkTSpace algorithm from This StackOverflow Answer

Constructor

Variables

@:value([null, null, null, null, null, null, null])buffers:Array<FoxVertexBuffer> = [null, null, null, null, null, null, null]

An array containing vertex buffers for this mesh.

Access them via buffers[FoxVertexBufferType.<type>]

These buffers represent Level of Detail 0

lods:Array<Array<FoxVertexBuffer>>

An array containing levels of detail for this mesh

Note: LODs are yet to be implemented

@:value(0x88E4)bufferUsage:Int = 0x88E4

The buffer usage pattern for optimization purposes. Set it to true if you're updating mesh buffers constantly

Note: This will be applied on the next call to setArrays().

@:value(null)material:FoxMaterial = null

@:value(null)assetsKey:String = null

@:value(null)bounds:BoundingBox = null

@:value(null)context:Context3D = null

@:value(false)__isCopy:Bool = false

read onlyloaded:Bool

Mesh is considered loaded when the vertex array is atleast loaded

Methods

privateget_loaded():Bool

setBuffer(type:FoxVertexBufferType, data:Array<Float>):Void

Writes buffer data on the GPU

Parameters:

type

The buffer to write to

data

The data array

setBufferRaw(type:FoxVertexBufferType, data:ArrayBufferView):Void

Writes buffer data on the GPU using an existing ArrayBufferView. This method runs faster than setBuffer

setIndexBuffer(data:Array<Int>):Void

Same as setBuffer() but exclusive to the Index buffer

Note: This uses a UInt16Array internally, if your model has meshes with over 65k unique vertices, consider using setIndexBufferBig() instead

setIndexBufferBig(data:Array<Int>):Void

setIndexBufferRaw(data:ArrayBufferView):Void

@:value({ offset : 0 })updateBuffer(type:FoxVertexBufferType, data:Array<Float>, offset:Int = 0):Void

Updates buffer data on the GPU

Use this to set portions of it or are updating data constantly. Tip: Make sure the buffer is set to GL.DYNAMIC_DRAW on its usage.

Parameters:

type

The buffer to update

data

The data array

offset

The index of the buffer where to start writing data

@:value({ offset : 0 })updateIndexBuffer(data:Array<Int>, offset:Int = 0):Void

Same as updateBuffer() but exclusive to the Index buffer

@:value({ byteOffset : 0 })inlineupdateBufferRaw(type:FoxVertexBufferType, data:ArrayBufferView, byteOffset:Int = 0):Void

Same as updateBuffer() and updateIndexBuffer(), but there's no data copying to a typed array, instead, you provide it.

This method is faster than the other ones, but needs more setup.

@:value({ bigInfluence : false, bigIndices : false })setArrays(?vertices:Array<Float>, ?uvtData:Array<Float>, ?indices:Array<Int>, ?material_:FoxMaterial, ?normals:Array<Float>, ?colors:Array<Float>, ?weights:Array<Float>, ?influences:Array<Int>, bigIndices:Bool = false, bigInfluence:Bool = false):Void

Creates buffers and uploads data to the GPU.

Parameters:

vertices

Positions (xyz)

uvtData

Texture coordinates (u,v)

indices

Vertex index (i)

material_

The material for this mesh

normals

Vertex normals (x,y,z)

colors

Vertex colors (r,g,b,a)

weights

Skin weights (w1,w2,w3,w4)

influences

Joints (j1, j2, j3, j4)

bigIndices

Use ~4.3 billion vertex pointers per index instead of 65536 (UInt32 instead of UInt16)

bigInfluence

Use 65536 influence pointers per joint instead of 256 (UInt16 instead of UInt8)

getBufferByType(type:FoxVertexBufferType):FoxVertexBuffer

Deprecated:

Returns a vertex buffer of this mesh.

Parameters:

type

The buffer type. See FoxVertexBufferType

inlinegetLod(lod:Int):Array<FoxVertexBuffer>

calculateBounds(vertices:Dynamic):BoundingBox

copy():FoxMesh

Copies this mesh object, does not create new data on GPU. Use this to use different materials or mix different buffers.

Warning! destroying this copy won't free memory on the GPU unless the original is destroyed!

destroy():Void