ArcGIS Procedural Runtime  3.2.10650
List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Member Functions
prtx::EncodePreparator Class Referenceabstract

#include <EncodePreparator.h>

Classes

class  FinalizedInstance
 
struct  FinalizedInstanceBase
 
class  PreparationFlags
 

Public Types

typedef std::vector< FinalizedInstanceInstanceVector
 
enum  MeshProperties {
  ALL_MESH_FACES_CONVEX = 1 << 0,
  ALL_MESH_FACES_PLANAR = 1 << 1
}
 

Public Member Functions

virtual void add (prt::Cache *cache, const ShapePtr &shape, const prt::AttributeMap *initialShapeAttributes, const ReportsPtr &reports=ReportsPtr())=0
 
virtual void add (prt::Cache *cache, const prtx::InitialShape &initialShape, size_t initialShapeIndex)=0
 
virtual void clear ()=0
 
virtual void fetchFinalizedInstances (InstanceVector &instances, const PreparationFlags &flags, prt::SimpleOutputCallbacks *cbForLogStats=nullptr)=0
 
virtual void getBoundingBox (prtx::BoundingBox &bbox)=0
 
virtual uint64_t getUsedMem (bool considerInstanceCounts=false) const =0
 

Static Public Member Functions

static EncodePreparatorPtr create (bool enforceTextureConsistency, NamePreparator &namePreparator, const NamePreparator::NamespacePtr &nsMeshes, const NamePreparator::NamespacePtr &nsMaterials, const MaterialTransformer *materialTransformer=0)
 
static uint32_t getInitialShapePseudoShapeId (size_t initialShapeIndex)
 

Static Public Attributes

static const prtx::DoubleVector IDENTITY
 

Protected Member Functions

 EncodePreparator (const EncodePreparator &)=delete
 
EncodePreparatoroperator= (const EncodePreparator &)=delete
 

Static Protected Member Functions

static FinalizedInstanceBasegetBase (FinalizedInstance &instance)
 

Detailed Description

The EncodePreparator is the most important tool for encoder authors. It implements common geometry encoding tasks. Its main purpose is to gather prtx::Shape objects from the generated shape tree and create exportable groups of prtx::Geometry objects with associated prtx::Mesh, prtx::Material and prtx::Texture objects. It identifies identical geometry, material and texture instances and allows for their efficient sharing (e.g. to implement instancing).

The preparation process is triggered by calling fetchFinalizedInstances and can be controlled by setting the appropriate PreparationFlags.

A simple usage example looks like this:

#include "prtx/EncodePreparator.h"
prtx::DefaultNamePreparator namePrep;
// create two namespaces for mesh and material names
prtx::NamePreparator::NamespacePtr nsMesh = namePrep.newNamespace();
prtx::NamePreparator::NamespacePtr nsMaterial = namePrep.newNamespace();
// create the preparator
prtx::EncodePreparatorPtr encPrep = prtx::EncodePreparator::create(true, namePrep, nsMesh, nsMaterial);
// add any number of shapes
encPrep->add(...);
// ...
// setup some simple preparation flags
flags.instancing(false).mergeByMaterial(true).triangulate(true);
// trigger the preparation of the shapes added so far
prtx::EncodePreparator::InstanceVector instances;
encPrep->fetchFinalizedInstances(instances, flags);
// the instances are now ready for the actual encoding...

Member Enumeration Documentation

◆ MeshProperties

Mesh property type.

See also
FinalizedInstance::allMeshFacesConvex()
FinalizedInstance::allMeshFacesPlanar()
Enumerator
ALL_MESH_FACES_CONVEX 

All faces of mesh are convex.

ALL_MESH_FACES_PLANAR 

All faces of mesh are planar.

Member Function Documentation

◆ add() [1/2]

virtual void prtx::EncodePreparator::add ( prt::Cache cache,
const ShapePtr shape,
const prt::AttributeMap initialShapeAttributes,
const ReportsPtr &  reports = ReportsPtr() 
)
pure virtual

Adds a shape to the preparator.

Parameters
cacheA valid cache. It is used to determine if the shape geometry is re-used (instanced).
shapeThe shape to add. Typically a shape created by a ShapeIterator subclass.
initialShapeAttributesThe attributes of the corresponding initial shape.
reportsOptional reports to process for this shape.
See also
Shape
InitialShape
AttributeMap
MaterialTransformer

◆ add() [2/2]

virtual void prtx::EncodePreparator::add ( prt::Cache cache,
const prtx::InitialShape initialShape,
size_t  initialShapeIndex 
)
pure virtual

Adds an initial shape to the preparator. This can be used to directly encode the geometry of an initial shape.

Parameters
cacheA valid cache. It is used to determine if the shape geometry is re-used (instanced).
initialShapeThe initial shape to add.
initialShapeIndexThe current index of the initial shape in the encode sequence.
See also
InitialShape
MaterialTransformer

◆ clear()

virtual void prtx::EncodePreparator::clear ( )
pure virtual

Resets the preparator

◆ create()

static EncodePreparatorPtr prtx::EncodePreparator::create ( bool  enforceTextureConsistency,
NamePreparator &  namePreparator,
const NamePreparator::NamespacePtr &  nsMeshes,
const NamePreparator::NamespacePtr &  nsMaterials,
const MaterialTransformer materialTransformer = 0 
)
static

Factory member function to create an encode preparator instance. Typically, an encoder should keep one preparator instance during its life-time to perform multiple add and fetch operations.

Parameters
[in]enforceTextureConsistencyMatches the materials to the corresponding meshes. If true, any textures without corresponding texture coordinates in the mesh(es) will be deleted from the corresponding materials.
[in]namePreparatorSee NamePreparator
[in]nsMeshesThe namespace for mesh names.
[in]nsMaterialsThe namespace for material names.
Returns
Returns a shared pointer to the preparator instance.
See also
NamePreparator

◆ fetchFinalizedInstances()

virtual void prtx::EncodePreparator::fetchFinalizedInstances ( InstanceVector &  instances,
const PreparationFlags flags,
prt::SimpleOutputCallbacks cbForLogStats = nullptr 
)
pure virtual

Create geometry instances with corresponding transformations from the accumulated shapes and resets the preparator. Please note that a material and texture pool is kept during the whole lifetime of the preparator in order to detect identical materials and textures.

Any unused vertex attribute data (e.g. unused vertex coordinates) are removed from the meshes regardless of the preparator flags.

Parameters
[out]instancesReceives the instances.
flagsPreparation flags to control the preparation process.
cbForLogStatsoptional pointer to a prt::SimpleOutputCallbacks instance. If provided some option-dependent stats might be written to logStats().
See also
FinalizedInstance
prt::SimpleOutputCallbacks

◆ getBoundingBox()

virtual void prtx::EncodePreparator::getBoundingBox ( prtx::BoundingBox bbox)
pure virtual

Returns the world-space bounding box of the accumulated geometry. Will be reset after calling fetchFinalizedInstances.

See also
prtx::BoundingBox

◆ getInitialShapePseudoShapeId()

static uint32_t prtx::EncodePreparator::getInitialShapePseudoShapeId ( size_t  initialShapeIndex)
static

When adding an initial shape the encode preparator assigns a pseudo shape id that is then available in the finalized instance. This function returns this pseudo shape id.

Parameters
initialShapeIndexThe current index of the initial shape in question.
See also
FinalizedInstance

◆ getUsedMem()

virtual uint64_t prtx::EncodePreparator::getUsedMem ( bool  considerInstanceCounts = false) const
pure virtual

Returns an estimate of how much memory (in bytes) is consumed by the content added so far.


The documentation for this class was generated from the following file: