BGE/Model3dOps
Alias: BGE.Model3dOps
Static Methods
applyTexture(
model: BGE.Model3d,
bitmap: roBitmap,
cacheId: string,
): void
Points every textured face of a model at one texture - see applyTextureToFaces().
Parameters
model(BGE.Model3d)bitmap(roBitmap)cacheId(string) — a stable, unique-per-texture id (the resolved texture path works well) used as the triangle-cache key for every draw of this texture
Returns
void
groupFacesByTexture(
model: BGE.Model3d,
overridePath?: string,
): roAssociativeArray
Groups the faces that have UV points by the texture each should be drawn with: overridePath for all of them if it isn't "", otherwise its material's texture, and for a face with no material the model's own texturePath. Faces that get no texture aren't included.
Parameters
model(BGE.Model3d)overridePath(string, optional, default: "\"\"") — a texture for every textured face (Model3dLoadOptions.texturePath)
Returns
roAssociativeArray— texture path -> the faces (Model3dFace[]) that use it
getMaterialTexturePath(
model: BGE.Model3d,
face: BGE.Model3dFace,
): string
The texture a face's material gives it, or the model's own texturePath for a face with no material.
Parameters
model(BGE.Model3d)face(BGE.Model3dFace)
Returns
string— the path, or "" for none
applyTextureToFaces(
faces: Array.<BGE.Model3dFace>,
bitmap: roBitmap,
cacheId: string,
): void
Points each of these faces at one texture, converting their normalized UV points to pixel space (flipping v, since .obj UVs are bottom-up and bitmaps are top-down). A face whose UVs reach past 0..1 repeats the texture, the .obj default: it's given a copy of the texture tiled as many times as its UVs span (one per size, shared by every face that spans the same number of repeats). Faces with no Texture are left alone.
Parameters
faces(Array.<BGE.Model3dFace>)bitmap(roBitmap)cacheId(string) — a stable, unique-per-texture id (the resolved texture path works well) used as the triangle-cache key for every draw of this texture
Returns
void
getUVTileRange(
uvPoints: Array.<BGE.Math.Vector>,
): BGE.UVTileRange
The whole texture repeats a UV range covers, e.g. {minU: -1, maxU: 2, minV: 0, maxV: 1} for u from -0.5 to 1.5 - 0..1 for UVs within a single copy of the texture. A UV within 0.001 of a whole number counts as that number.
Parameters
uvPoints(Array.<BGE.Math.Vector>) — normalized UV points
Returns
getTiledTextureMaxSize(): integer
The largest a tiled model texture may be on each side on this device: an HD or SD Roku has only 64MB of texture memory.
Returns
integer
createTiledTexture(
bitmap: roBitmap,
tilesX: integer,
tilesY: integer,
maxSize: integer,
cacheId: string,
): BGE.ModelFaceTexture
Draws a texture repeated tilesX x tilesY times into a new bitmap, shrinking each copy if needed to keep the bitmap within maxSize on each side.
Parameters
bitmap(roBitmap) — the texturetilesX(integer)tilesY(integer)maxSize(integer)cacheId(string)
Returns
BGE.ModelFaceTexture— invalid if a bitmap couldn't be allocated
finishTextures(model: BGE.Model3d): void
Call once a model's textures are applied: any face still waiting for a texture (none was given, or it failed to load) falls back to a flat fill, and an untextured face with a material takes that material's color (Kd).
Parameters
model(BGE.Model3d)
Returns
void