#include <DLLPlugi.h>
Inheritance diagram for DLLPlugin:
Public Member Functions | |
DLLPlugin () | |
DLLPlugin (HTreeObject *treeobject) | |
virtual | ~DLLPlugin () |
void | Init () |
virtual void | Init (Time time) |
virtual void | Copy (const DLLPlugin &other) |
HTreeObject * | GetOwner () |
virtual UINT | GetIconID () |
virtual UINT | GetNameID () |
virtual char * | GetClassName () |
virtual HProperty * | GetPropertyAt (int i) |
virtual int | GetNumProperties () |
virtual BOOL | Save (char *&label, char *&value, int count) |
virtual BOOL | ParseArg (const char *label, const char *value) |
virtual BOOL | OnNotifyEndProjectLoad (float productversion) |
virtual HTreeObject ** | GetPtrAt (int index) |
void | ReassignPtr (void *ptruplink, HTreeObject *newvalue) |
virtual BOOL | OnPtrMessage (PtrMessage ptrmessage, HTreeObject **ptruplink, LONG lparam, Time time=0) |
Public Attributes | |
HINSTANCE | m_hresource |
HTreeObject * | m_treeobject |
The functions are broken down into three main categories: Construction/Destruction, Interface and Serialization. A fourth category, Rendering, is defined in the derived classes.
Definition at line 21 of file DLLPlugi.h.
|
The constructor is where all the per-instance initialization is done for the texture. I say per-instance because within a given scene, a new copy of your plugin is created for every object it is applied to. This allows for time-based textures, for example, that are different on a per-instance basis. There are however certain things that should not be instanced, but rather declared static within your derived class. Anything that is constant between all instances should be done this way to preserve memory, and sometimes initialization time. The most common case of this is a noise table in a texture derived class, which could be declared as a member variable somewhere in your class something like this.
static short noiz_tbl[MAXX][MAXY][MAXZ]; The constructor would then initialize it only if it hasn't already been done. Saving time and memory. Definition at line 31 of file DLLPlugi.h. References Init(). Here is the call graph for this function: ![]() |
|
Definition at line 32 of file DLLPlugi.h. References Init(), and m_treeobject. Here is the call graph for this function: ![]() |
|
Any allocations made by your plugin should be freed here. Definition at line 33 of file DLLPlugi.h. |
|
This function is called any time the plugin "cache" is changed. Its purpose is to give you the chance to copy any member variables to the instances of the plugin. An example might be the seamless flag on a projection map, here's what that code looks like.
void CustomTexture::Copy( const DLLPlugin &other ) { CustomTexture *cache = &(CustomTexture &)other; isseamless = cache->isseamless; } Definition at line 38 of file DLLPlugi.h. |
|
Your company name and a plugin description (separated by a "\\") should be returned by this function (for example, return Definition at line 45 of file DLLPlugi.h. Referenced by ImageIO::Write(). |
|
The resource ID for your plugin's icon should be returned by this function. A 32x32 and a 16x16 version should be created for the icon. The larger of the two will be shown as a preview for your plugin in the available plugin attribute pannel. When your plugin is chosen, it's small icon becomes visible in the Project Workspace. Definition at line 42 of file DLLPlugi.h. |
|
This should be the resource ID of a string resource for the name of your plugin. An ID is used rather than text to aid in localization. Definition at line 44 of file DLLPlugi.h. |
|
Definition at line 48 of file DLLPlugi.h. References GetPropertyAt(). Here is the call graph for this function: ![]() |
|
Definition at line 39 of file DLLPlugi.h. References m_treeobject. |
|
In order for a property to show in plugin property panel of the PWS, the HProperty derived class must be assigned an index. GetPropertyAt is continuously called until you return NULL. The count parameter 'i' starts out at zero on the first call, and increments for each subsequent call. For each property you wish to add to the property panel, you return the pointer to the apporpriate HProperty derived class instance. For example: HProperty *CustomTurbulence::GetPropertyAt( int i ) { switch (i) { case 0: return m_octaves; case 1: return m_density; case 2: return m_diameter; case 3: return m_euclid; default: return NULL; } }
Definition at line 47 of file DLLPlugi.h. Referenced by GetNumProperties(). |
|
Definition at line 61 of file DLLPlugi.h. |
|
Definition at line 37 of file DLLPlugi.h. |
|
Definition at line 66 of file DLLPlugi.h. References m_hresource. Referenced by DLLPlugin(). |
|
Definition at line 58 of file DLLPlugi.h. References TRUE. |
|
When a user clicks within the property control you will receive a call to your virtual OnPtrMessage function. BOOL CustomTexture::OnPtrMessage(PtrMessage ptrmessage, HTreeObject **ptruplink, LONG lparam, Time time) { int i=0; switch (ptrmessage ) { case PTM_VALUESTORED: { HProperty *dueto = (HProperty*)lparam; if (dueto == m_buttonproperty) { // use your properties address here ... } return TRUE; } case PTM_DELETED: m_mygroup = NULL; return TRUE; case PTM_RENAMED: // Group was renamed, might do something here return TRUE; return FALSE; } If anyone ever deletes the hgroup, the hgroup will notify all of its dependences (classes that called ReassignPtr with it as a parameter) that hgroup is being deleted. It does this through the OnPtrMessage virtual function in your DllPlugin class. So lets say the user deletes the hgroup in the interface that your plugin has a pointer to. Your DLLPlugin class will receive an OnPtrMessage call that will notify you that the group was deleted.
Definition at line 63 of file DLLPlugi.h. References FALSE. |
|
Reading saved values back in is the job of ParseArg. ParseArg is called for each line within the plugin parameters portion of a material file that the standard parser does not understand. This gives you the chance to handle the loading of this data. If you did parse the label, and decide it is one of yours, you should return TRUE, otherwise return FALSE. Here is an example of how to read what we wrote out in the previous example:
BOOL CustomTexture::ParseArg( const char *label, const char *value ) { if (strcmp(label, "ShowPreview") == 0) { showpreview = (strcmp(value, "ON") == 0); return TRUE; } return FALSE; }
Definition at line 57 of file DLLPlugi.h. References FALSE. |
|
ReassignPtr adds information to the assigned object that states that your class has a pointer to it. This information may be used later through calls to OnPtrMessage to let the plugin know that something have happened to the referenced object. Lets say you have this member variable in your CustumTexture class:
HGroup *m_mygroup; You can call
ReassignPtr(&m_mygroup, hgroup); This will set m_mygroup to hgroup. You do this rather than m_mygroup = group. What ReassignPtr actually does is adds information to the hgroup that states that your class has a pointer to it.
Definition at line 62 of file DLLPlugi.h. References m_treeobject, and HTreeObject::ReassignPtr(). Here is the call graph for this function: ![]() |
|
When a plugin specific parameter set is saved to disk, the Save function is called to write out your custom data. Some common examples of things written in this function are boolean variables, and filenames. Save is continuously called until you return FALSE. The count variable starts out at zero on the first call, and increments for each subsequent call. For each item you wish to write you fill the label and value variables with the appropriate text. For example:
BOOL CustomTexture::Save( char *&label, char *&value, int count ) { switch (count) { case 0: label = "ShowPreview"; value = showpreview ? "ON" : "OFF"; return TRUE; } return FALSE; } This would write a line out in the material file that says "ShowPreview=ON". You would add more cases for each line you wish to write out. Labels should be choosen so that they are not mistaken with any typical reserved labels in the A:M files. See CustomTexture::ParseArg for an explanation.
Definition at line 56 of file DLLPlugi.h. References FALSE. |
|
Definition at line 23 of file DLLPlugi.h. Referenced by Init(). |
|
Definition at line 24 of file DLLPlugi.h. Referenced by DLLPlugin(), GetOwner(), and ReassignPtr(). |
Generated on Thu Oct 27 11:46:51 2005 with
1.4.5 written by Dimitri van Heesch,
© 1997-2001