182 lines
4.0 KiB
C++
182 lines
4.0 KiB
C++
#ifndef __AVCLASS__H
|
|
#define __AVCLASS__H
|
|
#include "avlib.h"
|
|
|
|
class CAvColor {
|
|
public:
|
|
AvColorSystem system;
|
|
ads_point color;
|
|
public:
|
|
CAvColor(): system(AvRGB)
|
|
{
|
|
}
|
|
|
|
};
|
|
|
|
class CAvRmatMap {
|
|
public:
|
|
char *name;
|
|
double value;
|
|
AvTileType tile;
|
|
XPoint scale;
|
|
XPoint offset;
|
|
double angle;
|
|
int mappingFlags; //Added for AVLIB 0.02
|
|
unsigned long flags;
|
|
public:
|
|
CAvRmatMap(): name(NULL), value(0.0), tile(AvTileTile),
|
|
angle(0.0), mappingFlags(0), flags(0)
|
|
{
|
|
}
|
|
~CAvRmatMap() {
|
|
if(name)
|
|
free(name);
|
|
}
|
|
};
|
|
|
|
|
|
|
|
class CAvRmatStandard {
|
|
public:
|
|
CAvColor color;
|
|
double colorWeight;
|
|
CAvRmatMap patternMap;
|
|
CAvColor ambient;
|
|
double ambWeight;
|
|
double transparency;
|
|
CAvRmatMap opacityMap;
|
|
double refraction;
|
|
unsigned long flags;
|
|
public:
|
|
CAvRmatStandard():colorWeight(0.0), ambWeight(0.0), transparency(0.0),
|
|
refraction(0.0), flags(0)
|
|
{
|
|
}
|
|
~CAvRmatStandard() {
|
|
}
|
|
};
|
|
|
|
|
|
class CAvRmatParam {
|
|
public:
|
|
AvRmatMode mode;
|
|
AvMaterialType matType;
|
|
char *name;
|
|
int aci;
|
|
ads_name selectionSet;
|
|
ads_name entity;
|
|
char *layerName;
|
|
char *newName;
|
|
CAvRmatMap bumpMap;
|
|
AvBoolean reflMirror;
|
|
AvColor reflColor;
|
|
double reflWeight;
|
|
CAvRmatMap reflMap;
|
|
double roughness;
|
|
struct resbuf *rb;
|
|
AvRmatAttachMethod attachment;
|
|
union {
|
|
AvRmatStandard standard; // safe while query
|
|
AvRmatMarble marble;
|
|
AvRmatGranite granite;
|
|
AvRmatWood wood;
|
|
};
|
|
unsigned long flags;
|
|
|
|
public:
|
|
CAvRmatParam(): mode(AvRmatUI), matType(AvRmatStandardMaterial),
|
|
name(NULL), aci(0), layerName(NULL), newName(NULL), reflWeight(0.0),
|
|
roughness(0.0), rb(NULL), attachment(AvRmatByLayer), flags(0)
|
|
{
|
|
selectionSet[0]=selectionSet[1]=0L;
|
|
entity[0]=entity[1]=0L;
|
|
CAvRmatStandard tmp; //use to free standard
|
|
memcpy(&standard, &tmp, sizeof(CAvRmatStandard));
|
|
}
|
|
~CAvRmatParam() {
|
|
if(flags&AvRmatMatParams) {
|
|
if(matType==AvRmatStandardMaterial) {
|
|
CAvRmatStandard tmp; //use to free standard
|
|
memcpy(&tmp, &standard, sizeof(CAvRmatStandard));
|
|
} else {
|
|
AfxMessageBox("Unstandard material is not supported");
|
|
}
|
|
}
|
|
if(name) free(name);
|
|
if(layerName) free(layerName);
|
|
if(newName) free(newName);
|
|
if(rb) ads_relrb(rb); //rbÑ¡Ôñ¼¯Ã»ÓÐÊÍ·Å
|
|
}
|
|
AvRmatParam * operator &() {
|
|
return (AvRmatParam *)this;
|
|
}
|
|
operator AvRmatParam &() {
|
|
return *(AvRmatParam *)this;
|
|
}
|
|
BOOL IsExist() {
|
|
if(!name)
|
|
return FALSE;
|
|
|
|
CAvRmatParam rmatPara;
|
|
rmatPara.mode=AvRmatList;
|
|
rmatPara.flags = 0;
|
|
rmatPara.name = NULL;
|
|
if(av_rmat(&rmatPara)!=AvRetNorm)
|
|
return FALSE;
|
|
BOOL bExist=FALSE;
|
|
for(resbuf *rb=rmatPara.rb; rb!=NULL; rb=rb->rbnext) {
|
|
ASSERT(rb->restype==RTSTR && rb->resval.rstring);
|
|
if(stricmp(rb->resval.rstring, name)==0) {
|
|
bExist=TRUE;
|
|
break;
|
|
}
|
|
}
|
|
return bExist;
|
|
/*
|
|
CAvRmatParam query;
|
|
query.name=strdup(name);
|
|
query.mode = AvRmatList;
|
|
query.flags = AvRmatName;
|
|
BOOL bExist=(av_rmat(&query)==AvRetNorm);
|
|
return bExist; */
|
|
}
|
|
BOOL MatNew() {
|
|
mode = AvRmatNew;
|
|
AvRmatParam *rmat=(AvRmatParam *)this;
|
|
AvErrorCode retCode=av_rmat(rmat);
|
|
BOOL bOk=(retCode==AvRetNorm);
|
|
return bOk;
|
|
}
|
|
|
|
BOOL MatModify() {
|
|
mode = AvRmatModify;
|
|
AvErrorCode retCode=av_rmat((AvRmatParam *)this);
|
|
BOOL bOk=(retCode==AvRetNorm);
|
|
return bOk;
|
|
}
|
|
|
|
BOOL AttachByLayer(const char *pszLay) {
|
|
mode = AvRmatAttach;
|
|
ASSERT(pszLay);
|
|
if(layerName) free(layerName);
|
|
layerName = strdup(pszLay);
|
|
attachment=AvRmatByLayer;
|
|
flags |= AvRmatLayerName;
|
|
flags |= AvRmatAttachment;
|
|
BOOL bOk=(av_rmat((AvRmatParam *)this)==AvRetNorm);
|
|
return bOk;
|
|
}
|
|
|
|
/*
|
|
BOOL RenameAs(const char *szNewName) {
|
|
mode = AvRmatModify;
|
|
if(newName) free(newName);
|
|
newName=strdup(szNewName);
|
|
flags |= (AvRmatName|AvRmatNewName);
|
|
return MatModify();
|
|
}*/
|
|
};
|
|
|
|
|
|
|
|
#endif |