Planetarium
Planetarium
Bon c'est vrai je fais toujours 2 choses a la fois, ça me permet lorsque je bloque sur quelques choses de passer a l'autre...ça change les idées et ça permet lorsqu'on revient sur le premier d'avoir un regard un peu plus "neuf"
Mais là je bloque...
Je souhaite faire une sorte de planetarium... un peu comme si on metait une camera au centre de l'univers et qu'on puisse regarder a 360° dans tout les senses les étoiles au tour de sois !
Pas de moteur 3D style ogre ou Dreamotion3D, j'aimerais resté simple juste faire les calcules et utilise point(x,y) pour afficher mes points !
J'ai déjà lu pas mal de tutorial dont l'exelent "LA CAO SANS PEINE" de Jean-Pierre petit.
Afficher un point de coordonnée(x,y,z) sur un plan 2D, là j'y arrive
c'est facile
2DX = 3DX - ((DX / (3DZ + Distance)) * 3DX)
2DY = 3DY - ((DY / (3DZ + Distance)) * 3DY)
mais des que je veux avoir une camera qui puisse changer d'angle ('Azimute et Site) je n'arrive plus a rien ...
c'est pourtant de la trigo toute bête...j'ai beau faire des dessins sur papier etc....ça marche pas...
Quelqu'un aurait il des petits fonctions toute faite permettant d'afficher la vu en fonction des angles de la camera et des coordonées des points ?
Merci d'avance et en attendant...je me replonge pour essayer de comprendre...
Mais là je bloque...
Je souhaite faire une sorte de planetarium... un peu comme si on metait une camera au centre de l'univers et qu'on puisse regarder a 360° dans tout les senses les étoiles au tour de sois !
Pas de moteur 3D style ogre ou Dreamotion3D, j'aimerais resté simple juste faire les calcules et utilise point(x,y) pour afficher mes points !
J'ai déjà lu pas mal de tutorial dont l'exelent "LA CAO SANS PEINE" de Jean-Pierre petit.
Afficher un point de coordonnée(x,y,z) sur un plan 2D, là j'y arrive
c'est facile
2DX = 3DX - ((DX / (3DZ + Distance)) * 3DX)
2DY = 3DY - ((DY / (3DZ + Distance)) * 3DY)
mais des que je veux avoir une camera qui puisse changer d'angle ('Azimute et Site) je n'arrive plus a rien ...
c'est pourtant de la trigo toute bête...j'ai beau faire des dessins sur papier etc....ça marche pas...
Quelqu'un aurait il des petits fonctions toute faite permettant d'afficher la vu en fonction des angles de la camera et des coordonées des points ?
Merci d'avance et en attendant...je me replonge pour essayer de comprendre...
Dernière modification par Thyphoon le lun. 23/avr./2007 16:03, modifié 2 fois.
Re: Planetarium
tes coordonées 2DX et 2dY sont bien dans un plan (qui est en fait l'ecran de la camera !)Thyphoon a écrit : 2DX = 3DX - ((DX / (3DZ + Distance)) * 3DX)
2DY = 3DY - ((DY / (3DZ + Distance)) * 3DY)
Quelqu'un aurait il des petits fonctions toute faite permettant d'afficher la vu en fonction des angles de la camera et des coordonées des points ?
Merci d'avance et en attendant...je me replonge pour essayer de comprendre...
si tu fait
2DX=2DX+2 , en fait tu tourne la camera vers la gauche
2DX=2DX-2 , en fait tu tourne la camera vers la droite
2DY= 2DY+2 , en fait tu tourne la camera vers le haut
2DY= 2DY-2 , en fait tu tourne la camera vers le bas
3dz=3dz+2 , en fait tu recule la camera dans la profondeur
3dz=3dz-2 , en fait tu avance la camera dans la profondeur
non ?


Re: Planetarium
en faisant ça ton ecran bouge sur un seul plan...Dobro a écrit : tes coordonées 2DX et 2dY sont bien dans un plan (qui est en fait l'ecran de la camera !)
si tu fait
2DX=2DX+2 , en fait tu tourne la camera vers la gauche
2DX=2DX-2 , en fait tu tourne la camera vers la droite
2DY= 2DY+2 , en fait tu tourne la camera vers le haut
2DY= 2DY-2 , en fait tu tourne la camera vers le bas
non ?![]()
je voudrais pouvoir regarder au dessus, en dessous derrière, etc..
Les coordonées de la camera reste fixe mais l'angle change...horizontalement et verticalement...
je sais pas si je m'exprime bien !!!

un peu comme le code du feu d'artifice (que j'ai remis en PB4 en passant)
http://www.purebasic.fr/french/viewtopic.php?t=3341
sauf que ta camera serait au centre du cube

-
- Messages : 1554
- Inscription : lun. 24/juil./2006 6:44
- Localisation : vosges (France) 47°54'39.06"N 6°20'06.39"E
Tes planettes et etoiles, tu les représenteras par des sprite ou des points ?
(fonctions 2D de PB ?)
si cela peux t'aider, voici un très sympathique moteur 100% software,
en C, mais bien commenté
http://www.cppfrance.com/codes/MOTEUR-3 ... 11089.aspx
analyse, et bien sur, si tu veux un coup de main, ou des expli, n'hesite pas
(fonctions 2D de PB ?)
si cela peux t'aider, voici un très sympathique moteur 100% software,
en C, mais bien commenté
http://www.cppfrance.com/codes/MOTEUR-3 ... 11089.aspx
analyse, et bien sur, si tu veux un coup de main, ou des expli, n'hesite pas

Force et sagesse...
haaa , bienvenu dans la galère 
bon , pour faire simple utilise les matrices de rotation et de translation et matrice finale d'un objet
Cherche un de mes posts s'intitulant [challenge] mini moteur 3D
dedans il y a un lien interessant, je te préviens que réinventé la roue est assez galère, surtout si comme moi , tu es un non matheux ^^

bon , pour faire simple utilise les matrices de rotation et de translation et matrice finale d'un objet
Cherche un de mes posts s'intitulant [challenge] mini moteur 3D
dedans il y a un lien interessant, je te préviens que réinventé la roue est assez galère, surtout si comme moi , tu es un non matheux ^^
Voila un vieux code qui pourra te servir de base pour gerer une caméra :
Code : Tout sélectionner
InitSprite() : InitKeyboard()
OpenScreen(640,480,32,"")
#Xoff = 320
#Yoff = 240
#Zoff = 1500
; Structure de notre monde 3D, on represente les points3D la dedans.
Structure WORLD3D
x.f
y.f
z.f
WaveHeight_A.f
WaveHeight_B.f
EndStructure
Structure MATRIX4
_11.f:_21.f:_31.f:_41.f
_12.f:_22.f:_32.f:_42.f
_13.f:_23.f:_33.f:_43.f
_14.f:_24.f:_34.f:_44.f
EndStructure
Structure VECTOR3
x.f:y.f:z.f
EndStructure
Structure CAMERA
Position.VECTOR3
LookAT.VECTOR3
Rotation.VECTOR3
Pitch.f
Yaw.f
Roll.f
EndStructure
Global Dim Map3D.WORLD3D(100,100)
Global Dim Map2D.WORLD3D(100,100)
Global Dim Sommet.WORLD3D(100,100)
Global Matrice_Rotation.MATRIX4 ; Notre matrice de rotation
Global Matrice_Translation.MATRIX4 ; Notre matrice de Translation
Global Matrice_Finale.MATRIX4 ; Matrice finale
; NOTRE CAMERA
Global Camera.CAMERA
Camera\Position\x=-50000
Camera\Position\y=7000
Camera\Position\z=-50000
; Initialisation de notre map 3D
For z = 0 To 100
For x = 0 To 100
Sommet(x,z)\x= x*1000
Sommet(x,z)\z= z*1000
Sommet(x,z)\y = 0
Next x
Next z
; Procedure de tracage de ligne optimisé
Procedure lineXY2(x1.f,y1.f,x2.f,y2.f,Couleur.l,ScreenX=640,ScreenY=480)
Shared dx.f,dy.f,xincr.l,yincr.l,x.l,y.l,erreur.f
If x1<>0 And y1<>0 And x2<>0 And y2<>0
;/* On initialise nos variables */
dx = Abs(x2-x1)
dy = Abs(y2-y1)
If x1<x2
xincr = 1
Else
xincr = -1
EndIf
If y1<y2
yincr = 1
Else
yincr = -1
EndIf
;/* Trace de ligne */
x = x1
y = y1
If dx>dy
erreur = dx/2 ; /* c'est plus esthetique comme ca */
For i= 0 To dx
x = x+xincr;
erreur = erreur+dy
If erreur > dx
erreur = erreur - dx
y = y+yincr
EndIf
If x>0 And x<ScreenX-1 And y>0 And y<ScreenY-1
Plot(x,y,Couleur)
EndIf
Next i
Else
erreur = dy/2; /* c'est plus esthetique comme ca */
For i=0 To dy
y = y + yincr
erreur = erreur + dx
If erreur>dy
erreur = erreur - dy
x = x + xincr
EndIf
If x>0 And x<ScreenX-1 And y>0 And y<ScreenY-1
Plot(x,y,Couleur)
EndIf
Next i
EndIf
EndIf
EndProcedure
; procedure de projection 3D --> 2D
Procedure Projection3D2D()
Static WaveSpeed.f
WaveSpeed-0.1
For z = 0 To 100
For x = 0 To 100
;Calcul des vagues 3D, puis affectation à la hauteur (y).
Map3D(x,z)\WaveHeight_A = (1000+1000*Cos(WaveSpeed*#PI/180)) *Cos((x*20*2*0.144)+WaveSpeed)
Map3D(z,x)\WaveHeight_B = (1000+1000*Cos(WaveSpeed*#PI/180)) *Sin((x*20*2*0.144)+WaveSpeed)
Map3D(x,z)\y = Map3D(x,z)\y -(Map3D(x,z)\WaveHeight_A + Map3D(x,z)\WaveHeight_B)/2
; ;Map3D(x,z)\y - ((Map3D(x,z)\x*Map3D(x,z)\x)/Map3D(x,z)\z)/5 ; Donne un effet déformer aux points
;
;FORMULE DE PROJECTION
Map2D(x,z)\x=(Map3D(x,z)\x*512)/(Map3D(x,z)\z+#Zoff)+#Xoff;
Map2D(x,z)\y=(Map3D(x,z)\y*512)/(Map3D(x,z)\z+#Zoff)+#Yoff;
; LE *512 joue sur le FOV
; Y a plus qu'a trouvé une formule pour la gestion du FOV
; Couleur.l = Map3D(x,z)\z / 255
; Couleur = Couleur-Couleur*3
If Map3D(x,z)\z>0 And Map2D(x,z)\x>-100 And Map2D(x,z)\x < 900 And Map2D(x,z)\y>-100 And Map2D(x,z)\y<700
If x+1<100
lineXY2(Map2D(x,z)\x,Map2D(x,z)\y,Map2D(x+1,z)\x,Map2D(x+1,z)\y,RGB(255 ,Couleur ,Couleur))
EndIf
If z+1<100
lineXY2(Map2D(x,z)\x,Map2D(x,z)\y,Map2D(x,z+1)\x,Map2D(x,z+1)\y,RGB(Couleur ,Couleur ,255))
EndIf
EndIf
Next x
Next z
EndProcedure
; Proc pour effectuer une translation
Procedure Translation(*Translation.VECTOR3)
Matrice_Translation\_11 = 1
Matrice_Translation\_12 = 0
Matrice_Translation\_13 = 0
Matrice_Translation\_14 = 0
Matrice_Translation\_21 = 0
Matrice_Translation\_22 = 1
Matrice_Translation\_23 = 0
Matrice_Translation\_24 = 0
Matrice_Translation\_31 = 0
Matrice_Translation\_32 = 0
Matrice_Translation\_33 = 1
Matrice_Translation\_34 = 0
Matrice_Translation\_41 = *Translation\x
Matrice_Translation\_42 = *Translation\y
Matrice_Translation\_43 = *Translation\z
Matrice_Translation\_44 = 1
EndProcedure
; Multiplication de la matrice finale et de la matrice de rotation
Procedure MultiplyMAT()
Matrice_Finale\_11 = Matrice_Translation\_11 * Matrice_Rotation\_11 + Matrice_Translation\_12 * Matrice_Rotation\_21 + Matrice_Translation\_13 * Matrice_Rotation\_31 + Matrice_Translation\_14 * Matrice_Rotation\_41
Matrice_Finale\_12 = Matrice_Translation\_11 * Matrice_Rotation\_12 + Matrice_Translation\_12 * Matrice_Rotation\_22 + Matrice_Translation\_13 * Matrice_Rotation\_32 + Matrice_Translation\_14 * Matrice_Rotation\_42
Matrice_Finale\_13 = Matrice_Translation\_11 * Matrice_Rotation\_13 + Matrice_Translation\_12 * Matrice_Rotation\_23 + Matrice_Translation\_13 * Matrice_Rotation\_33 + Matrice_Translation\_14 * Matrice_Rotation\_43
Matrice_Finale\_14 = Matrice_Translation\_11 * Matrice_Rotation\_14 + Matrice_Translation\_12 * Matrice_Rotation\_24 + Matrice_Translation\_13 * Matrice_Rotation\_34 + Matrice_Translation\_14 * Matrice_Rotation\_44
Matrice_Finale\_21 = Matrice_Translation\_21 * Matrice_Rotation\_11 + Matrice_Translation\_22 * Matrice_Rotation\_21 + Matrice_Translation\_23 * Matrice_Rotation\_31 + Matrice_Translation\_24 * Matrice_Rotation\_41
Matrice_Finale\_22 = Matrice_Translation\_21 * Matrice_Rotation\_12 + Matrice_Translation\_22 * Matrice_Rotation\_22 + Matrice_Translation\_23 * Matrice_Rotation\_32 + Matrice_Translation\_24 * Matrice_Rotation\_42
Matrice_Finale\_23 = Matrice_Translation\_21 * Matrice_Rotation\_13 + Matrice_Translation\_22 * Matrice_Rotation\_23 + Matrice_Translation\_23 * Matrice_Rotation\_33 + Matrice_Translation\_24 * Matrice_Rotation\_43
Matrice_Finale\_24 = Matrice_Translation\_21 * Matrice_Rotation\_14 + Matrice_Translation\_22 * Matrice_Rotation\_24 + Matrice_Translation\_23 * Matrice_Rotation\_34 + Matrice_Translation\_24 * Matrice_Rotation\_44
Matrice_Finale\_31 = Matrice_Translation\_31 * Matrice_Rotation\_11 + Matrice_Translation\_32 * Matrice_Rotation\_21 + Matrice_Translation\_33 * Matrice_Rotation\_31 + Matrice_Translation\_34 * Matrice_Rotation\_41
Matrice_Finale\_32 = Matrice_Translation\_31 * Matrice_Rotation\_12 + Matrice_Translation\_32 * Matrice_Rotation\_22 + Matrice_Translation\_33 * Matrice_Rotation\_32 + Matrice_Translation\_34 * Matrice_Rotation\_42
Matrice_Finale\_33 = Matrice_Translation\_31 * Matrice_Rotation\_13 + Matrice_Translation\_32 * Matrice_Rotation\_23 + Matrice_Translation\_33 * Matrice_Rotation\_33 + Matrice_Translation\_34 * Matrice_Rotation\_43
Matrice_Finale\_34 = Matrice_Translation\_31 * Matrice_Rotation\_14 + Matrice_Translation\_32 * Matrice_Rotation\_24 + Matrice_Translation\_33 * Matrice_Rotation\_34 + Matrice_Translation\_34 * Matrice_Rotation\_44
Matrice_Finale\_41 = Matrice_Translation\_41 * Matrice_Rotation\_11 + Matrice_Translation\_42 * Matrice_Rotation\_21 + Matrice_Translation\_43 * Matrice_Rotation\_31 + Matrice_Translation\_44 * Matrice_Rotation\_41
Matrice_Finale\_42 = Matrice_Translation\_41 * Matrice_Rotation\_12 + Matrice_Translation\_42 * Matrice_Rotation\_22 + Matrice_Translation\_43 * Matrice_Rotation\_32 + Matrice_Translation\_44 * Matrice_Rotation\_42
Matrice_Finale\_43 = Matrice_Translation\_41 * Matrice_Rotation\_13 + Matrice_Translation\_42 * Matrice_Rotation\_23 + Matrice_Translation\_43 * Matrice_Rotation\_33 + Matrice_Translation\_44 * Matrice_Rotation\_43
Matrice_Finale\_44 = Matrice_Translation\_41 * Matrice_Rotation\_14 + Matrice_Translation\_42 * Matrice_Rotation\_24 + Matrice_Translation\_43 * Matrice_Rotation\_34 + Matrice_Translation\_44 * Matrice_Rotation\_44
Matrice_Translation\_11 = Matrice_Finale\_11
Matrice_Translation\_11 = Matrice_Finale\_12
Matrice_Translation\_11 = Matrice_Finale\_13
Matrice_Translation\_11 = Matrice_Finale\_14
Matrice_Translation\_21 = Matrice_Finale\_21
Matrice_Translation\_21 = Matrice_Finale\_22
Matrice_Translation\_21 = Matrice_Finale\_23
Matrice_Translation\_21 = Matrice_Finale\_24
Matrice_Translation\_31 = Matrice_Finale\_31
Matrice_Translation\_31 = Matrice_Finale\_32
Matrice_Translation\_31 = Matrice_Finale\_33
Matrice_Translation\_31 = Matrice_Finale\_34
Matrice_Translation\_41 = Matrice_Finale\_41
Matrice_Translation\_41 = Matrice_Finale\_42
Matrice_Translation\_41 = Matrice_Finale\_43
Matrice_Translation\_41 = Matrice_Finale\_44
; Mise à jour de tout les points 3D
For z = 0 To 100
For x = 0 To 100
Map3D(x,z)\x = Matrice_Finale\_11*Sommet(x,z)\x + Matrice_Finale\_21*Sommet(x,z)\y + Matrice_Finale\_31*Sommet(x,z)\z + Matrice_Finale\_41
Map3D(x,z)\y = Matrice_Finale\_12*Sommet(x,z)\x + Matrice_Finale\_22*Sommet(x,z)\y + Matrice_Finale\_32*Sommet(x,z)\z + Matrice_Finale\_42
Map3D(x,z)\z = Matrice_Finale\_13*Sommet(x,z)\x + Matrice_Finale\_23*Sommet(x,z)\y + Matrice_Finale\_33*Sommet(x,z)\z + Matrice_Finale\_43
Next x
Next z
; Projection3D2D()
EndProcedure
; Proc pour la rotation xyz de la matrice
Procedure Rotation(*Rotation.VECTOR3)
Matrice_Rotation\_11 = Cos(*Rotation\z)*Cos(*Rotation\y)
Matrice_Rotation\_12 = Cos(*Rotation\z)*Sin(*Rotation\y)*Sin(*Rotation\x) - Sin(*Rotation\z)*Cos(*Rotation\x)
Matrice_Rotation\_13 = Cos(*Rotation\z)*Sin(*Rotation\y)*Cos(*Rotation\x) + Sin(*Rotation\z)*Sin(*Rotation\x)
Matrice_Rotation\_14 = 0
Matrice_Rotation\_21 = Sin(*Rotation\z)*Cos(*Rotation\y)
Matrice_Rotation\_22 = Sin(*Rotation\z)*Sin(*Rotation\y)*Sin(*Rotation\x) + Cos(*Rotation\x)*Cos(*Rotation\z)
Matrice_Rotation\_23 = Sin(*Rotation\z)*Sin(*Rotation\y)*Cos(*Rotation\x) - Cos(*Rotation\z)*Sin(*Rotation\x)
Matrice_Rotation\_24 = 0
Matrice_Rotation\_31 =-Sin(*Rotation\y)
Matrice_Rotation\_32 = Sin(*Rotation\x)*Cos(*Rotation\y)
Matrice_Rotation\_33 = Cos(*Rotation\x)*Cos(*Rotation\y)
Matrice_Rotation\_34 = 0
Matrice_Rotation\_41 = 0
Matrice_Rotation\_42 = 0
Matrice_Rotation\_43 = 0
Matrice_Rotation\_44 = 1
EndProcedure
Procedure Free_Camera(*Camera.CAMERA)
*Camera\Pitch = *Camera\Pitch - MouseDeltaY()/1000
*Camera\Yaw = *Camera\Yaw - MouseDeltaX()/1000
*Camera\LookAT\x = *Camera\Position\x + KeyboardPushed(#PB_Key_Up) * Cos((*Camera\Yaw))
*Camera\LookAT\z = *Camera\Position\z + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Yaw))
*Camera\LookAT\y = *Camera\Position\y + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Pitch))
*Camera\Position\x = *Camera\LookAT\x + KeyboardPushed(#PB_Key_Up) * Cos((*Camera\Yaw))
*Camera\Position\z = *Camera\LookAT\z + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Yaw))
*Camera\Position\y = *Camera\LookAT\y + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Pitch))
*Camera\Rotation\x= *Camera\Pitch+(#PI/180)
*Camera\Rotation\y=-*Camera\Yaw+(270*#PI/180)
*Camera\Rotation\z= *Camera\Roll ; GLIMBAL LOCK :(
EndProcedure
InitMouse()
FPS_TIMER.l
FPS_COUNT.l
FPS_.l
;-BOUCLE PRINCIPALE
Repeat
ClearScreen(0) : ExamineKeyboard() : ExamineMouse()
;======================================
;CALCUL DU FPS
;======================================
If FPS_TIMER<ElapsedMilliseconds()
FPS_TIMER=ElapsedMilliseconds()+1000
FPS_=FPS_COUNT
FPS_COUNT=0
EndIf
If FPS_TIMER>ElapsedMilliseconds()
FPS_COUNT+1
EndIf
;======================================
;======================================
Translation(Camera\Position) ; Procedure de translation
Rotation(Camera\Rotation) ; de rotation
Free_Camera(Camera) ; Gestion de la camera
MultiplyMAT() ; Multiplication des matrices de transformations
;======================================
;======================================
StartDrawing(ScreenOutput())
DrawText(0,0,"MATRICE3D SOFTWARE PAR CPL.BATOR. FPS = "+Str(FPS_))
Projection3D2D() ; Projection à l'écran
StopDrawing()
;======================================
FlipBuffers(0)
Until KeyboardPushed(#PB_Key_Escape)
Bonne question je pensais des pointstmyke a écrit :Tes planettes et etoiles, tu les représenteras par des sprite ou des points ?
(fonctions 2D de PB ?)
Merci beaucoup je vais aller voir ça c'est tres sympa pour la proposition.tmyke a écrit : si cela peux t'aider, voici un très sympathique moteur 100% software,
en C, mais bien commenté
http://www.cppfrance.com/codes/MOTEUR-3 ... 11089.aspx
analyse, et bien sur, si tu veux un coup de main, ou des expli, n'hesite pas
Oui j'avais suivi tes aventures avec ton mini moteur 3D...Un beau boulot. Mais maintenant je comprends le pourquoi du "bienvenu dans la galère".Cpl.Bator a écrit :haaa , bienvenu dans la galère
bon , pour faire simple utilise les matrices de rotation et de translation et matrice finale d'un objet
Cherche un de mes posts s'intitulant [challenge] mini moteur 3D
dedans il y a un lien interessant, je te préviens que réinventé la roue est assez galère, surtout si comme moi , tu es un non matheux ^^

merci pour le code...je vais regarder tout cela de plus prêt des que mon gamin sera couché ...car pour se concentrer avec lui a côté c'est pas gagné lolllllllll
Oui, c'est pas évident a assimiler
- Tu dois retenir se nom : christophe heulin ( googelise le nom
)
j'avais réussi à refaire tout ses codes en purebasic, mais une saloperie de virus ( distribué par un membre de se forum involontairement ) à eu raison de ma partition
c'est vraiment dommage , j'avais réussi à faire de bon trucs, comme l'éclairage, tris des faces, on aurais pu faire un monde en 3D soft dynamique...
c'est étonant la puissance de purebasic quand même

si tu as des problèmes pour gerer tout ca, n'hésites surtout pas
- Tu dois retenir se nom : christophe heulin ( googelise le nom

j'avais réussi à refaire tout ses codes en purebasic, mais une saloperie de virus ( distribué par un membre de se forum involontairement ) à eu raison de ma partition

c'est vraiment dommage , j'avais réussi à faire de bon trucs, comme l'éclairage, tris des faces, on aurais pu faire un monde en 3D soft dynamique...
c'est étonant la puissance de purebasic quand même


si tu as des problèmes pour gerer tout ca, n'hésites surtout pas

vraiment tres bien le tutorial de christophe heulin !
Un truc que j'ai pas compris ! C'est quoi exactement
#Xoff , #Yoff , #Zoff
je ne comprend pas tres bien ce que c'est
"Ainsi, la position d'un objet dans notre espace image est définie d'une part par les coordonnées de son centre, et d'autre part par son orientation dans l'espace. Ceci nous mène donc naturellement à utiliser un vecteur de translation (Xoff,Yoff,Zoff) et trois angles de rotation distincts (un pour chaque axe)."
ça serait le centre de l'objet c'est ça ou bien ça un rapport avec la taille de l'ecran d'affichage ?
Sinon un truc curieux dans ton code ..si j'ai bien compris la camera ne bouge jamais...ce sont les points qui bouge c'est ça ?
[Edit 9h20]
Bon je viens d'essayer quelques choses mais je comprends pas pourquoi j'ai rien...
je veux ma camera a l'origne et pouvoir regarder des points tout au tour.
J'avoue que j'ai du mal avec les matrices lollllllllll j'ai compris le principe..mais bon c'est pas tres claire...lollllllll
Un truc que j'ai pas compris ! C'est quoi exactement
#Xoff , #Yoff , #Zoff
je ne comprend pas tres bien ce que c'est
"Ainsi, la position d'un objet dans notre espace image est définie d'une part par les coordonnées de son centre, et d'autre part par son orientation dans l'espace. Ceci nous mène donc naturellement à utiliser un vecteur de translation (Xoff,Yoff,Zoff) et trois angles de rotation distincts (un pour chaque axe)."
ça serait le centre de l'objet c'est ça ou bien ça un rapport avec la taille de l'ecran d'affichage ?
Sinon un truc curieux dans ton code ..si j'ai bien compris la camera ne bouge jamais...ce sont les points qui bouge c'est ça ?
[Edit 9h20]
Bon je viens d'essayer quelques choses mais je comprends pas pourquoi j'ai rien...
je veux ma camera a l'origne et pouvoir regarder des points tout au tour.
J'avoue que j'ai du mal avec les matrices lollllllllll j'ai compris le principe..mais bon c'est pas tres claire...lollllllll
Code : Tout sélectionner
InitSprite() : InitKeyboard()
OpenScreen(800,600,32,"")
#Xoff = 400
#Yoff = 300
#Zoff = 1500
; Structure de notre monde 3D, on represente les points3D la dedans.
Structure WORLD3D
x.f
y.f
z.f
WaveHeight_A.f
WaveHeight_B.f
EndStructure
Structure MATRIX4
_11.f:_21.f:_31.f:_41.f
_12.f:_22.f:_32.f:_42.f
_13.f:_23.f:_33.f:_43.f
_14.f:_24.f:_34.f:_44.f
EndStructure
Structure VECTOR3
x.f:y.f:z.f
EndStructure
Structure CAMERA
Position.VECTOR3
LookAT.VECTOR3
Rotation.VECTOR3
Pitch.f
Yaw.f
Roll.f
EndStructure
;Global Dim Map3D.WORLD3D(100,100)
;Global Dim Map2D.WORLD3D(100,100)
Global Dim Sommet.WORLD3D(100,100)
Global Matrice_Rotation.MATRIX4 ; Notre matrice de rotation
Global Matrice_Translation.MATRIX4 ; Notre matrice de Translation
Global Matrice_Finale.MATRIX4 ; Matrice finale
; NOTRE CAMERA
Global Camera.CAMERA
Camera\Position\x=0
Camera\Position\y=0
Camera\Position\z=4500
Global Dim Star.VECTOR3(1000)
For z=0 To 1000
Star(z)\x=Random(10000)
Star(z)\y=Random(10000)
Star(z)\z=Random(10000)
Next
; Procedure de tracage de ligne optimisé
Procedure lineXY2(x1.f,y1.f,x2.f,y2.f,Couleur.l,ScreenX=640,ScreenY=480)
Shared dx.f,dy.f,xincr.l,yincr.l,x.l,y.l,erreur.f
If x1<>0 And y1<>0 And x2<>0 And y2<>0
;/* On initialise nos variables */
dx = Abs(x2-x1)
dy = Abs(y2-y1)
If x1<x2
xincr = 1
Else
xincr = -1
EndIf
If y1<y2
yincr = 1
Else
yincr = -1
EndIf
;/* Trace de ligne */
x = x1
y = y1
If dx>dy
erreur = dx/2 ; /* c'est plus esthetique comme ca */
For i= 0 To dx
x = x+xincr;
erreur = erreur+dy
If erreur > dx
erreur = erreur - dx
y = y+yincr
EndIf
If x>0 And x<ScreenX-1 And y>0 And y<ScreenY-1
Plot(x,y,Couleur)
EndIf
Next i
Else
erreur = dy/2; /* c'est plus esthetique comme ca */
For i=0 To dy
y = y + yincr
erreur = erreur + dx
If erreur>dy
erreur = erreur - dy
x = x + xincr
EndIf
If x>0 And x<ScreenX-1 And y>0 And y<ScreenY-1
Plot(x,y,Couleur)
EndIf
Next i
EndIf
EndIf
EndProcedure
; procedure de projection 3D --> 2D
Procedure Projection3D2D()
For z=0 To 1000
;FORMULE DE PROJECTION
x=(Star(z)\x*512)/(Star(z)\z+#Zoff)+#Xoff;
y=(Star(z)\y*512)/(Star(z)\z+#Zoff)+#Yoff;
; LE *512 joue sur le FOV
; Y a plus qu'a trouvé une formule pour la gestion du FOV
If x>0 And x<800 And y>0 And y<600
Circle(x,y,16,RGB(255,255,255))
EndIf
Next z
EndProcedure
; Proc pour effectuer une translation
Procedure Translation(*Translation.VECTOR3)
Matrice_Translation\_11 = 1
Matrice_Translation\_12 = 0
Matrice_Translation\_13 = 0
Matrice_Translation\_14 = 0
Matrice_Translation\_21 = 0
Matrice_Translation\_22 = 1
Matrice_Translation\_23 = 0
Matrice_Translation\_24 = 0
Matrice_Translation\_31 = 0
Matrice_Translation\_32 = 0
Matrice_Translation\_33 = 1
Matrice_Translation\_34 = 0
Matrice_Translation\_41 = *Translation\x
Matrice_Translation\_42 = *Translation\y
Matrice_Translation\_43 = *Translation\z
Matrice_Translation\_44 = 1
EndProcedure
; Multiplication de la matrice finale et de la matrice de rotation
Procedure MultiplyMAT()
Matrice_Finale\_11 = Matrice_Translation\_11 * Matrice_Rotation\_11 + Matrice_Translation\_12 * Matrice_Rotation\_21 + Matrice_Translation\_13 * Matrice_Rotation\_31 + Matrice_Translation\_14 * Matrice_Rotation\_41
Matrice_Finale\_12 = Matrice_Translation\_11 * Matrice_Rotation\_12 + Matrice_Translation\_12 * Matrice_Rotation\_22 + Matrice_Translation\_13 * Matrice_Rotation\_32 + Matrice_Translation\_14 * Matrice_Rotation\_42
Matrice_Finale\_13 = Matrice_Translation\_11 * Matrice_Rotation\_13 + Matrice_Translation\_12 * Matrice_Rotation\_23 + Matrice_Translation\_13 * Matrice_Rotation\_33 + Matrice_Translation\_14 * Matrice_Rotation\_43
Matrice_Finale\_14 = Matrice_Translation\_11 * Matrice_Rotation\_14 + Matrice_Translation\_12 * Matrice_Rotation\_24 + Matrice_Translation\_13 * Matrice_Rotation\_34 + Matrice_Translation\_14 * Matrice_Rotation\_44
Matrice_Finale\_21 = Matrice_Translation\_21 * Matrice_Rotation\_11 + Matrice_Translation\_22 * Matrice_Rotation\_21 + Matrice_Translation\_23 * Matrice_Rotation\_31 + Matrice_Translation\_24 * Matrice_Rotation\_41
Matrice_Finale\_22 = Matrice_Translation\_21 * Matrice_Rotation\_12 + Matrice_Translation\_22 * Matrice_Rotation\_22 + Matrice_Translation\_23 * Matrice_Rotation\_32 + Matrice_Translation\_24 * Matrice_Rotation\_42
Matrice_Finale\_23 = Matrice_Translation\_21 * Matrice_Rotation\_13 + Matrice_Translation\_22 * Matrice_Rotation\_23 + Matrice_Translation\_23 * Matrice_Rotation\_33 + Matrice_Translation\_24 * Matrice_Rotation\_43
Matrice_Finale\_24 = Matrice_Translation\_21 * Matrice_Rotation\_14 + Matrice_Translation\_22 * Matrice_Rotation\_24 + Matrice_Translation\_23 * Matrice_Rotation\_34 + Matrice_Translation\_24 * Matrice_Rotation\_44
Matrice_Finale\_31 = Matrice_Translation\_31 * Matrice_Rotation\_11 + Matrice_Translation\_32 * Matrice_Rotation\_21 + Matrice_Translation\_33 * Matrice_Rotation\_31 + Matrice_Translation\_34 * Matrice_Rotation\_41
Matrice_Finale\_32 = Matrice_Translation\_31 * Matrice_Rotation\_12 + Matrice_Translation\_32 * Matrice_Rotation\_22 + Matrice_Translation\_33 * Matrice_Rotation\_32 + Matrice_Translation\_34 * Matrice_Rotation\_42
Matrice_Finale\_33 = Matrice_Translation\_31 * Matrice_Rotation\_13 + Matrice_Translation\_32 * Matrice_Rotation\_23 + Matrice_Translation\_33 * Matrice_Rotation\_33 + Matrice_Translation\_34 * Matrice_Rotation\_43
Matrice_Finale\_34 = Matrice_Translation\_31 * Matrice_Rotation\_14 + Matrice_Translation\_32 * Matrice_Rotation\_24 + Matrice_Translation\_33 * Matrice_Rotation\_34 + Matrice_Translation\_34 * Matrice_Rotation\_44
Matrice_Finale\_41 = Matrice_Translation\_41 * Matrice_Rotation\_11 + Matrice_Translation\_42 * Matrice_Rotation\_21 + Matrice_Translation\_43 * Matrice_Rotation\_31 + Matrice_Translation\_44 * Matrice_Rotation\_41
Matrice_Finale\_42 = Matrice_Translation\_41 * Matrice_Rotation\_12 + Matrice_Translation\_42 * Matrice_Rotation\_22 + Matrice_Translation\_43 * Matrice_Rotation\_32 + Matrice_Translation\_44 * Matrice_Rotation\_42
Matrice_Finale\_43 = Matrice_Translation\_41 * Matrice_Rotation\_13 + Matrice_Translation\_42 * Matrice_Rotation\_23 + Matrice_Translation\_43 * Matrice_Rotation\_33 + Matrice_Translation\_44 * Matrice_Rotation\_43
Matrice_Finale\_44 = Matrice_Translation\_41 * Matrice_Rotation\_14 + Matrice_Translation\_42 * Matrice_Rotation\_24 + Matrice_Translation\_43 * Matrice_Rotation\_34 + Matrice_Translation\_44 * Matrice_Rotation\_44
Matrice_Translation\_11 = Matrice_Finale\_11
Matrice_Translation\_11 = Matrice_Finale\_12
Matrice_Translation\_11 = Matrice_Finale\_13
Matrice_Translation\_11 = Matrice_Finale\_14
Matrice_Translation\_21 = Matrice_Finale\_21
Matrice_Translation\_21 = Matrice_Finale\_22
Matrice_Translation\_21 = Matrice_Finale\_23
Matrice_Translation\_21 = Matrice_Finale\_24
Matrice_Translation\_31 = Matrice_Finale\_31
Matrice_Translation\_31 = Matrice_Finale\_32
Matrice_Translation\_31 = Matrice_Finale\_33
Matrice_Translation\_31 = Matrice_Finale\_34
Matrice_Translation\_41 = Matrice_Finale\_41
Matrice_Translation\_41 = Matrice_Finale\_42
Matrice_Translation\_41 = Matrice_Finale\_43
Matrice_Translation\_41 = Matrice_Finale\_44
; Mise à jour de tout les points 3D
For z = 0 To 1000
Star(z)\x = Matrice_Finale\_11* Star(z)\x + Matrice_Finale\_21* Star(z)\y + Matrice_Finale\_31* Star(z)\z + Matrice_Finale\_41
Star(z)\y = Matrice_Finale\_12* Star(z)\x + Matrice_Finale\_22* Star(z)\y + Matrice_Finale\_32* Star(z)\z + Matrice_Finale\_42
Star(z)\z = Matrice_Finale\_13* Star(z)\x + Matrice_Finale\_23* Star(z)\y + Matrice_Finale\_33* Star(z)\z + Matrice_Finale\_43
Next z
; Projection3D2D()
EndProcedure
; Proc pour la rotation xyz de la matrice
Procedure Rotation(*Rotation.VECTOR3)
Matrice_Rotation\_11 = Cos(*Rotation\z)*Cos(*Rotation\y)
Matrice_Rotation\_12 = Cos(*Rotation\z)*Sin(*Rotation\y)*Sin(*Rotation\x) - Sin(*Rotation\z)*Cos(*Rotation\x)
Matrice_Rotation\_13 = Cos(*Rotation\z)*Sin(*Rotation\y)*Cos(*Rotation\x) + Sin(*Rotation\z)*Sin(*Rotation\x)
Matrice_Rotation\_14 = 0
Matrice_Rotation\_21 = Sin(*Rotation\z)*Cos(*Rotation\y)
Matrice_Rotation\_22 = Sin(*Rotation\z)*Sin(*Rotation\y)*Sin(*Rotation\x) + Cos(*Rotation\x)*Cos(*Rotation\z)
Matrice_Rotation\_23 = Sin(*Rotation\z)*Sin(*Rotation\y)*Cos(*Rotation\x) - Cos(*Rotation\z)*Sin(*Rotation\x)
Matrice_Rotation\_24 = 0
Matrice_Rotation\_31 =-Sin(*Rotation\y)
Matrice_Rotation\_32 = Sin(*Rotation\x)*Cos(*Rotation\y)
Matrice_Rotation\_33 = Cos(*Rotation\x)*Cos(*Rotation\y)
Matrice_Rotation\_34 = 0
Matrice_Rotation\_41 = 0
Matrice_Rotation\_42 = 0
Matrice_Rotation\_43 = 0
Matrice_Rotation\_44 = 1
EndProcedure
Procedure Free_Camera(*Camera.CAMERA)
*Camera\Pitch = *Camera\Pitch - MouseDeltaY()/1000
*Camera\Yaw = *Camera\Yaw - MouseDeltaX()/1000
*Camera\LookAT\x = *Camera\Position\x + KeyboardPushed(#PB_Key_Up) * Cos((*Camera\Yaw))
*Camera\LookAT\z = *Camera\Position\z + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Yaw))
*Camera\LookAT\y = *Camera\Position\y + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Pitch))
*Camera\Position\x = *Camera\LookAT\x + KeyboardPushed(#PB_Key_Up) * Cos((*Camera\Yaw))
*Camera\Position\z = *Camera\LookAT\z + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Yaw))
*Camera\Position\y = *Camera\LookAT\y + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Pitch))
*Camera\Rotation\x= *Camera\Pitch+(#PI/180)
*Camera\Rotation\y=-*Camera\Yaw+(270*#PI/180)
*Camera\Rotation\z= *Camera\Roll ; GLIMBAL LOCK :(
EndProcedure
InitMouse()
FPS_TIMER.l
FPS_COUNT.l
FPS_.l
;-BOUCLE PRINCIPALE
Repeat
ClearScreen(0) : ExamineKeyboard() : ExamineMouse()
;======================================
;CALCUL DU FPS
;======================================
If FPS_TIMER<ElapsedMilliseconds()
FPS_TIMER=ElapsedMilliseconds()+1000
FPS_=FPS_COUNT
FPS_COUNT=0
EndIf
If FPS_TIMER>ElapsedMilliseconds()
FPS_COUNT+1
EndIf
;======================================
;======================================
Translation(Camera\Position) ; Procedure de translation
Rotation(Camera\Rotation) ; de rotation
Free_Camera(Camera) ; Gestion de la camera
MultiplyMAT() ; Multiplication des matrices de transformations
;======================================
;======================================
StartDrawing(ScreenOutput())
DrawText(0,0,"MATRICE3D SOFTWARE PAR CPL.BATOR. FPS = "+Str(FPS_))
Projection3D2D() ; Projection à l'écran
For z=0 To 1000
x=(Star(z)\x*FOV)/(Star(z)\z+Zoff)+Xoff;
y=(Star(z)\y*FOV)/(Star(z)\z+Zoff)+Yoff;
If x>0 And x<800 And y>0 And y<600
Plot(x,y,RGB(255,255,255))
EndIf
Next
StopDrawing()
;======================================
FlipBuffers(0)
Until KeyboardPushed(#PB_Key_Escape)
-
- Messages : 1554
- Inscription : lun. 24/juil./2006 6:44
- Localisation : vosges (France) 47°54'39.06"N 6°20'06.39"E
pour ce qui est des valeur Xoff/Yoff/Zoff, au vue du code, il s'agit de valeur
qui servent a la projection 2D:
Xoff = taille demi ecran en largeur
Yoff = taille demi ecran en hauteur
Zoff = profondeur de vue
Sinon, voici un code épuré qui t'aidera peut-etre:
qui servent a la projection 2D:
Xoff = taille demi ecran en largeur
Yoff = taille demi ecran en hauteur
Zoff = profondeur de vue
Sinon, voici un code épuré qui t'aidera peut-etre:
Code : Tout sélectionner
InitSprite() : InitKeyboard()
OpenScreen(640,480,32,"")
#Xoff = 320
#Yoff = 240
#Zoff = 1500
; Structure de notre monde 3D, on represente les points3D la dedans.
Structure WORLD3D
x.f
y.f
z.f
WaveHeight_A.f
WaveHeight_B.f
EndStructure
Structure MATRIX4
_11.f:_21.f:_31.f:_41.f
_12.f:_22.f:_32.f:_42.f
_13.f:_23.f:_33.f:_43.f
_14.f:_24.f:_34.f:_44.f
EndStructure
Structure VECTOR3
x.f:y.f:z.f
EndStructure
Structure CAMERA
Position.VECTOR3
LookAT.VECTOR3
Rotation.VECTOR3
Pitch.f
Yaw.f
Roll.f
EndStructure
Global Dim Map3D.WORLD3D(100)
Global Dim Map2D.WORLD3D(100)
Global Dim Sommet.WORLD3D(100)
Global Matrice_Rotation.MATRIX4 ; Notre matrice de rotation
Global Matrice_Translation.MATRIX4 ; Notre matrice de Translation
Global Matrice_Finale.MATRIX4 ; Matrice finale
; NOTRE CAMERA
Global Camera.CAMERA
Camera\Position\x=0
Camera\Position\y=0
Camera\Position\z=0
; Initialisation de notre map 3D
For z = 0 To 100
Sommet(z)\x= 500-Random(1000)
Sommet(z)\z= 500-Random(1000)
Sommet(z)\y =500-Random(1000)
Next z
; procedure de projection 3D --> 2D
Procedure Projection3D2D()
Static WaveSpeed.f
For z = 0 To 100
;FORMULE DE PROJECTION
Map2D(z)\x=(Map3D(z)\x*512)/(Map3D(z)\z+#Zoff)+#Xoff;
Map2D(z)\y=(Map3D(z)\y*512)/(Map3D(z)\z+#Zoff)+#Yoff;
Circle(Map2D(z)\x, Map2D(z)\y,16,RGB(255,255,255))
Next z
EndProcedure
; Proc pour effectuer une translation
Procedure Translation(*Translation.VECTOR3)
Matrice_Translation\_11 = 1
Matrice_Translation\_12 = 0
Matrice_Translation\_13 = 0
Matrice_Translation\_14 = 0
Matrice_Translation\_21 = 0
Matrice_Translation\_22 = 1
Matrice_Translation\_23 = 0
Matrice_Translation\_24 = 0
Matrice_Translation\_31 = 0
Matrice_Translation\_32 = 0
Matrice_Translation\_33 = 1
Matrice_Translation\_34 = 0
Matrice_Translation\_41 = *Translation\x
Matrice_Translation\_42 = *Translation\y
Matrice_Translation\_43 = *Translation\z
Matrice_Translation\_44 = 1
EndProcedure
; Multiplication de la matrice finale et de la matrice de rotation
Procedure MultiplyMAT()
Matrice_Finale\_11 = Matrice_Translation\_11 * Matrice_Rotation\_11 + Matrice_Translation\_12 * Matrice_Rotation\_21 + Matrice_Translation\_13 * Matrice_Rotation\_31 + Matrice_Translation\_14 * Matrice_Rotation\_41
Matrice_Finale\_12 = Matrice_Translation\_11 * Matrice_Rotation\_12 + Matrice_Translation\_12 * Matrice_Rotation\_22 + Matrice_Translation\_13 * Matrice_Rotation\_32 + Matrice_Translation\_14 * Matrice_Rotation\_42
Matrice_Finale\_13 = Matrice_Translation\_11 * Matrice_Rotation\_13 + Matrice_Translation\_12 * Matrice_Rotation\_23 + Matrice_Translation\_13 * Matrice_Rotation\_33 + Matrice_Translation\_14 * Matrice_Rotation\_43
Matrice_Finale\_14 = Matrice_Translation\_11 * Matrice_Rotation\_14 + Matrice_Translation\_12 * Matrice_Rotation\_24 + Matrice_Translation\_13 * Matrice_Rotation\_34 + Matrice_Translation\_14 * Matrice_Rotation\_44
Matrice_Finale\_21 = Matrice_Translation\_21 * Matrice_Rotation\_11 + Matrice_Translation\_22 * Matrice_Rotation\_21 + Matrice_Translation\_23 * Matrice_Rotation\_31 + Matrice_Translation\_24 * Matrice_Rotation\_41
Matrice_Finale\_22 = Matrice_Translation\_21 * Matrice_Rotation\_12 + Matrice_Translation\_22 * Matrice_Rotation\_22 + Matrice_Translation\_23 * Matrice_Rotation\_32 + Matrice_Translation\_24 * Matrice_Rotation\_42
Matrice_Finale\_23 = Matrice_Translation\_21 * Matrice_Rotation\_13 + Matrice_Translation\_22 * Matrice_Rotation\_23 + Matrice_Translation\_23 * Matrice_Rotation\_33 + Matrice_Translation\_24 * Matrice_Rotation\_43
Matrice_Finale\_24 = Matrice_Translation\_21 * Matrice_Rotation\_14 + Matrice_Translation\_22 * Matrice_Rotation\_24 + Matrice_Translation\_23 * Matrice_Rotation\_34 + Matrice_Translation\_24 * Matrice_Rotation\_44
Matrice_Finale\_31 = Matrice_Translation\_31 * Matrice_Rotation\_11 + Matrice_Translation\_32 * Matrice_Rotation\_21 + Matrice_Translation\_33 * Matrice_Rotation\_31 + Matrice_Translation\_34 * Matrice_Rotation\_41
Matrice_Finale\_32 = Matrice_Translation\_31 * Matrice_Rotation\_12 + Matrice_Translation\_32 * Matrice_Rotation\_22 + Matrice_Translation\_33 * Matrice_Rotation\_32 + Matrice_Translation\_34 * Matrice_Rotation\_42
Matrice_Finale\_33 = Matrice_Translation\_31 * Matrice_Rotation\_13 + Matrice_Translation\_32 * Matrice_Rotation\_23 + Matrice_Translation\_33 * Matrice_Rotation\_33 + Matrice_Translation\_34 * Matrice_Rotation\_43
Matrice_Finale\_34 = Matrice_Translation\_31 * Matrice_Rotation\_14 + Matrice_Translation\_32 * Matrice_Rotation\_24 + Matrice_Translation\_33 * Matrice_Rotation\_34 + Matrice_Translation\_34 * Matrice_Rotation\_44
Matrice_Finale\_41 = Matrice_Translation\_41 * Matrice_Rotation\_11 + Matrice_Translation\_42 * Matrice_Rotation\_21 + Matrice_Translation\_43 * Matrice_Rotation\_31 + Matrice_Translation\_44 * Matrice_Rotation\_41
Matrice_Finale\_42 = Matrice_Translation\_41 * Matrice_Rotation\_12 + Matrice_Translation\_42 * Matrice_Rotation\_22 + Matrice_Translation\_43 * Matrice_Rotation\_32 + Matrice_Translation\_44 * Matrice_Rotation\_42
Matrice_Finale\_43 = Matrice_Translation\_41 * Matrice_Rotation\_13 + Matrice_Translation\_42 * Matrice_Rotation\_23 + Matrice_Translation\_43 * Matrice_Rotation\_33 + Matrice_Translation\_44 * Matrice_Rotation\_43
Matrice_Finale\_44 = Matrice_Translation\_41 * Matrice_Rotation\_14 + Matrice_Translation\_42 * Matrice_Rotation\_24 + Matrice_Translation\_43 * Matrice_Rotation\_34 + Matrice_Translation\_44 * Matrice_Rotation\_44
Matrice_Translation\_11 = Matrice_Finale\_11
Matrice_Translation\_11 = Matrice_Finale\_12
Matrice_Translation\_11 = Matrice_Finale\_13
Matrice_Translation\_11 = Matrice_Finale\_14
Matrice_Translation\_21 = Matrice_Finale\_21
Matrice_Translation\_21 = Matrice_Finale\_22
Matrice_Translation\_21 = Matrice_Finale\_23
Matrice_Translation\_21 = Matrice_Finale\_24
Matrice_Translation\_31 = Matrice_Finale\_31
Matrice_Translation\_31 = Matrice_Finale\_32
Matrice_Translation\_31 = Matrice_Finale\_33
Matrice_Translation\_31 = Matrice_Finale\_34
Matrice_Translation\_41 = Matrice_Finale\_41
Matrice_Translation\_41 = Matrice_Finale\_42
Matrice_Translation\_41 = Matrice_Finale\_43
Matrice_Translation\_41 = Matrice_Finale\_44
; Mise à jour de tout les points 3D
For z = 0 To 100
Map3D(z)\x = Matrice_Finale\_11*Sommet(z)\x + Matrice_Finale\_21*Sommet(z)\y + Matrice_Finale\_31*Sommet(z)\z + Matrice_Finale\_41
Map3D(z)\y = Matrice_Finale\_12*Sommet(z)\x + Matrice_Finale\_22*Sommet(z)\y + Matrice_Finale\_32*Sommet(z)\z + Matrice_Finale\_42
Map3D(z)\z = Matrice_Finale\_13*Sommet(z)\x + Matrice_Finale\_23*Sommet(z)\y + Matrice_Finale\_33*Sommet(z)\z + Matrice_Finale\_43
Next z
; Projection3D2D()
EndProcedure
; Proc pour la rotation xyz de la matrice
Procedure Rotation(*Rotation.VECTOR3)
Matrice_Rotation\_11 = Cos(*Rotation\z)*Cos(*Rotation\y)
Matrice_Rotation\_12 = Cos(*Rotation\z)*Sin(*Rotation\y)*Sin(*Rotation\x) - Sin(*Rotation\z)*Cos(*Rotation\x)
Matrice_Rotation\_13 = Cos(*Rotation\z)*Sin(*Rotation\y)*Cos(*Rotation\x) + Sin(*Rotation\z)*Sin(*Rotation\x)
Matrice_Rotation\_14 = 0
Matrice_Rotation\_21 = Sin(*Rotation\z)*Cos(*Rotation\y)
Matrice_Rotation\_22 = Sin(*Rotation\z)*Sin(*Rotation\y)*Sin(*Rotation\x) + Cos(*Rotation\x)*Cos(*Rotation\z)
Matrice_Rotation\_23 = Sin(*Rotation\z)*Sin(*Rotation\y)*Cos(*Rotation\x) - Cos(*Rotation\z)*Sin(*Rotation\x)
Matrice_Rotation\_24 = 0
Matrice_Rotation\_31 =-Sin(*Rotation\y)
Matrice_Rotation\_32 = Sin(*Rotation\x)*Cos(*Rotation\y)
Matrice_Rotation\_33 = Cos(*Rotation\x)*Cos(*Rotation\y)
Matrice_Rotation\_34 = 0
Matrice_Rotation\_41 = 0
Matrice_Rotation\_42 = 0
Matrice_Rotation\_43 = 0
Matrice_Rotation\_44 = 1
EndProcedure
Procedure Free_Camera(*Camera.CAMERA)
*Camera\Pitch = *Camera\Pitch - MouseDeltaY()/1000
*Camera\Yaw = *Camera\Yaw - MouseDeltaX()/1000
*Camera\LookAT\x = *Camera\Position\x + KeyboardPushed(#PB_Key_Up) * Cos((*Camera\Yaw))
*Camera\LookAT\z = *Camera\Position\z + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Yaw))
*Camera\LookAT\y = *Camera\Position\y + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Pitch))
*Camera\Position\x = *Camera\LookAT\x + KeyboardPushed(#PB_Key_Up) * Cos((*Camera\Yaw))
*Camera\Position\z = *Camera\LookAT\z + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Yaw))
*Camera\Position\y = *Camera\LookAT\y + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Pitch))
*Camera\Rotation\x= *Camera\Pitch+(#PI/180)
*Camera\Rotation\y=-*Camera\Yaw+(270*#PI/180)
*Camera\Rotation\z= *Camera\Roll ; GLIMBAL LOCK :(
EndProcedure
InitMouse()
FPS_TIMER.l
FPS_COUNT.l
FPS_.l
;-BOUCLE PRINCIPALE
Repeat
ClearScreen(0) : ExamineKeyboard() : ExamineMouse()
;======================================
;CALCUL DU FPS
;======================================
If FPS_TIMER<ElapsedMilliseconds()
FPS_TIMER=ElapsedMilliseconds()+1000
FPS_=FPS_COUNT
FPS_COUNT=0
EndIf
If FPS_TIMER>ElapsedMilliseconds()
FPS_COUNT+1
EndIf
;======================================
;======================================
Translation(Camera\Position) ; Procedure de translation
Rotation(Camera\Rotation) ; de rotation
Free_Camera(Camera) ; Gestion de la camera
MultiplyMAT() ; Multiplication des matrices de transformations
;======================================
;======================================
StartDrawing(ScreenOutput())
DrawText(0,0,"MATRICE3D SOFTWARE PAR CPL.BATOR. FPS = "+Str(FPS_))
Projection3D2D() ; Projection à l'écran
StopDrawing()
;======================================
FlipBuffers(0)
Until KeyboardPushed(#PB_Key_Escape)
Dernière modification par tmyke le mar. 24/avr./2007 9:06, modifié 1 fois.
Force et sagesse...
Voilà un premier essaie....
J'ai compris plein de chose mais je bloque toujours sur la position de la cmera ..si quelqu'un a une piste a me donner

J'ai compris plein de chose mais je bloque toujours sur la position de la cmera ..si quelqu'un a une piste a me donner
Code : Tout sélectionner
;http://atunivers.free.fr/sattelit.html
InitSprite() : InitKeyboard()
OpenScreen(640,480,32,"")
#Xoff = 320
#Yoff = 240
#Zoff = 1500
; Structure de notre monde 3D, on represente les points3D la dedans.
Structure MATRIX4
_11.f:_21.f:_31.f:_41.f
_12.f:_22.f:_32.f:_42.f
_13.f:_23.f:_33.f:_43.f
_14.f:_24.f:_34.f:_44.f
EndStructure
Structure VECTOR3
x.f:y.f:z.f
EndStructure
Structure CAMERA
Position.VECTOR3
LookAT.VECTOR3
Rotation.VECTOR3
Pitch.f
Yaw.f
Roll.f
EndStructure
Global NbPoint
#NBPointMax=1000
Global Dim Map3D.VECTOR3(#NBPointMax)
Global Dim Map2D.VECTOR3(#NBPointMax)
Global Dim Sommet.VECTOR3(#NBPointMax)
Global Matrice_Rotation.MATRIX4 ; Notre matrice de rotation
Global Matrice_Translation.MATRIX4 ; Notre matrice de Translation
Global Matrice_Finale.MATRIX4 ; Matrice finale
; NOTRE CAMERA
Global Camera.CAMERA
Camera\Position\x=0
Camera\Position\y=0
Camera\Position\z=0
; If LoadSprite(0, "media\tex64.bmp")=0
; End
; EndIf
; Initialisation de notre map 3D
For z = 0 To 36
Sommet(z)\x=Cos(z*10*#PI/180)*900
Sommet(z)\z=Sin(z*10*#PI/180)*900
Sommet(z)\y=0
Next z
For z = 0 To 36
Sommet(z+37)\x=Cos(z*10*#PI/180)*400
Sommet(z+37)\z=Sin(z*10*#PI/180)*400
Sommet(z+37)\y=0
Next z
For z = 0 To 36
Sommet(z+74)\x=Cos(z*10*#PI/180)*100
Sommet(z+74)\z=Sin(z*10*#PI/180)*100
Sommet(z+74)\y=0
Next z
For z=200 To #NBPointMax
Sommet(z)\x=500-Random(1000)
Sommet(z)\z=500-Random(1000)
Sommet(z)\y=500-Random(1000)
Next
; procedure
; procedure de projection 3D --> 2D
; Procedure de tracage de ligne optimisé
Procedure lineXY2(x1.f,y1.f,x2.f,y2.f,Couleur.l,ScreenX=800,ScreenY=600)
Shared dx.f,dy.f,xincr.l,yincr.l,x.l,y.l,erreur.f
If x1<>0 And y1<>0 And x2<>0 And y2<>0
;/* On initialise nos variables */
dx = Abs(x2-x1)
dy = Abs(y2-y1)
If x1<x2
xincr = 1
Else
xincr = -1
EndIf
If y1<y2
yincr = 1
Else
yincr = -1
EndIf
;/* Trace de ligne */
x = x1
y = y1
If dx>dy
erreur = dx/2 ; /* c'est plus esthetique comme ca */
For i= 0 To dx
x = x+xincr;
erreur = erreur+dy
If erreur > dx
erreur = erreur - dx
y = y+yincr
EndIf
If x>0 And x<ScreenX-1 And y>0 And y<ScreenY-1
Plot(x,y,Couleur)
EndIf
Next i
Else
erreur = dy/2; /* c'est plus esthetique comme ca */
For i=0 To dy
y = y + yincr
erreur = erreur + dx
If erreur>dy
erreur = erreur - dy
x = x + xincr
EndIf
If x>0 And x<ScreenX-1 And y>0 And y<ScreenY-1
Plot(x,y,Couleur)
EndIf
Next i
EndIf
EndIf
EndProcedure
; Proc pour effectuer une translation
Procedure Translation(*Translation.VECTOR3)
Matrice_Translation\_11 = 1
Matrice_Translation\_12 = 0
Matrice_Translation\_13 = 0
Matrice_Translation\_14 = 0
Matrice_Translation\_21 = 0
Matrice_Translation\_22 = 1
Matrice_Translation\_23 = 0
Matrice_Translation\_24 = 0
Matrice_Translation\_31 = 0
Matrice_Translation\_32 = 0
Matrice_Translation\_33 = 1
Matrice_Translation\_34 = 0
Matrice_Translation\_41 = *Translation\x
Matrice_Translation\_42 = *Translation\y
Matrice_Translation\_43 = *Translation\z
Matrice_Translation\_44 = 1
EndProcedure
; Multiplication de la matrice finale et de la matrice de rotation
Procedure MultiplyMAT()
Matrice_Finale\_11 = Matrice_Translation\_11 * Matrice_Rotation\_11 + Matrice_Translation\_12 * Matrice_Rotation\_21 + Matrice_Translation\_13 * Matrice_Rotation\_31 + Matrice_Translation\_14 * Matrice_Rotation\_41
Matrice_Finale\_12 = Matrice_Translation\_11 * Matrice_Rotation\_12 + Matrice_Translation\_12 * Matrice_Rotation\_22 + Matrice_Translation\_13 * Matrice_Rotation\_32 + Matrice_Translation\_14 * Matrice_Rotation\_42
Matrice_Finale\_13 = Matrice_Translation\_11 * Matrice_Rotation\_13 + Matrice_Translation\_12 * Matrice_Rotation\_23 + Matrice_Translation\_13 * Matrice_Rotation\_33 + Matrice_Translation\_14 * Matrice_Rotation\_43
Matrice_Finale\_14 = Matrice_Translation\_11 * Matrice_Rotation\_14 + Matrice_Translation\_12 * Matrice_Rotation\_24 + Matrice_Translation\_13 * Matrice_Rotation\_34 + Matrice_Translation\_14 * Matrice_Rotation\_44
Matrice_Finale\_21 = Matrice_Translation\_21 * Matrice_Rotation\_11 + Matrice_Translation\_22 * Matrice_Rotation\_21 + Matrice_Translation\_23 * Matrice_Rotation\_31 + Matrice_Translation\_24 * Matrice_Rotation\_41
Matrice_Finale\_22 = Matrice_Translation\_21 * Matrice_Rotation\_12 + Matrice_Translation\_22 * Matrice_Rotation\_22 + Matrice_Translation\_23 * Matrice_Rotation\_32 + Matrice_Translation\_24 * Matrice_Rotation\_42
Matrice_Finale\_23 = Matrice_Translation\_21 * Matrice_Rotation\_13 + Matrice_Translation\_22 * Matrice_Rotation\_23 + Matrice_Translation\_23 * Matrice_Rotation\_33 + Matrice_Translation\_24 * Matrice_Rotation\_43
Matrice_Finale\_24 = Matrice_Translation\_21 * Matrice_Rotation\_14 + Matrice_Translation\_22 * Matrice_Rotation\_24 + Matrice_Translation\_23 * Matrice_Rotation\_34 + Matrice_Translation\_24 * Matrice_Rotation\_44
Matrice_Finale\_31 = Matrice_Translation\_31 * Matrice_Rotation\_11 + Matrice_Translation\_32 * Matrice_Rotation\_21 + Matrice_Translation\_33 * Matrice_Rotation\_31 + Matrice_Translation\_34 * Matrice_Rotation\_41
Matrice_Finale\_32 = Matrice_Translation\_31 * Matrice_Rotation\_12 + Matrice_Translation\_32 * Matrice_Rotation\_22 + Matrice_Translation\_33 * Matrice_Rotation\_32 + Matrice_Translation\_34 * Matrice_Rotation\_42
Matrice_Finale\_33 = Matrice_Translation\_31 * Matrice_Rotation\_13 + Matrice_Translation\_32 * Matrice_Rotation\_23 + Matrice_Translation\_33 * Matrice_Rotation\_33 + Matrice_Translation\_34 * Matrice_Rotation\_43
Matrice_Finale\_34 = Matrice_Translation\_31 * Matrice_Rotation\_14 + Matrice_Translation\_32 * Matrice_Rotation\_24 + Matrice_Translation\_33 * Matrice_Rotation\_34 + Matrice_Translation\_34 * Matrice_Rotation\_44
Matrice_Finale\_41 = Matrice_Translation\_41 * Matrice_Rotation\_11 + Matrice_Translation\_42 * Matrice_Rotation\_21 + Matrice_Translation\_43 * Matrice_Rotation\_31 + Matrice_Translation\_44 * Matrice_Rotation\_41
Matrice_Finale\_42 = Matrice_Translation\_41 * Matrice_Rotation\_12 + Matrice_Translation\_42 * Matrice_Rotation\_22 + Matrice_Translation\_43 * Matrice_Rotation\_32 + Matrice_Translation\_44 * Matrice_Rotation\_42
Matrice_Finale\_43 = Matrice_Translation\_41 * Matrice_Rotation\_13 + Matrice_Translation\_42 * Matrice_Rotation\_23 + Matrice_Translation\_43 * Matrice_Rotation\_33 + Matrice_Translation\_44 * Matrice_Rotation\_43
Matrice_Finale\_44 = Matrice_Translation\_41 * Matrice_Rotation\_14 + Matrice_Translation\_42 * Matrice_Rotation\_24 + Matrice_Translation\_43 * Matrice_Rotation\_34 + Matrice_Translation\_44 * Matrice_Rotation\_44
Matrice_Translation\_11 = Matrice_Finale\_11
Matrice_Translation\_11 = Matrice_Finale\_12
Matrice_Translation\_11 = Matrice_Finale\_13
Matrice_Translation\_11 = Matrice_Finale\_14
Matrice_Translation\_21 = Matrice_Finale\_21
Matrice_Translation\_21 = Matrice_Finale\_22
Matrice_Translation\_21 = Matrice_Finale\_23
Matrice_Translation\_21 = Matrice_Finale\_24
Matrice_Translation\_31 = Matrice_Finale\_31
Matrice_Translation\_31 = Matrice_Finale\_32
Matrice_Translation\_31 = Matrice_Finale\_33
Matrice_Translation\_31 = Matrice_Finale\_34
Matrice_Translation\_41 = Matrice_Finale\_41
Matrice_Translation\_41 = Matrice_Finale\_42
Matrice_Translation\_41 = Matrice_Finale\_43
Matrice_Translation\_41 = Matrice_Finale\_44
; Mise à jour de tout les points 3D
For z = 0 To 360
Map3D(z)\x = Matrice_Finale\_11*Sommet(z)\x + Matrice_Finale\_21*Sommet(z)\y + Matrice_Finale\_31*Sommet(z)\z + Matrice_Finale\_41
Map3D(z)\y = Matrice_Finale\_12*Sommet(z)\x + Matrice_Finale\_22*Sommet(z)\y + Matrice_Finale\_32*Sommet(z)\z + Matrice_Finale\_42
Map3D(z)\z = Matrice_Finale\_13*Sommet(z)\x + Matrice_Finale\_23*Sommet(z)\y + Matrice_Finale\_33*Sommet(z)\z + Matrice_Finale\_43
Next z
; Projection3D2D()
EndProcedure
; Proc pour la rotation xyz de la matrice
Procedure Rotation(*Rotation.VECTOR3)
Matrice_Rotation\_11 = Cos(*Rotation\z)*Cos(*Rotation\y)
Matrice_Rotation\_12 = Cos(*Rotation\z)*Sin(*Rotation\y)*Sin(*Rotation\x) - Sin(*Rotation\z)*Cos(*Rotation\x)
Matrice_Rotation\_13 = Cos(*Rotation\z)*Sin(*Rotation\y)*Cos(*Rotation\x) + Sin(*Rotation\z)*Sin(*Rotation\x)
Matrice_Rotation\_14 = 0
Matrice_Rotation\_21 = Sin(*Rotation\z)*Cos(*Rotation\y)
Matrice_Rotation\_22 = Sin(*Rotation\z)*Sin(*Rotation\y)*Sin(*Rotation\x) + Cos(*Rotation\x)*Cos(*Rotation\z)
Matrice_Rotation\_23 = Sin(*Rotation\z)*Sin(*Rotation\y)*Cos(*Rotation\x) - Cos(*Rotation\z)*Sin(*Rotation\x)
Matrice_Rotation\_24 = 0
Matrice_Rotation\_31 =-Sin(*Rotation\y)
Matrice_Rotation\_32 = Sin(*Rotation\x)*Cos(*Rotation\y)
Matrice_Rotation\_33 = Cos(*Rotation\x)*Cos(*Rotation\y)
Matrice_Rotation\_34 = 0
Matrice_Rotation\_41 = 0
Matrice_Rotation\_42 = 0
Matrice_Rotation\_43 = 0
Matrice_Rotation\_44 = 1
EndProcedure
Procedure Free_Camera(*Camera.CAMERA)
*Camera\Pitch = *Camera\Pitch - MouseDeltaY()/1000
*Camera\Yaw = *Camera\Yaw - MouseDeltaX()/1000
*Camera\LookAT\x = *Camera\Position\x + KeyboardPushed(#PB_Key_Up) * Cos((*Camera\Yaw))
*Camera\LookAT\z = *Camera\Position\z + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Yaw))
*Camera\LookAT\y = *Camera\Position\y + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Pitch))
*Camera\Position\x = *Camera\LookAT\x + KeyboardPushed(#PB_Key_Up) * Cos((*Camera\Yaw))
*Camera\Position\z = *Camera\LookAT\z + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Yaw))
*Camera\Position\y = *Camera\LookAT\y + KeyboardPushed(#PB_Key_Up) * Sin((*Camera\Pitch))
*Camera\Rotation\x= *Camera\Pitch+(#PI/180)
*Camera\Rotation\y=-*Camera\Yaw+(270*#PI/180)
*Camera\Rotation\z= *Camera\Roll ; GLIMBAL LOCK :(
EndProcedure
Procedure Projection3D2D()
For p = 0 To #NBPointMax
;FORMULE DE PROJECTION
Map2D(p)\x=(Map3D(p)\x*512)/(Map3D(z)\z+#Zoff)+#Xoff;
Map2D(p)\y=(Map3D(p)\y*512)/(Map3D(z)\z+#Zoff)+#Yoff;
Next
For n=1 To 36
If n=1
sx=Map2D(36)\x
sy=Map2D(36)\y
Else
sx=Map2D(n-1)\x
sy=Map2D(n-1)\y
EndIf
LineXY(sx,sy,Map2D(n)\x,Map2D(n)\y,RGB(0,0,255))
Next n
For n=37 To 73
If n=37
sx=Map2D(73)\x
sy=Map2D(73)\y
Else
sx=Map2D(n-1)\x
sy=Map2D(n-1)\y
EndIf
LineXY(sx,sy,Map2D(n)\x,Map2D(n)\y,RGB(0,0,255))
Next n
For n=74 To 110
If n=74
sx=Map2D(110)\x
sy=Map2D(110)\y
Else
sx=Map2D(n-1)\x
sy=Map2D(n-1)\y
EndIf
LineXY(sx,sy,Map2D(n)\x,Map2D(n)\y,RGB(0,0,255))
Next n
LineXY(Map2D(0)\x,Map2D(0)\y,Map2D(74)\x,Map2D(74)\y,RGB(0,0,255))
LineXY(Map2D(9)\x,Map2D(9)\y,Map2D(83)\x,Map2D(83)\y,RGB(0,0,255))
LineXY(Map2D(18)\x,Map2D(18)\y,Map2D(92)\x,Map2D(92)\y,RGB(0,0,255))
LineXY(Map2D(27)\x,Map2D(27)\y,Map2D(101)\x,Map2D(101)\y,RGB(0,0,255))
For z=200 To #NBPointMax
Circle(Map2D(z)\x,Map2D(z)\y,2,RGB(255,255,255))
Next
EndProcedure
InitMouse()
FPS_TIMER.l
FPS_COUNT.l
FPS_.l
;-BOUCLE PRINCIPALE
Repeat
ClearScreen(0) : ExamineKeyboard() : ExamineMouse()
;======================================
;CALCUL DU FPS
;======================================
If FPS_TIMER<ElapsedMilliseconds()
FPS_TIMER=ElapsedMilliseconds()+1000
FPS_=FPS_COUNT
FPS_COUNT=0
EndIf
If FPS_TIMER>ElapsedMilliseconds()
FPS_COUNT+1
EndIf
;======================================
If KeyboardPushed(#PB_Key_Right)
Camera\Position\y+1
EndIf
If KeyboardPushed(#PB_Key_Left)
Camera\Position\y-1
EndIf
;======================================
Translation(Camera\Position) ; Procedure de translation
Rotation(Camera\Rotation) ; de rotation
Free_Camera(Camera) ; Gestion de la camera
MultiplyMAT() ; Multiplication des matrices de transformations
;======================================
;======================================
StartDrawing(ScreenOutput())
DrawText(0,0,"MATRICE3D SOFTWARE PAR CPL.BATOR. FPS = "+Str(FPS_))
Projection3D2D() ; Projection à l'écran
StopDrawing()
;======================================
FlipBuffers(0)
Until KeyboardPushed(#PB_Key_Escape)
je n'ai pas le temps de me plonger dans du code pour le moment mais voici la marche à suivre (je parle en 3D generale ) :
Chaque objet possède ses propres matrices :
Via les calculs matriciels tu obtients la liste des points 3D dans l'espace
Ensuite tout les sommets que tu as "transformé" en points 3D , tu les balance à ta camera qui elle meme va subir les meme calculs que ton objet à une exeption près : l'ordre des multiplications des matrices
Pour un objet :
je vais essayer de faire un exemple simple

Chaque objet possède ses propres matrices :
Ensuite avec les sommets de ton mesh tu détermine la position des vertices 3D dans l'espace et via une formule de projection tu obtients les vertices 2D, Pour résumé, les sommets ne change jamais ils définisent (les sommets) la forme de ton objet 3DStructure MESH3D
Position.VECTOR3 ; Position in 3D space
Rotation.Quaternions ; use quaternion for rotations (x,y,z,w)
*Sommets_List.l
*Points3D_List.l
*Points2D_List.l
Mat_Translate.MATRIX4x4
Mat_Rotation.MATRIX4x4
Mat_Projection.MATRIX4x4
EndStructure
Via les calculs matriciels tu obtients la liste des points 3D dans l'espace
Ensuite tout les sommets que tu as "transformé" en points 3D , tu les balance à ta camera qui elle meme va subir les meme calculs que ton objet à une exeption près : l'ordre des multiplications des matrices
Pour un objet :
Pour une camera :\Mat_Translate X \Mat_Rotation = \Mat_Projection
ou c'est l'inverse (de tete c'est pas facile)\Mat_Rotation X \Mat_Translate = \Mat_Projection
je vais essayer de faire un exemple simple
