DSX File Extensions
.DSX files are DreamScape extensions files. Currently, only DreamScape Terrain modifiers are supported.
All DSX files must have a ".dsx" extension. The .DSX file must be placed in the same folder as the DreamScape.dlr file.
DSFilter class
All DreamScape Terrain modifiers should be inherited from this base class. This class includes two methods.
Execute(HWND wndprog, float **data, BYTE **mask, int size, float height
This function is called when a filter is applied to the terrain.
- wndprog: window of the progress bar (10 steps initially)
- **data: pointer to the terrain data
- **mask:pointer to the selection mask.
For **mask values, 0 means there is no selection, and 255 that there is selection. In the case where feather was applied, mask values can also vary from 0 to 255.
**mask can be NULL if selection is not active
- size: grid size (total size is size x size)
- height: actual terrain height
DeleteMe(void)
Called from DreamScape terrain when the filter is no longer needed.
class DSFilter{
public:
virtual void Execute(HWND wndprog, float **data, BYTE **mask, int size, float height)=0;
virtual void DeleteMe(void)=0;
};
Example:
void SampleFilter::DeleteMe(void) {
delete this;
}
void SampleFilter::Execute(HWND wndprog, float **data, int size, float height)
{ for(int y=0; y < size; y++){
if(y%10==0) SendMessage(wndprog, PBM_STEPIT, 0, 0); //update the progress bar
for(int x=0; x < size; x++) data[y][x]*=(float)pow(data[y][x],2); //modify the values
}
return;
}
FilterDesc class
Each filter has to create its own class inherited from the FilterDesc base class. This class includes two methods.
DSFilter* Create(void): which is called from the DreamScape Terrain when a filter should be applied (the user have selected it from the Modify menu).
TCHAR* GetName(void): should return the name of your filter which will be displayed in the Modify menu.
class FilterDesc{
public:
virtual DSFilter* Create(void)=0;
virtual TCHAR* GetName(void)=0;
};
Example:
class SampleFilterDesc : public FilterDesc{
public: DSFilter* Create(void) { return new SampleFilter; }
TCHAR* GetName(void) { return _T("DS Sample"); }
};
Also, each .dsx file has to implement two methods.
int WINAPI NumFilters(void) - this method is called by the DreamScape terrain to determine how many filters there are inside this .dsx file.
FilterDesc* WINAPI GetFilterDesc(int i) - you have to return the *FilterDesc of each filter included inside a particular .dsx.
Example:
static SampleFilterDesc sfDesc;
FilterDesc* GetSampleFD() {return &sfDesc;}
int WINAPI NumFilters(void) { return 1; }
FilterDesc* WINAPI GetFilterDesc(int i){
switch(i){
case 0:
return GetSampleFD();
break;
}
}