# TBasicPrimitive Class Reference
[Base Classes for plugins]

Inheritance diagram for TBasicPrimitive:

List of all members.

## Public Member Functions
| TBasicPrimitive ()
virtual | ~TBasicPrimitive ()
virtual MCCOMErr MCCOMAPI | QueryInterface (const MCIID &riid, void **ppvObj)
virtual uint32 MCCOMAPI | AddRef ()
virtual void *MCCOMAPI | GetExtensionDataBuffer ()
| You MUST implement this method if you have a pmap (the default returns NULL).
virtual void MCCOMAPI | GetRenderingBoundingBox (TBBox3D &bbox)
virtual MCCOMErr MCCOMAPI | GetApproximateBoundingBox (TBBox3D &bbox)
virtual MCCOMErr MCCOMAPI | EnumPatches (EnumPatchesCallback callback, void *privData, boolean &closed)
virtual MCCOMErr MCCOMAPI | GetNbrLOD (int16 &nbrLod)
virtual MCCOMErr MCCOMAPI | GetLOD (int16 lodIndex, real &lod)
virtual MCCOMErr MCCOMAPI | GetFacetMesh (uint32 lodIndex, FacetMesh **outMesh)
virtual void MCCOMAPI | ChangeLocalTimeInHit (RayHitParameters &params)
virtual boolean MCCOMAPI | NeedAnimatedShader ()
| Returns true if this primitive uses local time and therefore need animated shaders.
virtual boolean MCCOMAPI | HasRenderingFacetMesh ()
virtual MCCOMErr MCCOMAPI | GetRenderingFacetMesh (FacetMesh **outMesh)
| Returns the mesh that should be used for final rendering.
virtual void MCCOMAPI | GetRenderingMesh (MeshDataStructure::TMeshList **meshList)
virtual void MCCOMAPI | GetFaceSetList (TMCCountedPtrArray< TFaceSet > &faceSetList)
| Returns the face set list associated with the primitive.
virtual boolean MCCOMAPI | CanBeSplit ()
virtual MCCOMErr MCCOMAPI | SplitPrimitive (TMCCountedPtrArray< I3DExGeometricPrimitive > &subParts, TMCArray< TTransform3D > &subPartPositions)
virtual uint32 MCCOMAPI | GetUVSpaceCount ()
virtual MCCOMErr MCCOMAPI | GetUVSpace (uint32 uvSpaceID, UVSpaceInfo *uvSpaceInfo)
virtual boolean MCCOMAPI | CanRenameUVSpace ()
virtual MCCOMErr MCCOMAPI | RenameUVSpace (uint32 uvSpaceID, const TMCString &name)
virtual MCCOMErr MCCOMAPI | UV2XYZ (TVector2 *uv, uint32 uvSpaceID, TVector3 *resultPosition, boolean *inUVSpace)
virtual MCCOMErr MCCOMAPI | GetUVSpaceRDS5 (uint32 uvSpaceID, UVSpaceInfoRDS5 *uvSpaceInfoRDS5)
virtual MCCOMErr MCCOMAPI | AppendToRenderables (const TTransform3D &worldFromModelTfm, TRenderableAndTfmArray &renderableAndTfm)
virtual boolean MCCOMAPI | AutoSwitchToModeler () const
virtual boolean MCCOMAPI | IsBBoxPickable () const
virtual MCCOMErr MCCOMAPI | GetWizardPath (TMCString &path)
virtual boolean MCCOMAPI | CanConvertToOtherModeler ()
virtual void MCCOMAPI | GetUserPresetPath (TMCDynamicString &path)
| Return the path from the preset folder to the user-defined preset folder.
virtual boolean MCCOMAPI | IsExcludedFromTripleBuffer ()
virtual void MCCOMAPI | GetDefaultShader (I3DShShader **shader, TMCString *name=nil)
virtual void MCCOMAPI | GetDefaultShaderInfo (int32 &outShaderResID, int32 &outNameStringResID, int32 &outNameStringIndex)
virtual void MCCOMAPI | ChangedData ()
virtual boolean MCCOMAPI | IsGenerator () const
virtual void MCCOMAPI | GetPreviewObject (I3DShMasterShader *masterShader, I3DShObject **object, I3DShTreeElement **previewTree, I3DShTreeElement **additionnalChildInstance)
virtual int32 MCCOMAPI | GetPrimitiveInstanceType () const
virtual boolean MCCOMAPI | IsScalable () const
virtual real32 MCCOMAPI | GetScalingFactor () const
virtual void MCCOMAPI | SetScalingFactor (real32 inValue)
virtual boolean MCCOMAPI | CanImportData (I3DImportData *inImportData, I3DShInstance *inInstance)
| Returns true if the Primitive can import the given data on the given instance.
virtual boolean MCCOMAPI | ImportData (I3DImportData *inImportData, I3DShInstance *inInstance)
| Imports the given data on the given instance, returns false if the import was aborted.
virtual boolean MCCOMAPI | ImplementDisplacementMapping ()
virtual void MCCOMAPI | DisplacementShaderChanged ()
virtual ELODParamType MCCOMAPI | GetLODParamType () const
virtual int16 MCCOMAPI | GetLODIndex (real32 distance) const
virtual void | GetAdditionalBoundingBoxVertices (TMCArray< TVector3 > &additionalVertices) const
virtual void MCCOMAPI | AboutToRemoveInstance (I3DShInstance *instance)
virtual boolean MCCOMAPI | ShouldDeleteWithInstance (I3DShInstance *inInstance)
| return true if the master should be deleted with the instance (used for figures)
## Protected Member Functions
virtual real | GetFidelity ()
virtual void | GetMinMaxLOD (real &minLOD, real &maxLOD)

