The program at work now will end up in a drawing third dimension editor.
I draw in the window but when I touch a window's control (a menu option, maximize, minimize buttons, other window, etc...) the image at window disappears, do I have to redraw everything? if so, which controls should I include (at WndProc?), and when it's necessary to redraw?. Which is the message for each case, for example, "click on another window?. Otherwise, is there a control that prevents erase?, in this case (surely) is there something I don't know about windows, WndProc, form or other component?.
I have assumed that the case WM_PAINT will behave similarly. Is this true? (I have not used this command yet).
At end of code there is a default case to redraw everything, but it redraws everything all the time !!!!. I don't include functions code and other classes (only the put_pixel function, the math and the 3d class definition. The others have similar definition).
Infinite thanks for your comments.
#include <vcl.h>
#include <windows.h>
#include <DOS.H>
#include <MEM.H>
#include <STDLIB.H>
#include <STDIO.H>
#include <CONIO.H>
#include <STRING.H>
#include <MATH.H>
#include <TIME.H>
#pragma hdrstop
#define ID_AXIS_SHOW 1000
#define ID_AXIS_HIDE 1001
#define ID_ANGLEX_PLUS 1002
#define ID_ANGLEX_MINUS 1003
#define ID_ANGLEY_PLUS 1004
#define ID_ANGLEY_MINUS 1005
#define ID_ANGLEZ_PLUS 1006
#define ID_ANGLEZ_MINUS 1007
#define ID_MOVE_RIGHT 1008
#define ID_MOVE_LEFT 1009
#define ID_MOVE_DOWN 1010
#define ID_MOVE_UP 1011
#define ID_MOVE_FAREST 1012
#define ID_MOVE_NEAREST 1013
#define ID_EXAMPLE 2000
#define ID_ERASE 2001
#define ID_FILE_EXIT 9001
#define ID_STUFF_GO 9002
#define GETMAXX 1150
#define GETMAXY 880
#define WHITE 255,255,255
#define OP_MENU1 7001
#define OP_MENU2 7002
#define OP_MENU3 7003
#define OP_MENU4 7004
#define OP_MENU5 7005
#define OP_MENU6 7006
#define OP_MENU7 7007
#define OP_MENU8 7008
#define OP_MENU9 7009
#define OP_MENU10 7010
#define OP_MENU11 7011
#define OP_MENU12 7012
#define OP_MENU13 7013
#define OP_MENU14 7014
#define OP_MENU_LAYER1 7101
#define OP_MENU_LAYER2 7102
#define OP_MENU_LAYER3 7103
#define OP_MENU_LAYER4 7104
#define OP_MENU_LAYER5 7105
#define OP_MENU_LAYER6 7106
#define ID_CUENTAGOTAS 8000
#define ID_AIRBRUSH 8001
#define ID_PINCEL 8002
#define ID_LINEA 8003
#define ID_LAYER_SHOW 800
#define ID_DEF_X 801
#define ID_DEF_Y 802
#define ID_DEF_Z 803
#define CuadLayerX1 900
#define CuadLayerX2 1100
#define CuadLayerY1 50
#define CuadLayerY2 CuadLayerY1+200
#define CuadLayerY3 CuadLayerY2+200
#define CuadLayerY4 CuadLayerY3+200
#define xMenuLayer1 CuadLayerX1+5
#define xMenuLayer2 CuadLayerX1+25
#define xMenuLayer3 CuadLayerX1+35
#define xMenuLayer4 CuadLayerX1+55
#define xMenuLayer5 CuadLayerX1+65+10
#define xMenuLayer6 CuadLayerX1+85+10
#define xMenuLayer7 CuadLayerX1+95+10
#define xMenuLayer8 CuadLayerX1+115+10
#define xMenuLayer9 CuadLayerX1+125+20
#define xMenuLayer10 CuadLayerX1+145+20
#define xMenuLayer11 CuadLayerX1+155+20
#define xMenuLayer12 CuadLayerX1+175+20
#define yMenuLayer1 CuadLayerY1-20
#define yMenuLayer2 CuadLayerY1-2
#define yMenuLayer3 CuadLayerY2-20+30
#define yMenuLayer4 CuadLayerY2-2+30
#define yMenuLayer5 CuadLayerY3-20+60
#define yMenuLayer6 CuadLayerY3-2+60
#include "edit3d-2.cpp" // all functions not included on this post
//------------------- DRAWS A PIXEL -------------------------------------
int put_pixel(int red, int green, int blue, int x, int y)
{
if(x>0&&x<GETMAXX&&y>0&&y<GETMAXY)
{
COLORREF color = RGB(red,green,blue);
HWND hwnd = FindWindow(NULL, "Editor 3d"); // Find window
HDC hdc = GetDC(hwnd); // Get the DC from that HWND
SetPixel(hdc, x, y, color);
ReleaseDC(hwnd, hdc); // Release the DC
DeleteDC(hdc); // Delete the DC
return(0);
}
return(1);
};
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// THIRD DIMENSION
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class TerceraDimension {
friend Layer;
double distpan; /* EYES DISTANCE (mts.)*/
double dimpany; /* VERTICAL SCREEN DIMENSIàN (mts. VGA)*/
double dimpanx; /* HORIZONTAL SCREEN DIMENSIàN (mts. VGA)*/
double distx,disty,distz; /* PIXELS POSITION */
double xpan,ypan; /* END PIXEL COORDS ON SCREEN */
double ojpan; /* (.185 / 5 ) EYES POSITION */
double centrox; /* HALF SCREEN */
double ojpanpix; /* EYES HIGH POSITION PIXELS */
double X,Y,Z;
double X1, Y1, Z1, X2, Y2, Z2, X3, Y3, Z3, X4, Y4, Z4;
double incrx,incry,incrz;
double xo,yo,zo;
double alf,bet,gam;
int cd, i, co, cf;
int mododib;
int proceso;
double xpanAnt, ypanAnt;
double cpan(double X,double Y,double Z,int i);
double cpanDer(double X,double Y,double Z, int i);
int DibP(double Dibx,double Diby,double Dibz,int cd);
int pyx(double Dibx,double Diby,double Dibz,int cd);
double conv3Da2(int que,double alf_i,double bet_i,double gam_i,double alf_j,double bet_j,double gam_j,double alf_k,double bet_k,double gam_k);
double conv3Da2xyz(int que,double x, double y, double z,double alf_i,double bet_i,double gam_i,double alf_j,double bet_j,double gam_j,double alf_k,double bet_k,double gam_k,int red,int green,int blue);
void vectorUnit(double x, double y, double z);
int inicio;
int terminaDib;
void dibRectaAngs(double xRel,double yRel,double zRel,double xi,double yi,double zi,double xf,double yf,double zf,double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk);
long double incr1,incr2,incr3,incr4,incr5,incr6;
public:
double angejex; /* PLANE ANGLE XY' (PI/2=1.570796327) */
double distejpanx1; /* HORIZONTAL EYES DISTANCE (mts.) */
double distejpanz1; /* SCREEN VERTICAL DESVIATION (mts.) */
double distejpany1; /* SCREEN HORIZONTAL DESVIATION (mts.) */
double angejexRel;
double angejeyRel;
double angejezRel;
double distejpanx1Rel;
double distejpany1Rel;
double distejpanz1Rel;
double xRel;
double yRel;
double zRel;
double xAbs,yAbs,zAbs;
double i1,i2,i3,j1,j2,j3,k1,k2,k3;
double alf_iGl,bet_iGl,gam_iGl,alf_jGl,bet_jGl,gam_jGl,alf_kGl,bet_kGl,gam_kGl;
double alf_iAnt,bet_iAnt,gam_iAnt,alf_jAnt,bet_jAnt,gam_jAnt,alf_kAnt,bet_kAnt,gam_kAnt;
double alf_iRel,bet_iRel,gam_iRel,alf_jRel,bet_jRel,gam_jRel,alf_kRel,bet_kRel,gam_kRel;
int color;
double xIniLine,yIniLine,zIniLine,xFinLine,yFinLine,zFinLine;
//--------FUNTIONS
dirAngles obVectsEjesRel(int,double,double,double,double,double,double,double,double,double,double);
dirAngles obVectsEjesRel2(int cualPlanoRota,double x1,double y1,double z1,double x2,double y2,double z2);
void planOrto(double x1,double y1,double z1,double x2,double y2,double z2);
dirAngles cuadrantes(double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk);
coordsXYZ obtieneCoords(void);
coordsXYZ obCoords(int cual,double incr);
dirAngles obOrto(double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk);
dirAngles obOrtoZ(double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk);
void lit(double Xp1,double Yp1,double Zp1,double Xp2,double Yp2,double Zp2,double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk,int c);
void linRel(double xAbs,double yAbs,double zAbs,double Xp1,double Yp1,double Zp1,double Xp2,double Yp2,double Zp2,double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk,int c);
void TerceraDimension::linea(int que,double xpar1,double ypar1,double zpar1,double xpar2,double ypar2,double zpar2,int red, int green, int blue);
void anguloEjeXMas(double angulo);
void anguloEjeXMenos(double angulo);
void anguloEjeX(double angulo);
void anguloEjeYMas(double angulo);
void distanciaOjosXalOrigen(double distancia);
void distanciaOjosYalOrigen(double distancia);
void distanciaOjosZalOrigen(double distancia);
void imperror(void);
void OjosXalOrigenMas(double distancia);
void OjosXalOrigenMenos(double distancia);
void OjosYalOrigenIzq(double distancia);
void OjosYalOrigenDer(double distancia);
void OjosZalOrigenArr(double distancia);
void OjosZalOrigenAba(double distancia);
void anguloEjeXRel(double angulo);
void anguloEjeXMasRel(double angulo);
void anguloEjeXMenosRel(double angulo);
void anguloEjeYRel(double angulo);
void anguloEjeYMasRel(double angulo);
void anguloEjeYMenosRel(double angulo);
void anguloEjeZRel(double angulo);
void anguloEjeZMasRel(double angulo);
void anguloEjeZMenosRel(double angulo);
void distanciaOjosXalOrigenRel(double distancia);
void OjosXalOrigenMasRel(double distancia);
void OjosXalOrigenMenosRel(double distancia);
void distanciaOjosYalOrigenRel(double distancia);
void OjosYalOrigenIzqRel(double distancia);
void OjosYalOrigenDerRel(double distancia);
void distanciaOjosZalOrigenRel(double distancia);
void OjosZalOrigenArrRel(double distancia);
void OjosZalOrigenAbaRel(double distancia);
void dibujaInicio(int red, int green, int blue);
int abre(char archivo[]);
void area4puntosRellena(double xpar1,double ypar1,double zpar1,double xpar2,double ypar2,double zpar2, double xpar3,double ypar3,double zpar3,double xpar4,double ypar4,double zpar4, int borra, int c);
void ejemArea4puntos(double xpar1,double ypar1,double zpar1,double xpar2,double ypar2,double zpar2, double xpar3,double ypar3,double zpar3,double xpar4,double ypar4,double zpar4, int borra, int c);
void parhiper5(int borDib,double alf_i,double bet_i,double gam_i,double alf_j,double bet_j,double gam_j,double alf_k,double bet_k,double gam_k);
void ejes(int red,int green,int blue);
void ejesConvs3(double alf_i,double bet_i,double gam_i,double alf_j,double bet_j,double gam_j,double alf_k,double bet_k,double gam_k,int c);
void TerceraDimension::nuevosEjesConvs3(double x,double y,double z,double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk,int red,int green,int blue);
int avion(int borDib, double alf_i,double bet_i,double gam_i,double alf_j,double bet_j,double gam_j,double alf_k,double bet_k,double gam_k);
int elipsoide(void);
int elipsoide2(void);
int elipsoide3(void);
void forma(void);
TerceraDimension::TerceraDimension(void);
};
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
// MATH
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
//||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
class Math{
friend TerceraDimension;
public:
long double devAng2VecXYZ(double x1,double y1,double z1,double x2,double y2,double z2);
double devAng2VecAng(double alfa1,double gama1,double beta1,double alfa2,double beta2,double gama2);
angsVector obAngsDirects(double x1, double y1, double z1,double x2, double y2, double z2);
coordsXYZ convRelAbs(double xRel, double yRel, double zRel,double x, double y, double z,double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk);
coordsXYZ convAbsRel(double x,double y,double z,double xRel, double yRel, double zRel,double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk);
numsDirects rectaOrtoTriang(double xAbs, double yAbs, double zAbs, double a1,double b1,double c1,double a2,double b2,double c2,double a3,double b3,double c3);
coordsXYZ obCoordsAngsyPunto(double x1,double y1,double z1,double x2,double y2,double z2,double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk);
coordsXYZ convxyz(double xRel,double yRel,double zRel,double x,double y,double z,double alfi,double beti,double gami,double alfj,double betj,double gamj,double alfk,double betk,double gamk,int col);
};
//------------------------- LRESULT ------------------------------------
LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
switch(Message)
{
case WM_CREATE:
{
HMENU hMenu, hSubMenu;
HICON hIcon, hIconSm;
hMenu = CreateMenu();
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&File");
AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "&New");
AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "&Save");
AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "&Save as");
AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "&Save masque");
AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "&Import");
AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "&Print");
AppendMenu(hSubMenu, MF_STRING, ID_FILE_EXIT, "&Exit");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Edit");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Copy");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Paste");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Paste object");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Insert");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Select");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Create 3d node");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Redefine 3d node");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&DrawTools");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Line");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Square");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Rectangle");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Poligon");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Circle");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Ellipse");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Sphere");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Ellipsoid");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Plane");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&X lay");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Y lay");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Z lay");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Grid");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&PaintTools");
AppendMenu(hSubMenu, MF_STRING, ID_CUENTAGOTAS, "&CuentaGotas");
AppendMenu(hSubMenu, MF_STRING, ID_PINCEL, "&Pincel");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Water");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Oil");
AppendMenu(hSubMenu, MF_STRING, ID_AIRBRUSH, "&Air brush");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Erase");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Set drawing color");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Set back color");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Set fill color");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Sculpt");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Repujado sphere");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Repujado transversal bar");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Repujado cilinder");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Aspirator sphere");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Aspirator transversal bar");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Aspirator cilinder");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Cincel");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Metal brush");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Paste");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Heat");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Layer");
AppendMenu(hSubMenu, MF_STRING, ID_LAYER_SHOW, "&Show Layer");
AppendMenu(hSubMenu, MF_STRING, ID_DEF_X, "&Define x");
AppendMenu(hSubMenu, MF_STRING, ID_DEF_Y, "&Define y");
AppendMenu(hSubMenu, MF_STRING, ID_DEF_Z, "&Define z");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Move 3d");
AppendMenu(hSubMenu, MF_STRING, ID_AXIS_SHOW, "&Show axis");
AppendMenu(hSubMenu, MF_STRING, ID_AXIS_HIDE, "&Hide axis");
AppendMenu(hSubMenu, MF_STRING, ID_MOVE_UP, "&Up");
AppendMenu(hSubMenu, MF_STRING, ID_MOVE_DOWN, "&Down");
AppendMenu(hSubMenu, MF_STRING, ID_MOVE_RIGHT, "&Right");
AppendMenu(hSubMenu, MF_STRING, ID_MOVE_LEFT, "&Left");
AppendMenu(hSubMenu, MF_STRING, ID_MOVE_NEAREST, "&Nearest");
AppendMenu(hSubMenu, MF_STRING, ID_MOVE_FAREST, "&Farest");
AppendMenu(hSubMenu, MF_STRING, ID_ANGLEX_PLUS, "&AngleX +");
AppendMenu(hSubMenu, MF_STRING, ID_ANGLEX_MINUS, "&AngleX -");
AppendMenu(hSubMenu, MF_STRING, ID_ANGLEY_PLUS, "&AngleY +");
AppendMenu(hSubMenu, MF_STRING, ID_ANGLEY_MINUS, "&AngleY -");
AppendMenu(hSubMenu, MF_STRING, ID_ANGLEZ_PLUS, "&AngleZ +");
AppendMenu(hSubMenu, MF_STRING, ID_ANGLEZ_MINUS, "&AngleZ -");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Redraw");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Object");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Create cube");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Create sphere");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Create ellipsoid");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Delete");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&Script");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&New");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&See all");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Action object");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Rewind");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Choose time");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&End");
hSubMenu = CreatePopupMenu();
AppendMenu(hMenu, MF_STRING | MF_POPUP, (UINT)hSubMenu, "&View");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&RGB Pallete");
AppendMenu(hSubMenu, MF_STRING, ID_STUFF_GO, "&Objects");
AppendMenu(hSubMenu, MF_STRING, ID_EXAMPLE, "&Ejemplo");
AppendMenu(hSubMenu, MF_STRING, ID_ERASE, "&Borra");
SetMenu(hwnd, hMenu);
hIcon = (HICON)LoadImage(NULL, "menu_two.ico", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
//hIcon = (HICON)LoadImage(NULL, "menu_two.bmp", IMAGE_ICON, 32, 32, LR_LOADFROMFILE);
if(hIcon) {SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);}
else {MessageBox(hwnd, "Could not load large icon! Is it in the current working directory?", "Error", MB_OK | MB_ICONERROR);}
hIconSm = (HICON)LoadImage(NULL, "menu_two.ico", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
//hIcon = (HICON)LoadImage(NULL, "menu_two.bmp", IMAGE_ICON, 16, 16, LR_LOADFROMFILE);
if(hIconSm){SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hIconSm);}
else{MessageBox(hwnd, "Could not load small icon! Is it in the current working directory?", "Error", MB_OK | MB_ICONERROR);}
}
break;
case WM_COMMAND:
switch(LOWORD(wParam))
{
case ID_FILE_EXIT:PostMessage(hwnd, WM_CLOSE, 0, 0); break;
case ID_STUFF_GO: procesoGlobal= 0;MessageBox(hwnd, "You clicked 1!", "Woo!", MB_OK); break;
case ID_CUENTAGOTAS:procesoGlobal= ID_CUENTAGOTAS; break;
case ID_AIRBRUSH:procesoGlobal= ID_AIRBRUSH; break;
case ID_PINCEL:procesoGlobal= ID_PINCEL; break;
case ID_MOVE_NEAREST:procesoGlobal= ID_MOVE_NEAREST; break;
case ID_MOVE_FAREST:procesoGlobal= ID_MOVE_FAREST; break;
case ID_MOVE_RIGHT: procesoGlobal= ID_MOVE_RIGHT; break;
case ID_MOVE_LEFT: procesoGlobal= ID_MOVE_LEFT; break;
case ID_ANGLEX_PLUS: procesoGlobal= ID_ANGLEX_PLUS; break;
case ID_ANGLEX_MINUS:procesoGlobal= ID_ANGLEX_MINUS; break;
case ID_ANGLEY_PLUS: procesoGlobal= ID_ANGLEY_PLUS; break;
case ID_ANGLEY_MINUS:procesoGlobal= ID_ANGLEY_MINUS; break;
case ID_ANGLEZ_PLUS: procesoGlobal= ID_ANGLEZ_PLUS; break;
case ID_ANGLEZ_MINUS:procesoGlobal= ID_ANGLEZ_MINUS; break;
case ID_MOVE_DOWN:procesoGlobal= ID_MOVE_DOWN; break;
case ID_MOVE_UP:procesoGlobal= ID_MOVE_UP; break;
case ID_EXAMPLE:procesoGlobal= ID_EXAMPLE; break;
case ID_ERASE:procesoGlobal= ID_ERASE; break;
case ID_AXIS_SHOW: procesoGlobal= ID_AXIS_SHOW; break;
case ID_AXIS_HIDE: procesoGlobal= ID_AXIS_HIDE; break;
case ID_LAYER_SHOW: procesoGlobal= ID_LAYER_SHOW; break;
}
break;
case WM_CLOSE: DestroyWindow(hwnd);break;
case WM_DESTROY:PostQuitMessage(0);break;
//BEGIN MOUSE EVENTS--------------------------------------------
case WM_PAINT:
// Adding drawing code ...
break;
// Left button event used to print the screen
case WM_LBUTTONDOWN:
flag = true;
xMouse = LOWORD(lParam);
yMouse = HIWORD(lParam);
if(xMouse>xMenu1&&yMouse>yMenu1&&xMouse<xMenu2&&yMouse<yMenu2)
procesoGlobal=OP_MENU1;
if(xMouse>xMenu3&&yMouse>yMenu3&&xMouse<xMenu4&&yMouse<yMenu4)
procesoGlobal=OP_MENU2;
if(xMouse>xMenu5&&yMouse>yMenu5&&xMouse<xMenu6&&yMouse<yMenu6)
procesoGlobal=OP_MENU3;
if(xMouse>xMenu7&&yMouse>yMenu7&&xMouse<xMenu8&&yMouse<yMenu8)
procesoGlobal=OP_MENU4;
if(xMouse>xMenu9&&yMouse>yMenu9&&xMouse<xMenu10&&yMouse<yMenu10)
procesoGlobal=OP_MENU5;
if(xMouse>xMenu11&&yMouse>yMenu11&&xMouse<xMenu12&&yMouse<yMenu12)
procesoGlobal=OP_MENU6;
if(xMouse>xMenu15&&yMouse>yMenu15&&xMouse<xMenu16&&yMouse<yMenu16)
procesoGlobal=OP_MENU7;
if(xMouse>xMenu17&&yMouse>yMenu17&&xMouse<xMenu18&&yMouse<yMenu18)
procesoGlobal=OP_MENU8;
if(xMouse>xMenu19&&yMouse>yMenu19&&xMouse<xMenu20&&yMouse<yMenu20)
procesoGlobal=OP_MENU9;
if(xMouse>xMenu21&&yMouse>yMenu21&&xMouse<xMenu22&&yMouse<yMenu22)
procesoGlobal=OP_MENU10;
if(xMouse>xMenu23&&yMouse>yMenu23&&xMouse<xMenu24&&yMouse<yMenu24)
procesoGlobal=OP_MENU11;
if(xMouse>xMenu25&&yMouse>yMenu25&&xMouse<xMenu26&&yMouse<yMenu26)
procesoGlobal=OP_MENU12;
if(xMouse>xMenu27&&yMouse>yMenu27&&xMouse<xMenu28&&yMouse<yMenu28)
procesoGlobal=OP_MENU13;
if(xMouse>xMenu29&&yMouse>yMenu29&&xMouse<xMenu30&&yMouse<yMenu30)
procesoGlobal=OP_MENU14;
if(xMouse>xMenuLayer1&&yMouse>yMenuLayer1&&xMouse<xMenuLayer2&&yMouse<yMenuLayer2)
procesoGlobal=OP_MENU_LAYER1;
if(xMouse>xMenuLayer3&&yMouse>yMenuLayer1&&xMouse<xMenuLayer4&&yMouse<yMenuLayer2)
procesoGlobal=OP_MENU_LAYER2;
if(xMouse>xMenuLayer5&&yMouse>yMenuLayer1&&xMouse<xMenuLayer6&&yMouse<yMenuLayer2)
procesoGlobal=OP_MENU_LAYER3;
if(xMouse>xMenuLayer7&&yMouse>yMenuLayer1&&xMouse<xMenuLayer8&&yMouse<yMenuLayer2)
procesoGlobal=OP_MENU_LAYER4;
if(xMouse>xMenuLayer9&&yMouse>yMenuLayer1&&xMouse<xMenuLayer10&&yMouse<yMenuLayer2)
procesoGlobal=OP_MENU_LAYER5;
if(xMouse>xMenuLayer11&&yMouse>yMenuLayer1&&xMouse<xMenuLayer12&&yMouse<yMenuLayer2)
procesoGlobal=OP_MENU_LAYER6;
switch(principalTool)
{
case 0:
put_pixel(color, xMouse, yMouse);break;
case ID_AIRBRUSH:
airBrush(0,100,color, xMouse, yMouse); break;
case ID_CUENTAGOTAS:
color=get_pixel(xMouse,yMouse);
principalTool=0;
case ID_PINCEL:
pincel(0,.5,color, xMouse, yMouse); break;
case ID_LINEA:
procesoGlobal=ID_LINEA;break;
}
break;
// Right button event used to erase the screen content
// supposed nothing occur yet.
case WM_RBUTTONDOWN:
flag = true;
xMouse = LOWORD(lParam);
yMouse = HIWORD(lParam);
put_pixel(10,50,120, xMouse, yMouse);
break;
// Sets the flag to false so that we know the left mouse button was released
case WM_LBUTTONUP:
flag = false;
break;
// Sets the flag to false so that we know the right mouse button was released
case WM_RBUTTONUP:
flag = false;
break;
// Controls the mouse movement and shows its current position on the Window title
case WM_MOUSEMOVE:
if(flag)
{
AnsiString strTitle;
xMouse = LOWORD(lParam);
yMouse = HIWORD(lParam);
switch(principalTool)
{
case 0:
put_pixel(color, xMouse, yMouse);break;
case ID_AIRBRUSH:
airBrush(0,100,color, xMouse, yMouse); break;
case ID_CUENTAGOTAS:
color=get_pixel(xMouse,yMouse);
principalTool=0;
case ID_PINCEL:
pincel(0,1.5,color, xMouse, yMouse); break;
}
}
else
{
AnsiString strTitle;
xMouse = LOWORD(lParam);
yMouse = HIWORD(lParam);
}
break;
//END MOUSE EVENTS--------------------------------------------
default:return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
};
//==============================================================================
//==============================================================================
//==============================================================================
//==============================================================================
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow){
// CLASES
WNDCLASSEX wc;
HWND hwnd;
MSG Msg;
TerceraDimension td;
GraficosMenu gm;
Layer lay;
Colors col;
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = 0;
wc.lpfnWndProc = WndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wc.lpszMenuName = NULL;
wc.lpszClassName = g_szClassName;
wc.hIconSm = NULL;
if(!RegisterClassEx(&wc))
{
MessageBox(NULL, "Window Registration Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
hwnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
g_szClassName,
"Editor 3d",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, GETMAXX, GETMAXY,
NULL, NULL, hInstance, NULL);
if(hwnd == NULL)
{
MessageBox(NULL, "Window Creation Failed!", "Error!",
MB_ICONEXCLAMATION | MB_OK);
return 0;
}
ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);
td.distejpanx1 = 50;
td.distejpanz1 = 3;
td.distejpany1 = 0;
td.angejex=3.141592654/8.0;
ActRed=0, ActGreen=0, ActBlue=0;
color = RGB(ActRed,ActGreen,ActBlue);
td.alf_iGl=0; td.bet_iGl=PI/2;td.gam_iGl=PI/2;
td.alf_jGl=PI/2; td.bet_jGl=0; td.gam_jGl=PI/2;
td.alf_kGl=PI+PI/2;td.bet_kGl=PI/2;td.gam_kGl=0;
td.alf_iRel=0; td.bet_iRel=PI/2;td.gam_iRel=PI/2;
td.alf_jRel=PI/2; td.bet_jRel=0; td.gam_jRel=PI/2;
td.alf_kRel=PI/2; td.bet_kRel=PI/2;td.gam_kRel=0;
td.xAbs=0;td.yAbs=0;td.zAbs=0;
td.alf_iAnt=td.alf_iGl;td.bet_iAnt=td.bet_iGl;td.gam_iAnt=td.gam_iGl;
td.alf_jAnt=td.alf_jGl;td.bet_jAnt=td.bet_jGl;td.gam_jAnt=td.gam_jGl;
td.alf_kAnt=td.alf_kGl;td.bet_kAnt=td.bet_kGl;td.gam_kAnt=td.gam_kGl;
int axR=5,axB=20,axG=20;
int axRR=5,axRB=20,axRG=20;
int i=0,j=0;
xMenu1=15;yMenu1=15; xMenu2=33;yMenu2=33;
xMenu3=35;yMenu3=15; xMenu4=53;yMenu4=33;
xMenu5=55;yMenu5=15; xMenu6=73;yMenu6=33;
xMenu7=75;yMenu7=15; xMenu8=93;yMenu8=33;
xMenu9=95;yMenu9=15; xMenu10=113;yMenu10=33;
xMenu11=115;yMenu11=15; xMenu12=133;yMenu12=33;
xMenu13=135;yMenu13=15; xMenu14=153;yMenu14=53;
xMenu15=15;yMenu15=35; xMenu16=33;yMenu16=53;
xMenu17=35;yMenu17=35; xMenu18=53;yMenu18=53;
xMenu19=55;yMenu19=35; xMenu20=73;yMenu20=53;
xMenu21=75;yMenu21=35; xMenu22=93;yMenu22=53;
xMenu23=95;yMenu23=35; xMenu24=113;yMenu24=53;
xMenu25=115;yMenu25=35; xMenu26=133;yMenu26=53;
// THESE for's ARE ON VERY SLOW MOOD WAITING TO BE INCLUDED ON A FUNCTION
for (i=xMenu1;i<xMenu2;i++)
for (j=yMenu1;j<yMenu2;j++)
put_pixel(255,0,0,i,j);
for (i=xMenu3;i<xMenu4;i++)
for (j=yMenu3;j<yMenu4;j++)
put_pixel(0,255,0,i,j);
for (i=xMenu5;i<xMenu6;i++)
for (j=yMenu5;j<yMenu6;j++)
put_pixel(0,0,255,i,j);
for (i=xMenu7;i<xMenu8;i++)
for (j=yMenu7;j<yMenu8;j++)
put_pixel(255,0,0,i,j);
for (i=xMenu9;i<xMenu10;i++)
for (j=yMenu9;j<yMenu10;j++)
put_pixel(0,255,0,i,j);
for (i=xMenu11;i<xMenu12;i++)
for (j=yMenu11;j<yMenu12;j++)
put_pixel(0,0,255,i,j);
for (i=xMenu13;i<xMenu14;i++)
for (j=yMenu13;j<yMenu14;j++)
put_pixel(ActRed,ActGreen,ActBlue,i,j);
for (i=xMenu15;i<xMenu16;i++)
for (j=yMenu15;j<yMenu16;j++)
put_pixel(255,0,0,i,j);
for (i=xMenu17;i<xMenu18;i++)
for (j=yMenu17;j<yMenu18;j++)
put_pixel(0,255,0,i,j);
for (i=xMenu19;i<xMenu20;i++)
for (j=yMenu19;j<yMenu20;j++)
put_pixel(0,0,255,i,j);
for (i=xMenu21;i<xMenu22;i++)
for (j=yMenu21;j<yMenu22;j++)
put_pixel(255,0,0,i,j);
for (i=xMenu23;i<xMenu24;i++)
for (j=yMenu23;j<yMenu24;j++)
put_pixel(0,255,0,i,j);
for (i=xMenu25;i<xMenu26;i++)
for (j=yMenu25;j<yMenu26;j++)
put_pixel(0,0,255,i,j);
xMenu27=155;yMenu27=15; xMenu28=173;yMenu28=28;//AIR BRUSH
xMenu29=175;yMenu29=15; xMenu30=193;yMenu30=28;//BRUSH
for (i=xMenu27;i<xMenu28;i++)
for (j=yMenu27;j<yMenu28;j++)
put_pixel(150,150,150,i,j);
for (i=xMenu29;i<xMenu30;i++)
for (j=yMenu29;j<yMenu30;j++)
put_pixel(200,200,200,i,j);
int dibujaLinea=0;
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
switch(procesoGlobal)
{
case ID_LAYER_SHOW:
lay.cuadroDib(CuadLayerX1,CuadLayerY1,CuadLayerX2,CuadLayerY2);
lay.cuadroDib(CuadLayerX1,CuadLayerY2+30,CuadLayerX2,CuadLayerY3+30);
lay.cuadroDib(CuadLayerX1,CuadLayerY3+60,CuadLayerX2,CuadLayerY4+60);
{int i=0,J=0;
for (i=xMenuLayer1;i<xMenuLayer2;i++)
for (j=yMenuLayer1;j<yMenuLayer2;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer3;i<xMenuLayer4;i++)
for (j=yMenuLayer1;j<yMenuLayer2;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer5;i<xMenuLayer6;i++)
for (j=yMenuLayer1;j<yMenuLayer2;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer7;i<xMenuLayer8;i++)
for (j=yMenuLayer1;j<yMenuLayer2;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer9;i<xMenuLayer10;i++)
for (j=yMenuLayer1;j<yMenuLayer2;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer11;i<xMenuLayer12;i++)
for (j=yMenuLayer1;j<yMenuLayer2;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer1;i<xMenuLayer2;i++)
for (j=yMenuLayer3;j<yMenuLayer4;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer3;i<xMenuLayer4;i++)
for (j=yMenuLayer3;j<yMenuLayer4;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer5;i<xMenuLayer6;i++)
for (j=yMenuLayer3;j<yMenuLayer4;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer7;i<xMenuLayer8;i++)
for (j=yMenuLayer3;j<yMenuLayer4;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer9;i<xMenuLayer10;i++)
for (j=yMenuLayer3;j<yMenuLayer4;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer11;i<xMenuLayer12;i++)
for (j=yMenuLayer3;j<yMenuLayer4;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer1;i<xMenuLayer2;i++)
for (j=yMenuLayer5;j<yMenuLayer6;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer3;i<xMenuLayer4;i++)
for (j=yMenuLayer5;j<yMenuLayer6;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer5;i<xMenuLayer6;i++)
for (j=yMenuLayer5;j<yMenuLayer6;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer7;i<xMenuLayer8;i++)
for (j=yMenuLayer5;j<yMenuLayer6;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer9;i<xMenuLayer10;i++)
for (j=yMenuLayer5;j<yMenuLayer6;j++)
put_pixel(130,150,200,i,j);
for (i=xMenuLayer11;i<xMenuLayer12;i++)
for (j=yMenuLayer5;j<yMenuLayer6;j++)
put_pixel(130,150,200,i,j);
}
procesoGlobal=0;
break;
case ID_AXIS_SHOW:
Application->Run();
td.dibujaInicio(10, 50, 255);
procesoGlobal=0; break;
case ID_AXIS_HIDE:
td.dibujaInicio(255, 255, 255);
procesoGlobal=0; break;
case ID_ANGLEX_PLUS:
{
coordsXYZ xyz1;coordsXYZ xyz2;
dirAngles ang;
xyz1=td.obCoords(YZROT,(long double).05);gotoxy(1,8);
xyz2=td.obCoords(YZROT,(long double)PI/2+.05);
ang=td.obVectsEjesRel2(YZROT,xyz1.x,xyz1.y,xyz1.z,xyz2.x,xyz2.y,xyz2.z);
td.alf_iRel=(double)ang.alfiSt;td.bet_iRel=(double)ang.betiSt;
td.gam_iRel=(double)ang.gamiSt;td.alf_jRel=(double)ang.alfjSt;
td.bet_jRel=(double)ang.betjSt;td.gam_jRel=(double)ang.gamjSt;
td.alf_kRel=(double)ang.alfkSt;td.bet_kRel=(double)ang.betkSt;
td.gam_kRel=(double)ang.gamkSt;
td.ejesConvs3(td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl,5);
td.nuevosEjesConvs3(td.xRel,td.yRel,td.zRel,td.alf_iRel,td.bet_iRel,td.gam_iRel,td.alf_jRel,td.bet_jRel,td.gam_jRel,td.alf_kRel,td.bet_kRel,td.gam_kRel,axRR,axRB,axRG);
}
procesoGlobal=0; break;
case ID_ANGLEX_MINUS:
{
coordsXYZ xyz1;coordsXYZ xyz2;
dirAngles ang;
xyz1=td.obCoords(YZROT,(long double)-.01);gotoxy(1,8);
xyz2=td.obCoords(YZROT,(long double)PI/2-.01);
ang=td.obVectsEjesRel2(YZROT,xyz1.x,xyz1.y,xyz1.z,xyz2.x,xyz2.y,xyz2.z);
td.alf_iRel=(double)ang.alfiSt;td.bet_iRel=(double)ang.betiSt;
td.gam_iRel=(double)ang.gamiSt;td.alf_jRel=(double)ang.alfjSt;
td.bet_jRel=(double)ang.betjSt;td.gam_jRel=(double)ang.gamjSt;
td.alf_kRel=(double)ang.alfkSt;td.bet_kRel=(double)ang.betkSt;
td.gam_kRel=(double)ang.gamkSt;
td.ejesConvs3(td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl,5);
td.nuevosEjesConvs3(td.xRel,td.yRel,td.zRel,td.alf_iRel,td.bet_iRel,td.gam_iRel,td.alf_jRel,td.bet_jRel,td.gam_jRel,td.alf_kRel,td.bet_kRel,td.gam_kRel,axRR,axRB,axRG);
}
procesoGlobal=0; break;
case ID_ANGLEY_PLUS:
{
coordsXYZ xyz1;coordsXYZ xyz2;
dirAngles ang;
xyz1=td.obCoords(XZROT,(long double).05);gotoxy(1,8);
xyz2=td.obCoords(XZROT,(long double)PI/2+.05);
ang=td.obVectsEjesRel2(XZROT,xyz1.x,xyz1.y,xyz1.z,xyz2.x,xyz2.y,xyz2.z);
td.alf_iRel=(double)ang.alfiSt;td.bet_iRel=(double)ang.betiSt;
td.gam_iRel=(double)ang.gamiSt;td.alf_jRel=(double)ang.alfjSt;
td.bet_jRel=(double)ang.betjSt;td.gam_jRel=(double)ang.gamjSt;
td.alf_kRel=(double)ang.alfkSt;td.bet_kRel=(double)ang.betkSt;
td.gam_kRel=(double)ang.gamkSt;
td.ejesConvs3(td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl,5);
td.nuevosEjesConvs3(td.xRel,td.yRel,td.zRel,td.alf_iRel,td.bet_iRel,td.gam_iRel,td.alf_jRel,td.bet_jRel,td.gam_jRel,td.alf_kRel,td.bet_kRel,td.gam_kRel,axRR,axRB,axRG);
}
procesoGlobal=0; break;
case ID_ANGLEY_MINUS:
{
coordsXYZ xyz1;coordsXYZ xyz2;
dirAngles ang;
xyz1=td.obCoords(XZROT,(long double)-.01);gotoxy(1,8);
xyz2=td.obCoords(XZROT,(long double)PI/2-.01);
ang=td.obVectsEjesRel2(XZROT,xyz1.x,xyz1.y,xyz1.z,xyz2.x,xyz2.y,xyz2.z);
td.alf_iRel=(double)ang.alfiSt;td.bet_iRel=(double)ang.betiSt;
td.gam_iRel=(double)ang.gamiSt;td.alf_jRel=(double)ang.alfjSt;
td.bet_jRel=(double)ang.betjSt;td.gam_jRel=(double)ang.gamjSt;
td.alf_kRel=(double)ang.alfkSt;td.bet_kRel=(double)ang.betkSt;
td.gam_kRel=(double)ang.gamkSt;
td.ejesConvs3(td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl,5);
td.nuevosEjesConvs3(td.xRel,td.yRel,td.zRel,td.alf_iRel,td.bet_iRel,td.gam_iRel,td.alf_jRel,td.bet_jRel,td.gam_jRel,td.alf_kRel,td.bet_kRel,td.gam_kRel,axRR,axRB,axRG);
}
procesoGlobal=0; break;
case ID_ANGLEZ_PLUS:
{
coordsXYZ xyz1;coordsXYZ xyz2;
dirAngles ang;
xyz1=td.obCoords(XYROT,(long double).05);gotoxy(1,8);
xyz2=td.obCoords(XYROT,(long double)PI/2+.05);
ang=td.obVectsEjesRel2(XYROT,xyz1.x,xyz1.y,xyz1.z,xyz2.x,xyz2.y,xyz2.z);
td.alf_iRel=(double)ang.alfiSt;td.bet_iRel=(double)ang.betiSt;
td.gam_iRel=(double)ang.gamiSt;td.alf_jRel=(double)ang.alfjSt;
td.bet_jRel=(double)ang.betjSt;td.gam_jRel=(double)ang.gamjSt;
td.alf_kRel=(double)ang.alfkSt;td.bet_kRel=(double)ang.betkSt;
td.gam_kRel=(double)ang.gamkSt;
td.ejesConvs3(td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl,5);
td.nuevosEjesConvs3(td.xRel,td.yRel,td.zRel,td.alf_iRel,td.bet_iRel,td.gam_iRel,td.alf_jRel,td.bet_jRel,td.gam_jRel,td.alf_kRel,td.bet_kRel,td.gam_kRel,axRR,axRB,axRG);
}
procesoGlobal=0; break;
case ID_ANGLEZ_MINUS:
{
coordsXYZ xyz1;coordsXYZ xyz2;
dirAngles ang;
xyz1=td.obCoords(XYROT,(long double)-.01);gotoxy(1,8);
xyz2=td.obCoords(XYROT,(long double)PI/2-.01);
ang=td.obVectsEjesRel2(XYROT,xyz1.x,xyz1.y,xyz1.z,xyz2.x,xyz2.y,xyz2.z);
td.alf_iRel=(double)ang.alfiSt;td.bet_iRel=(double)ang.betiSt;
td.gam_iRel=(double)ang.gamiSt;td.alf_jRel=(double)ang.alfjSt;
td.bet_jRel=(double)ang.betjSt;td.gam_jRel=(double)ang.gamjSt;
td.alf_kRel=(double)ang.alfkSt;td.bet_kRel=(double)ang.betkSt;
td.gam_kRel=(double)ang.gamkSt;
td.ejesConvs3(td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl,5);
td.nuevosEjesConvs3(td.xRel,td.yRel,td.zRel,td.alf_iRel,td.bet_iRel,td.gam_iRel,td.alf_jRel,td.bet_jRel,td.gam_jRel,td.alf_kRel,td.bet_kRel,td.gam_kRel,axRR,axRB,axRG);
}
procesoGlobal=0; break;
case ID_MOVE_NEAREST:
td.nuevosEjesConvs3(0,0,0,REL_ANGS,WHITE);
td.OjosYalOrigenDer(1);
td.nuevosEjesConvs3(0,0,0,REL_ANGS,axRR,axRB,axRG);
procesoGlobal=0; break;
case ID_MOVE_FAREST:
td.nuevosEjesConvs3(0,0,0,REL_ANGS,WHITE);
td.OjosYalOrigenIzq(1);
td.nuevosEjesConvs3(0,0,0,REL_ANGS,axRR,axRB,axRG);
procesoGlobal=0; break;
case ID_MOVE_DOWN:
td.nuevosEjesConvs3(0,0,0,REL_ANGS,WHITE);
td.OjosZalOrigenArr(1);
td.nuevosEjesConvs3(0,0,0,REL_ANGS,axRR,axRB,axRG);
procesoGlobal=0; break;
case ID_MOVE_UP:
td.nuevosEjesConvs3(0,0,0,REL_ANGS,WHITE);
td.OjosZalOrigenAba(1);
td.nuevosEjesConvs3(0,0,0,REL_ANGS,axRR,axRB,axRG);
procesoGlobal=0; break;
case ID_MOVE_LEFT:
td.nuevosEjesConvs3(0,0,0,REL_ANGS,WHITE);
td.OjosXalOrigenMas(.5);
td.ejesConvs3(td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl,100);
td.nuevosEjesConvs3(0,0,0,REL_ANGS,axRR,axRB,axRG);
procesoGlobal=0; break;
case ID_MOVE_RIGHT:
td.nuevosEjesConvs3(0,0,0,REL_ANGS,WHITE);
td.OjosXalOrigenMenos(1);
td.nuevosEjesConvs3(0,0,0,REL_ANGS,axRR,axRB,axRG);
procesoGlobal=0; break;
case ID_EXAMPLE:
td.avion(DIBUJ,td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl);
procesoGlobal=0; break;
case ID_ERASE:
td.avion(0,td.alf_iGl,td.bet_iGl,td.gam_iGl,td.alf_jGl,td.bet_jGl,td.gam_jGl,td.alf_kGl,td.bet_kGl,td.gam_kGl);
procesoGlobal=0; break;
case OP_MENU1:
ActRed=col.moreRed(ActRed);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU2:
ActGreen=col.moreGreen(ActGreen);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU3:
ActBlue=col.moreBlue(ActBlue);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU4:
ActRed=col.more10Red(ActRed);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU5:
ActGreen=col.more10Green(ActGreen);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU6:
ActBlue=col.more10Blue(ActBlue);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU7:
ActRed=col.lessRed(ActRed);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU8:
ActGreen=col.lessGreen(ActGreen);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU9:
ActBlue=col.lessBlue(ActBlue);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU10:
ActRed=col.less10Red(ActRed);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU11:
ActGreen=col.less10Green(ActGreen);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU12:
ActBlue=col.less10Blue(ActBlue);
color = RGB(ActRed,ActGreen,ActBlue);
procesoGlobal=0; break;
case OP_MENU13:
principalTool=ID_AIRBRUSH;
procesoGlobal=0; break;
case OP_MENU14:
principalTool=ID_PINCEL;
procesoGlobal=0; break;
case OP_MENU_LAYER1:
td.xIniLine+=1;
for(i=-3;i<=3;i++)
for(j=-3;j<=3;j++)
put_pixel(50,10,50,i+CuadLayerX1+100+td.xIniLine,j+CuadLayerY1+100+td.yIniLine);
procesoGlobal=0;
break;
case OP_MENU_LAYER2:
td.xIniLine-=1;
for(i=-3;i<=3;i++)
for(j=-3;j<=3;j++)
put_pixel(50,10,50,i+CuadLayerX1+100+td.xIniLine,j+CuadLayerY1+100+td.yIniLine);
procesoGlobal=0;
break;
case OP_MENU_LAYER3:
td.yIniLine+=1;
for(i=-3;i<=3;i++)
for(j=-3;j<=3;j++)
put_pixel(50,10,50,i+CuadLayerX1+100+td.xIniLine,j+CuadLayerY1+100+td.yIniLine);
procesoGlobal=0;
break;
case OP_MENU_LAYER4:
td.yIniLine-=1;
for(i=-3;i<=3;i++)
for(j=-3;j<=3;j++)
put_pixel(50,10,50,i+CuadLayerX1+100+td.xIniLine,j+CuadLayerY1+100+td.yIniLine);
procesoGlobal=0;
break;
case ID_CUENTAGOTAS:
principalTool=ID_CUENTAGOTAS;
procesoGlobal=0; break;
case ID_AIRBRUSH:
principalTool=ID_AIRBRUSH;
procesoGlobal=0; break;
case ID_PINCEL:
principalTool=ID_PINCEL;
procesoGlobal=0; break;
case ID_LINEA:
switch(dibujaLinea)
{
case 0:
td.xIniLine=xMouse;
dibujaLinea++;
break;
case 1:
td.xFinLine=xMouse;
break;
}
break;
// THIS REDRAW EVERYTHING:
default: {int i=0,j=0;
// THESE for's ARE ALSO ON VERY SLOW MOOD WAITING TO BE INCLUDED ON A FUNCTION (when I'll solve the redraw question (hehehe...
for (i=xMenu1;i<xMenu2;i++)
for (j=yMenu1;j<yMenu2;j++)
put_pixel(255,0,0,i,j);
for (i=xMenu3;i<xMenu4;i++)
for (j=yMenu3;j<yMenu4;j++)
put_pixel(0,255,0,i,j);
for (i=xMenu5;i<xMenu6;i++)
for (j=yMenu5;j<yMenu6;j++)
put_pixel(0,0,255,i,j);
for (i=xMenu7;i<xMenu8;i++)
for (j=yMenu7;j<yMenu8;j++)
put_pixel(255,0,0,i,j);
for (i=xMenu9;i<xMenu10;i++)
for (j=yMenu9;j<yMenu10;j++)
put_pixel(0,255,0,i,j);
for (i=xMenu11;i<xMenu12;i++)
for (j=yMenu11;j<yMenu12;j++)
put_pixel(0,0,255,i,j);
color = RGB(ActRed,ActGreen,ActBlue);
for (i=xMenu13;i<xMenu14;i++)
for (j=yMenu13;j<yMenu14;j++)
put_pixel(color,i,j);
for (i=xMenu15;i<xMenu16;i++)
for (j=yMenu15;j<yMenu16;j++)
put_pixel(255,0,0,i,j);
for (i=xMenu17;i<xMenu18;i++)
for (j=yMenu17;j<yMenu18;j++)
put_pixel(0,255,0,i,j);
for (i=xMenu19;i<xMenu20;i++)
for (j=yMenu19;j<yMenu20;j++)
put_pixel(0,0,255,i,j);
for (i=xMenu21;i<xMenu22;i++)
for (j=yMenu21;j<yMenu22;j++)
put_pixel(255,0,0,i,j);
for (i=xMenu23;i<xMenu24;i++)
for (j=yMenu23;j<yMenu24;j++)
put_pixel(0,255,0,i,j);
for (i=xMenu25;i<xMenu26;i++)
for (j=yMenu25;j<yMenu26;j++)
put_pixel(0,0,255,i,j);
for (i=xMenu27;i<xMenu28;i++)
for (j=yMenu27;j<yMenu28;j++)
put_pixel(150,150,150,i,j);
for (i=xMenu29;i<xMenu30;i++)
for (j=yMenu29;j<yMenu30;j++)
put_pixel(200,200,200,i,j);
[B] // AND IT REDRAWS MORE AND MORE, AND MORE ...[/B]
}
break;
}
}
return Msg.wParam;
}