Merge branch 'storyline/s2e1' into yubo

fix_opengl_on_mac
Ulukyn 5 years ago
commit 521a5c8fb7

@ -3269,77 +3269,79 @@ CRGBAF CBitmap::getColor (float x, float y) const
uint32 i; uint32 i;
bool isValid = true;
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
{ {
nlassert (nX[i] >= 0); if (nX[i] < 0 || nY[i] < 0 || nX[i] >= nWidth || nY[i] >= nHeight)
nlassert (nY[i] >= 0 ); isValid = false;
nlassert (nX[i] < nWidth);
nlassert (nY[i] < nHeight);
} }
// Decimal part of (x,y) if (isValid)
x = x - (float)nX[0];
y = y - (float)nY[0];
switch (this->PixelFormat)
{ {
case RGBA: // Decimal part of (x,y)
case DXTC1: x = x - (float)nX[0];
case DXTC1Alpha: y = y - (float)nY[0];
case DXTC3:
case DXTC5:
{
CRGBAF finalVal;
CRGBA val[4];
if (this->PixelFormat == RGBA) switch (this->PixelFormat)
{
case RGBA:
case DXTC1:
case DXTC1Alpha:
case DXTC3:
case DXTC5:
{ {
for (i = 0; i < 4; ++i) CRGBAF finalVal;
CRGBA val[4];
if (this->PixelFormat == RGBA)
{ {
val[i] = CRGBA (rBitmap[(nX[i]+nY[i]*nWidth)*4+0], for (i = 0; i < 4; ++i)
rBitmap[(nX[i]+nY[i]*nWidth)*4+1], {
rBitmap[(nX[i]+nY[i]*nWidth)*4+2], val[i] = CRGBA (rBitmap[(nX[i]+nY[i]*nWidth)*4+0],
rBitmap[(nX[i]+nY[i]*nWidth)*4+3]); rBitmap[(nX[i]+nY[i]*nWidth)*4+1],
rBitmap[(nX[i]+nY[i]*nWidth)*4+2],
rBitmap[(nX[i]+nY[i]*nWidth)*4+3]);
}
} }
} else
else
{
// slower version : get from DXT
for (i = 0; i < 4; ++i)
{ {
val[i] = getPixelColor(nX[i], nY[i]); // slower version : get from DXT
for (i = 0; i < 4; ++i)
{
val[i] = getPixelColor(nX[i], nY[i]);
}
} }
}
finalVal.R = getColorInterp (x, y, val[0].R, val[1].R, val[2].R, val[3].R); finalVal.R = getColorInterp (x, y, val[0].R, val[1].R, val[2].R, val[3].R);
finalVal.G = getColorInterp (x, y, val[0].G, val[1].G, val[2].G, val[3].G); finalVal.G = getColorInterp (x, y, val[0].G, val[1].G, val[2].G, val[3].G);
finalVal.B = getColorInterp (x, y, val[0].B, val[1].B, val[2].B, val[3].B); finalVal.B = getColorInterp (x, y, val[0].B, val[1].B, val[2].B, val[3].B);
finalVal.A = getColorInterp (x, y, val[0].A, val[1].A, val[2].A, val[3].A); finalVal.A = getColorInterp (x, y, val[0].A, val[1].A, val[2].A, val[3].A);
finalVal /= 255.f; finalVal /= 255.f;
return finalVal; return finalVal;
} }
break; break;
case Alpha: case Alpha:
case Luminance: case Luminance:
{ {
float finalVal; float finalVal;
float val[4]; float val[4];
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
val[i] = rBitmap[(nX[i]+nY[i]*nWidth)]; val[i] = rBitmap[(nX[i]+nY[i]*nWidth)];
finalVal = getColorInterp (x, y, val[0], val[1], val[2], val[3]); finalVal = getColorInterp (x, y, val[0], val[1], val[2], val[3]);
finalVal /= 255.f; finalVal /= 255.f;
if (this->PixelFormat == Alpha) if (this->PixelFormat == Alpha)
return CRGBAF (1.f, 1.f, 1.f, finalVal); return CRGBAF (1.f, 1.f, 1.f, finalVal);
else // Luminance else // Luminance
return CRGBAF (finalVal, finalVal, finalVal, 1.f); return CRGBAF (finalVal, finalVal, finalVal, 1.f);
}
break;
default: break;
} }
break;
default: break;
} }
return CRGBAF (0.0f, 0.0f, 0.0f, 0.0f); return CRGBAF (0.0f, 0.0f, 0.0f, 0.0f);
@ -3626,7 +3628,7 @@ void CBitmap::loadSize(NLMISC::IStream &f, uint32 &retWidth, uint32 &retHeight)
{ {
uint8 imagePrecision = 0; // sample precision uint8 imagePrecision = 0; // sample precision
uint32 imageSize = 0; // width and height uint32 imageSize = 0; // width and height
f.serial(imagePrecision); f.serial(imagePrecision);
f.serial(imageSize); f.serial(imageSize);
NLMISC_BSWAP32(imageSize); NLMISC_BSWAP32(imageSize);

@ -2298,13 +2298,28 @@ int CLuaIHMRyzom::addShape(CLuaState &ls)
if(!instance.empty()) if(!instance.empty())
{ {
if (texture == "#season#" || texture.empty())
{
uint8 selectedTextureSet = (uint8)::computeCurrSeason();
instance.selectTextureSet(selectedTextureSet);
texture = "";
}
else if (texture[0] == '#')
{
uint8 selectedTextureSet;
fromString(texture.substr(1), selectedTextureSet);
instance.selectTextureSet(selectedTextureSet);
texture = "";
}
for(uint j=0;j<instance.getNumMaterials();j++) for(uint j=0;j<instance.getNumMaterials();j++)
{ {
if (!highlight) if (!highlight)
{ {
instance.getMaterial(j).setAmbient(CRGBA(0,0,0,255)); /*instance.getMaterial(j).setAmbient(CRGBA(0,0,0,255));
instance.getMaterial(j).setEmissive(CRGBA(255,255,255,255)); instance.getMaterial(j).setEmissive(CRGBA(255,255,255,255));
instance.getMaterial(j).setShininess(10.0f); instance.getMaterial(j).setShininess(10.0f);*/
} }
else else
{ {

Loading…
Cancel
Save