## Detailed Description

Basic Primitive class. Derive from this for a default implementation of I3DExGeometricPrimitive

See also:
  I3DExGeometricPrimitive

## Constructor & Destructor Documentation

TBasicPrimitive::TBasicPrimitive | ( |  | ) |

virtual TBasicPrimitive::~TBasicPrimitive | ( |  | ) | `[virtual]`

## Member Function Documentation

virtual void MCCOMAPI TBasicPrimitive::AboutToRemoveInstance | ( | I3DShInstance * | instance | ) | `[inline, virtual]`

Implements I3DExGeometricPrimitive.

virtual uint32 MCCOMAPI TBasicPrimitive::AddRef | ( |  | ) | `[inline, virtual]`

Increments the reference count of the object

Reimplemented from TBasicDataExchanger.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::AppendToRenderables | ( | const TTransform3D & | worldFromModelTfm,
|  | TRenderableAndTfmArray & | renderableAndTfm |
| ) |  |  | `[virtual]`

Appends the renderable to the renderable array. This is used to append extra renderables on top of the geometry itself. If the function returns MC_S_FALSE instead of MC_S_OK, the default renderable will not be visible.

Parameters:

  | worldFromModelTfm | The global transform of the primitive.
  | renderableAndTfm | The array of renderable and transforms.

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::AutoSwitchToModeler | ( |  | ) | const`[virtual]`

Returns true if the primitive should be open in its modeler immediately after its insertion

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::CanBeSplit | ( |  | ) | `[virtual]`

Never implement that one, reserved for future use (primitives with an infinite number of resolutions) Returns true if the primitive can split itself into sub parts of the same type.

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::CanConvertToOtherModeler | ( |  | ) | `[inline, virtual]`

Returns true if need an apparent button to convert to other modeler.

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::CanImportData | ( | I3DImportData * | inImportData,
|  | I3DShInstance * | inInstance |
| ) |  |  | `[inline, virtual]`

Returns true if the Primitive can import the given data on the given instance.

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::CanRenameUVSpace | ( |  | ) | `[inline, virtual]`

Returns true if the primitive can rename uv spaces (ie. implements RenameUVSpace()).

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::ChangedData | ( |  | ) | `[inline, virtual]`

Do not use. Temporary call.

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::ChangeLocalTimeInHit | ( | RayHitParameters & | params | ) | `[inline, virtual]`

Let the object change the local time after a hit

Parameters:

  | params | the parameters of the hit, only params.fHit->fTime should be changed

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::DisplacementShaderChanged | ( |  | ) | `[inline, virtual]`

