Ir ao conteúdo
  • Cadastre-se

Cambalinho

Membro Pleno
  • Posts

    942
  • Cadastrado em

  • Última visita

Tudo que Cambalinho postou

  1. quer dizer que não posso fazer login, com o mesmo utilizador, em computadores diferentes, na mesma rede? PS: para mudar o IP basta desligar e ligar o router?
  2. preciso de entender porque recebo muitos mails falsos da Policia(ao menos é o que diz... e em ambos é só 1 imagem e não texto)? eu sei que tenho o meu mail(o hotmail) em alguns forums ou isso.. alguns tenho control outros já nem sei(passado ou isso e esqueci). e sim recebo no hotmail e não no gmail(sim tenho 2 mails). eu os tento bloquear, mas aparecem outros.. de 3 ou 4 dias aparece outro mail... alguns vão para o Spam e outros para a Entrada... o que me aconselham, além de os bloquear? PS: o hotmail é o mais antigo que tenho... mas parece que vou ter de desistir dele, porque mails importantes nem recebo e nem no Spam e não sei o motivo
  3. testei o portatil, mas noutra rede, e funcionou de boa(yah na loja de reparação kkkkk... mas o touchpad lembrou-se de ir de férias de Natal, porque nem funcionou kkk). mas como funcionou, eu penso que tem haver com o IP.. mas o meu portatil usava o mesmo IP e funciona de boa(testei agora, com o meu portatil, após reset o router). mas se foi 1 erro de IP, alguém me pode explicar melhor? eu sei que o IP é 1 identificação de rede.. mas acredito que seja mais que isso e eu não sei.
  4. honestamente eu não sei, mas eu já lhes liguei sobre isso e se é só 1 portatil que dá o problema.. então o erro esta no portatil e não no site lol a não ser que não aceitam o mesmo mail ou login em portateis diferentes
  5. eu instalei o Windows 10(algumas vezes) no portatil da minha mulher: HP Pavilion DV6000: CPU: duo core 1.82GHz; RAM: 3 GBz; i think the graphics is 500MB's dedicated. eu usei vários browsers\navegadores, mas o mesmo problema acontece. neste caso estou a usar o site https://nostv.pt/bem-vindo eu escolho o login de mail. insiro o mail e depois a senha... após inserir a senha, eu volto para este link de escolha do tipo de login. por algum motivo o do celular dá erro. mesmo no meu portatil... no meu portatil consigo fazer login sem problemas. algumas vezes, no portatil da minha mulher, eu consigo aceder.. após limpar os ficheiros no %temp% e limpar o navegador... mas mesmo assim nem sempre funciona. alguém me pode explicar porque motivo eu tenho esteve erro\bug?(mesmo a testar após instalação do windows 10 ou mesmo o 7)
  6. preciso de 1 correção sobre desenhar 1 linha 3D: preciso de calcular da perspectiva só no ponto da origem e no destino da linha? ou todos os pontos da linha?
  7. finalmente ficou a funcionar(em vez adicionar o Multirefa ao meu codigo, devido a erros, eu adicionei a classe image ao Multitarefa): #include <iostream> #include <thread> #include <windows.h> #include <math.h> using namespace std; class image { public: int ImageWidth = 0; int ImageHeight = 0; HDC ImageHDC = NULL; HBITMAP ImageBitmap; HBITMAP oldBit; BITMAP bmp; BITMAPINFO info; size_t pixelSize; size_t scanlineSize; size_t bitmapSize; void* p; LPBYTE Pixels; void Clear(COLORREF BackColor = RGB(0,0,0)) { RECT rec{0,0,ImageWidth,ImageHeight}; HBRUSH HB = CreateSolidBrush(BackColor); FillRect(ImageHDC,&rec,HB); DeleteObject(HB); } image(int Width, int Height, COLORREF BackColor=RGB(0,0,0)) { ImageHDC = CreateCompatibleDC(NULL); ImageWidth = Width; ImageHeight =Height; ZeroMemory (&info, sizeof (BITMAPINFO)); info.bmiHeader.biSize = sizeof(info.bmiHeader); info.bmiHeader.biWidth = ImageWidth; // pay attention to the sign, you most likely want a // top-down pixel array as it's easier to use info.bmiHeader.biHeight = -ImageHeight; info.bmiHeader.biPlanes = 1; info.bmiHeader.biBitCount = 32; info.bmiHeader.biCompression = BI_RGB; info.bmiHeader.biSizeImage = 0; info.bmiHeader.biXPelsPerMeter = 0; info.bmiHeader.biYPelsPerMeter = 0; info.bmiHeader.biClrUsed = 0; info.bmiHeader.biClrImportant = 0; // the following calculations work for 16/24/32 bits bitmaps // but assume a byte pixel array ImageBitmap = CreateDIBSection(ImageHDC, &info, DIB_RGB_COLORS, (LPVOID*)&Pixels, 0, 0); if(ImageBitmap ==NULL) cout << "no HBITMAP"; if(SelectObject(ImageHDC, ImageBitmap)==NULL) cout << "error"; pixelSize = info.bmiHeader.biBitCount / 8; // the + 3 ) & ~3 part is there to ensure that each // scan line is 4 byte aligned scanlineSize = (pixelSize * info.bmiHeader.biWidth + 3) & ~3; bitmapSize = bmp.bmHeight * scanlineSize; Clear(BackColor); } void NewSetPixel(HDC DestinationHDC, int X, int Y, BYTE RedColor, BYTE GreenColor, BYTE BlueColor) { size_t pixelOffset = Y *scanlineSize + X *pixelSize; Pixels[pixelOffset+2]=RedColor; Pixels[pixelOffset+1]=GreenColor; Pixels[pixelOffset+0]=BlueColor; } void DrawLine( float X0, float Y0, float Z0, float X1, float Y1, float Z1, COLORREF LineColor) { //Getting Line Distance(float results): float DX = abs(X1 - X0); float DY = abs(Y1 - Y0); float DZ = abs(Z1 - Z0); float LineDistance =sqrt((DX * DX) + (DY * DY) + (DZ * DZ)); //Getting the Steps incrementation(float results): float XSteps = DX/LineDistance; float YSteps = DY/LineDistance; float ZSteps = DZ/LineDistance; //Draw Line using the Steps\ Incrementation: float X = X0; float Y = Y0; float Z = Z0; BYTE R = GetRValue(LineColor); BYTE G = GetGValue(LineColor); BYTE B = GetBValue(LineColor); std::thread th[(int)LineDistance+1]; for(int i =0; i <LineDistance; i++) { //For every steps we calculate the perspective: float EyeDistance = 500; //Avoiding division by zero: if(Z==0) Z=1; float Perspective = EyeDistance/(EyeDistance+Z); //The 3D to 2D convertion(i use 300 of eye distance, but we can change it): int PosX = trunc(X*Perspective); int PosY = trunc(Y*Perspective); if(Z>=0 && PosX<ImageWidth && PosX>=0 && PosY<ImageHeight && PosY>=0) { th[i] = std::thread(&image::NewSetPixel,this,ImageHDC, PosX,PosY,R,G,B);//erros th[i].join(); } //Increment steps(integer results): X+=XSteps; Y+=YSteps; Z+=ZSteps; } } void DrawRectangle(float PosX, float PosY, float PosZ, float Width, float Height, float Depth, COLORREF Color = RGB(255,0,0), bool Filled = false) { DrawLine( PosX, PosY, PosZ,PosX + Width, PosY, PosZ + Depth, Color); DrawLine( PosX, PosY, PosZ, PosX, PosY + Height, PosZ, Color); DrawLine( PosX + Width, PosY, PosZ + Depth, PosX + Width, PosY+Height, PosZ + Depth, Color); DrawLine( PosX, PosY + Height, PosZ, PosX + Width, PosY + Height, PosZ + Depth, Color); if(Filled==true) { for(int i = 0; i<Height; i++) DrawLine( PosX, PosY + i, PosZ,PosX + Width, PosY +i, PosZ + Depth, Color); } } ~image() { SelectObject(ImageHDC, oldBit); DeleteObject(ImageBitmap); DeleteDC(ImageHDC); } }; image img(200,200); int main() { img.DrawRectangle(0,100,0, 100,100,500, RGB(255,0,0),true); BitBlt(GetWindowDC(GetConsoleWindow()),10,100,img.ImageWidth,img.ImageHeight,img.ImageHDC,0,0,SRCCOPY); return 0; } mas ficou mais lento do que sem usar Multitarefa... porque?
  8. corrigi.... e já explico como foi. #include <iostream> #include <thread> struct test { struct Person { int Age = 0; std::string Name = ""; int *H; }; void f(Person *Pessoa) { std::cout <<"Name: " << Pessoa->Name << "\n"; std::cout << "Age: " << Pessoa->Age << "\n"; std::cout << "H: " << *Pessoa->H << "\n"; } void te() { std::thread th[1000]; Person Pessoa; Pessoa.Age=39; Pessoa.Name ="Joaquim"; for (int i=0; i<1000; i++) { Pessoa.H = new int(i); th[i] = std::thread(&test::f, this, &Pessoa); th[i].join(); } delete Pessoa.H; } }; test a; int main() { a.te(); std::cout << "Todas thread terminaram\n"; return 0; } vamos analisar a função thread() numa classe: th[i] = std::thread(&test::f, this, &Pessoa); Parametros: 1 - o nome da função; 2 - o Parametro da função.(não sei se aceita vários argumentos). Parametros dentro de 1 classe: 1 - endereço da função com o nome da classe: "&NomeDaClasse::NomeDaFunção"; 2 - o ponteiro da classe; 3 - o parametro da função(repito, não sei aceito mais que 1). vi 1 exemplo e tentei testar e deu. muito obrigado tentei usar no meu código, mas não tenho resultados e nem erros. struct Pixel { image *img; float X = 0; float Y = 0; float Z = 0; COLORREF color = 0; }; void DrawPixel(Pixel *Pix ) { //For every steps we calculate the perspective: //Avoiding division by zero: float EyeDistance = 500;// doing these i avoid the black\empty vertical lines const float d = EyeDistance+Pix->Z; // Note that Z==0 is irrelevant here const float Perspective = (d != 0) ? (EyeDistance/d) : 0; //The 3D to 2D convertion(i use 300 of eye distance, but we can change it): int PosX = Pix->X*Perspective; int PosY = Pix->Y*Perspective; //Draw the pixel on valid positions: if(Pix->Z>=0 && PosX<Pix->img->Width && PosX>=0 && PosY<Pix->img->Height && PosY>=0) { size_t pixelOffset = PosY * Pix->img->scanlineSize + PosX * Pix->img->pixelSize; int PosR = pixelOffset+2; int PosG = pixelOffset+1; int PosB = pixelOffset+0; Pix->img->Pixels[PosR]=GetRValue(Pix->color); Pix->img->Pixels[PosG]=GetGValue(Pix->color); Pix->img->Pixels[PosB]=GetBValue(Pix->color); } } void DrawLine(float X0, float Y0, float Z0, float X1, float Y1, float Z1, COLORREF LineColor = RGB(255,0,0)) { //Getting Line Distance(float results): float DX = X1 - X0; float DY = Y1 - Y0; float DZ = Z1 - Z0; float LineDistance =sqrt((DX * DX) + (DY * DY) + (DZ * DZ)); if(LineDistance < 1) return; //Getting the Steps incrementation(float results): float XSteps = DX/LineDistance; float YSteps = DY/LineDistance; float ZSteps = DZ/LineDistance; //Draw Line using the Steps\ Incrementation: float X = X0; float Y = Y0; float Z = Z0; int i=0; std::thread th[(int)LineDistance]; do { Pixel *pix= new Pixel{this, X,Y,Z,LineColor}; th[i] = std::thread(&image::DrawPixel,this, pix); th[i].join(); //Increment steps(integer results): X+=XSteps; Y+=YSteps; Z+=ZSteps; i++; delete pix; }while(i<LineDistance); } estou a testar e já sei: alterei a função e consigo ver o 'X'... significa que os dados estão a ser dados e imagino onde errei. veja na estrutura Pixel: struct Pixel { image *img; agora vou perguntar: como passo o ponteiro da classe no 'img'? pix->img = new image(*this);
  9. deu o mesmo problema. voltemos ao codigo de testes: struct test { struct Person { int Age = 0; std::string Name = ""; int *H; }; void f(Person *Pessoa) { std::cout <<"Name: " << Pessoa->Name << "\n"; std::cout << "Age: " << Pessoa->Age << "\n"; std::cout << "H: " << *Pessoa->H << "\n"; } void te() { std::thread th[100]; Person Pessoa; Pessoa.Age=39; Pessoa.Name ="Joaquim"; Pessoa.H = new int(1000); for (int i = 0; i < 100; i += 1) { th[i] = std::thread(this->f, &Pessoa);//erros th[i].join(); } delete Pessoa.H; } }; test a; int main() { a.te(); std::cout << "Todas thread terminaram\n"; return 0; } a linha: th[i] = std::thread(this->f, &Pessoa);//erros dá-me imensos erros... porque estou a usar dentro de 1 estrutura... e é o mesmo erro que num classe. então pergunto: como posso usar dentro de 1 classe?
  10. eu já fiz o teste que funcionou, mas como disse: foi 1 função fora da classe. para fazer 1 estrutura, que use 1 variável de classe, antes da classe criada, tenho de fazer isto, certo? class NomeClass; agora vou testar o que estava a pensar ver se resulta. desculpe mas vamos então testar o mais simples já noto 2 problemas, no meu teste: #include <iostream> #include <thread> #include <windows.h> struct Person { int Age = 0; std::string Name = ""; }; auto f = [](Person Pessoa) -> void { std::cout <<"Name: " << Pessoa.Name << "\n"; std::cout << "Age: " << Pessoa.Age << "\n"; }; int main() { std::thread th; Person Pessoa; Pessoa.Age=39; Pessoa.Name ="Joaquim"; th = std::thread(f, Pessoa); for (int i = 0; i < 8; i += 1) { th.join(); }; std::cout << "Todas thread terminaram\n"; return 0; } 1 - não posso usar o 'th.join()' mais que 1 vez... porque? eu quero chamar a função quantas vezes eu preciso? (sim a função é simples, mas imagine 1 loop de pixels) 2 - não posso usar ponteiros? porquê? sim tentei e deu erro. ok.. estamos a começar mais simples para usar no meu código principal. testando: 1 - tenho de usar mesmo 1 array... mesmo que fosse 1 item por cada pixel; 2 - ainda falho num membro ponteiro numa classe ou estrutura? mas aprendi desta forma ao pesquisar: struct Person { int Age = 0; std::string Name = ""; int *H; }; Pessoa.H = new int(1000); delete Pessoa.H; //ou int *a = new int(1000); Pessoa.H = a; delete a; //sim nunca esquecer usar, se usar 'new' temos de usar 'delete' agora vou tentar no meu código
  11. Eu imagino qual é o meu problema: estou a usar uma função que está dentro de uma classe. Eu tinha feito um teste fora da classe e funciona. Parece ser uma dor de cabeça quando queremos usar dentro das classes, como sempre é tem me acontecido. Mais logo vou testar fora da classe
  12. eu tentei mas sem sorte e não entendo onde errei //alterações: void DrawPixel(void *threadarg ) { struct Pixel *Pix; Pix = (struct Pixel *) threadarg; //For every steps we calculate the perspective: //Avoiding division by zero: float EyeDistance = 500;// doing these i avoid the black\empty vertical lines const float d = EyeDistance+Pix->Z; // Note that Z==0 is irrelevant here const float Perspective = (d != 0) ? (EyeDistance/d) : 0; //............... int i=0; std::thread th; do { Pixel pix{this, X,Y,Z,LineColor}; th = std::thread(this->DrawPixel, pix); th.join(); desculpe, mas onde errei? sim selecionei o C++17 ISO no compilador. mas continuo com erros "||=== Build: Debug in DrawLine (compiler: GNU GCC Compiler) ===| C:\Users\Camba\Documents\CodeBlocks\DrawLine\DrawLine.cpp||In function 'int main()':| C:\Users\Camba\Documents\CodeBlocks\DrawLine\DrawLine.cpp|474|warning: unused variable 'TextureY' [-Wunused-variable]| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread||In instantiation of 'struct std::thread::_Invoker<std::tuple<void (image::*)(void*), image::Pixel> >':| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|127|required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (image::*)(void*); _Args = {image::Pixel&}]'| C:\Users\Camba\Documents\CodeBlocks\DrawLine\DrawLine.cpp|228|required from here| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|240|error: no matching function for call to 'std::thread::_Invoker<std::tuple<void (image::*)(void*), image::Pixel> >::_M_invoke(std::thread::_Invoker<std::tuple<void (image::*)(void*), image::Pixel> >::_Indices)'| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|231|note: candidate: 'template<long long unsigned int ..._Ind> decltype (std::__invoke((_S_declval<_Ind>)()...)) std::thread::_Invoker<_Tuple>::_M_invoke(std::_Index_tuple<_Ind ...>) [with long long unsigned int ..._Ind = {_Ind ...}; _Tuple = std::tuple<void (image::*)(void*), image::Pixel>]'| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|231|note: template argument deduction/substitution failed:| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|240|required from 'struct std::thread::_Invoker<std::tuple<void (image::*)(void*), image::Pixel> >'| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|127|required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (image::*)(void*); _Args = {image::Pixel&}]'| C:\Users\Camba\Documents\CodeBlocks\DrawLine\DrawLine.cpp|228|required from here| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|233|error: no matching function for call to '__invoke(std::__tuple_element_t<0, std::tuple<void (image::*)(void*), image::Pixel> >, std::__tuple_element_t<1, std::tuple<void (image::*)(void*), image::Pixel> >)'| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\invoke.h|89|note: candidate: 'template<class _Callable, class ... _Args> constexpr typename std::__invoke_result<_Functor, _ArgTypes>::type std::__invoke(_Callable&&, _Args&& ...)'| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\invoke.h|89|note: template argument deduction/substitution failed:| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|233| required by substitution of 'template<long long unsigned int ..._Ind> decltype (std::__invoke(_S_declval<_Ind>()...)) std::thread::_Invoker<std::tuple<void (image::*)(void*), image::Pixel> >::_M_invoke<_Ind ...>(std::_Index_tuple<_Ind ...>) [with long long unsigned int ..._Ind = {0, 1}]'| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|240|required from 'struct std::thread::_Invoker<std::tuple<void (image::*)(void*), image::Pixel> >'| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\thread|127|required from 'std::thread::thread(_Callable&&, _Args&& ...) [with _Callable = void (image::*)(void*); _Args = {image::Pixel&}]'| C:\Users\Camba\Documents\CodeBlocks\DrawLine\DrawLine.cpp|228|required from here| C:\Program Files\CodeBlocks\MinGW\lib\gcc\x86_64-w64-mingw32\8.1.0\include\c++\bits\invoke.h|89|error: no type named 'type' in 'struct std::__invoke_result<void (image::*)(void*), image::Pixel>'| ||=== Build failed: 4 error(s), 10 warning(s) (0 minute(s), 3 second(s)) ===|" o que me pode dizer?
  13. para usar multitarefa temos de usar a libraria: #include <pthread.h> //por exemplo // dentro de 1 classe tenho: struct Pixel { image *img; float X = 0; float Y = 0; float Z = 0; COLORREF color = 0; }; static void *DrawPixel(void *threadarg ) { struct Pixel *Pix; Pix = (struct Pixel *) threadarg; //For every steps we calculate the perspective: //Avoiding division by zero: float EyeDistance = 500;// doing these i avoid the black\empty vertical lines const float d = EyeDistance+Pix->Z; // Note that Z==0 is irrelevant here const float Perspective = (d != 0) ? (EyeDistance/d) : 0; //The 3D to 2D convertion(i use 300 of eye distance, but we can change it): int PosX = Pix->X*Perspective; int PosY = Pix->Y*Perspective; //Draw the pixel on valid positions: if(Pix->Z>=0 && PosX<Pix->img->Width && PosX>=0 && PosY<Pix->img->Height && PosY>=0) { size_t pixelOffset = PosY * Pix->img->scanlineSize + PosX * Pix->img->pixelSize; int PosR = pixelOffset+2; int PosG = pixelOffset+1; int PosB = pixelOffset+0; Pix->img->Pixels[PosR]=GetRValue(Pix->color); Pix->img->Pixels[PosG]=GetGValue(Pix->color); Pix->img->Pixels[PosB]=GetBValue(Pix->color); } return NULL; } //quero chamar esta função num ciclo utilizando multitarefa: int i=0; pthread_t threads; int rc; do { Pixel pix{this, X,Y,Z,LineColor}; //DrawPixel(pix); rc=pthread_create(&threads, NULL, DrawPixel, (void *)&pix); if (rc) { cout << "Error:unable to create thread," << rc << endl; exit(-1); } //Increment steps(integer results): X+=XSteps; Y+=YSteps; Z+=ZSteps; i++; }while(i<LineDistance); ao fechar a janela é que vejo a mensagem de erro. estou a fazer de forma errada? estou a tentar usar multitarefa, mas está complicado tenho de tirar a função da classe ou isso?
  14. desculpem a demora... gripes é completado. honestamente estou a usar DIB's(Win32) e CPU e Matemática. prefiro, para já, não usar DirectX ou outra libraria. neste momento, sem multitarefa, estou a obter ~240FPS só para mostrar, ponto a ponto, 1 linha(mesmo usando o Z). a pergunta seria: esta normal ou deveria ser mais rápido? corrige-me outra coisa: preciso estar a converter todos os pontos da linha usando a perspetiva(3D) ou basta só converter a origem e o destino? (se fosse igual, podia poupar algum procedimento)
  15. No C++, Multitarefa aumenta a velocidade? é muito usada em jogos ou pode prejudicar?
  16. eu tenho essa função por 2 razões: 1 - aprender a desenhar linhas em programação, usando Matemática; 2 - aprender a fazer a mesma função para 3D. mais tarde vou aprender a fazer círculos e depois curvas no #5 está a função DrawLine3D() eu gostava de aprender mais sobre otimização e velocidade nas funções.. se souber alguma coisa ou link por favor partilhe
  17. desculpa, mas não entendi. - DrawLine3D() desenha a linha com Z; - LineMoveBack() e LineMoveFront() usa Z e é para mover a linha para a frente e para trás. desculpem perguntar fora do tópico: mas o que devo ter em atenção para aumentar a velocidade da função? claro que o SetPixel() é lento
  18. isso era simples, mas não funciona.. tive de criar estas funções: void LineMoveFront(int &X0, int &Y0, int &Z0,int &X1, int &Y1, int &Z1, int Speed) { float DX = X1 - X0; float DY = Y1 - Y0; float DZ = Z1 - Z0; float LineDistance = sqrt(pow(DX,2) + pow(DY,2) + pow(DZ,2)); float XStep = DX / LineDistance; float YStep = DY / LineDistance; float ZStep = DZ / LineDistance; X0+=round(XStep*Speed); Y0+=round(YStep*Speed); Z0+=round(ZStep*Speed); X1+=round(XStep*Speed); Y1+=round(YStep*Speed); Z1+=round(ZStep*Speed); } void LineMoveBack(int &X0, int &Y0, int &Z0,int &X1, int &Y1, int &Z1, int Speed=1) { float DX = X1 - X0; float DY = Y1 - Y0; float DZ = Z1 - Z0; float LineDistance = sqrt(pow(DX,2) + pow(DY,2) + pow(DZ,2)); float XStep = DX / LineDistance; float YStep = DY / LineDistance; float ZStep = DZ / LineDistance; X0-=round(XStep*Speed); Y0-=round(YStep*Speed); Z0-=round(ZStep*Speed); X1-=round(XStep*Speed); Y1-=round(YStep*Speed); Z1-=round(ZStep*Speed); } int main() { HDC HDCConsole = GetConsoleHDC(); RECT rec; GetClientRect(GetConsoleWindow(),&rec); int Speed=1; int LinePositions[6] = {100,100,0,900,100,500}; do { DrawLine3D(HDCConsole,LinePositions[0],LinePositions[1], LinePositions[2], LinePositions[3], LinePositions[4], LinePositions[5]); Sleep(50); FillRect(HDCConsole,&rec,CreateSolidBrush(RGB(0,0,0))); Speed=1; if((GetKeyState(VK_RSHIFT) & 0x8000)) { Speed=10; } if((GetKeyState(VK_UP) & 0x8000)) { LineMoveBack(LinePositions[0],LinePositions[1], LinePositions[2], LinePositions[3], LinePositions[4], LinePositions[5], Speed); } if((GetKeyState(VK_DOWN) & 0x8000)) { LineMoveFront(LinePositions[0],LinePositions[1], LinePositions[2], LinePositions[3], LinePositions[4], LinePositions[5], Speed); } }while(!(GetKeyState(VK_ESCAPE) & 0x8000)); cout << "Draw ended!!!"; cin.get(); return 0; } é mais complexo mas faz o que queria... a linha se move com a mesma direção\angulo
  19. eu estou a tentar mover a figura para a frente e para trás.... mas, algumas vezes, a figura se move para a direita ou esquerda..... algo está mal neste codigo: void DrawLine3D(HDC Destination, int X0, int Y0, int Z0, int X1, int Y1, int Z1, COLORREF LineColor = RGB(255,0,0)) { //Avoiding division by zero: if(Z0==0) Z0=1; if(Z1==0) Z1=1; //Getting Line Distance(float results): float DX = X1 - X0; float DY = Y1 - Y0; float DZ = Z1 - Z0; float LineDistance = sqrt(pow(DX,2) + pow(DY,2) + pow(DZ,2)); //Getting the Steps incrementation(float results): float XSteps = DX/LineDistance; float YSteps = DY/LineDistance; float ZSteps = DZ/LineDistance; //Draw Line using the Steps\ Incrementation: float X = X0; float Y = Y0; float Z = Z0; int OldPosX=X0; int OldPosY=Y0; for(int i=0; i<LineDistance; i++) { //For every steps we calculate the perspective: float Perspective = 300/(300+Z); //The 3D to 2D convertion(i use 300 of eye distance, but we can change it): int PosX = trunc(X*Perspective); int PosY = trunc(Y*Perspective); //if(PosX==OldPosX && PosY==OldPosY) continue; OldPosX=PosX; OldPosY=PosY; //Draw the pixel: if(Z>0) SetPixel(Destination,PosX,PosY,LineColor); //Increment steps(integer results): X+=XSteps; Y+=YSteps; Z+=ZSteps; } } //............... int Front=0; int Speed=1; do { DrawLine3D(HDCConsole,100-Front,100,0-Front, 900-Front,100,500-Front); DrawLine3D(HDCConsole,100-Front,100,0-Front, 100-Front,400,0-Front); DrawLine3D(HDCConsole,900-Front,100,500-Front, 900-Front,400,500-Front); DrawLine3D(HDCConsole,100-Front,400,0-Front, 900-Front,400,500-Front); Sleep(50); FillRect(HDCConsole,&rec,CreateSolidBrush(RGB(0,0,0))); Speed=1; if((GetKeyState(VK_RSHIFT) & 0x8000)) { Speed=10; } if((GetKeyState(VK_UP) & 0x8000)) { Front+=Speed; } if((GetKeyState(VK_DOWN) & 0x8000)) { Front-=Speed; } }while(!(GetKeyState(VK_ESCAPE) & 0x8000)); sim em algumas coordenadas a figura se move para a direita e não, só, para a frente e para trás
  20. isso eu sei.. o ecrã só usa X e Y.. mas falo em 3D... e isso é que me está a fazer confusão.. o que me baralha mesmo muito é o movimento Z. hás vezes consigo o calculo correto e outras vezes não consigo
  21. Em Matemática, ainda fico confuso, como se move 1 ponto em Z? exemplo: Movimento = 1 A(100, 100, 0) tenho de fazer: A(100 + Movimento, 100, 0 + Movimento)? ou A(100, 100, 0 + Movimento)? eu já fiz vários códigos, mas muitas das vezes falho aqui.
  22. eu tenho drivers para 1 portátil\laptop. como posso criar 1 Driver Pack a partir dos instaladores dos drivers? penso que o formato fica *.7zip.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

 

GRÁTIS: ebook Redes Wi-Fi – 2ª Edição

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!