mirror of
https://github.com/leozide/leocad
synced 2025-01-28 19:58:12 +01:00
Keep LDraw color codes.
This commit is contained in:
parent
296300a9e1
commit
c8cb684299
8 changed files with 123 additions and 84 deletions
|
@ -376,3 +376,15 @@ void LoadDefaultColors()
|
|||
File.Seek(0, SEEK_SET);
|
||||
LoadColorFile(File);
|
||||
}
|
||||
|
||||
int lcGetColorIndex(lcuint32 ColorCode)
|
||||
{
|
||||
unsigned char ConvertColor(int c); // temp fix
|
||||
return ConvertColor(ColorCode);
|
||||
}
|
||||
|
||||
int lcGetColorCode(int ColorIndex)
|
||||
{
|
||||
const int ExtendedColorTable[LC_MAXCOLORS] = { 4,12,2,10,1,9,14,15,8,0,6,13,13,334,36,44,34,42,33,41,46,47,7,382,6,13,11,383 }; // temp fix
|
||||
return ExtendedColorTable[ColorIndex];
|
||||
}
|
||||
|
|
|
@ -15,6 +15,14 @@ struct lcColor
|
|||
extern lcColor* gColorList;
|
||||
extern int gNumColors;
|
||||
|
||||
int lcGetColorIndex(lcuint32 ColorCode);
|
||||
int lcGetColorCode(int ColorIndex);
|
||||
|
||||
inline bool lcIsColorTranslucent(int ColorIndex)
|
||||
{
|
||||
return (ColorIndex > 13 && ColorIndex < 22); // temp
|
||||
}
|
||||
|
||||
inline void lcSetColor(int ColorIndex)
|
||||
{
|
||||
float* Color = gColorList[ColorIndex].Value;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "algebra.h"
|
||||
#include "lc_application.h"
|
||||
|
||||
#define LC_PIECE_SAVE_VERSION 10 // LeoCAD 0.75.2
|
||||
#define LC_PIECE_SAVE_VERSION 11 // LeoCAD 0.77
|
||||
|
||||
static LC_OBJECT_KEY_INFO piece_key_info[LC_PK_COUNT] =
|
||||
{
|
||||
|
@ -72,7 +72,8 @@ Piece::Piece(PieceInfo* pPieceInfo)
|
|||
m_pNext = NULL;
|
||||
m_pPieceInfo = pPieceInfo;
|
||||
m_nState = 0;
|
||||
m_nColor = 0;
|
||||
mColorIndex = 0;
|
||||
mColorCode = 0;
|
||||
m_nStepShow = 1;
|
||||
m_nStepHide = 255;
|
||||
m_nFrameHide = 65535;
|
||||
|
@ -253,13 +254,25 @@ bool Piece::FileLoad(lcFile& file, char* name)
|
|||
}
|
||||
else
|
||||
file.ReadBuffer(name, LC_PIECE_NAME_LEN);
|
||||
file.ReadU8(&m_nColor, 1);
|
||||
|
||||
if (version < 5)
|
||||
{
|
||||
const unsigned char conv[20] = { 0,2,4,9,7,6,22,8,10,11,14,16,18,9,21,20,22,8,10,11 };
|
||||
m_nColor = conv[m_nColor];
|
||||
}
|
||||
if (version < 11)
|
||||
{
|
||||
lcuint8 Color;
|
||||
|
||||
file.ReadU8(&Color, 1);
|
||||
|
||||
if (version < 5)
|
||||
{
|
||||
const int OriginalColorTable[20] = { 0,2,4,9,7,6,22,8,10,11,14,16,18,9,21,20,22,8,10,11 };
|
||||
Color = OriginalColorTable[Color];
|
||||
}
|
||||
|
||||
const int ExtendedColorTable[28] = { 4,12,2,10,1,9,14,15,8,0,6,13,13,334,36,44,34,42,33,41,46,47,7,382,6,13,11,383 };
|
||||
mColorCode = ExtendedColorTable[Color];
|
||||
}
|
||||
else
|
||||
file.ReadU32(&mColorCode, 1);
|
||||
mColorIndex = lcGetColorIndex(mColorCode);
|
||||
|
||||
file.ReadU8(&m_nStepShow, 1);
|
||||
if (version > 1)
|
||||
|
@ -320,7 +333,7 @@ void Piece::FileSave(lcFile& file, Group* pGroups)
|
|||
Object::FileSave (file);
|
||||
|
||||
file.WriteBuffer(m_pPieceInfo->m_strName, LC_PIECE_NAME_LEN);
|
||||
file.WriteU8(m_nColor);
|
||||
file.WriteU32(mColorCode);
|
||||
file.WriteU8(m_nStepShow);
|
||||
file.WriteU8(m_nStepHide);
|
||||
file.WriteU16(m_nFrameShow);
|
||||
|
@ -351,20 +364,18 @@ void Piece::FileSave(lcFile& file, Group* pGroups)
|
|||
file.WriteS32(i);
|
||||
}
|
||||
|
||||
void Piece::Initialize(float x, float y, float z, unsigned char nStep, unsigned short nFrame, unsigned char nColor)
|
||||
void Piece::Initialize(float x, float y, float z, unsigned char nStep, unsigned short nFrame)
|
||||
{
|
||||
m_nFrameShow = nFrame;
|
||||
m_nStepShow = nStep;
|
||||
m_nFrameShow = nFrame;
|
||||
m_nStepShow = nStep;
|
||||
|
||||
float pos[3] = { x, y, z }, rot[4] = { 0, 0, 1, 0 };
|
||||
ChangeKey (1, false, true, pos, LC_PK_POSITION);
|
||||
ChangeKey (1, false, true, rot, LC_PK_ROTATION);
|
||||
ChangeKey (1, true, true, pos, LC_PK_POSITION);
|
||||
ChangeKey (1, true, true, rot, LC_PK_ROTATION);
|
||||
float pos[3] = { x, y, z }, rot[4] = { 0, 0, 1, 0 };
|
||||
ChangeKey (1, false, true, pos, LC_PK_POSITION);
|
||||
ChangeKey (1, false, true, rot, LC_PK_ROTATION);
|
||||
ChangeKey (1, true, true, pos, LC_PK_POSITION);
|
||||
ChangeKey (1, true, true, rot, LC_PK_ROTATION);
|
||||
|
||||
UpdatePosition (1, false);
|
||||
|
||||
m_nColor = nColor;
|
||||
UpdatePosition (1, false);
|
||||
}
|
||||
|
||||
void Piece::CreateName(Piece* pPiece)
|
||||
|
@ -886,12 +897,12 @@ void Piece::BuildDrawInfo()
|
|||
for (group = m_pPieceInfo->m_nGroupCount, dg = m_pPieceInfo->m_pGroups; group--; dg++)
|
||||
{
|
||||
lcuint16* sh = dg->connections;
|
||||
add = IsTransparent() || *sh == 0xFFFF;
|
||||
add = IsTranslucent() || *sh == 0xFFFF;
|
||||
|
||||
if (!add)
|
||||
for (; *sh != 0xFFFF; sh++)
|
||||
if ((m_pConnections[*sh].link == NULL) ||
|
||||
(m_pConnections[*sh].link->owner->IsTransparent()))
|
||||
(m_pConnections[*sh].link->owner->IsTranslucent()))
|
||||
{
|
||||
add = true;
|
||||
break;
|
||||
|
@ -977,12 +988,12 @@ void Piece::BuildDrawInfo()
|
|||
for (group = m_pPieceInfo->m_nGroupCount, dg = m_pPieceInfo->m_pGroups; group--; dg++)
|
||||
{
|
||||
lcuint16* sh = dg->connections;
|
||||
add = IsTransparent() || *sh == 0xFFFF;
|
||||
add = IsTranslucent() || *sh == 0xFFFF;
|
||||
|
||||
if (!add)
|
||||
for (; *sh != 0xFFFF; sh++)
|
||||
if ((m_pConnections[*sh].link == NULL) ||
|
||||
(m_pConnections[*sh].link->owner->IsTransparent()))
|
||||
(m_pConnections[*sh].link->owner->IsTranslucent()))
|
||||
{
|
||||
add = true;
|
||||
break;
|
||||
|
@ -1066,12 +1077,12 @@ void Piece::BuildDrawInfo()
|
|||
for (group = m_pPieceInfo->m_nGroupCount, dg = m_pPieceInfo->m_pGroups; group--; dg++)
|
||||
{
|
||||
lcuint16* sh = dg->connections;
|
||||
add = IsTransparent() || *sh == 0xFFFF;
|
||||
add = IsTranslucent() || *sh == 0xFFFF;
|
||||
|
||||
if (!add)
|
||||
for (; *sh != 0xFFFF; sh++)
|
||||
if ((m_pConnections[*sh].link == NULL) ||
|
||||
(m_pConnections[*sh].link->owner->IsTransparent()))
|
||||
(m_pConnections[*sh].link->owner->IsTranslucent()))
|
||||
{
|
||||
add = true;
|
||||
break;
|
||||
|
@ -1153,7 +1164,7 @@ void Piece::RenderBox(bool bHilite, float fLineWidth)
|
|||
}
|
||||
else
|
||||
{
|
||||
glColor3ubv(FlatColorArray[m_nColor]);
|
||||
glColor3ubv(FlatColorArray[mColorIndex]);
|
||||
glCallList(m_pPieceInfo->GetBoxDisplayList());
|
||||
}
|
||||
glPopMatrix();
|
||||
|
@ -1172,7 +1183,7 @@ void Piece::Render(bool bLighting, bool bEdges)
|
|||
m_pPieceInfo->m_pTextures[sh].texture->MakeCurrent();
|
||||
|
||||
if (m_pPieceInfo->m_pTextures[sh].color == LC_COL_DEFAULT)
|
||||
SetCurrentColor(m_nColor, bLighting);
|
||||
SetCurrentColor(mColorIndex, bLighting);
|
||||
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBegin(GL_QUADS);
|
||||
|
@ -1199,7 +1210,7 @@ void Piece::Render(bool bLighting, bool bEdges)
|
|||
bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES);
|
||||
|
||||
if (*info == LC_COL_DEFAULT)
|
||||
SetCurrentColor(m_nColor, bLighting);
|
||||
SetCurrentColor(mColorIndex, bLighting);
|
||||
else
|
||||
SetCurrentColor((unsigned char)*info, bLighting);
|
||||
info++;
|
||||
|
@ -1264,7 +1275,7 @@ void Piece::Render(bool bLighting, bool bEdges)
|
|||
bool lock = lockarrays && (*info == LC_COL_DEFAULT || *info == LC_COL_EDGES);
|
||||
|
||||
if (*info == LC_COL_DEFAULT)
|
||||
SetCurrentColor(m_nColor, bLighting);
|
||||
SetCurrentColor(mColorIndex, bLighting);
|
||||
else
|
||||
SetCurrentColor((unsigned char)*info, bLighting);
|
||||
info++;
|
||||
|
|
|
@ -8,6 +8,7 @@ class PieceInfo;
|
|||
#include "object.h"
|
||||
#include "globals.h"
|
||||
#include "typedefs.h"
|
||||
#include "lc_colors.h"
|
||||
|
||||
#define LC_PIECE_HIDDEN 0x01
|
||||
#define LC_PIECE_SELECTED 0x02
|
||||
|
@ -54,7 +55,7 @@ public:
|
|||
|
||||
void MinIntersectDist(LC_CLICKLINE* pLine);
|
||||
bool IsVisible(unsigned short nTime, bool bAnimation);
|
||||
void Initialize(float x, float y, float z, unsigned char nStep, unsigned short nFrame, unsigned char nColor);
|
||||
void Initialize(float x, float y, float z, unsigned char nStep, unsigned short nFrame);
|
||||
void CreateName(Piece* pPiece);
|
||||
void AddConnections(CONNECTION_TYPE* pConnections);
|
||||
void RemoveConnections(CONNECTION_TYPE* pConnections);
|
||||
|
@ -78,10 +79,6 @@ public:
|
|||
{ strcpy(m_strName, name); }
|
||||
const char* GetName()
|
||||
{ return m_strName; }
|
||||
const unsigned char GetColor()
|
||||
{ return m_nColor; }
|
||||
void SetColor(unsigned char color)
|
||||
{ m_nColor = color; }
|
||||
PieceInfo* GetPieceInfo()
|
||||
{ return m_pPieceInfo; }
|
||||
void SetStepShow(unsigned char step)
|
||||
|
@ -112,20 +109,26 @@ public:
|
|||
void Render(bool bLighting, bool bEdges);
|
||||
void RenderBox(bool bHilite, float fLineWidth);
|
||||
|
||||
inline bool IsTransparent()
|
||||
void SetColorCode(lcuint32 ColorCode)
|
||||
{
|
||||
if (m_nColor < 14) return false;
|
||||
if (m_nColor > 21) return false;
|
||||
return true;
|
||||
};
|
||||
|
||||
/*
|
||||
inline void UseTransform()
|
||||
{
|
||||
glTranslatef(m_fPosition[0], m_fPosition[1], m_fPosition[2]);
|
||||
glRotatef(m_fRotation[3], m_fRotation[0], m_fRotation[1], m_fRotation[2]);
|
||||
mColorCode = ColorCode;
|
||||
mColorIndex = lcGetColorIndex(ColorCode);
|
||||
}
|
||||
*/
|
||||
|
||||
void SetColorIndex(int ColorIndex)
|
||||
{
|
||||
mColorIndex = ColorIndex;
|
||||
mColorCode = lcGetColorCode(ColorIndex);
|
||||
}
|
||||
|
||||
bool IsTranslucent() const
|
||||
{
|
||||
return lcIsColorTranslucent(mColorIndex);
|
||||
}
|
||||
|
||||
int mColorIndex;
|
||||
lcuint32 mColorCode;
|
||||
|
||||
protected:
|
||||
void BuildDrawInfo();
|
||||
|
||||
|
@ -138,7 +141,6 @@ protected:
|
|||
unsigned char m_nStepShow;
|
||||
unsigned char m_nStepHide;
|
||||
|
||||
unsigned char m_nColor;
|
||||
unsigned char m_nState;
|
||||
char m_strName[81];
|
||||
|
||||
|
|
|
@ -496,6 +496,8 @@ bool Project::FileLoad(lcFile* file, bool bUndo, bool bMerge)
|
|||
|
||||
const unsigned char conv[20] = { 0,2,4,9,7,6,22,8,10,11,14,16,18,9,21,20,22,8,10,11 };
|
||||
color = conv[color];
|
||||
const int ExtendedColorTable[LC_MAXCOLORS] = { 4,12,2,10,1,9,14,15,8,0,6,13,13,334,36,44,34,42,33,41,46,47,7,382,6,13,11,383 };
|
||||
lcuint32 ColorCode = ExtendedColorTable[color];
|
||||
|
||||
PieceInfo* pInfo = lcGetPiecesLibrary()->FindPieceInfo(name);
|
||||
if (pInfo != NULL)
|
||||
|
@ -503,7 +505,8 @@ bool Project::FileLoad(lcFile* file, bool bUndo, bool bMerge)
|
|||
Piece* pPiece = new Piece(pInfo);
|
||||
Matrix mat;
|
||||
|
||||
pPiece->Initialize(pos[0], pos[1], pos[2], step, 1, color);
|
||||
pPiece->Initialize(pos[0], pos[1], pos[2], step, 1);
|
||||
pPiece->SetColorCode(ColorCode);
|
||||
pPiece->CreateName(m_pPieces);
|
||||
AddPiece(pPiece);
|
||||
mat.CreateOld(0,0,0, rot[0],rot[1],rot[2]);
|
||||
|
@ -1040,8 +1043,6 @@ void Project::FileReadLDraw(lcFile* file, Matrix* prevmat, int* nOk, int DefColo
|
|||
int cl = 0;
|
||||
if (color == 16)
|
||||
cl = DefColor;
|
||||
else
|
||||
cl = ConvertColor(color);
|
||||
|
||||
strcpy(pn, tmp);
|
||||
ptr = strrchr(tmp, '.');
|
||||
|
@ -1063,7 +1064,8 @@ void Project::FileReadLDraw(lcFile* file, Matrix* prevmat, int* nOk, int DefColo
|
|||
read = false;
|
||||
|
||||
tmpmat.GetTranslation(&x, &y, &z);
|
||||
pPiece->Initialize(x, y, z, *nStep, 1, cl);
|
||||
pPiece->Initialize(x, y, z, *nStep, 1);
|
||||
pPiece->SetColorCode(cl);
|
||||
pPiece->CreateName(m_pPieces);
|
||||
AddPiece(pPiece);
|
||||
tmpmat.ToAxisAngle(rot);
|
||||
|
@ -1110,7 +1112,8 @@ void Project::FileReadLDraw(lcFile* file, Matrix* prevmat, int* nOk, int DefColo
|
|||
read = false;
|
||||
|
||||
tmpmat.GetTranslation(&x, &y, &z);
|
||||
pPiece->Initialize(x, y, z, *nStep, 1, cl);
|
||||
pPiece->Initialize(x, y, z, *nStep, 1);
|
||||
pPiece->SetColorCode(cl);
|
||||
pPiece->CreateName(m_pPieces);
|
||||
AddPiece(pPiece);
|
||||
tmpmat.ToAxisAngle(rot);
|
||||
|
@ -1216,7 +1219,6 @@ bool Project::DoSave(char* lpszPathName, bool bReplace)
|
|||
|
||||
if ((strcmp(ext, "dat") == 0) || (strcmp(ext, "ldr") == 0))
|
||||
{
|
||||
const int col[28] = { 4,12,2,10,1,9,14,15,8,0,6,13,13,334,36,44,34,42,33,41,46,47,7,382,6,13,11,383 };
|
||||
Piece* pPiece;
|
||||
int i, steps = GetLastStep();
|
||||
char buf[256], *ptr;
|
||||
|
@ -1254,7 +1256,7 @@ bool Project::DoSave(char* lpszPathName, bool bReplace)
|
|||
Matrix mat(rotation, position);
|
||||
mat.ToLDraw(f);
|
||||
sprintf (buf, " 1 %d %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %.2f %s.DAT\r\n",
|
||||
col[pPiece->GetColor()], f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8], f[9], f[10], f[11], pPiece->GetPieceInfo()->m_strName);
|
||||
pPiece->mColorCode, f[0], f[1], f[2], f[3], f[4], f[5], f[6], f[7], f[8], f[9], f[10], f[11], pPiece->GetPieceInfo()->m_strName);
|
||||
file.WriteBuffer(buf, strlen(buf));
|
||||
}
|
||||
}
|
||||
|
@ -1935,7 +1937,7 @@ void Project::RenderScenePieces(View* view)
|
|||
if (!pPiece->IsVisible(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation))
|
||||
continue;
|
||||
|
||||
if (!pPiece->IsTransparent())
|
||||
if (!pPiece->IsTranslucent())
|
||||
{
|
||||
if (pPiece->IsSelected())
|
||||
{
|
||||
|
@ -2846,11 +2848,11 @@ void CCADDoc::AddPiece(CPiece* pNewPiece)
|
|||
for (pos1 = m_Pieces.GetHeadPosition(); (pos2 = pos1) != NULL;)
|
||||
{
|
||||
CPiece* pPiece = m_Pieces.GetNext(pos1);
|
||||
if (pPiece->IsTransparent())
|
||||
if (pPiece->IsTranslucent())
|
||||
break;
|
||||
}
|
||||
|
||||
if (pos2 == NULL || pNewPiece->IsTransparent())
|
||||
if (pos2 == NULL || pNewPiece->IsTranslucent())
|
||||
m_Pieces.AddTail(pNewPiece);
|
||||
else
|
||||
m_Pieces.InsertBefore(pos2, pNewPiece);
|
||||
|
@ -3212,7 +3214,7 @@ void Project::CreateHTMLPieceList(FILE* f, int nStep, bool bImages, const char*
|
|||
for (pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
|
||||
{
|
||||
if ((pPiece->GetStepShow() == nStep) || (nStep == 0))
|
||||
col[pPiece->GetColor()]++;
|
||||
col[pPiece->mColorCode]++;
|
||||
}
|
||||
fputs("<br><table border=1><tr><td><center>Piece</center></td>\n",f);
|
||||
|
||||
|
@ -3239,7 +3241,7 @@ void Project::CreateHTMLPieceList(FILE* f, int nStep, bool bImages, const char*
|
|||
if ((pPiece->GetPieceInfo() == pInfo) &&
|
||||
((pPiece->GetStepShow() == nStep) || (nStep == 0)))
|
||||
{
|
||||
count [pPiece->GetColor()]++;
|
||||
count [pPiece->mColorCode]++;
|
||||
Add = true;
|
||||
}
|
||||
}
|
||||
|
@ -3347,7 +3349,7 @@ void Project::HandleNotify(LC_NOTIFY id, unsigned long param)
|
|||
pPiece->UnHide();
|
||||
|
||||
pPiece->SetName(mod->name);
|
||||
pPiece->SetColor(mod->color);
|
||||
pPiece->SetColorIndex(mod->color);
|
||||
pPiece->UpdatePosition(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation);
|
||||
pPiece->CalculateConnections(m_pConnections, m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, false, true);
|
||||
|
||||
|
@ -4166,7 +4168,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
float fl[12], pos[3], rot[4];
|
||||
int Color;
|
||||
|
||||
Color = piece->GetColor();
|
||||
Color = piece->mColorIndex;
|
||||
const char* Suffix = (Color > 13 && Color < 22) ? "_clear" : "";
|
||||
|
||||
piece->GetPosition(pos);
|
||||
|
@ -4314,7 +4316,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
buf[i] = '_';
|
||||
|
||||
fprintf(stream, "g %s\n", buf);
|
||||
pPiece->GetPieceInfo()->WriteWavefront(stream, pPiece->GetColor(), &vert);
|
||||
pPiece->GetPieceInfo()->WriteWavefront(stream, pPiece->mColorCode, &vert);
|
||||
}
|
||||
|
||||
fclose(stream);
|
||||
|
@ -4340,7 +4342,7 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
for (Piece* pPiece = m_pPieces; pPiece; pPiece = pPiece->m_pNext)
|
||||
{
|
||||
int idx = lcGetPiecesLibrary()->GetPieceIndex (pPiece->GetPieceInfo ());
|
||||
opts.count[idx*LC_MAXCOLORS+pPiece->GetColor()]++;
|
||||
opts.count[idx*LC_MAXCOLORS+pPiece->mColorIndex]++;
|
||||
}
|
||||
|
||||
if (SystemDoDialog(LC_DLG_PROPERTIES, &opts))
|
||||
|
@ -4810,16 +4812,17 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
|
||||
GetPieceInsertPosition(pLast, Pos, Rot);
|
||||
|
||||
pPiece->Initialize(Pos[0], Pos[1], Pos[2], m_nCurStep, m_nCurFrame, m_nCurColor);
|
||||
pPiece->Initialize(Pos[0], Pos[1], Pos[2], m_nCurStep, m_nCurFrame);
|
||||
|
||||
pPiece->ChangeKey(m_nCurStep, false, false, Rot, LC_PK_ROTATION);
|
||||
pPiece->ChangeKey(m_nCurFrame, true, false, Rot, LC_PK_ROTATION);
|
||||
pPiece->UpdatePosition(m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation);
|
||||
}
|
||||
else
|
||||
pPiece->Initialize(0, 0, 0, m_nCurStep, m_nCurFrame, m_nCurColor);
|
||||
pPiece->Initialize(0, 0, 0, m_nCurStep, m_nCurFrame);
|
||||
|
||||
SelectAndFocusNone(false);
|
||||
pPiece->SetColorIndex(m_nCurColor);
|
||||
pPiece->CreateName(m_pPieces);
|
||||
AddPiece(pPiece);
|
||||
pPiece->CalculateConnections(m_pConnections, m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, true, true);
|
||||
|
@ -4869,7 +4872,8 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
Vector4& Position = Wizard.m_Matrices[i][3];
|
||||
Vector4 Rotation = Wizard.m_Matrices[i].ToAxisAngle();
|
||||
Rotation[3] *= LC_RTOD;
|
||||
pPiece->Initialize(Position[0], Position[1], Position[2], m_nCurStep, m_nCurFrame, Wizard.m_Colors[i]);
|
||||
pPiece->Initialize(Position[0], Position[1], Position[2], m_nCurStep, m_nCurFrame);
|
||||
pPiece->SetColorIndex(Wizard.m_Colors[i]);
|
||||
pPiece->CreateName(m_pPieces);
|
||||
AddPiece(pPiece);
|
||||
pPiece->Select(true, false, false);
|
||||
|
@ -5000,8 +5004,8 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
else
|
||||
pLast = pFirst = new Piece(pPiece->GetPieceInfo());
|
||||
|
||||
pLast->Initialize(pos[0]+i*opts.fMove[0], pos[1]+i*opts.fMove[1], pos[2]+i*opts.fMove[2],
|
||||
m_nCurStep, m_nCurFrame, pPiece->GetColor());
|
||||
pLast->Initialize(pos[0]+i*opts.fMove[0], pos[1]+i*opts.fMove[1], pos[2]+i*opts.fMove[2], m_nCurStep, m_nCurFrame);
|
||||
pLast->SetColorIndex(pPiece->mColorIndex);
|
||||
pLast->ChangeKey(1, false, false, param, LC_PK_ROTATION);
|
||||
pLast->ChangeKey(1, true, false, param, LC_PK_ROTATION);
|
||||
}
|
||||
|
@ -5021,8 +5025,8 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
else
|
||||
pLast = pFirst = new Piece(pPiece->GetPieceInfo());
|
||||
|
||||
pLast->Initialize(pos[0]+i*opts.fMove[0]+j*opts.f2D[0], pos[1]+i*opts.fMove[1]+j*opts.f2D[1], pos[2]+i*opts.fMove[2]+j*opts.f2D[2],
|
||||
m_nCurStep, m_nCurFrame, pPiece->GetColor());
|
||||
pLast->Initialize(pos[0]+i*opts.fMove[0]+j*opts.f2D[0], pos[1]+i*opts.fMove[1]+j*opts.f2D[1], pos[2]+i*opts.fMove[2]+j*opts.f2D[2], m_nCurStep, m_nCurFrame);
|
||||
pLast->SetColorIndex(pPiece->mColorIndex);
|
||||
pLast->ChangeKey(1, false, false, param, LC_PK_ROTATION);
|
||||
pLast->ChangeKey(1, true, false, param, LC_PK_ROTATION);
|
||||
}
|
||||
|
@ -5040,8 +5044,8 @@ void Project::HandleCommand(LC_COMMANDS id, unsigned long nParam)
|
|||
else
|
||||
pLast = pFirst = new Piece(pPiece->GetPieceInfo());
|
||||
|
||||
pLast->Initialize(pos[0]+i*opts.fMove[0]+j*opts.f2D[0]+k*opts.f3D[0], pos[1]+i*opts.fMove[1]+j*opts.f2D[1]+k*opts.f3D[1], pos[2]+i*opts.fMove[2]+j*opts.f2D[2]+k*opts.f3D[2],
|
||||
m_nCurStep, m_nCurFrame, pPiece->GetColor());
|
||||
pLast->Initialize(pos[0]+i*opts.fMove[0]+j*opts.f2D[0]+k*opts.f3D[0], pos[1]+i*opts.fMove[1]+j*opts.f2D[1]+k*opts.f3D[1], pos[2]+i*opts.fMove[2]+j*opts.f2D[2]+k*opts.f3D[2], m_nCurStep, m_nCurFrame);
|
||||
pLast->SetColorIndex(pPiece->mColorIndex);
|
||||
pLast->ChangeKey(1, false, false, param, LC_PK_ROTATION);
|
||||
pLast->ChangeKey(1, true, false, param, LC_PK_ROTATION);
|
||||
}
|
||||
|
@ -7608,11 +7612,11 @@ void Project::OnLeftButtonDown(View* view, int x, int y, bool bControl, bool bSh
|
|||
{
|
||||
Piece* pPiece = (Piece*)Closest;
|
||||
|
||||
if (pPiece->GetColor() != m_nCurColor)
|
||||
if (pPiece->mColorIndex != m_nCurColor)
|
||||
{
|
||||
bool bTrans = pPiece->IsTransparent();
|
||||
pPiece->SetColor(m_nCurColor);
|
||||
if (bTrans != pPiece->IsTransparent())
|
||||
bool bTrans = pPiece->IsTranslucent();
|
||||
pPiece->SetColorIndex(m_nCurColor);
|
||||
if (bTrans != pPiece->IsTranslucent())
|
||||
pPiece->CalculateConnections(m_pConnections, m_bAnimation ? m_nCurFrame : m_nCurStep, m_bAnimation, true, true);
|
||||
|
||||
SetModifiedFlag(true);
|
||||
|
@ -7634,7 +7638,8 @@ void Project::OnLeftButtonDown(View* view, int x, int y, bool bControl, bool bSh
|
|||
GetPieceInsertPosition(view, x, y, Pos, Rot);
|
||||
|
||||
Piece* pPiece = new Piece(m_pCurPiece);
|
||||
pPiece->Initialize(Pos[0], Pos[1], Pos[2], m_nCurStep, m_nCurFrame, m_nCurColor);
|
||||
pPiece->Initialize(Pos[0], Pos[1], Pos[2], m_nCurStep, m_nCurFrame);
|
||||
pPiece->SetColorIndex(m_nCurColor);
|
||||
|
||||
pPiece->ChangeKey(m_nCurStep, false, false, Rot, LC_PK_ROTATION);
|
||||
pPiece->ChangeKey(m_nCurFrame, true, false, Rot, LC_PK_ROTATION);
|
||||
|
@ -7866,7 +7871,8 @@ void Project::OnLeftButtonUp(View* view, int x, int y, bool bControl, bool bShif
|
|||
GetPieceInsertPosition(view, x, y, Pos, Rot);
|
||||
|
||||
Piece* pPiece = new Piece(m_pCurPiece);
|
||||
pPiece->Initialize(Pos[0], Pos[1], Pos[2], m_nCurStep, m_nCurFrame, m_nCurColor);
|
||||
pPiece->Initialize(Pos[0], Pos[1], Pos[2], m_nCurStep, m_nCurFrame);
|
||||
pPiece->SetColorIndex(m_nCurColor);
|
||||
|
||||
pPiece->ChangeKey(m_nCurStep, false, false, Rot, LC_PK_ROTATION);
|
||||
pPiece->ChangeKey(m_nCurFrame, true, false, Rot, LC_PK_ROTATION);
|
||||
|
|
|
@ -410,7 +410,7 @@ static void PrintPiecesThread(void* pv)
|
|||
CFrameWndEx* pFrame = (CFrameWndEx*)pv;
|
||||
CView* pView = pFrame->GetActiveView();
|
||||
CPrintDialog* PD = new CPrintDialog(FALSE, PD_ALLPAGES|PD_USEDEVMODECOPIES|PD_NOPAGENUMS|PD_NOSELECTION, pFrame);
|
||||
PiecesLibrary *pLib = lcGetPiecesLibrary();
|
||||
PiecesLibrary *pLib = lcGetPiecesLibrary();
|
||||
Project* project = lcGetActiveProject();
|
||||
|
||||
UINT *pieces = (UINT*)malloc(pLib->GetPieceCount ()*28*sizeof(UINT));
|
||||
|
@ -421,8 +421,8 @@ static void PrintPiecesThread(void* pv)
|
|||
for (Piece* tmp = project->m_pPieces; tmp; tmp = tmp->m_pNext)
|
||||
{
|
||||
int idx = pLib->GetPieceIndex (tmp->GetPieceInfo ());
|
||||
pieces[(idx*28)+tmp->GetColor()]++;
|
||||
col[tmp->GetColor()]++;
|
||||
pieces[(idx*28)+tmp->mColorCode]++; // fix LC_MAXCOLORS
|
||||
col[tmp->mColorCode]++;
|
||||
}
|
||||
|
||||
int rows = 0, cols = 1, i, j;
|
||||
|
|
|
@ -544,7 +544,7 @@ void Export3DStudio()
|
|||
if (facemats[j])
|
||||
{
|
||||
InitMatArrayIndex3ds (mobj, i, facemats[j]);
|
||||
sprintf(mobj->matarray[i].name, "Material%02d", j == LC_COL_DEFAULT ? pPiece->GetColor() : j);
|
||||
sprintf(mobj->matarray[i].name, "Material%d", j == LC_COL_DEFAULT ? pPiece->mColorCode : j);
|
||||
mobj->matarray[i].nfaces = facemats[j];
|
||||
|
||||
UINT curface = 0;
|
||||
|
|
|
@ -237,7 +237,7 @@ void CPropertiesPane::SetPiece(Object* Focus)
|
|||
CMFCPropertyGridProperty* Appearence = m_wndPropList.GetProperty(2);
|
||||
UpdateProperty(Appearence->GetSubItem(0), From);
|
||||
UpdateProperty(Appearence->GetSubItem(1), To);
|
||||
((CLeoCADMFCPropertyGridColorProperty*)Appearence->GetSubItem(2))->SetColor(pPiece->GetColor(), true);
|
||||
((CLeoCADMFCPropertyGridColorProperty*)Appearence->GetSubItem(2))->SetColor(pPiece->mColorIndex, true);
|
||||
|
||||
mObject = Focus;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue