.. role:: ts-api-decorator

##################
CgeoModelGenerator
##################

.. js:module:: cee.geo
   :noindex:

.. container:: ts-api-section

   .. js:class:: 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:

      .. code-block:: javascript

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



      ** CGEO format documentation **


      .. code-block::

 
         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;



.. container:: api-index-section

   .. rubric:: Constructors

   .. rst-class:: api-index-list-item api-kind-constructor api-parent-kind-class

   * :js:meth:`~cee.geo.CgeoModelGenerator.constructor`



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~cee.geo.CgeoModelGenerator.buildModel`





------------

Constructors
============

.. container:: ts-api-section

   .. js:function:: CgeoModelGenerator.constructor( cgeoBuffer, geoModel)

      :param cgeoBuffer: None
      :type cgeoBuffer: ArrayBuffer
      :param geoModel: None
      :type geoModel: GeometryModel


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


      :rtype: CgeoModelGenerator



Methods
=======

.. rst-class:: ts-api-section

buildModel
----------

.. js:method:: CgeoModelGenerator.buildModel( preserveSharpEdges)

   :param preserveSharpEdges: None
   :type preserveSharpEdges: boolean


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


   :rtype: void

