High-Tech
Santé-Médecine
Droit-Finances
CodeS-SourceS
Inscription
Plan
Connexion
Rechercher un code, un tuto, une réponse
Accueil
Forum
Tutoriels
Codes Sources
Snippets
Top membres
Tous les langages
Delphi / Pascal
Java
Python
SQL
RegEx
Flash
ASM
IRC
Graphisme
PDA
ColdFusion
Foxpro
Flex
Visual Basic / VB.NET
Forum
Tutoriels
Codes Sources
Snippets
Top membres
PHP
Forum
Tutoriels
Codes Sources
Snippets
Top membres
C/C++/C++.NET
Forum
Tutoriels
Codes Sources
Snippets
Top membres
Javascript
Forum
Tutoriels
Codes Sources
Snippets
Top membres
C#/.NET
Forum
Tutoriels
Codes Sources
Snippets
Top membres
ASP/ASP.NET
Forum
Tutoriels
Codes Sources
Snippets
Top membres
Accueil
Connexion
Déposer un code
Code
Recherche
Haut
Forum
Commentaires sur une source
Sujet Précédent
Sujet Suivant
PROJECTION 3D
cs_koko
Messages postés
654
Date d'inscription
lundi 14 janvier 2002
Statut
Membre
Dernière intervention
20 février 2005
- 7 déc. 2003 à 10:07
Utilisateur anonyme -
20 nov. 2007 à 11:53
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
https://codes-sources.commentcamarche.net/source/18474-projection-3d
Utilisateur anonyme
20 nov. 2007 à 11:53
Oui pas mal !
Petite amélioration pour eviter que ça devienne le bordel =)
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
T3DPoint = record
X : LongInt;
Y : LongInt;
Z : LongInt;
end;
type
TFrmMain = class(TForm)
Img: TImage;
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
Points: array[1..8] of T3DPoint;
procedure CreerPoint(const Index, x, y, z: Integer);
procedure Bouge(const IndexPoint: Integer);
procedure Ligne(const IndexCible: Integer; const IndexDepart: Integer = 0);
public
{ Déclarations publiques }
function Get2DCoords(Point : T3DPoint): TPoint;
end;
var
FrmMain: TFrmMain;
implementation
{$R *.dfm}
function TfrmMain.Get2DCoords(Point : T3DPoint): TPoint;
var Buffer: TPoint;
begin
Buffer.X := Trunc(((Point.X - 344) * (256 / (256 + Point.Z))) + 344);
Buffer.Y := Trunc(((Point.Y - 223) * (256 / (256 + Point.Z))) + 223);
Get2DCoords := Buffer;
end;
procedure TFrmMain.FormCreate(Sender: TObject);
var Buffer : T3DPoint;
L: Integer;
begin
FillChar(Points, SizeOf(Points), 0);
L:= 200;
CreerPoint(1, 0, 0, 0);
CreerPoint(2, L, 0, 0);
CreerPoint(3, L, 0, L);
CreerPoint(4, 0, 0, L);
CreerPoint(5, 0, L, 0);
CreerPoint(6, L, L, 0);
CreerPoint(7, L, L, L);
CreerPoint(8, 0, L, L);
with Img.Canvas do
begin
Bouge(1);
Ligne(2);
Ligne(3);
Ligne(4);
Ligne(1);
Ligne(5);
Ligne(6);
Ligne(7);
Ligne(8);
Ligne(5);
Ligne(1, 5);
Ligne(2, 6);
Ligne(3, 7);
Ligne(4, 8);
end;
end;
procedure TFrmMain.CreerPoint(const Index, x, y, z: Integer);
begin
Points[Index].X:= x;
Points[Index].Y:= y;
Points[Index].Z:= z;
end;
procedure TFrmMain.Bouge(const IndexPoint: Integer);
begin
Img.Canvas.PenPos := Get2DCoords(Points[IndexPoint]);
end;
procedure TFrmMain.Ligne(const IndexCible: Integer; const IndexDepart: Integer = 0);
begin
if IndexDepart > 0 then
Bouge(IndexDepart);
Img.Canvas.LineTo(Get2DCoords(Points[IndexCible]).X, Get2DCoords(Points[IndexCible]).Y);
end;
end.
cs_koko
Messages postés
654
Date d'inscription
lundi 14 janvier 2002
Statut
Membre
Dernière intervention
20 février 2005
7 déc. 2003 à 10:07
du beau travail !!!
Votre réponse
Discussions similaires
Math 3D changement de repere
cs_Stephane
-
5 mai 2005 à 20:13
Stephane
-
20 mai 2005 à 22:41
ecrie en arabe avec xara
achill2005
-
10 mai 2006 à 23:44
Moudii
-
16 déc. 2009 à 03:28
viewer 3D
survcopt
-
19 août 2011 à 22:05
nadhir31
-
16 janv. 2014 à 15:46
passer d'un repère 3D à l'écran
adrienva
-
10 déc. 2006 à 15:13
yann_lo_san
-
10 déc. 2006 à 15:42
Changement de repère
Lepripri
-
15 juin 2004 à 10:41
MetalDwarf
-
15 juin 2004 à 18:46
Rejoignez-nous
A voir également
Dessin 3d facile cube
Rotation quelle est la formule pour une rotation?
Opengl 3d
De la 3d a la 2d
Souris 3d solidworks
20 nov. 2007 à 11:53
Petite amélioration pour eviter que ça devienne le bordel =)
unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls;
type
T3DPoint = record
X : LongInt;
Y : LongInt;
Z : LongInt;
end;
type
TFrmMain = class(TForm)
Img: TImage;
procedure FormCreate(Sender: TObject);
private
{ Déclarations privées }
Points: array[1..8] of T3DPoint;
procedure CreerPoint(const Index, x, y, z: Integer);
procedure Bouge(const IndexPoint: Integer);
procedure Ligne(const IndexCible: Integer; const IndexDepart: Integer = 0);
public
{ Déclarations publiques }
function Get2DCoords(Point : T3DPoint): TPoint;
end;
var
FrmMain: TFrmMain;
implementation
{$R *.dfm}
function TfrmMain.Get2DCoords(Point : T3DPoint): TPoint;
var Buffer: TPoint;
begin
Buffer.X := Trunc(((Point.X - 344) * (256 / (256 + Point.Z))) + 344);
Buffer.Y := Trunc(((Point.Y - 223) * (256 / (256 + Point.Z))) + 223);
Get2DCoords := Buffer;
end;
procedure TFrmMain.FormCreate(Sender: TObject);
var Buffer : T3DPoint;
L: Integer;
begin
FillChar(Points, SizeOf(Points), 0);
L:= 200;
CreerPoint(1, 0, 0, 0);
CreerPoint(2, L, 0, 0);
CreerPoint(3, L, 0, L);
CreerPoint(4, 0, 0, L);
CreerPoint(5, 0, L, 0);
CreerPoint(6, L, L, 0);
CreerPoint(7, L, L, L);
CreerPoint(8, 0, L, L);
with Img.Canvas do
begin
Bouge(1);
Ligne(2);
Ligne(3);
Ligne(4);
Ligne(1);
Ligne(5);
Ligne(6);
Ligne(7);
Ligne(8);
Ligne(5);
Ligne(1, 5);
Ligne(2, 6);
Ligne(3, 7);
Ligne(4, 8);
end;
end;
procedure TFrmMain.CreerPoint(const Index, x, y, z: Integer);
begin
Points[Index].X:= x;
Points[Index].Y:= y;
Points[Index].Z:= z;
end;
procedure TFrmMain.Bouge(const IndexPoint: Integer);
begin
Img.Canvas.PenPos := Get2DCoords(Points[IndexPoint]);
end;
procedure TFrmMain.Ligne(const IndexCible: Integer; const IndexDepart: Integer = 0);
begin
if IndexDepart > 0 then
Bouge(IndexDepart);
Img.Canvas.LineTo(Get2DCoords(Points[IndexCible]).X, Get2DCoords(Points[IndexCible]).Y);
end;
end.
7 déc. 2003 à 10:07