# I3DShExternalPrimitive Struct Reference
[Shell Interfaces]

Inheritance diagram for I3DShExternalPrimitive:

List of all members.

## Public Member Functions
virtual MCCOMErr MCCOMAPI | SetPrimitiveComponent (IShComponent *primitiveComponent, ECloneMode cloneMode)=0
virtual MCCOMErr MCCOMAPI | GetPrimitiveComponent (IShComponent **primitiveComponent)=0
virtual IShComponent *MCCOMAPI | GetPrimitiveComponent ()=0
virtual I3DShPrimitive *MCCOMAPI | GetPrimitive ()=0
virtual MCCOMErr MCCOMAPI | GetOriginalPrimitive (I3DShPrimitive **origPrimitive)=0

## Detailed Description

I3DShExternalPrimitive is interface for external primitives. All primitives in Carrara are External Primitives. However some primitives imported from Raydream are still stored internally.

Primitive is one particular type of Master Objects (see I3DShObject). They can be instantianted multiple times.

There are 2 COM objects to consider:

- The Primitive that supports I3DShExternalPrimitive, I3DShPrimitive and I3DShObject.
- The Primitive Component that supports IShComponent, I3DShPrimitiveComponent and I3DExGeometricPrimitive

For advanced users: You should note that there are actually 3 C++ object (The primitive, the primitive component and the primitive light). However the primitive component and the external primitive are aggregated by COM which means that you can be considered as one single COM object).

To get a pointer to a I3DShExternalPrimitive from a I3DExGeometricPrimitive, you can use the following code:

     TMCCountedPtr<I3DShPrimitiveComponent> primitiveComponent;
     exPrimitive->QueryInterface(IID_I3DShPrimitiveComponent,(void**)&primitiveComponent);
     ThrowIfNil(primitiveComponent);

     TMCCountedPtr<I3DShPrimitive> primitive;
     primitiveComponent->GetPrimitive(&primitive);
     ThrowIfNil(primitive);

     TMCCountedPtr<I3DShExternalPrimitive> externalPrimitive;
     primitive->QueryInterface(IID_I3DShExternalPrimitive.(void**)&externalPrimitive);

To access I3DExGeometricPrimitive from I3DShPrimitive, you can use the following code:

     TMCCountedPtr<I3DShExternalPrimitive> externalPrimitive;
     shPrimitive->QueryInterface(IID_I3DShExternalPrimitive,(void**)&externalPrimitive);
     ThrowIfNil(externalPrimitive);

     TMCCountedPtr<IShComponent> primitiveComponent;
     externalPrimitive->GetPrimitiveComponent(&primitiveComponent);
     ThrowIfNil(primitiveComponent);

     TMCCountedPtr<I3DExGeometricPrimitive> externalPrimitive;
     primitiveComponent->QueryInterface(IID_I3DExGeometricPrimitive,(void**)&externalPrimitive);

This code might seem a bit complicated at first but it is actually simple. You have two COM objects that point on each other. I3DShExternalPrimitive::GetPrimitiveComponent() and I3DShPrimitiveComponent::GetPrimitive() allow you to get a pointer from one object to the other. The rest is only calling QueryInterface to get the right interface on each object.

See also:
  I3DShPrimitiveComponent
  I3DExGeometricPrimitive
  I3DShPrimitive

## Member Function Documentation

virtual MCCOMErr MCCOMAPI I3DShExternalPrimitive::GetOriginalPrimitive | ( | I3DShPrimitive ** | origPrimitive | ) | `[pure virtual]`

Returns a pointer to the primitive interface to which this primitive is applied when it is a deformer. Returns MC_S_OK if the primitive was indeed a deformer and MC_S_FALSE otherwise.

Parameters:

  | origPrimitive | A pointer to the shell primitive

virtual I3DShPrimitive* MCCOMAPI I3DShExternalPrimitive::GetPrimitive | ( |  | ) | `[pure virtual]`

Returns a pointer to the primitive interface. (This is a bit faster than using QueryInterface).

virtual IShComponent* MCCOMAPI I3DShExternalPrimitive::GetPrimitiveComponent | ( |  | ) | `[pure virtual]`

Returns a pointer to the primitive component associated with this primitive.

virtual MCCOMErr MCCOMAPI I3DShExternalPrimitive::GetPrimitiveComponent | ( | IShComponent ** | primitiveComponent | ) | `[pure virtual]`

Returns a pointer to the primitive component associated with this primitive.

Parameters:

  | primitiveComponent | A pointer to the primitive component.

virtual MCCOMErr MCCOMAPI I3DShExternalPrimitive::SetPrimitiveComponent | ( | IShComponent * | primitiveComponent,
|  | ECloneMode | cloneMode |
| ) |  |  | `[pure virtual]`

Sets the primitive component associated with this primitive.

Parameters:

  | primitiveComponent | The new primitive component.
  | cloneMode | The clone mode (see ECloneMode).

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

- I3dShObject.h