#include <MaterialParam.h>
Public Member Functions | |
TextureParam (void) | |
virtual | ~TextureParam (void) |
void | init (void) |
void | free (void) |
void | clear (void) |
void | dup (TextureParam m) |
bool | isSetTexture (void) |
bool | isSetColor (void) |
bool | isSetAlpha (void) |
bool | isSetParams (void) |
bool | isSetShift (void) |
bool | isSetScale (void) |
bool | isSetRotate (void) |
void | setName (const char *nm) |
char * | getName (void) |
void | addName (const char *nm) |
void | setColor (double r, double g, double b, double a=1.0) |
void | setColor (double v, int c) |
void | setShiftU (double u) |
void | setShiftV (double v) |
void | setScaleU (double u) |
void | setScaleV (double v) |
void | setRotate (double r) |
void | setFlipU (bool f) |
void | setFlipV (bool f) |
void | setShift (double u, double v) |
void | setScale (double u, double v) |
void | setAlphaChannel (bool h) |
void | setAlphaMode (int m) |
void | setAlphaCutoff (double m) |
double | getColor (int c) |
double | getShiftU (void) |
double | getShiftV (void) |
double | getScaleU (void) |
double | getScaleV (void) |
double | getRotate (void) |
bool | getAlphaChannel (void) |
int | getAlphaMode (void) |
double | getAlphaCutoff (void) |
void | execTrans (UVMap< double > *uv, int n) |
Rotate -> Scale -> Shift. | |
void | execShift (UVMap< double > *uv, int n) |
void | execScale (UVMap< double > *uv, int n) |
void | execRotate (UVMap< double > *uv, int n) |
void | execInvTrans (UVMap< double > *uv, int n) |
Shift -> Scale -> Rotate. | |
void | execInvShift (UVMap< double > *uv, int n) |
void | execInvScale (UVMap< double > *uv, int n) |
void | execInvRotate (UVMap< double > *uv, int n) |
void | execFlipU (UVMap< double > *uv, int n) |
void | execFlipV (UVMap< double > *uv, int n) |
void | printParam (FILE *fp) |
Private Attributes | |
Buffer | name |
テクスチャ名 | |
double | color [4] |
RGBA. | |
bool | alphaChannel |
テクスチャデータがアルファチャンネルを持っているかどうか. | |
int | alphaMode |
アルファチャンネルのモード | |
double | alphaCutoff |
アルファチャンネルの Cutoff値.alphaMode==MATERIAL_ALPHA_MASKING の場合に有効 | |
double | shiftU |
UVマップのシフト (U方向). | |
double | shiftV |
UVマップのシフト (V方向). | |
double | scaleU |
UVマップのスケール (U方向). | |
double | scaleV |
UVマップのスケール (V方向). | |
double | rotate |
UVマップの回転. | |
bool | flipU |
UVマップで U方向の反転を行うか. | |
bool | flipV |
UVマップで V方向の反転を行うか. |
Definition at line 57 of file MaterialParam.h.
TextureParam | ( | void | ) | [inline] |
Definition at line 78 of file MaterialParam.h.
virtual ~TextureParam | ( | void | ) | [inline, virtual] |
Definition at line 79 of file MaterialParam.h.
void addName | ( | const char * | nm | ) | [inline] |
Definition at line 98 of file MaterialParam.h.
References cat_s2Buffer, and TextureParam::name.
Referenced by MaterialParam::setupFullName().
00098 { if(nm!=NULL) cat_s2Buffer(nm, &name);}
void clear | ( | void | ) | [inline] |
Definition at line 83 of file MaterialParam.h.
References TextureParam::free(), and TextureParam::init().
void dup | ( | TextureParam | m | ) |
Definition at line 45 of file MaterialParam.cpp.
References dup_Buffer(), and TextureParam::name.
Referenced by MaterialParam::dup().
00046 { 00047 *this = t; 00048 00049 name = dup_Buffer(t.name); 00050 }
void execFlipU | ( | UVMap< double > * | uv, | |
int | n | |||
) | [inline] |
Definition at line 137 of file MaterialParam.h.
Referenced by MaterialParam::execFlipU(), TextureParam::execInvTrans(), and TextureParam::execTrans().
void execFlipV | ( | UVMap< double > * | uv, | |
int | n | |||
) | [inline] |
Definition at line 138 of file MaterialParam.h.
Referenced by MaterialParam::execFlipV(), TextureParam::execInvTrans(), and TextureParam::execTrans().
void execInvRotate | ( | UVMap< double > * | uv, | |
int | n | |||
) |
Definition at line 118 of file MaterialParam.cpp.
References TextureParam::rotate, UVMap< T >::u, and UVMap< T >::v.
Referenced by MaterialParam::execInvRotate(), and TextureParam::execInvTrans().
00119 { 00120 double uu, vv; 00121 double cs = cos(rotate); 00122 double sn = -sin(rotate); 00123 00124 for (int i=0; i<num; i++) { 00125 uu = uv[i].u - 0.5; 00126 vv = uv[i].v - 0.5; 00127 uv[i].u = uu*cs + vv*sn + 0.5; 00128 uv[i].v = -uu*sn + vv*cs + 0.5; 00129 } 00130 }
void execInvScale | ( | UVMap< double > * | uv, | |
int | n | |||
) |
Definition at line 88 of file MaterialParam.cpp.
References TextureParam::scaleU, TextureParam::scaleV, UVMap< T >::u, and UVMap< T >::v.
Referenced by MaterialParam::execInvScale(), and TextureParam::execInvTrans().
00089 { 00090 double uu, vv; 00091 00092 for (int i=0; i<num; i++) { 00093 uu = (uv[i].u - 0.5)/scaleU; 00094 vv = (uv[i].v - 0.5)/scaleV; 00095 uv[i].u = uu + 0.5; 00096 uv[i].v = vv + 0.5; 00097 } 00098 }
void execInvShift | ( | UVMap< double > * | uv, | |
int | n | |||
) |
Definition at line 64 of file MaterialParam.cpp.
References TextureParam::shiftU, TextureParam::shiftV, UVMap< T >::u, and UVMap< T >::v.
Referenced by MaterialParam::execInvShift(), and TextureParam::execInvTrans().
00065 { 00066 for (int i=0; i<num; i++) { 00067 uv[i].u -= shiftU; 00068 uv[i].v -= shiftV; 00069 } 00070 }
void execInvTrans | ( | UVMap< double > * | uv, | |
int | n | |||
) |
Definition at line 148 of file MaterialParam.cpp.
References TextureParam::execFlipU(), TextureParam::execFlipV(), TextureParam::execInvRotate(), TextureParam::execInvScale(), TextureParam::execInvShift(), TextureParam::flipU, TextureParam::flipV, TextureParam::isSetRotate(), TextureParam::isSetScale(), and TextureParam::isSetShift().
Referenced by MaterialParam::execInvTrans().
00149 { 00150 if (flipU) { execFlipU(uv, num); flipU = false;} 00151 if (flipV) { execFlipV(uv, num); flipV = false;} 00152 if (isSetShift()) execInvShift (uv, num); 00153 if (isSetScale()) execInvScale (uv, num); 00154 if (isSetRotate()) execInvRotate(uv, num); 00155 00156 return; 00157 }
void execRotate | ( | UVMap< double > * | uv, | |
int | n | |||
) |
Definition at line 102 of file MaterialParam.cpp.
References TextureParam::rotate, UVMap< T >::u, and UVMap< T >::v.
Referenced by MaterialParam::execRotate(), and TextureParam::execTrans().
00103 { 00104 double uu, vv; 00105 double cs = cos(rotate); 00106 double sn = sin(rotate); 00107 00108 for (int i=0; i<num; i++) { 00109 uu = uv[i].u - 0.5; 00110 vv = uv[i].v - 0.5; 00111 uv[i].u = uu*cs + vv*sn + 0.5; 00112 uv[i].v = -uu*sn + vv*cs + 0.5; 00113 } 00114 }
void execScale | ( | UVMap< double > * | uv, | |
int | n | |||
) |
Definition at line 74 of file MaterialParam.cpp.
References TextureParam::scaleU, TextureParam::scaleV, UVMap< T >::u, and UVMap< T >::v.
Referenced by MaterialParam::execScale(), and TextureParam::execTrans().
00075 { 00076 double uu, vv; 00077 00078 for (int i=0; i<num; i++) { 00079 uu = (uv[i].u - 0.5)*scaleU; 00080 vv = (uv[i].v - 0.5)*scaleV; 00081 uv[i].u = uu + 0.5; 00082 uv[i].v = vv + 0.5; 00083 } 00084 }
void execShift | ( | UVMap< double > * | uv, | |
int | n | |||
) |
Definition at line 54 of file MaterialParam.cpp.
References TextureParam::shiftU, TextureParam::shiftV, UVMap< T >::u, and UVMap< T >::v.
Referenced by MaterialParam::execShift(), and TextureParam::execTrans().
00055 { 00056 for (int i=0; i<num; i++) { 00057 uv[i].u += shiftU; 00058 uv[i].v += shiftV; 00059 } 00060 }
void execTrans | ( | UVMap< double > * | uv, | |
int | n | |||
) |
Definition at line 134 of file MaterialParam.cpp.
References TextureParam::execFlipU(), TextureParam::execFlipV(), TextureParam::execRotate(), TextureParam::execScale(), TextureParam::execShift(), TextureParam::flipU, TextureParam::flipV, TextureParam::isSetRotate(), TextureParam::isSetScale(), and TextureParam::isSetShift().
Referenced by MaterialParam::execTrans().
00135 { 00136 //DEBUG_MODE PRINT_MESG("%f %f, %f %f, %f\n", shiftU, shiftV, scaleU, scaleV, rotate); 00137 if (flipU) { execFlipU(uv, num); flipU = false;} 00138 if (flipV) { execFlipV(uv, num); flipV = false;} 00139 if (isSetRotate()) execRotate(uv, num); 00140 if (isSetScale()) execScale (uv, num); 00141 if (isSetShift()) execShift (uv, num); 00142 00143 return; 00144 }
void free | ( | void | ) |
Definition at line 36 of file MaterialParam.cpp.
References free_Buffer(), and TextureParam::name.
Referenced by TextureParam::clear(), and MaterialParam::free().
00037 { 00038 free_Buffer(&name); 00039 00040 return; 00041 }
bool getAlphaChannel | ( | void | ) | [inline] |
Definition at line 123 of file MaterialParam.h.
References TextureParam::alphaChannel.
Referenced by MaterialParam::getAlphaChannel().
00123 { return alphaChannel;}
double getAlphaCutoff | ( | void | ) | [inline] |
Definition at line 125 of file MaterialParam.h.
References TextureParam::alphaCutoff.
Referenced by MaterialParam::getAlphaCutoff().
00125 { return alphaCutoff;}
int getAlphaMode | ( | void | ) | [inline] |
Definition at line 124 of file MaterialParam.h.
References TextureParam::alphaMode, TextureParam::color, and MATERIAL_ALPHA_BLENDING.
Referenced by MaterialParam::getAlphaMode().
00124 { if (color[3]<0.99) return MATERIAL_ALPHA_BLENDING; else return alphaMode;}
double getColor | ( | int | c | ) | [inline] |
Definition at line 116 of file MaterialParam.h.
References TextureParam::color.
Referenced by ColladaXML::addEffect(), MaterialParam::getColor(), and jbxl::isSameTexture().
00116 { if(c<0) c = 0; else if(c>3) c = 3; return color[c];}
char* getName | ( | void | ) | [inline] |
Definition at line 97 of file MaterialParam.h.
References Buffer::buf, and TextureParam::name.
Referenced by MaterialParam::getBumpMapName(), MaterialParam::getSpecMapName(), MaterialParam::getTextureName(), and jbxl::isSameTexture().
double getRotate | ( | void | ) | [inline] |
Definition at line 121 of file MaterialParam.h.
References TextureParam::rotate.
Referenced by MaterialParam::getRotate().
00121 { return rotate;}
double getScaleU | ( | void | ) | [inline] |
Definition at line 119 of file MaterialParam.h.
References TextureParam::scaleU.
Referenced by MaterialParam::getScaleU().
00119 { return scaleU;}
double getScaleV | ( | void | ) | [inline] |
Definition at line 120 of file MaterialParam.h.
References TextureParam::scaleV.
Referenced by MaterialParam::getScaleV().
00120 { return scaleV;}
double getShiftU | ( | void | ) | [inline] |
Definition at line 117 of file MaterialParam.h.
References TextureParam::shiftU.
Referenced by MaterialParam::getShiftU().
00117 { return shiftU;}
double getShiftV | ( | void | ) | [inline] |
Definition at line 118 of file MaterialParam.h.
References TextureParam::shiftV.
Referenced by MaterialParam::getShiftV().
00118 { return shiftV;}
void init | ( | void | ) |
Definition at line 12 of file MaterialParam.cpp.
References TextureParam::alphaChannel, TextureParam::alphaCutoff, TextureParam::alphaMode, TextureParam::color, TextureParam::flipU, TextureParam::flipV, init_Buffer(), MATERIAL_ALPHA_NONE, TextureParam::name, TextureParam::rotate, TextureParam::scaleU, TextureParam::scaleV, TextureParam::shiftU, and TextureParam::shiftV.
Referenced by TextureParam::clear(), and MaterialParam::init().
00013 { 00014 name = init_Buffer(); 00015 00016 for (int i=0; i<4; i++) color[i] = 1.0; 00017 00018 alphaChannel = false; 00019 alphaMode = MATERIAL_ALPHA_NONE; 00020 alphaCutoff = 0.0; 00021 00022 shiftU = 0.0; 00023 shiftV = 0.0; 00024 scaleU = 1.0; 00025 scaleV = 1.0; 00026 rotate = 0.0; 00027 00028 flipU = false; 00029 flipV = false; 00030 00031 return; 00032 }
bool isSetAlpha | ( | void | ) | [inline] |
Definition at line 89 of file MaterialParam.h.
References TextureParam::alphaChannel, TextureParam::alphaMode, MATERIAL_ALPHA_BLENDING, and MATERIAL_ALPHA_MASKING.
Referenced by MaterialParam::isSetAlpha(), and TextureParam::isSetParams().
00089 { return (alphaChannel && (alphaMode==MATERIAL_ALPHA_BLENDING||alphaMode==MATERIAL_ALPHA_MASKING));}
bool isSetColor | ( | void | ) | [inline] |
Definition at line 88 of file MaterialParam.h.
References TextureParam::color.
Referenced by MaterialParam::isSetColor(), and TextureParam::isSetParams().
bool isSetParams | ( | void | ) | [inline] |
Definition at line 90 of file MaterialParam.h.
References TextureParam::isSetAlpha(), and TextureParam::isSetColor().
Referenced by MaterialParam::isSetTextureParams().
00090 { return (isSetColor() || isSetAlpha());}
bool isSetRotate | ( | void | ) | [inline] |
Definition at line 94 of file MaterialParam.h.
References TextureParam::rotate.
Referenced by TextureParam::execInvTrans(), and TextureParam::execTrans().
00094 { return (rotate!=0.0);}
bool isSetScale | ( | void | ) | [inline] |
Definition at line 93 of file MaterialParam.h.
References TextureParam::scaleU, and TextureParam::scaleV.
Referenced by TextureParam::execInvTrans(), and TextureParam::execTrans().
bool isSetShift | ( | void | ) | [inline] |
Definition at line 92 of file MaterialParam.h.
References TextureParam::shiftU, and TextureParam::shiftV.
Referenced by TextureParam::execInvTrans(), and TextureParam::execTrans().
bool isSetTexture | ( | void | ) | [inline] |
Definition at line 87 of file MaterialParam.h.
References Buffer::buf, and TextureParam::name.
Referenced by MaterialParam::isSetBumpMap(), MaterialParam::isSetSpecMap(), MaterialParam::isSetTexture(), MaterialParam::printParam(), and MaterialParam::setupFullName().
void printParam | ( | FILE * | fp | ) |
Definition at line 161 of file MaterialParam.cpp.
References TextureParam::alphaChannel, Buffer::buf, TextureParam::color, TextureParam::flipU, TextureParam::flipV, TextureParam::name, TextureParam::rotate, TextureParam::scaleU, TextureParam::scaleV, TextureParam::shiftU, and TextureParam::shiftV.
Referenced by MaterialParam::printParam().
00162 { 00163 fprintf(fp, "TextureParam.name = %s\n", name.buf); 00164 fprintf(fp, "TextureParam.color = (%f,%f,%f,%f) [RGBA]\n", color[0], color[1], color[2], color[3]); 00165 fprintf(fp, "TextureParam.shiftU = %f\n", shiftU); 00166 fprintf(fp, "TextureParam.shiftV = %f\n", shiftV); 00167 fprintf(fp, "TextureParam.scaleU = %f\n", scaleU); 00168 fprintf(fp, "TextureParam.scaleV = %f\n", scaleV); 00169 fprintf(fp, "TextureParam.rotate = %f\n", rotate); 00170 00171 if (alphaChannel) fprintf(fp, "TextureParam.alphaChannel = true\n"); 00172 else fprintf(fp, "TextureParam.alphaChannel = flase\n"); 00173 00174 if (flipU) fprintf(fp, "TextureParam.flipU = true\n"); 00175 else fprintf(fp, "TextureParam.flipU = false\n"); 00176 if (flipV) fprintf(fp, "TextureParam.flipV = true\n"); 00177 else fprintf(fp, "TextureParam.flipV = false\n"); 00178 00179 fflush(fp); 00180 return; 00181 }
void setAlphaChannel | ( | bool | h | ) | [inline] |
Definition at line 112 of file MaterialParam.h.
References TextureParam::alphaChannel.
Referenced by MaterialParam::setAlphaChannel().
00112 { alphaChannel = h;}
void setAlphaCutoff | ( | double | m | ) | [inline] |
Definition at line 114 of file MaterialParam.h.
References TextureParam::alphaCutoff.
Referenced by MaterialParam::setAlphaCutoff().
00114 { alphaCutoff = m;}
void setAlphaMode | ( | int | m | ) | [inline] |
Definition at line 113 of file MaterialParam.h.
References TextureParam::alphaMode.
Referenced by MaterialParam::setAlphaMode().
00113 { alphaMode = m;}
void setColor | ( | double | v, | |
int | c | |||
) | [inline] |
Definition at line 101 of file MaterialParam.h.
References TextureParam::color.
00101 { if(c<0) c = 0; else if(c>3) c = 3; color[c] = v;}
void setColor | ( | double | r, | |
double | g, | |||
double | b, | |||
double | a = 1.0 | |||
) | [inline] |
Definition at line 100 of file MaterialParam.h.
References TextureParam::color.
Referenced by MaterialParam::setColor().
void setFlipU | ( | bool | f | ) | [inline] |
Definition at line 107 of file MaterialParam.h.
References TextureParam::flipU.
Referenced by MaterialParam::setFlipU().
00107 { flipU = f;}
void setFlipV | ( | bool | f | ) | [inline] |
Definition at line 108 of file MaterialParam.h.
References TextureParam::flipV.
Referenced by MaterialParam::setFlipV().
00108 { flipV = f;}
void setName | ( | const char * | nm | ) | [inline] |
Definition at line 96 of file MaterialParam.h.
References free_Buffer(), make_Buffer_bystr, and TextureParam::name.
Referenced by MaterialParam::setBumpMapName(), MaterialParam::setSpecMapName(), and MaterialParam::setTextureName().
00096 { free_Buffer(&name); if(nm!=NULL) name = make_Buffer_bystr(nm);}
void setRotate | ( | double | r | ) | [inline] |
Definition at line 106 of file MaterialParam.h.
References TextureParam::rotate.
Referenced by MaterialParam::setRotate().
00106 { rotate = r;}
void setScale | ( | double | u, | |
double | v | |||
) | [inline] |
Definition at line 110 of file MaterialParam.h.
References TextureParam::scaleU, and TextureParam::scaleV.
void setScaleU | ( | double | u | ) | [inline] |
Definition at line 104 of file MaterialParam.h.
References TextureParam::scaleU.
Referenced by MaterialParam::setScale(), and MaterialParam::setScaleU().
00104 { scaleU = u;}
void setScaleV | ( | double | v | ) | [inline] |
Definition at line 105 of file MaterialParam.h.
References TextureParam::scaleV.
Referenced by MaterialParam::setScale(), and MaterialParam::setScaleV().
00105 { scaleV = v;}
void setShift | ( | double | u, | |
double | v | |||
) | [inline] |
Definition at line 109 of file MaterialParam.h.
References TextureParam::shiftU, and TextureParam::shiftV.
void setShiftU | ( | double | u | ) | [inline] |
Definition at line 102 of file MaterialParam.h.
References TextureParam::shiftU.
Referenced by MaterialParam::setShift(), and MaterialParam::setShiftU().
00102 { shiftU = u;}
void setShiftV | ( | double | v | ) | [inline] |
Definition at line 103 of file MaterialParam.h.
References TextureParam::shiftV.
Referenced by MaterialParam::setShift(), and MaterialParam::setShiftV().
00103 { shiftV = v;}
bool alphaChannel [private] |
Definition at line 64 of file MaterialParam.h.
Referenced by TextureParam::getAlphaChannel(), TextureParam::init(), TextureParam::isSetAlpha(), TextureParam::printParam(), and TextureParam::setAlphaChannel().
double alphaCutoff [private] |
Definition at line 66 of file MaterialParam.h.
Referenced by TextureParam::getAlphaCutoff(), TextureParam::init(), and TextureParam::setAlphaCutoff().
int alphaMode [private] |
Definition at line 65 of file MaterialParam.h.
Referenced by TextureParam::getAlphaMode(), TextureParam::init(), TextureParam::isSetAlpha(), and TextureParam::setAlphaMode().
double color[4] [private] |
Definition at line 62 of file MaterialParam.h.
Referenced by TextureParam::getAlphaMode(), TextureParam::getColor(), TextureParam::init(), TextureParam::isSetColor(), TextureParam::printParam(), and TextureParam::setColor().
bool flipU [private] |
Definition at line 74 of file MaterialParam.h.
Referenced by TextureParam::execInvTrans(), TextureParam::execTrans(), TextureParam::init(), TextureParam::printParam(), and TextureParam::setFlipU().
bool flipV [private] |
Definition at line 75 of file MaterialParam.h.
Referenced by TextureParam::execInvTrans(), TextureParam::execTrans(), TextureParam::init(), TextureParam::printParam(), and TextureParam::setFlipV().
Definition at line 60 of file MaterialParam.h.
Referenced by TextureParam::addName(), TextureParam::dup(), TextureParam::free(), TextureParam::getName(), TextureParam::init(), TextureParam::isSetTexture(), TextureParam::printParam(), and TextureParam::setName().
double rotate [private] |
Definition at line 72 of file MaterialParam.h.
Referenced by TextureParam::execInvRotate(), TextureParam::execRotate(), TextureParam::getRotate(), TextureParam::init(), TextureParam::isSetRotate(), TextureParam::printParam(), and TextureParam::setRotate().
double scaleU [private] |
Definition at line 70 of file MaterialParam.h.
Referenced by TextureParam::execInvScale(), TextureParam::execScale(), TextureParam::getScaleU(), TextureParam::init(), TextureParam::isSetScale(), TextureParam::printParam(), TextureParam::setScale(), and TextureParam::setScaleU().
double scaleV [private] |
Definition at line 71 of file MaterialParam.h.
Referenced by TextureParam::execInvScale(), TextureParam::execScale(), TextureParam::getScaleV(), TextureParam::init(), TextureParam::isSetScale(), TextureParam::printParam(), TextureParam::setScale(), and TextureParam::setScaleV().
double shiftU [private] |
Definition at line 68 of file MaterialParam.h.
Referenced by TextureParam::execInvShift(), TextureParam::execShift(), TextureParam::getShiftU(), TextureParam::init(), TextureParam::isSetShift(), TextureParam::printParam(), TextureParam::setShift(), and TextureParam::setShiftU().
double shiftV [private] |
Definition at line 69 of file MaterialParam.h.
Referenced by TextureParam::execInvShift(), TextureParam::execShift(), TextureParam::getShiftV(), TextureParam::init(), TextureParam::isSetShift(), TextureParam::printParam(), TextureParam::setShift(), and TextureParam::setShiftV().