Called to invalidate the primitive when the displacement shader has changed

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::EnumPatches | ( | EnumPatchesCallback | callback,
|  | void * | privData,
|  | boolean & | closed |
| ) |  |  | `[virtual]`

Returns the primitive as a list of bicubic patches. It is recommended to use GetFacetMesh() instead.

Parameters:

  | callback | Callback procedure that should be called for each Patch generated by the Primitive.
  | privData | Points to private data from the Shell. Pass this pointer to callback.
  | closed | Returns True when the surface is closed. This helps set the backface mask correctly.

Implements I3DExGeometricPrimitive.

virtual void TBasicPrimitive::GetAdditionalBoundingBoxVertices | ( | TMCArray< TVector3 > & | additionalVertices | ) | const`[virtual]`

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::GetApproximateBoundingBox | ( | TBBox3D & | bbox | ) | `[inline, virtual]`

Computes the approximate bounding box (should not used any other object geometry).

Parameters:

  | bbox | A reference to a structure where the bounding box should be stored.

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::GetDefaultShader | ( | I3DShShader ** | shader,
|  | TMCString * | name = `nil` |
| ) |  |  | `[virtual]`

Returns the default shader for this primitive. This is called each time a primitive is inserted in a scene without a shader

Parameters:

  | shader | should return a pointer to the shader that should be used for this primitive (NULL to use the default master shader)
  | name | if not nil can fill with the name of the default shader

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::GetDefaultShaderInfo | ( | int32 & | outShaderResID,
|  | int32 & | outNameStringResID,
|  | int32 & | outNameStringIndex |
| ) |  |  | `[virtual]`

Returns the info necessary to load the default shader for this primitive. This is called each time a primitive is inserted in a scene without a shader.

Parameters:

  | outShaderResID | Resource ID of the SHAD resource storing the shader
  | outNameStringResID | Resource ID of the STR# resource to use for the shader's name
  | outNameStringIndex | Index of the string for the shader name

Implements I3DExGeometricPrimitive.

virtual void* MCCOMAPI TBasicPrimitive::GetExtensionDataBuffer | ( |  | ) | `[virtual]`

You MUST implement this method if you have a pmap (the default returns NULL).

Reimplemented from TBasicDataExchanger.

virtual void MCCOMAPI TBasicPrimitive::GetFaceSetList | ( | TMCCountedPtrArray< TFaceSet > & | faceSetList | ) | `[inline, virtual]`

Returns the face set list associated with the primitive.

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::GetFacetMesh | ( | uint32 | lodIndex,
|  | FacetMesh ** | outMesh |
| ) |  |  | `[virtual]`

Returns the Facet Mesh for this lod index.

Parameters:

  | lodIndex | The index of the level of detail that is asked (see GetNbrLOD())
  | outMesh | A pointer to a pointer that should be set to point on the FacetMesh.

Implements I3DExGeometricPrimitive.

virtual real TBasicPrimitive::GetFidelity | ( |  | ) | `[protected, virtual]`

virtual MCCOMErr MCCOMAPI TBasicPrimitive::GetLOD | ( | int16 | lodIndex,
|  | real & | lod |
| ) |  |  | `[virtual]`

Return the floating point value of the level of detail that corresponds to the 0-based 'lodIndex'. (lodIndex=0 means highest resolution)

Parameters:

  | lodIndex | The index of the level of detail
  | lod | The returned lod precision.

Implements I3DExGeometricPrimitive.

virtual int16 MCCOMAPI TBasicPrimitive::GetLODIndex | ( | real32 | distance | ) | const`[virtual]`

Implements I3DExGeometricPrimitive.

virtual ELODParamType MCCOMAPI TBasicPrimitive::GetLODParamType | ( |  | ) | const`[virtual]`

Returns:
  The type of information used to calculate the appropriate LOD

Implements I3DExGeometricPrimitive.

virtual void TBasicPrimitive::GetMinMaxLOD | ( | real & | minLOD,
|  | real & | maxLOD |
| ) |  |  | `[protected, virtual]`

