// UVから色を取得. void CLatLongMapProxy::getColor( IZ_FLOAT u, IZ_FLOAT v, SFloatColor& color) { IZ_UINT x = static_cast<IZ_UINT>(u * (m_Tex->GetWidth() - 1)); IZ_UINT y = static_cast<IZ_UINT>(v * (m_Tex->GetHeight() - 1)); if (m_Data == IZ_NULL) { IZ_ASSERT(m_Tex); m_Pitch = m_Tex->Lock(0, (void**)&m_Data); } #if 0 IZ_UINT8* data = m_Data + m_Pitch * y + x * m_Bpp; if (m_IsFloat) { IZ_FLOAT* d = reinterpret_cast<IZ_FLOAT*>(data); color.r = d[0]; color.g = d[1]; color.b = d[2]; color.a = d[3]; } else { color.r = NormalizeColor(data[0]); color.g = NormalizeColor(data[1]); color.b = NormalizeColor(data[2]); color.a = NormalizeColor(data[3]); } #else #ifdef ENABLE_BILINEAR CTexProxy::getBiLinearColor( m_IsFloat, m_Tex->GetWidth(), m_Tex->GetHeight(), m_Pitch, m_Bpp, m_Data, u, v, color); #else CTexProxy::getColor( m_IsFloat, x, y, m_Pitch, m_Bpp, m_Data, color); #endif #endif }
void Entity_setColour(){ if ( GlobalSelectionSystem().countSelected() != 0 ) { bool normalize = false; const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path(); Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 ) { const char* strColor = entity->getKeyValue( "_color" ); if ( !string_empty( strColor ) ) { Vector3 rgb; if ( string_parse_vector3( strColor, rgb ) ) { g_entity_globals.color_entity = rgb; } } if ( g_pGameDescription->mGameType == "doom3" ) { normalize = false; } if ( color_dialog( MainFrame_getWindow(), g_entity_globals.color_entity ) ) { if ( normalize ) { NormalizeColor( g_entity_globals.color_entity ); } char buffer[128]; sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0], g_entity_globals.color_entity[1], g_entity_globals.color_entity[2] ); Scene_EntitySetKeyValue_Selected( "_color", buffer ); } } } }
void LoadRGBEToHalfs( const char *name, unsigned short **halfImage, int *width, int *height ) { int i, j; int w, h; float *hdrImage; float *floatbuf; unsigned short *halfbuf; #if 0 w = h = 0; LoadRGBEToFloats( name, &hdrImage, &w, &h, qtrue, qtrue, qtrue ); *width = w; *height = h; *ldrImage = ri.Malloc( w * h * 4 ); pixbuf = *ldrImage; floatbuf = hdrImage; for ( i = 0; i < ( w * h ); i++ ) { for ( j = 0; j < 3; j++ ) { sample[ j ] = *floatbuf++; } NormalizeColor( sample, sample ); *pixbuf++ = ( byte )( sample[ 0 ] * 255 ); *pixbuf++ = ( byte )( sample[ 1 ] * 255 ); *pixbuf++ = ( byte )( sample[ 2 ] * 255 ); *pixbuf++ = ( byte ) 255; } #else w = h = 0; LoadRGBEToFloats( name, &hdrImage, &w, &h, qtrue, qfalse, qtrue ); *width = w; *height = h; *halfImage = ( unsigned short * ) Com_Allocate( w * h * 3 * 6 ); halfbuf = *halfImage; floatbuf = hdrImage; for ( i = 0; i < ( w * h ); i++ ) { for ( j = 0; j < 3; j++ ) { half sample( *floatbuf++ ); *halfbuf++ = sample.bits(); } } #endif Com_Dealloc( hdrImage ); }
void Entity_normalizeColor(){ if ( GlobalSelectionSystem().countSelected() != 0 ) { const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path(); Entity* entity = Node_getEntity( path.top() ); if( entity == 0 && path.size() == 3 ){ entity = Node_getEntity( path.parent() ); } if ( entity != 0 ) { const char* strColor = entity->getKeyValue( "_color" ); if ( !string_empty( strColor ) ) { Vector3 rgb; if ( string_parse_vector3( strColor, rgb ) ) { g_entity_globals.color_entity = rgb; NormalizeColor( g_entity_globals.color_entity ); char buffer[128]; sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0], g_entity_globals.color_entity[1], g_entity_globals.color_entity[2] ); StringOutputStream command( 256 ); command << "entityNormalizeColour " << buffer; UndoableCommand undo( command.c_str() ); Scene_EntitySetKeyValue_Selected( "_color", buffer ); } } } } }
COLORREF CColorSpace::MakeBrightColor(COLORREF color, double brightness) { ASSERT(brightness >= 0.0); ASSERT(brightness <= 1.0); double dred= GetRValue(color) / 255.0; double dgreen= GetGValue(color) / 255.0; double dblue= GetBValue(color) / 255.0; double f= 3.0 * brightness / (dred + dgreen + dblue); dred*= f; dgreen*= f; dblue*= f; int red = (int)(dred * 255); int green = (int)(dgreen * 255); int blue = (int)(dblue * 255); NormalizeColor(red, green, blue); return RGB(red, green, blue); }
void Entity_normalizeColor(){ if ( GlobalSelectionSystem().countSelected() != 0 ) { const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path(); Entity* entity = Node_getEntity( path.top() ); if ( entity != 0 ) { const char* strColor = entity->getKeyValue( "_color" ); if ( !string_empty( strColor ) ) { Vector3 rgb; if ( string_parse_vector3( strColor, rgb ) ) { g_entity_globals.color_entity = rgb; NormalizeColor( g_entity_globals.color_entity ); char buffer[128]; sprintf( buffer, "%g %g %g", g_entity_globals.color_entity[0], g_entity_globals.color_entity[1], g_entity_globals.color_entity[2] ); Scene_EntitySetKeyValue_Selected( "_color", buffer ); } } } } }