Updated color functions for selected and focused objects.

This commit is contained in:
leo 2012-03-25 00:47:53 +00:00
parent 3a045f17d5
commit 296300a9e1
10 changed files with 156 additions and 142 deletions

View file

@ -1,6 +1,7 @@
// Camera object. // Camera object.
#include "lc_global.h" #include "lc_global.h"
#include "lc_colors.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@ -610,37 +611,43 @@ void Camera::Render(float fLineWidth)
// Create the display lists if this is the first time we're rendered. // Create the display lists if this is the first time we're rendered.
if (!m_nList) if (!m_nList)
{ {
m_nList = glGenLists(1); m_nList = glGenLists(1);
UpdateBoundingBox(); UpdateBoundingBox();
} }
if (IsEyeSelected()) if (IsEyeSelected())
{ {
glLineWidth(fLineWidth*2); glLineWidth(fLineWidth*2);
glColor3ubv(FlatColorArray[(m_nState & LC_CAMERA_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); if (m_nState & LC_CAMERA_FOCUSED)
lcSetColorFocused();
else
lcSetColorSelected();
glCallList(m_nList); glCallList(m_nList);
glLineWidth(fLineWidth); glLineWidth(fLineWidth);
} }
else else
{ {
glColor3f(0.5f, 0.8f, 0.5f); lcSetColorCamera();
glCallList(m_nList); glCallList(m_nList);
} }
if (IsTargetSelected()) if (IsTargetSelected())
{ {
glLineWidth(fLineWidth*2); glLineWidth(fLineWidth*2);
glColor3ubv(FlatColorArray[(m_nState & LC_CAMERA_TARGET_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); if (m_nState & LC_CAMERA_TARGET_FOCUSED)
lcSetColorFocused();
else
lcSetColorSelected();
glCallList(m_nTargetList); glCallList(m_nTargetList);
glLineWidth(fLineWidth); glLineWidth(fLineWidth);
} }
else else
{ {
glColor3f(0.5f, 0.8f, 0.5f); lcSetColorCamera();
glCallList(m_nTargetList); glCallList(m_nTargetList);
} }
glColor3f(0.5f, 0.8f, 0.5f); lcSetColorCamera();
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex3fv(m_fEye); glVertex3fv(m_fEye);
glVertex3fv(m_fTarget); glVertex3fv(m_fTarget);

View file

@ -2,6 +2,7 @@
// //
#include "lc_global.h" #include "lc_global.h"
#include "lc_colors.h"
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include "globals.h" #include "globals.h"
@ -215,13 +216,11 @@ void CurvePoint::Select (bool bSelecting, bool bFocus, bool bMultiple)
void CurvePoint::Render (LC_RENDER_INFO* pInfo) void CurvePoint::Render (LC_RENDER_INFO* pInfo)
{ {
if (m_nState & LC_CURVE_POINT_FOCUSED) if (m_nState & LC_CURVE_POINT_FOCUSED)
glColor3ubv (FlatColorArray[LC_COL_FOCUSED]); lcSetColorFocused();
else if (m_nState & LC_CURVE_POINT_SELECTED) else if (m_nState & LC_CURVE_POINT_SELECTED)
glColor3ubv (FlatColorArray[LC_COL_SELECTED]); lcSetColorSelected();
else else
glColor3f(0.5f, 0.8f, 0.5f); // FIXME: same as camera color, add to FlatColorArray lcSetColorCamera(); // FIXME: same as camera color
// glColor3ub (0, 0, 0); // FIXME: inverse of background
// FIXME: add a new color to the array and change the names from LC_COL to LC_COLOR ?
glPushMatrix (); glPushMatrix ();
glTranslatef (m_fPos[0], m_fPos[1], m_fPos[2]); glTranslatef (m_fPos[0], m_fPos[1], m_fPos[2]);
@ -661,13 +660,11 @@ void Curve::Render (LC_RENDER_INFO* pInfo)
for (int i = 0; i < m_nNumPoints; i++) for (int i = 0; i < m_nNumPoints; i++)
{ {
if (m_pPoints[i].m_nFlags & LC_CURVE_POINT_FOCUSED) if (m_pPoints[i].m_nFlags & LC_CURVE_POINT_FOCUSED)
glColor3ubv (FlatColorArray[LC_COL_FOCUSED]); lcSetColorFocused();
else if (m_pPoints[i].m_nFlags & LC_CURVE_POINT_SELECTED) else if (m_pPoints[i].m_nFlags & LC_CURVE_POINT_SELECTED)
glColor3ubv (FlatColorArray[LC_COL_SELECTED]); lcSetColorSelected();
else else
glColor3f(0.5f, 0.8f, 0.5f); // FIXME: same as camera color, add to FlatColorArray lcSetColorCamera(); // FIXME: same as camera color
// glColor3ub (0, 0, 0); // FIXME: inverse of background
// FIXME: add a new color to the array and change the names from LC_COL to LC_COLOR ?
glPushMatrix (); glPushMatrix ();
// RenderSegment (m_pPoints[i].m_fPos, m_pPoints[i+1].m_fPos, m_pSegments[i].m_fR1, m_pSegments[i].m_fR2); // RenderSegment (m_pPoints[i].m_fPos, m_pPoints[i+1].m_fPos, m_pSegments[i].m_fR1, m_pSegments[i].m_fR2);

View file

@ -130,8 +130,6 @@ int stricmp(const char* str1, const char* str2);
#define LC_MAXCOLORS 28 // Number of colors supported #define LC_MAXCOLORS 28 // Number of colors supported
#define LC_COL_EDGES 28 // Piece edges #define LC_COL_EDGES 28 // Piece edges
#define LC_COL_SELECTED 29 // Selected object
#define LC_COL_FOCUSED 30 // Focused object
#define LC_COL_DEFAULT 31 // Default piece color #define LC_COL_DEFAULT 31 // Default piece color

View file

@ -6,7 +6,6 @@
//#include "system.h" //#include "system.h"
lcColor* gColorList; lcColor* gColorList;
//int gNumUserColors;
int gNumColors; int gNumColors;
static const char sDefaultColors[] = static const char sDefaultColors[] =
@ -14,12 +13,12 @@ static const char sDefaultColors[] =
"0 LDraw.org Configuration File\n" "0 LDraw.org Configuration File\n"
"0 Name: LDConfig.ldr\n" "0 Name: LDConfig.ldr\n"
"0 Author: LDraw.org\n" "0 Author: LDraw.org\n"
"0 !LDRAW_ORG Configuration UPDATE 2011-06-03\n" "0 !LDRAW_ORG Configuration UPDATE 2012-01-06\n"
"\n" "\n"
"0 // LDraw Solid Colours\n" "0 // LDraw Solid Colours\n"
"0 !COLOUR Black CODE 0 VALUE #05131D EDGE #595959\n" "0 !COLOUR Black CODE 0 VALUE #05131D EDGE #595959\n"
"0 !COLOUR Blue CODE 1 VALUE #0055BF EDGE #333333\n" "0 !COLOUR Blue CODE 1 VALUE #0055BF EDGE #333333\n"
"0 !COLOUR Green CODE 2 VALUE #237841 EDGE #333333\n" "0 !COLOUR Green CODE 2 VALUE #257A3E EDGE #333333\n"
"0 !COLOUR Dark_Turquoise CODE 3 VALUE #008F9B EDGE #333333\n" "0 !COLOUR Dark_Turquoise CODE 3 VALUE #008F9B EDGE #333333\n"
"0 !COLOUR Red CODE 4 VALUE #C91A09 EDGE #333333\n" "0 !COLOUR Red CODE 4 VALUE #C91A09 EDGE #333333\n"
"0 !COLOUR Dark_Pink CODE 5 VALUE #C870A0 EDGE #333333\n" "0 !COLOUR Dark_Pink CODE 5 VALUE #C870A0 EDGE #333333\n"
@ -41,12 +40,14 @@ static const char sDefaultColors[] =
"0 !COLOUR Dark_Blue_Violet CODE 23 VALUE #2032B0 EDGE #1E1E1E\n" "0 !COLOUR Dark_Blue_Violet CODE 23 VALUE #2032B0 EDGE #1E1E1E\n"
"0 !COLOUR Orange CODE 25 VALUE #FE8A18 EDGE #333333\n" "0 !COLOUR Orange CODE 25 VALUE #FE8A18 EDGE #333333\n"
"0 !COLOUR Magenta CODE 26 VALUE #923978 EDGE #333333\n" "0 !COLOUR Magenta CODE 26 VALUE #923978 EDGE #333333\n"
"0 !COLOUR Lime CODE 27 VALUE #BBE90B EDGE #333333\n" "0 !COLOUR Lime CODE 27 VALUE #A5D426 EDGE #333333\n"
"0 !COLOUR Dark_Tan CODE 28 VALUE #958A73 EDGE #333333\n" "0 !COLOUR Dark_Tan CODE 28 VALUE #958A73 EDGE #333333\n"
"0 !COLOUR Bright_Pink CODE 29 VALUE #E4ADC8 EDGE #333333\n" "0 !COLOUR Bright_Pink CODE 29 VALUE #E4ADC8 EDGE #333333\n"
"0 !COLOUR Medium_Lavender CODE 30 VALUE #AC78BA EDGE #333333\n"
"0 !COLOUR Lavender CODE 31 VALUE #E1D5ED EDGE #333333\n"
"0 !COLOUR Very_Light_Orange CODE 68 VALUE #F3CF9B EDGE #333333\n" "0 !COLOUR Very_Light_Orange CODE 68 VALUE #F3CF9B EDGE #333333\n"
"0 !COLOUR Light_Purple CODE 69 VALUE #CD6298 EDGE #333333\n" "0 !COLOUR Light_Purple CODE 69 VALUE #CD6298 EDGE #333333\n"
"0 !COLOUR Reddish_Brown CODE 70 VALUE #582A12 EDGE #333333\n" "0 !COLOUR Reddish_Brown CODE 70 VALUE #582A12 EDGE #595959\n"
"0 !COLOUR Light_Bluish_Gray CODE 71 VALUE #A0A5A9 EDGE #333333\n" "0 !COLOUR Light_Bluish_Gray CODE 71 VALUE #A0A5A9 EDGE #333333\n"
"0 !COLOUR Dark_Bluish_Gray CODE 72 VALUE #6C6E68 EDGE #333333\n" "0 !COLOUR Dark_Bluish_Gray CODE 72 VALUE #6C6E68 EDGE #333333\n"
"0 !COLOUR Medium_Blue CODE 73 VALUE #5A93DB EDGE #333333\n" "0 !COLOUR Medium_Blue CODE 73 VALUE #5A93DB EDGE #333333\n"
@ -68,16 +69,18 @@ static const char sDefaultColors[] =
"0 !COLOUR Very_Light_Bluish_Gray CODE 151 VALUE #E6E3E0 EDGE #333333\n" "0 !COLOUR Very_Light_Bluish_Gray CODE 151 VALUE #E6E3E0 EDGE #333333\n"
"0 !COLOUR Bright_Light_Orange CODE 191 VALUE #F8BB3D EDGE #333333\n" "0 !COLOUR Bright_Light_Orange CODE 191 VALUE #F8BB3D EDGE #333333\n"
"0 !COLOUR Bright_Light_Blue CODE 212 VALUE #9FC3E9 EDGE #333333\n" "0 !COLOUR Bright_Light_Blue CODE 212 VALUE #9FC3E9 EDGE #333333\n"
"0 !COLOUR Rust CODE 216 VALUE #B31004 EDGE #333333\n" "0 !COLOUR Rust CODE 216 VALUE #A52D0A EDGE #333333\n"
"0 !COLOUR Bright_Light_Yellow CODE 226 VALUE #FFF03A EDGE #333333\n" "0 !COLOUR Bright_Light_Yellow CODE 226 VALUE #FFF03A EDGE #333333\n"
"0 !COLOUR Sky_Blue CODE 232 VALUE #7DBFDD EDGE #333333\n" "0 !COLOUR Sky_Blue CODE 232 VALUE #7DBFDD EDGE #333333\n"
"0 !COLOUR Dark_Blue CODE 272 VALUE #0A3463 EDGE #1E1E1E\n" "0 !COLOUR Dark_Blue CODE 272 VALUE #0A3463 EDGE #1E1E1E\n"
"0 !COLOUR Dark_Green CODE 288 VALUE #184632 EDGE #333333\n" "0 !COLOUR Dark_Green CODE 288 VALUE #184632 EDGE #595959\n"
"0 !COLOUR Dark_Brown CODE 308 VALUE #352100 EDGE #000000\n" "0 !COLOUR Dark_Brown CODE 308 VALUE #352100 EDGE #595959\n"
"0 !COLOUR Maersk_Blue CODE 313 VALUE #3592C3 EDGE #333333\n" "0 !COLOUR Maersk_Blue CODE 313 VALUE #3592C3 EDGE #333333\n"
"0 !COLOUR Dark_Red CODE 320 VALUE #720E0F EDGE #333333\n" "0 !COLOUR Dark_Red CODE 320 VALUE #720E0F EDGE #333333\n"
"0 !COLOUR Dark_Azure CODE 321 VALUE #078BC9 EDGE #088DCD\n" "0 !COLOUR Dark_Azure CODE 321 VALUE #078BC9 EDGE #333333\n"
"0 !COLOUR Light_Aqua CODE 323 VALUE #ADC3C0 EDGE #AFC9C2\n" "0 !COLOUR Medium_Azure CODE 322 VALUE #36AEBF EDGE #333333\n"
"0 !COLOUR Light_Aqua CODE 323 VALUE #ADC3C0 EDGE #333333\n"
"0 !COLOUR Olive_Green CODE 326 VALUE #9B9A5A EDGE #333333\n"
"0 !COLOUR Sand_Red CODE 335 VALUE #D67572 EDGE #333333\n" "0 !COLOUR Sand_Red CODE 335 VALUE #D67572 EDGE #333333\n"
"0 !COLOUR Medium_Dark_Pink CODE 351 VALUE #F785B1 EDGE #333333\n" "0 !COLOUR Medium_Dark_Pink CODE 351 VALUE #F785B1 EDGE #333333\n"
"0 !COLOUR Earth_Orange CODE 366 VALUE #FA9C1C EDGE #333333\n" "0 !COLOUR Earth_Orange CODE 366 VALUE #FA9C1C EDGE #333333\n"
@ -98,8 +101,8 @@ static const char sDefaultColors[] =
"0 !COLOUR Trans_Neon_Yellow CODE 54 VALUE #DAB000 EDGE #C3BA3F ALPHA 128\n" "0 !COLOUR Trans_Neon_Yellow CODE 54 VALUE #DAB000 EDGE #C3BA3F ALPHA 128\n"
"0 !COLOUR Trans_Yellow CODE 46 VALUE #F5CD2F EDGE #8E7400 ALPHA 128\n" "0 !COLOUR Trans_Yellow CODE 46 VALUE #F5CD2F EDGE #8E7400 ALPHA 128\n"
"0 !COLOUR Trans_Neon_Green CODE 42 VALUE #C0FF00 EDGE #84C300 ALPHA 128\n" "0 !COLOUR Trans_Neon_Green CODE 42 VALUE #C0FF00 EDGE #84C300 ALPHA 128\n"
"0 !COLOUR Trans_Bright_Green CODE 35 VALUE #D9E4A7 EDGE #9DA86B ALPHA 128\n" "0 !COLOUR Trans_Bright_Green CODE 35 VALUE #56E646 EDGE #9DA86B ALPHA 128\n"
"0 !COLOUR Trans_Green CODE 34 VALUE #84B68D EDGE #002800 ALPHA 128\n" "0 !COLOUR Trans_Green CODE 34 VALUE #237841 EDGE #1E6239 ALPHA 128\n"
"0 !COLOUR Trans_Dark_Blue CODE 33 VALUE #0020A0 EDGE #000064 ALPHA 128\n" "0 !COLOUR Trans_Dark_Blue CODE 33 VALUE #0020A0 EDGE #000064 ALPHA 128\n"
"0 !COLOUR Trans_Medium_Blue CODE 41 VALUE #559AB7 EDGE #196973 ALPHA 128\n" "0 !COLOUR Trans_Medium_Blue CODE 41 VALUE #559AB7 EDGE #196973 ALPHA 128\n"
"0 !COLOUR Trans_Light_Blue CODE 43 VALUE #AEE9EF EDGE #72B3B0 ALPHA 128\n" "0 !COLOUR Trans_Light_Blue CODE 43 VALUE #AEE9EF EDGE #72B3B0 ALPHA 128\n"
@ -113,7 +116,7 @@ static const char sDefaultColors[] =
"0 !COLOUR Chrome_Gold CODE 334 VALUE #BBA53D EDGE #BBB23D CHROME\n" "0 !COLOUR Chrome_Gold CODE 334 VALUE #BBA53D EDGE #BBB23D CHROME\n"
"0 !COLOUR Chrome_Silver CODE 383 VALUE #E0E0E0 EDGE #A4A4A4 CHROME\n" "0 !COLOUR Chrome_Silver CODE 383 VALUE #E0E0E0 EDGE #A4A4A4 CHROME\n"
"0 !COLOUR Chrome_Antique_Brass CODE 60 VALUE #645A4C EDGE #281E10 CHROME\n" "0 !COLOUR Chrome_Antique_Brass CODE 60 VALUE #645A4C EDGE #281E10 CHROME\n"
"0 !COLOUR Chrome_Black CODE 64 VALUE #1B2A34 EDGE #000000 CHROME\n" "0 !COLOUR Chrome_Black CODE 64 VALUE #1B2A34 EDGE #595959 CHROME\n"
"0 !COLOUR Chrome_Blue CODE 61 VALUE #6C96BF EDGE #202A68 CHROME\n" "0 !COLOUR Chrome_Blue CODE 61 VALUE #6C96BF EDGE #202A68 CHROME\n"
"0 !COLOUR Chrome_Green CODE 62 VALUE #3CB371 EDGE #007735 CHROME\n" "0 !COLOUR Chrome_Green CODE 62 VALUE #3CB371 EDGE #007735 CHROME\n"
"0 !COLOUR Chrome_Pink CODE 63 VALUE #AA4D8E EDGE #6E1152 CHROME\n" "0 !COLOUR Chrome_Pink CODE 63 VALUE #AA4D8E EDGE #6E1152 CHROME\n"
@ -134,8 +137,8 @@ static const char sDefaultColors[] =
"0 !COLOUR Metallic_Silver CODE 80 VALUE #A5A9B4 EDGE #333333 METAL\n" "0 !COLOUR Metallic_Silver CODE 80 VALUE #A5A9B4 EDGE #333333 METAL\n"
"0 !COLOUR Metallic_Green CODE 81 VALUE #899B5F EDGE #333333 METAL\n" "0 !COLOUR Metallic_Green CODE 81 VALUE #899B5F EDGE #333333 METAL\n"
"0 !COLOUR Metallic_Gold CODE 82 VALUE #DBAC34 EDGE #333333 METAL\n" "0 !COLOUR Metallic_Gold CODE 82 VALUE #DBAC34 EDGE #333333 METAL\n"
"0 !COLOUR Metallic_Black CODE 83 VALUE #1A2831 EDGE #000000 METAL\n" "0 !COLOUR Metallic_Black CODE 83 VALUE #1A2831 EDGE #333333 METAL\n"
"0 !COLOUR Metallic_Dark_Gray CODE 87 VALUE #6D6E5C EDGE #5D5B53 METAL\n" "0 !COLOUR Metallic_Dark_Gray CODE 87 VALUE #6D6E5C EDGE #333333 METAL\n"
"\n" "\n"
"0 // LDraw Milky Colours\n" "0 // LDraw Milky Colours\n"
"0 !COLOUR Milky_White CODE 79 VALUE #FFFFFF EDGE #C3C3C3 ALPHA 224\n" "0 !COLOUR Milky_White CODE 79 VALUE #FFFFFF EDGE #C3C3C3 ALPHA 224\n"
@ -144,24 +147,24 @@ static const char sDefaultColors[] =
"\n" "\n"
"0 // LDraw Glitter Colours\n" "0 // LDraw Glitter Colours\n"
"0 !COLOUR Glitter_Trans_Dark_Pink CODE 114 VALUE #DF6695 EDGE #9A2A66 ALPHA 128 MATERIAL GLITTER VALUE #923978 FRACTION 0.17 VFRACTION 0.2 SIZE 1\n" "0 !COLOUR Glitter_Trans_Dark_Pink CODE 114 VALUE #DF6695 EDGE #9A2A66 ALPHA 128 MATERIAL GLITTER VALUE #923978 FRACTION 0.17 VFRACTION 0.2 SIZE 1\n"
"0 !COLOUR Glitter_Trans_Clear CODE 117 VALUE #FFFFFF EDGE #C3C3C3 ALPHA 128 MATERIAL GLITTER VALUE #FFFFFF FRACTION 0.08 VFRACTION 0.1 SIZE 1\n" "0 !COLOUR Glitter_Trans_Clear CODE 117 VALUE #FCFCFC EDGE #C3C3C3 ALPHA 128 MATERIAL GLITTER VALUE #FFFFFF FRACTION 0.08 VFRACTION 0.1 SIZE 1\n"
"0 !COLOUR Glitter_Trans_Purple CODE 129 VALUE #640061 EDGE #280025 ALPHA 128 MATERIAL GLITTER VALUE #8C00FF FRACTION 0.3 VFRACTION 0.4 SIZE 1\n" "0 !COLOUR Glitter_Trans_Purple CODE 129 VALUE #640061 EDGE #280025 ALPHA 128 MATERIAL GLITTER VALUE #8C00FF FRACTION 0.3 VFRACTION 0.4 SIZE 1\n"
"\n" "\n"
"0 // LDraw Speckle Colours\n" "0 // LDraw Speckle Colours\n"
"0 !COLOUR Speckle_Black_Silver CODE 132 VALUE #000000 EDGE #595959 MATERIAL SPECKLE VALUE #595959 FRACTION 0.4 MINSIZE 1 MAXSIZE 3\n" "0 !COLOUR Speckle_Black_Silver CODE 132 VALUE #000000 EDGE #898788 MATERIAL SPECKLE VALUE #898788 FRACTION 0.4 MINSIZE 1 MAXSIZE 3\n"
"0 !COLOUR Speckle_Black_Gold CODE 133 VALUE #000000 EDGE #DBAC34 MATERIAL SPECKLE VALUE #AE7A59 FRACTION 0.4 MINSIZE 1 MAXSIZE 3\n" "0 !COLOUR Speckle_Black_Gold CODE 133 VALUE #000000 EDGE #DBAC34 MATERIAL SPECKLE VALUE #DBAC34 FRACTION 0.4 MINSIZE 1 MAXSIZE 3\n"
"0 !COLOUR Speckle_Black_Copper CODE 75 VALUE #000000 EDGE #595959 MATERIAL SPECKLE VALUE #AE7A59 FRACTION 0.4 MINSIZE 1 MAXSIZE 3\n" "0 !COLOUR Speckle_Black_Copper CODE 75 VALUE #000000 EDGE #AB6038 MATERIAL SPECKLE VALUE #AB6038 FRACTION 0.4 MINSIZE 1 MAXSIZE 3\n"
"0 !COLOUR Speckle_Dark_Bluish_Gray_Silver CODE 76 VALUE #635F61 EDGE #595959 MATERIAL SPECKLE VALUE #595959 FRACTION 0.4 MINSIZE 1 MAXSIZE 3\n" "0 !COLOUR Speckle_Dark_Bluish_Gray_Silver CODE 76 VALUE #635F61 EDGE #898788 MATERIAL SPECKLE VALUE #898788 FRACTION 0.4 MINSIZE 1 MAXSIZE 3\n"
"\n" "\n"
"0 // LDraw Rubber Colours\n" "0 // LDraw Rubber Colours\n"
"0 !COLOUR Rubber_Yellow CODE 65 VALUE #F5CD2F EDGE #333333 RUBBER\n" "0 !COLOUR Rubber_Yellow CODE 65 VALUE #ECC935 EDGE #333333 RUBBER\n"
"0 !COLOUR Rubber_Trans_Yellow CODE 66 VALUE #CAB000 EDGE #8E7400 ALPHA 128 RUBBER\n" "0 !COLOUR Rubber_Trans_Yellow CODE 66 VALUE #CAB000 EDGE #8E7400 ALPHA 128 RUBBER\n"
"0 !COLOUR Rubber_Trans_Clear CODE 67 VALUE #FFFFFF EDGE #C3C3C3 ALPHA 128 RUBBER\n" "0 !COLOUR Rubber_Trans_Clear CODE 67 VALUE #FFFFFF EDGE #C3C3C3 ALPHA 128 RUBBER\n"
"0 !COLOUR Rubber_Black CODE 256 VALUE #212121 EDGE #595959 RUBBER\n" "0 !COLOUR Rubber_Black CODE 256 VALUE #212121 EDGE #595959 RUBBER\n"
"0 !COLOUR Rubber_Blue CODE 273 VALUE #0033B2 EDGE #333333 RUBBER\n" "0 !COLOUR Rubber_Blue CODE 273 VALUE #0033B2 EDGE #333333 RUBBER\n"
"0 !COLOUR Rubber_Red CODE 324 VALUE #C40026 EDGE #333333 RUBBER\n" "0 !COLOUR Rubber_Red CODE 324 VALUE #C40026 EDGE #333333 RUBBER\n"
"0 !COLOUR Rubber_Light_Gray CODE 375 VALUE #C1C2C1 EDGE #333333 RUBBER\n" "0 !COLOUR Rubber_Light_Gray CODE 375 VALUE #C1C2C1 EDGE #333333 RUBBER\n"
"0 !COLOUR Rubber_Dark_Blue CODE 406 VALUE #001D68 EDGE #333333 RUBBER\n" "0 !COLOUR Rubber_Dark_Blue CODE 406 VALUE #001D68 EDGE #595959 RUBBER\n"
"0 !COLOUR Rubber_Purple CODE 449 VALUE #81007B EDGE #333333 RUBBER\n" "0 !COLOUR Rubber_Purple CODE 449 VALUE #81007B EDGE #333333 RUBBER\n"
"0 !COLOUR Rubber_Lime CODE 490 VALUE #D7F000 EDGE #333333 RUBBER\n" "0 !COLOUR Rubber_Lime CODE 490 VALUE #D7F000 EDGE #333333 RUBBER\n"
"0 !COLOUR Rubber_Light_Bluish_Gray CODE 496 VALUE #A3A2A4 EDGE #333333 RUBBER\n" "0 !COLOUR Rubber_Light_Bluish_Gray CODE 496 VALUE #A3A2A4 EDGE #333333 RUBBER\n"
@ -171,9 +174,11 @@ static const char sDefaultColors[] =
"0 // LDraw Internal Common Material Colours\n" "0 // LDraw Internal Common Material Colours\n"
"0 !COLOUR Main_Colour CODE 16 VALUE #7F7F7F EDGE #333333\n" "0 !COLOUR Main_Colour CODE 16 VALUE #7F7F7F EDGE #333333\n"
"0 !COLOUR Edge_Colour CODE 24 VALUE #7F7F7F EDGE #333333\n" "0 !COLOUR Edge_Colour CODE 24 VALUE #7F7F7F EDGE #333333\n"
"0 !COLOUR Trans_Black_IR_Lens CODE 32 VALUE #000000 EDGE #05131D ALPHA 220\n" "0 !COLOUR Trans_Black_IR_Lens CODE 32 VALUE #000000 EDGE #333333 ALPHA 200\n"
"0 !COLOUR Magnet CODE 493 VALUE #656761 EDGE #595959 METAL\n"
"0 !COLOUR Electric_Contact_Alloy CODE 494 VALUE #D0D0D0 EDGE #6E6E6E METAL\n" "0 !COLOUR Electric_Contact_Alloy CODE 494 VALUE #D0D0D0 EDGE #6E6E6E METAL\n"
"0 !COLOUR Electric_Contact_Copper CODE 495 VALUE #AE7A59 EDGE #723E1D METAL\n" "0 !COLOUR Electric_Contact_Copper CODE 495 VALUE #AE7A59 EDGE #723E1D METAL\n"
"0\n"
}; };
static void GetToken(char*& Ptr, char* Token) static void GetToken(char*& Ptr, char* Token)

View file

@ -15,6 +15,32 @@ struct lcColor
extern lcColor* gColorList; extern lcColor* gColorList;
extern int gNumColors; extern int gNumColors;
inline void lcSetColor(int ColorIndex)
{
float* Color = gColorList[ColorIndex].Value;
glColor4f(Color[0], Color[1], Color[2], Color[3]);
}
inline void lcSetColorFocused()
{
glColor4f(0.4000f, 0.2980f, 0.8980f, 1.0000f);
}
inline void lcSetColorSelected()
{
glColor4f(0.8980f, 0.2980f, 0.4000f, 1.0000f);
}
inline void lcSetColorCamera()
{
glColor4f(0.5f, 0.8f, 0.5f, 1.0f);
}
inline void lcSetColorLight()
{
glColor4f(0.5f, 0.8f, 0.5f, 1.0f);
}
/* /*
void lcColorInit(const char* FileName); void lcColorInit(const char* FileName);
void lcColorShutdown(); void lcColorShutdown();
@ -24,8 +50,6 @@ void lcColorShutdown();
//#define LC_MAXCOLORS 28 // Number of colors supported //#define LC_MAXCOLORS 28 // Number of colors supported
//#define LC_COL_EDGES 28 // Piece edges //#define LC_COL_EDGES 28 // Piece edges
//#define LC_COL_SELECTED 29 // Selected object
//#define LC_COL_FOCUSED 30 // Focused object
//#define LC_COL_DEFAULT 31 // Default piece color //#define LC_COL_DEFAULT 31 // Default piece color
*/ */

View file

@ -1,6 +1,7 @@
// Light object. // Light object.
#include "lc_global.h" #include "lc_global.h"
#include "lc_colors.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -432,30 +433,36 @@ void Light::Render (float fLineWidth)
if (IsEyeSelected()) if (IsEyeSelected())
{ {
glLineWidth(fLineWidth*2); glLineWidth(fLineWidth*2);
glColor3ubv(FlatColorArray[(m_nState & LC_LIGHT_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); if (m_nState & LC_LIGHT_FOCUSED)
lcSetColorFocused();
else
lcSetColorSelected();
glCallList(m_nList); glCallList(m_nList);
glLineWidth(fLineWidth); glLineWidth(fLineWidth);
} }
else else
{ {
glColor3f(0.5f, 0.8f, 0.5f); lcSetColorLight();
glCallList(m_nList); glCallList(m_nList);
} }
if (IsTargetSelected()) if (IsTargetSelected())
{ {
glLineWidth(fLineWidth*2); glLineWidth(fLineWidth*2);
glColor3ubv(FlatColorArray[(m_nState & LC_LIGHT_TARGET_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); if (m_nState & LC_LIGHT_TARGET_FOCUSED)
lcSetColorFocused();
else
lcSetColorSelected();
glCallList(m_nTargetList); glCallList(m_nTargetList);
glLineWidth(fLineWidth); glLineWidth(fLineWidth);
} }
else else
{ {
glColor3f(0.5f, 0.8f, 0.5f); lcSetColorLight();
glCallList(m_nTargetList); glCallList(m_nTargetList);
} }
glColor3f(0.5f, 0.8f, 0.5f); lcSetColorLight();
glBegin(GL_LINES); glBegin(GL_LINES);
glVertex3fv(m_fPos); glVertex3fv(m_fPos);
glVertex3fv(m_fTarget); glVertex3fv(m_fTarget);
@ -526,13 +533,16 @@ void Light::Render (float fLineWidth)
if (IsEyeSelected ()) if (IsEyeSelected ())
{ {
glLineWidth (fLineWidth*2); glLineWidth (fLineWidth*2);
glColor3ubv (FlatColorArray[(m_nState & LC_LIGHT_FOCUSED) != 0 ? LC_COL_FOCUSED : LC_COL_SELECTED]); if (m_nState & LC_LIGHT_FOCUSED)
lcSetColorFocused();
else
lcSetColorSelected();
glCallList (m_nSphereList); glCallList (m_nSphereList);
glLineWidth (fLineWidth); glLineWidth (fLineWidth);
} }
else else
{ {
glColor3f (0.5f, 0.8f, 0.5f); lcSetColorLight();
glCallList (m_nSphereList); glCallList (m_nSphereList);
} }

View file

@ -2,7 +2,6 @@
#define _OPENGL_H_ #define _OPENGL_H_
#ifdef LC_WINDOWS #ifdef LC_WINDOWS
#include "stdafx.h"
#include <GL/gl.h> #include <GL/gl.h>
#include "win_gl.h" #include "win_gl.h"
#else #else

View file

@ -2,6 +2,7 @@
// //
#include "lc_global.h" #include "lc_global.h"
#include "lc_colors.h"
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
@ -27,7 +28,7 @@ static LC_OBJECT_KEY_INFO piece_key_info[LC_PK_COUNT] =
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Static functions // Static functions
inline static void SetCurrentColor(unsigned char nColor, bool* bTrans, bool bLighting) inline static void SetCurrentColor(unsigned char nColor, bool bLighting)
{ {
bool Transparent = (nColor > 13 && nColor < 22); bool Transparent = (nColor > 13 && nColor < 22);
@ -41,22 +42,14 @@ inline static void SetCurrentColor(unsigned char nColor, bool* bTrans, bool bLig
if (Transparent) if (Transparent)
{ {
if (!*bTrans) glEnable(GL_BLEND);
{ glDepthMask(GL_FALSE);
*bTrans = true; glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glDepthMask(GL_FALSE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
} }
else else
{ {
if (*bTrans) glDepthMask(GL_TRUE);
{ glDisable(GL_BLEND);
*bTrans = false;
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
}
} }
} }
@ -1147,7 +1140,10 @@ void Piece::RenderBox(bool bHilite, float fLineWidth)
if (bHilite && ((m_nState & LC_PIECE_SELECTED) != 0)) if (bHilite && ((m_nState & LC_PIECE_SELECTED) != 0))
{ {
glColor3ubv(FlatColorArray[m_nState & LC_PIECE_FOCUSED ? LC_COL_FOCUSED : LC_COL_SELECTED]); if (m_nState & LC_PIECE_FOCUSED)
lcSetColorFocused();
else
lcSetColorSelected();
glLineWidth(2*fLineWidth); glLineWidth(2*fLineWidth);
glPushAttrib(GL_POLYGON_BIT); glPushAttrib(GL_POLYGON_BIT);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
@ -1163,7 +1159,7 @@ void Piece::RenderBox(bool bHilite, float fLineWidth)
glPopMatrix(); glPopMatrix();
} }
void Piece::Render(bool bLighting, bool bEdges, unsigned char* nLastColor, bool* bTrans) void Piece::Render(bool bLighting, bool bEdges)
{ {
glPushMatrix(); glPushMatrix();
glTranslatef(m_fPosition[0], m_fPosition[1], m_fPosition[2]); glTranslatef(m_fPosition[0], m_fPosition[1], m_fPosition[2]);
@ -1176,10 +1172,7 @@ void Piece::Render(bool bLighting, bool bEdges, unsigned char* nLastColor, bool*
m_pPieceInfo->m_pTextures[sh].texture->MakeCurrent(); m_pPieceInfo->m_pTextures[sh].texture->MakeCurrent();
if (m_pPieceInfo->m_pTextures[sh].color == LC_COL_DEFAULT) if (m_pPieceInfo->m_pTextures[sh].color == LC_COL_DEFAULT)
{ SetCurrentColor(m_nColor, bLighting);
SetCurrentColor(m_nColor, bTrans, bLighting);
*nLastColor = m_nColor;
}
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBegin(GL_QUADS); glBegin(GL_QUADS);
@ -1205,19 +1198,10 @@ void Piece::Render(bool bLighting, bool bEdges, unsigned char* nLastColor, bool*
{ {
bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES); bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES);
if (*info != *nLastColor) if (*info == LC_COL_DEFAULT)
{ SetCurrentColor(m_nColor, bLighting);
if (*info == LC_COL_DEFAULT) else
{ SetCurrentColor((unsigned char)*info, bLighting);
SetCurrentColor(m_nColor, bTrans, bLighting);
*nLastColor = m_nColor;
}
else
{
SetCurrentColor((unsigned char)*info, bTrans, bLighting);
*nLastColor = (unsigned char)*info;
}
}
info++; info++;
if (lock) if (lock)
@ -1241,24 +1225,26 @@ void Piece::Render(bool bLighting, bool bEdges, unsigned char* nLastColor, bool*
if (*info) if (*info)
{ {
if (m_nState & LC_PIECE_SELECTED) if (m_nState & LC_PIECE_SELECTED)
{ {
if (lock) if (lock)
glUnlockArraysEXT(); glUnlockArraysEXT();
SetCurrentColor(m_nState & LC_PIECE_FOCUSED ? LC_COL_FOCUSED : LC_COL_SELECTED, bTrans, bLighting); if (m_nState & LC_PIECE_FOCUSED)
*nLastColor = m_nState & LC_PIECE_FOCUSED ? LC_COL_FOCUSED : LC_COL_SELECTED; lcSetColorFocused();
else
lcSetColorSelected();
if (lock) if (lock)
glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount); glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount);
glDrawElements(GL_LINES, *info, GL_UNSIGNED_INT, info+1); glDrawElements(GL_LINES, *info, GL_UNSIGNED_INT, info+1);
} }
else else
if (bEdges) if (bEdges)
glDrawElements(GL_LINES, *info, GL_UNSIGNED_INT, info+1); glDrawElements(GL_LINES, *info, GL_UNSIGNED_INT, info+1);
info += *info + 1; info += *info + 1;
} }
else else
info++; info++;
@ -1277,19 +1263,10 @@ void Piece::Render(bool bLighting, bool bEdges, unsigned char* nLastColor, bool*
{ {
bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES); bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES);
if (*info != *nLastColor) if (*info == LC_COL_DEFAULT)
{ SetCurrentColor(m_nColor, bLighting);
if (*info == LC_COL_DEFAULT) else
{ SetCurrentColor((unsigned char)*info, bLighting);
SetCurrentColor(m_nColor, bTrans, bLighting);
*nLastColor = m_nColor;
}
else
{
SetCurrentColor((unsigned char)*info, bTrans, bLighting);
*nLastColor = (unsigned char)*info;
}
}
info++; info++;
if (lock) if (lock)
@ -1313,23 +1290,25 @@ void Piece::Render(bool bLighting, bool bEdges, unsigned char* nLastColor, bool*
if (*info) if (*info)
{ {
if (m_nState & LC_PIECE_SELECTED) if (m_nState & LC_PIECE_SELECTED)
{ {
if (lock) if (lock)
glUnlockArraysEXT(); glUnlockArraysEXT();
SetCurrentColor((m_nState & LC_PIECE_FOCUSED) ? LC_COL_FOCUSED : LC_COL_SELECTED, bTrans, bLighting); if (m_nState & LC_PIECE_FOCUSED)
*nLastColor = m_nState & LC_PIECE_FOCUSED ? LC_COL_FOCUSED : LC_COL_SELECTED; lcSetColorFocused();
else
lcSetColorSelected();
if (lock) if (lock)
glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount); glLockArraysEXT(0, m_pPieceInfo->m_nVertexCount);
glDrawElements(GL_LINES, *info, GL_UNSIGNED_SHORT, info+1); glDrawElements(GL_LINES, *info, GL_UNSIGNED_SHORT, info+1);
} }
else else
if (bEdges) if (bEdges)
glDrawElements(GL_LINES, *info, GL_UNSIGNED_SHORT, info+1); glDrawElements(GL_LINES, *info, GL_UNSIGNED_SHORT, info+1);
info += *info + 1; info += *info + 1;
} }
else else
info++; info++;

View file

@ -109,7 +109,7 @@ public:
void GetRotation (float* rotation) void GetRotation (float* rotation)
{ memcpy(rotation, m_fRotation, sizeof(m_fRotation)); } { memcpy(rotation, m_fRotation, sizeof(m_fRotation)); }
void Render(bool bLighting, bool bEdges, unsigned char* nLastColor, bool* bTrans); void Render(bool bLighting, bool bEdges);
void RenderBox(bool bHilite, float fLineWidth); void RenderBox(bool bHilite, float fLineWidth);
inline bool IsTransparent() inline bool IsTransparent()

View file

@ -1750,7 +1750,7 @@ typedef struct LC_BSPNODE
} }
} LC_BSPNODE; } LC_BSPNODE;
static void RenderBSP(LC_BSPNODE* node, float* eye, bool* bSel, bool bLighting, bool bEdges, unsigned char* nLastColor, bool* bTrans) static void RenderBSP(LC_BSPNODE* node, float* eye, bool* bSel, bool bLighting, bool bEdges)
{ {
if (node->piece) if (node->piece)
{ {
@ -1771,20 +1771,20 @@ static void RenderBSP(LC_BSPNODE* node, float* eye, bool* bSel, bool bLighting,
} }
} }
node->piece->Render(bLighting, bEdges, nLastColor, bTrans); node->piece->Render(bLighting, bEdges);
return; return;
} }
if (eye[0]*node->plane[0] + eye[1]*node->plane[1] + if (eye[0]*node->plane[0] + eye[1]*node->plane[1] +
eye[2]*node->plane[2] + node->plane[3] > 0.0f) eye[2]*node->plane[2] + node->plane[3] > 0.0f)
{ {
RenderBSP(node->back, eye, bSel, bLighting, bEdges, nLastColor, bTrans); RenderBSP(node->back, eye, bSel, bLighting, bEdges);
RenderBSP(node->front, eye, bSel, bLighting, bEdges, nLastColor, bTrans); RenderBSP(node->front, eye, bSel, bLighting, bEdges);
} }
else else
{ {
RenderBSP(node->front, eye, bSel, bLighting, bEdges, nLastColor, bTrans); RenderBSP(node->front, eye, bSel, bLighting, bEdges);
RenderBSP(node->back, eye, bSel, bLighting, bEdges, nLastColor, bTrans); RenderBSP(node->back, eye, bSel, bLighting, bEdges);
} }
} }
@ -1921,8 +1921,6 @@ void Project::RenderScenePieces(View* view)
if (m_nScene & LC_SCENE_FLOOR) if (m_nScene & LC_SCENE_FLOOR)
m_pTerrain->Render(view->m_Camera, AspectRatio); m_pTerrain->Render(view->m_Camera, AspectRatio);
unsigned char nLastColor = 255;
bool bTrans = false;
bool bSel = false; bool bSel = false;
bool bCull = false; bool bCull = false;
Piece* pPiece; Piece* pPiece;
@ -1956,7 +1954,7 @@ void Project::RenderScenePieces(View* view)
} }
} }
pPiece->Render((m_nDetail & LC_DET_LIGHTING) != 0, (m_nDetail & LC_DET_BRICKEDGES) != 0, &nLastColor, &bTrans); pPiece->Render((m_nDetail & LC_DET_LIGHTING) != 0, (m_nDetail & LC_DET_BRICKEDGES) != 0);
} }
else else
{ {
@ -1970,14 +1968,11 @@ void Project::RenderScenePieces(View* view)
float eye[3]; float eye[3];
view->m_Camera->GetEyePos (eye); view->m_Camera->GetEyePos (eye);
BuildBSP(&tree, pList); BuildBSP(&tree, pList);
RenderBSP(&tree, eye, &bSel, (m_nDetail & LC_DET_LIGHTING) != 0, (m_nDetail & LC_DET_BRICKEDGES) != 0, &nLastColor, &bTrans); RenderBSP(&tree, eye, &bSel, (m_nDetail & LC_DET_LIGHTING) != 0, (m_nDetail & LC_DET_BRICKEDGES) != 0);
} }
if (bTrans) glDepthMask(GL_TRUE);
{ glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
}
if (bSel) if (bSel)
glLineWidth(m_fLineWidth); glLineWidth(m_fLineWidth);