virtual MCCOMErr MCCOMAPI TBasicPrimitive::GetNbrLOD | ( | int16 & | nbrLod | ) | `[virtual]`

Returns the number of levels of detail (lod) of the primitive. This value is used to determine the lodIndex in GetLOD().

Parameters:

  | nbrLod | The number returned for the levels of detail for the primitive.

Note:
  : Read the technical explanations in BasicPrimitive.cpp to learn everything about LOD (Level Of Details) management, and multi-resolution support.

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::GetPreviewObject | ( | I3DShMasterShader * | masterShader,
|  | I3DShObject ** | object,
|  | I3DShTreeElement ** | previewTree,
|  | I3DShTreeElement ** | additionnalChildInstance |
| ) |  |  | `[inline, virtual]`

Return the Master object to preview if different from main one. Return NULL if it is the same,

Parameters:

  | masterShader | the master shader being previewed
  | object | the object to use to preview the shader
  | previewTree | a tree to set the transform of the preview object (only the transform will be used)
  | additionnalChild | the master object can also add an instance that will be used for the preview as well, puting it as child of the previewed object

Implements I3DExGeometricPrimitive.

virtual int32 MCCOMAPI TBasicPrimitive::GetPrimitiveInstanceType | ( |  | ) | const`[inline, virtual]`

Return the instance type for this primitive.

See also:
  I3DShInstance::EInstanceType

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::GetRenderingBoundingBox | ( | TBBox3D & | bbox | ) | `[inline, virtual]`

Computes the bounding box for rendering.

Parameters:

  | bbox | A reference to a structure where the bounding box should be stored.

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::GetRenderingFacetMesh | ( | FacetMesh ** | outMesh | ) | `[virtual]`

Returns the mesh that should be used for final rendering.

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::GetRenderingMesh | ( | MeshDataStructure::TMeshList ** | meshList | ) | `[virtual]`

Returns a pointer to the rendering mesh associated with the primitive. Note that the mesh is not cached by the primitive so you can modify it and it is your responsability to delete it.

