CgeoModelGenerator

class cee.geo.CgeoModelGenerator()

Helper class for creating a Model from a .cgeo blob.

The .cgeo blob is typically received from a web service or a local file.

Usage:

let geoModel = new cee.geo.GeometryModel();
let modelGenerator = new cee.geo.CgeoModelGenerator(buffer, geoModel);
modelGenerator.buildModel();

** CGEO format documentation **

Int     Magic Number (2072003)
Int     TextureCount
Int     PartCount

Textures (TextureCount number of this block):
     Int Index : Zero based index
     Int Width : Width of texture in pixels (see note below about dimensions)
     Int Height : Height of texture in pixels (see note below about dimensions)
     Int WrapMode : 1: Clamp To Edge, 2: Repeat
     Int MinFilter : 1: Nearest, 2: Linear, 3: Nearest Mipmap Nearest,
                     4: Nearest Mipmap Linear, 5: Linear Mipmap Nearest,
                     6: Linear Mipmap Linear
     Int MagFilter : 1: Nearest, 2: Linear
     ubyte\*Width\*Height  pixelData : First pixel is lower left corner

Parts (PartCount number of this block):
     Int     PartId
     Int     Color (r,g,b,a)
     Int     NumVertices
     Int     HasNormals (1=true, 0=false)
     Int     TextureIndex (-1 for none)
     Int     NumPrimitives
     Int     VerticesPerPrimitive

     Vertices:
       3*float     vertex x,y,z

     Normals:
       3*float     vertex nx,ny,nz

     TextureCoordinates:
       2*float     vertex s,t

     Indices:
       <NumPrimitives*VerticesPerPrimitive>

Notes:

Texture dimensions: Generally we recommend using textures where the dimensions (height and width) are a power of two (2,4,8,16, etc). Non-POT2 texture are partially supported in WebGL, but requires the sampler to be configured without MipMaps and with wrap mode set to ClampToEdge.

Color is r,g,b,a packet into one integer. Example with float colors (0..1 per component):

int intOpacity = (int)(opacity*255.0f); int intColor = (int)(color.r()*255.0f)<<24 | (int)(color.g()*255.0f)<<16 | (int)(color.b()*255.0f)<<8 | intOpacity;

Constructors

Methods


Constructors

CgeoModelGenerator.constructor(cgeoBuffer, geoModel)
Arguments:
  • cgeoBuffer (ArrayBuffer) – None

  • geoModel (GeometryModel) – None

Creates a new CgeoModelGenerator with the given input Cgeo array and output geometry model

Return type:

CgeoModelGenerator

Methods

buildModel

CgeoModelGenerator.buildModel(preserveSharpEdges)
Arguments:
  • preserveSharpEdges (boolean) – None

Adds parts to the input GeometryModel based on the content of the Cgeo array

Return type:

void