website logo
Auteur
avatar
artblink

Forum » » Création-Développement » » J'ai réussi mon tit moteur 3D


Posté : 28-11-2010 09:42 icone du post

Merci Creols... Ptdr, normal c'est la touche z... je me suis planté sur l'écran... qu'elle nazebruk, fichier modifié, merci de l'info

Au fait, voici le code

Amusez vous bien les gens à le modifier. Attention, le code c'est le bordel, n'oublier pas que je ne suis qu'un bidouilleur



@SCREEN?{Mode?=?"ask",?Width?=?640,?Height?=?400}
FC=200
CZ=200
Function?Controle()
????If?IsKeyDown("Left")=True?Then?Gauche()?;?Vers?la?gauche
????If?IsKeyDown("Right")=True?Then?Droite()?;?Vers?la?droite
????If?IsKeyDown("Up")=True?Then?Haut()?;?Vers?le?Haut
????If?IsKeyDown("Down")=True?Then?Bas()?;?Vers?le?bas
????If?IsKeyDown("a")=True?Then?Zoomin()?;?Zoom?in
????If?IsKeyDown("z")=True?Then?Zoomout()?;?Zoom?Out
????If?IsKeyDown("p")=True?Then?SetFillStyle(#FILLCOLOR)?;?Zoom?Out
????If?IsKeyDown("o")=True?Then?SetFillStyle(#FILLNONE)???
????If?IsKeyDown("i")=True?Then?SetFillStyle(#FILLGRADIENT,?#LINEAR,?$888888, ?$FFFFFF)
????If?IsKeyDown("u")=?True?Then?SetFormStyle(#ANTIALIAS)?
????If?IsKeyDown("y")=?True?Then?SetFormStyle(#NORMAL)?
EndFunction

Function?Gauche()
????AY=AY+1
????If?AY>359?Then?AY=0
EndFunction

Function?Droite()
????AY=AY-1
????If?AY<0?Then?AY=359
EndFunction

Function?Haut()
????AX=AX+1
????If?AX>359?Then?AX=0
EndFunction
????
Function?Bas()
????AX=AX-1
????If?AX<0?Then?AX=359
EndFunction

Function?Zoomin()
????CZ=CZ+10
????If?CZ>600?Then?CZ=600
EndFunction

Function?Zoomout()
????CZ=CZ-10
????If?CZ<150?Then?CZ=150
EndFunction

Function?PRG()
????
????Controle()?;?Exécution?de?la?fonction?Controle
????;?Réservation?mémoire?et?création?des?tableaux
????Dim?CO[360]?;?360?cases?réservé?car?une?rotation?c'est?360? ?pour?le?Cosinus
????Dim?SI[360]?;?360?cases?réservé?car?une?rotation?c'est?360? ?pour?le?Sinus
????Dim?X[8]?;?Un?cube,?c'est?8?points?en?X
????Dim?Y[8]?;?Un?cube,?c'est?8?points?en?Y
????Dim?Z[8]?;?Un?cube,?c'est?8?points?en?Z
????Dim?XE[8]?;?Point?final?du?cube?a?dessiner?en?X
????Dim?YE[8]?;?Point?final?du?cube?a?dessiner?en?Y
????Dim?ZZ[8]?;?Point?final?du?cube?a?dessiner?en?Z
????Dim?P1[10]?;?Polygone?1
????Dim?P2[10]?;?Polygone?2
????Dim?P3[10]?;?Polygone?3
????Dim?P4[10]?;?Polygone?4
????Dim?P5[10]?;?Polygone?5
????Dim?P6[10]?;?Polygone?6
????
Flip?;?Flip?d'écran?pour?le?double?buffer
Cls?;?Effacement?de?l'écran?sinon?on?verrait?des?cube?partout?lol

For?I=0?To?359
????CO[I]=Cos(I*0.1)*360?;?Mise?en?mémoire?de?360?calcule?du?Cosinus?d es?angles?sur?360?
????SI[I]=Sin(I*0.1)*360?;?Mise?en?mémoire?de?360?calcule?du?Sinus?des ?angles?sur?360?
Next?

????For?I=0?To?7
????????X?=?{-50,50,50,-50,-50,50,50,-50}?;?Coordonnées?des?points?dan s?l'espace?en?X
????????Y?=?{-50,-50,50,50,-50,-50,50,50}?;?Coordonnées?des?points?dan s?l'espace?en?Y
????????Z?=?{-50,-50,-50,-50,50,50,50,50}?;?Coordonnées?des?points?dan s?l'espace?en?Z
????????
????????;P={0,1,2,3,1,5,6,2,4,5,1,0,4,5,6,7,4,0,3,7,3,2,6,7}
????????;Calcule?3D?grâce?au?magazine?Dream?N?27?de?Mars?1996
????????Y1=(Y[I]*CO[AX]+Z[I]*SI[AX])/360
????????Z1=(-Y[I]*SI[AX]+Z[I]*CO[AX])/360
????????X1=(X[I]*CO[AY]+Z1*SI[AY])/360
????????ZZ[I]=(-X[I]*SI[AY]+Z1*CO[AY])/360
????????X=(X1*CO[AZ]+Y1*SI[AZ])/360
????????Y=(-X1*SI[AZ]+Y1*CO[AZ])/360
????????D=FC/(Sqrt(X^2+Y^2+(CZ+ZZ[I])^2))
????????XE[I]=320+X*D
????????YE[I]=200+Y*D
????
????Next
?????;?Calcule?final
????????P1?=?{XE[0],YE[0],XE[1],YE[1],XE[2],YE[2],XE[3],YE[3],XE[0],YE[0]}?;? Polygon?1
????????P2?=?{XE[1],YE[1],XE[5],YE[5],XE[6],YE[6],XE[2],YE[2],XE[1],YE[1]}?;? Polygon?2
????????P3?=?{XE[4],YE[4],XE[5],YE[5],XE[1],YE[1],XE[0],YE[0],XE[4],YE[4]}?;? Polygon?3?
????????P4?=?{XE[4],YE[4],XE[5],YE[5],XE[6],YE[6],XE[7],YE[7],XE[4],YE[4]}?;? Polygon?4
????????P5?=?{XE[4],YE[4],XE[0],YE[0],XE[3],YE[3],XE[7],YE[7],XE[4],YE[4]}?;? Polygon?5
????????P6?=?{XE[3],YE[3],XE[2],YE[2],XE[6],YE[6],XE[7],YE[7],XE[3],YE[3]}?;? Polygon?6

????????Box?(0,0,640,200,$3333EE)
????????Locate?(0,0)
????????Print?("Flèche?=>?Rotation?cube")
????????Locate?(0,12)
????????Print?("Touche?a?=>?Zoom?OUT")
????????Locate?(0,24)
????????Print?("Touche?z?=>?Zoom?IN")
????????Locate?(0,36)
????????Print?("Touche?p?=>?coloration?de?Garnier")
????????Locate?(0,48)
????????Print?("Touche?o?=>?annuler?la?coloration")
????????Locate?(0,60)
????????Print?("Touche?i?=>?Un?monde?d'acier?")
????????Locate?(0,72)
????????Print?("Touche?u?=>?Antialiasing")
????????Locate?(0,84)
????????Print?("Touche?y?=>?enlever?l'Antialiasing")
????????Locate?(0,96)
????????Print?("Ctrl+c?=>?Quitter")

????????;?Traçage?des?polygones?avec?tests
????????;?les?tests?se?font?sur?la?coordonnées?en?Z
????????;?en?gros?si?le?polygone?passe?derrière?les?autres?alors?il?s' affiche?pas
????????;?je?crois?que?normalement?sa?fais?gagner?du?temp?CPU...?Non?
????????If?ZZ[1]+ZZ[5]+ZZ[6]+ZZ[2]<-40?Then?Polygon?(0,0,P2,5,#BLUE)?
????????If?ZZ[4]+ZZ[5]+ZZ[1]+ZZ[0]<-40?Then?Polygon?(0,0,P3,5,#RED)?
????????If?ZZ[0]+ZZ[1]+ZZ[2]+ZZ[3]>40?Then?Polygon?(0,0,P4,5,#YELLOW)?
????????If?ZZ[1]+ZZ[5]+ZZ[6]+ZZ[2]>40?Then?Polygon?(0,0,P5,5,#WHITE)?
????????If?ZZ[4]+ZZ[5]+ZZ[1]+ZZ[0]>40?Then?Polygon?(0,0,P6,5,#GREEN)
????????If?ZZ[0]+ZZ[1]+ZZ[2]+ZZ[3]<-40?Then?Polygon?(0,0,P1,5,#PURPLE)?
EndFunction

BeginDoubleBuffer

SetInterval(1,PRG,1000/50)

Repeat
WaitEvent
Forever



Allez-y, modifié les formules 3D car elle déconne un peu

Edit: Pourquoi il me mets des & nbsp dans le code... enlever les sinon sa marchera pas

Respect

Message édité par : artblink / 28-11-2010 09:53

Cet article provient de Le site des utilisateurs francophones actuels et futurs d'AmigaOS 4.x
https://amiga-ng.org/viewtopic.php?topic=925&forum=14