00001
00032
00033
00034
00035 #include "llviewerprecompiledheaders.h"
00036
00037 #include "llviewerjointshape.h"
00038
00039 #include "llbox.h"
00040 #include "llsphere.h"
00041 #include "llcylinder.h"
00042 #include "llgldbg.h"
00043 #include "llglheaders.h"
00044
00045 F32 LLViewerJointShape::sColorScale = 1.0f;
00046
00047
00048
00049
00050 LLViewerJointShape::LLViewerJointShape()
00051 {
00052 mType = ST_NULL;
00053 mColor[0] = 1.0f;
00054 mColor[1] = 1.0f;
00055 mColor[2] = 1.0f;
00056 mColor[3] = 1.0f;
00057 mTexture = NULL;
00058 }
00059
00060
00061
00062
00063
00064 LLViewerJointShape::LLViewerJointShape( ShapeType type, F32 red, F32 green, F32 blue, F32 alpha )
00065 {
00066 mType = type;
00067 mColor[0] = red * sColorScale;
00068 mColor[1] = green * sColorScale;
00069 mColor[2] = blue * sColorScale;
00070 mColor[3] = alpha;
00071 mTexture = NULL;
00072 }
00073
00074
00075
00076
00077
00078
00079 LLViewerJointShape::~LLViewerJointShape()
00080 {
00081 }
00082
00083
00084
00085
00086
00087 LLViewerJointShape::ShapeType LLViewerJointShape::getType()
00088 {
00089 return mType;
00090 }
00091
00092
00093
00094
00095
00096 void LLViewerJointShape::setType( ShapeType type )
00097 {
00098 mType = type;
00099 }
00100
00101
00102
00103
00104
00105 void LLViewerJointShape::getColor( F32 *red, F32 *green, F32 *blue, F32 *alpha )
00106 {
00107 *red = mColor[0];
00108 *green = mColor[1];
00109 *blue = mColor[2];
00110 *alpha = mColor[3];
00111 }
00112
00113
00114
00115
00116 void LLViewerJointShape::setColor( F32 red, F32 green, F32 blue, F32 alpha )
00117 {
00118 mColor[0] = red * sColorScale;
00119 mColor[1] = green * sColorScale;
00120 mColor[2] = blue * sColorScale;
00121 mColor[3] = alpha;
00122 }
00123
00124
00125
00126
00127
00128 LLViewerImage *LLViewerJointShape::getTexture()
00129 {
00130 return mTexture;
00131 }
00132
00133
00134
00135
00136 void LLViewerJointShape::setTexture( LLViewerImage *texture )
00137 {
00138 mTexture = texture;
00139 }
00140
00141
00142
00143
00144
00145 void LLViewerJointShape::drawBone()
00146 {
00147 }
00148
00149
00150
00151
00152
00153 BOOL LLViewerJointShape::isTransparent()
00154 {
00155 return ( (mColor[3] < 1.0f) ||
00156 (!mTexture.isNull() && (mTexture->getComponents()==4)) );
00157 }
00158
00159
00160
00161
00162 U32 LLViewerJointShape::drawShape( F32 pixelArea, BOOL first_pass )
00163 {
00164 U32 triangle_count = 0;
00165
00166
00167
00168
00169 if (mType == ST_NULL)
00170 {
00171 return triangle_count;
00172 }
00173
00174
00175
00176
00177 glColor4fv(mColor.mV);
00178
00179
00180
00181
00182 glMatrixMode(GL_TEXTURE);
00183 glPushMatrix();
00184 glLoadIdentity();
00185 if (mType == ST_SPHERE)
00186 {
00187 glTranslatef(-0.25f, 0.0f, 0.0f);
00188 }
00189 glMatrixMode(GL_MODELVIEW);
00190 LLViewerImage::bindTexture(mTexture);
00191
00192
00193
00194
00195 F32 s1 = llmax( getScale().mV[VX], llmax( getScale().mV[VY], getScale().mV[VZ] ) );
00196 F32 s2 = llmin( getScale().mV[VX], llmax( getScale().mV[VY], getScale().mV[VZ] ) );
00197 pixelArea *= s1 * s2;
00198
00199
00200
00201
00202 switch ( mType )
00203 {
00204 case ST_CUBE:
00205 gBox.render();
00206 break;
00207
00208 case ST_SPHERE:
00209 gSphere.render( pixelArea );
00210 break;
00211
00212 case ST_CYLINDER:
00213 gCylinder.render( pixelArea );
00214 break;
00215
00216 default:
00217 break;
00218 }
00219
00220
00221
00222
00223 if ( mTexture )
00224 {
00225 glMatrixMode(GL_TEXTURE);
00226 glPopMatrix();
00227 glMatrixMode(GL_MODELVIEW);
00228 }
00229
00230 return triangle_count;
00231 }
00232
00233