Returns:
  NULL if the primitive does not support this (in which case you should get the facet mesh.

Implements I3DExGeometricPrimitive.

virtual real32 MCCOMAPI TBasicPrimitive::GetScalingFactor | ( |  | ) | const`[inline, virtual]`

Returns the scaling that should be applied to the primitive, i.e. the number of inches in the primitive's unit.

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::GetUserPresetPath | ( | TMCDynamicString & | path | ) | `[inline, virtual]`

Return the path from the preset folder to the user-defined preset folder.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::GetUVSpace | ( | uint32 | uvSpaceID,
|  | UVSpaceInfo * | uvSpaceInfo |
| ) |  |  | `[virtual]`

Returns the information regarding a particular uvSpace (= shading domain).

Parameters:

  | uvSpaceID | The ID of the uvspace (0 based index)
  | uvSpaceInfo | A pointer to a structure where the information will be stored.

Implements I3DExGeometricPrimitive.

virtual uint32 MCCOMAPI TBasicPrimitive::GetUVSpaceCount | ( |  | ) | `[virtual]`

Returns the number of UV space on the primitives.

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::GetUVSpaceRDS5 | ( | uint32 | uvSpaceID,
|  | UVSpaceInfoRDS5 * | uvSpaceInfoRDS5 |
| ) |  |  | `[virtual]`

Returns the information regarding a particular uvSpace (= shading domain). To be implemented only if your primitive existed in RDS 5 or earlier, so that UV spaces can be mapped properly to the new 0..1 boundaries

Parameters:

  | uvSpaceID | The ID of the uvspace (0 based index)
  | uvSpaceInfoRDS5 | A pointer to a structure where the information will be stored.

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::GetWizardPath | ( | TMCString & | path | ) | `[inline, virtual]`

Returns the path to the primitive wizard file (wizard.txt) from the application folder.

Parameters:

  | path | path to the primitive wizard file from the application folder

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::HasRenderingFacetMesh | ( |  | ) | `[virtual]`

Returns true if this primitive has a mesh used only for final rendering. If it returns false, you can assume that the mesh for lod 0 and the rendering mesh are the same.

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::ImplementDisplacementMapping | ( |  | ) | `[inline, virtual]`

Returns true if the primite can apply the displacement mapping by itself

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::ImportData | ( | I3DImportData * | inImportData,
|  | I3DShInstance * | inInstance |
| ) |  |  | `[inline, virtual]`

Imports the given data on the given instance, returns false if the import was aborted.

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::IsBBoxPickable | ( |  | ) | const`[inline, virtual]`

Returns true if the primitive can be picked in the 3D View when clicking on its bounding box. Usually, you want to reply no, since the picking is done thru a ray-tracing hit test. However, some primitives such as volumic primitives or particles systems may want to answer yes. Default implementation in TBasicPrimitive returns false.

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::IsExcludedFromTripleBuffer | ( |  | ) | `[inline, virtual]`

Return true if its instances should be excluded from the triple buffer (eg used for skinning)

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::IsGenerator | ( |  | ) | const`[inline, virtual]`

Return true if the object can generate sub instances if true the component should also implements I3DExInstancePrimitive

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::IsScalable | ( |  | ) | const`[inline, virtual]`

If true, the primitive is scaled at insertion in a scene, so that one unit for the primitive corresponds to one unit in the scene.

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::NeedAnimatedShader | ( |  | ) | `[inline, virtual]`

Returns true if this primitive uses local time and therefore need animated shaders.

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::QueryInterface | ( | const MCIID & | riid,
|  | void ** | ppvObj |
| ) |  |  | `[virtual]`

Check if the object supports a given interface and returns a pointer to that interface if it does. Note that QueryInterface will increment the reference count of the object by one if the interface is found.

Parameters:

  | riid | GUID of the interface
  | ppvObj | A pointer to the pointer being returned.

Reimplemented from TBasicDataExchanger.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::RenameUVSpace | ( | uint32 | uvSpaceID,
|  | const TMCString & | name |
| ) |  |  | `[inline, virtual]`

Rename a particular uvSpace (= shading domain).

Parameters:

  | uvSpaceID | The ID of the uvspace (0 based index)
  | name | The new name of the uvspace.

Implements I3DExGeometricPrimitive.

virtual void MCCOMAPI TBasicPrimitive::SetScalingFactor | ( | real32 | inValue | ) | `[inline, virtual]`

Sets the scaling factor of the primitive.

Parameters:

  | inValue | the number of inches to which the primitive's unit is equivalent

Implements I3DExGeometricPrimitive.

virtual boolean MCCOMAPI TBasicPrimitive::ShouldDeleteWithInstance | ( | I3DShInstance * | inInstance | ) | `[inline, virtual]`

return true if the master should be deleted with the instance (used for figures)

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::SplitPrimitive | ( | TMCCountedPtrArray< I3DExGeometricPrimitive > & | subParts,
|  | TMCArray< TTransform3D > & | subPartPositions |
| ) |  |  | `[virtual]`

Builds a list of sub-parts of itself. 'subPartPositions' gives the relative position of each sub part in the object local coordinates. Both arrays need to be of same size.

Note: the original primitive needs to remain intact.

Parameters:

  | subParts | An array of sub primitives.
  | subPartPositions | For each sub primitives, its transform.

Implements I3DExGeometricPrimitive.

virtual MCCOMErr MCCOMAPI TBasicPrimitive::UV2XYZ | ( | TVector2 * | uv,
|  | uint32 | uvSpaceID,
|  | TVector3 * | resultPosition,
|  | boolean * | inUVSpace |
| ) |  |  | `[virtual]`

Returns the position in 3D of a point given a set of UV coordinates. This is useful if you want to calculate a UV texture from a 3D shaders for instance.

Returns:
  MC_S_OK if it is implemented, E_NOTIMPL if it isn't (in which case a default implementation will be used by the shell).

Parameters:

  | uv | The uv coordinates used as input
  | uvSpaceID | The uv space ID to which this uv coordinates corresponds
  | resultPosition | The 3D Position that is returned.
  | inUVSpace | Returns true if the point was found in the upSpaceID specified.

Implements I3DExGeometricPrimitive.

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

- BasicPrimitive.h