Icosaèdre étoilé tournant
Publié : sam. 16/oct./2004 20:13
Une simple animation d'un model 3D. Un icosaèdre étoilé qui tourne sur lui-même.
Les datas proviennent d'un fichier directX directement. Copier/coller puis ajusté en data avec la fonction rechercher/remplacer.
A+
Guimauve
Les datas proviennent d'un fichier directX directement. Copier/coller puis ajusté en data avec la fonction rechercher/remplacer.
A+
Guimauve
Code : Tout sélectionner
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Amination 3D simple Icosaèdre étoilé (60 triangles) -- Source principal
; Version 1.0
; Programmation = OK
; Programmé par : Guimauve
; Date : 16 septembre 2004
; Codé avec PureBasic V3.92 Beta
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Enumeration
#Vertical
#Horizontal
#Icosahedron
#Icosahedron_tex
EndEnumeration
; Largeur et hauteur de la résolution windows
ScreenW = GetSystemMetrics_(#SM_CXSCREEN)
ScreenH = GetSystemMetrics_(#SM_CYSCREEN)
; Couleur 32 bits
ScreenD = 32
Declare DrawGradienttex(Color1.l, Color2.l, NbColor.l, largeur.l, hauteur.l, OutputID.l, Orientation.b)
InitEngine3D()
InitSprite()
InitKeyboard()
OpenScreen(ScreenW, ScreenH, ScreenD, "Icosaèdre étoilé")
CreateMesh(#Icosahedron)
SetMeshData(#Icosahedron, 0, ?Vertices, 180)
SetMeshData(#Icosahedron, 1, ?FacesIndexes, 60)
SetMeshData(#Icosahedron, 2, ?TextureCoordinates, 180)
CreateEntity(#Icosahedron, MeshID(#Icosahedron), CreateMaterial(#Icosahedron_tex, CreateTexture(0, 256, 256)))
; Dessin de la texture
DrawGradienttex(RGB(0, 255, 0), RGB(100, 000, 155), 255, 256, 256, TextureOutput(0), #Vertical)
CreateCamera(0, 0, 0, 100, 100)
CameraLocate(0, 0, 0, 20)
Repeat
ClearScreen(0, 0, 0)
RotateEntity(#Icosahedron, 1, 1, 1)
RenderWorld()
StartDrawing(ScreenOutput())
DrawingMode(1)
FrontColor(0, 255, 0)
DrawText("Presser ESCAPE pour sortir.")
StopDrawing()
FlipBuffers()
ExamineKeyboard()
Until KeyboardPushed(#PB_Key_Escape)
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Procedure DrawGradienttex(Color1.l, Color2.l, NbColor.l, largeur.l, hauteur.l, OutputID.l, Orientation.b)
rt = Red(Color1)
rd = Red(Color2) - rt
gt = Green(Color1)
gd = Green(Color2) - gt
bt = Blue(Color1)
bd = Blue(Color2) - bt
StartDrawing(OutputID)
If Orientation = #Vertical
While i < NbColor
r = MulDiv_(i, rd, NbColor) + rt
g = MulDiv_(i, gd, NbColor) + gt
b = MulDiv_(i, bd, NbColor) + bt
y = MulDiv_(i, hauteur, Nbcolor)
h = MulDiv_(i + 2, hauteur, NbColor)
Box( 0, y, largeur, h, RGB(r, g, b))
i + 1
Wend
ElseIf Orientation = #Horizontal
While i < NbColor
r = MulDiv_(i, rd, NbColor) + rt
g = MulDiv_(i, gd, NbColor) + gt
b = MulDiv_(i, bd, NbColor) + bt
x = MulDiv_(i, largeur, Nbcolor)
l = MulDiv_(i + 2, largeur, NbColor)
Box(x, 0, l, hauteur, RGB(r, g, b))
i + 1
Wend
EndIf
StopDrawing()
EndProcedure
; >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
DataSection
Vertices :
Data.f - 4.014306, 5.254795, 0.000000
Data.f 0.000000, 4.000000, 0.000000
Data.f - 2.894427, 1.788854, 2.102924
Data.f - 4.014306, 5.254795, 0.000000
Data.f - 2.894427, 1.788854, -2.102924
Data.f 0.000000, 4.000000, 0.000000
Data.f - 4.014306, 5.254795, -0.000000
Data.f - 2.894427, 1.788854, 2.102924
Data.f - 2.894427, 1.788854, -2.102924
Data.f - 1.240489, 5.254795, 3.817832
Data.f 0.000000, 4.000000, 0.000000
Data.f 1.105573, 1.788854, 3.402603
Data.f - 1.240489, 5.254795, 3.817832
Data.f - 2.894427, 1.788854, 2.102924
Data.f 0.000000, 4.000000, 0.000000
Data.f - 1.240489, 5.254795, 3.817832
Data.f 1.105573, 1.788854, 3.402603
Data.f - 2.894427, 1.788854, 2.102924
Data.f 3.247642, 5.254795, 2.359550
Data.f 0.000000, 4.000000, 0.000000
Data.f 3.577708, 1.788854, 0.000000
Data.f 3.247642, 5.254795, 2.359550
Data.f 1.105573, 1.788854, 3.402603
Data.f 0.000000, 4.000000, 0.000000
Data.f 3.247642, 5.254795, 2.359550
Data.f 3.577708, 1.788854, 0.000000
Data.f 1.105573, 1.788854, 3.402603
Data.f 3.247642, 5.254795, -2.359550
Data.f 0.000000, 4.000000, 0.000000
Data.f 1.105573, 1.788854, -3.402603
Data.f 3.247642, 5.254795, -2.359550
Data.f 3.577708, 1.788854, 0.000000
Data.f 0.000000, 4.000000, 0.000000
Data.f 3.247642, 5.254795, -2.359550
Data.f 1.105573, 1.788854, -3.402603
Data.f 3.577708, 1.788854, 0.000000
Data.f - 1.240489, 5.254795, -3.817832
Data.f 0.000000, 4.000000, 0.000000
Data.f - 2.894427, 1.788854, -2.102924
Data.f - 1.240489, 5.254795, -3.817832
Data.f 1.105573, 1.788854, -3.402603
Data.f 0.000000, 4.000000, 0.000000
Data.f - 1.240489, 5.254795, -3.817832
Data.f - 2.894427, 1.788854, -2.102924
Data.f 1.105573, 1.788854, -3.402603
Data.f - 6.495283, 1.240489, 0.000000
Data.f - 3.577709, -1.788854, 0.000000
Data.f - 2.894427, 1.788854, -2.102924
Data.f - 6.495283, 1.240489, 0.000000
Data.f - 2.894427, 1.788854, 2.102924
Data.f - 3.577709, -1.788854, 0.000000
Data.f - 6.495283, 1.240489, 0.000000
Data.f - 2.894427, 1.788854, -2.102924
Data.f - 2.894427, 1.788854, 2.102924
Data.f - 2.007153, 1.240489, 6.177382
Data.f - 1.105573, -1.788854, 3.402603
Data.f - 2.894427, 1.788854, 2.102924
Data.f - 2.007153, 1.240489, 6.177382
Data.f 1.105573, 1.788854, 3.402603
Data.f - 1.105573, -1.788854, 3.402603
Data.f - 2.007153, 1.240489, 6.177382
Data.f - 2.894427, 1.788854, 2.102924
Data.f 1.105573, 1.788854, 3.402603
Data.f 5.254795, 1.240489, 3.817831
Data.f 2.894427, -1.788854, 2.102924
Data.f 1.105573, 1.788854, 3.402603
Data.f 5.254795, 1.240489, 3.817832
Data.f 3.577708, 1.788854, -0.000000
Data.f 2.894427, -1.788854, 2.102924
Data.f 5.254795, 1.240489, 3.817831
Data.f 1.105573, 1.788854, 3.402603
Data.f 3.577708, 1.788854, -0.000000
Data.f 5.254794, 1.240489, -3.817832
Data.f 2.894427, -1.788854, -2.102925
Data.f 3.577708, 1.788854, -0.000000
Data.f 5.254794, 1.240489, -3.817832
Data.f 1.105572, 1.788854, -3.402603
Data.f 2.894427, -1.788854, -2.102925
Data.f 5.254794, 1.240489, -3.817832
Data.f 3.577708, 1.788854, -0.000000
Data.f 1.105572, 1.788854, -3.402603
Data.f - 2.007153, 1.240489, -6.177382
Data.f - 1.105573, -1.788854, -3.402603
Data.f 1.105572, 1.788854, -3.402603
Data.f - 2.007153, 1.240489, -6.177382
Data.f - 2.894427, 1.788854, -2.102924
Data.f - 1.105573, -1.788854, -3.402603
Data.f - 2.007153, 1.240489, -6.177382
Data.f 1.105572, 1.788854, -3.402603
Data.f - 2.894427, 1.788854, -2.102924
Data.f 2.007153, -1.240489, -6.177382
Data.f 1.105573, 1.788854, -3.402603
Data.f - 1.105572, -1.788854, -3.402603
Data.f 2.007153, -1.240489, -6.177382
Data.f 2.894427, -1.788854, -2.102924
Data.f 1.105573, 1.788854, -3.402603
Data.f 2.007153, -1.240489, -6.177382
Data.f - 1.105572, -1.788854, -3.402603
Data.f 2.894427, -1.788854, -2.102924
Data.f - 5.254794, -1.240489, -3.817832
Data.f - 2.894427, 1.788854, -2.102925
Data.f - 3.577708, -1.788854, -0.000000
Data.f - 5.254794, -1.240489, -3.817832
Data.f - 1.105572, -1.788854, -3.402603
Data.f - 2.894427, 1.788854, -2.102925
Data.f - 5.254794, -1.240489, -3.817832
Data.f - 3.577708, -1.788854, -0.000000
Data.f - 1.105572, -1.788854, -3.402603
Data.f - 5.254795, -1.240489, 3.817831
Data.f - 2.894427, 1.788854, 2.102924
Data.f - 1.105573, -1.788854, 3.402603
Data.f - 5.254795, -1.240489, 3.817832
Data.f - 3.577708, -1.788854, -0.000000
Data.f - 2.894427, 1.788854, 2.102924
Data.f - 5.254795, -1.240489, 3.817831
Data.f - 1.105573, -1.788854, 3.402603
Data.f - 3.577708, -1.788854, -0.000000
Data.f 2.007153, -1.240489, 6.177382
Data.f 1.105573, 1.788854, 3.402603
Data.f 2.894427, -1.788854, 2.102924
Data.f 2.007153, -1.240489, 6.177382
Data.f - 1.105573, -1.788854, 3.402603
Data.f 1.105573, 1.788854, 3.402603
Data.f 2.007153, -1.240489, 6.177382
Data.f 2.894427, -1.788854, 2.102924
Data.f - 1.105573, -1.788854, 3.402603
Data.f 6.495283, -1.240489, 0.000000
Data.f 3.577709, 1.788854, 0.000000
Data.f 2.894427, -1.788854, -2.102924
Data.f 6.495283, -1.240489, 0.000000
Data.f 2.894427, -1.788854, 2.102924
Data.f 3.577709, 1.788854, 0.000000
Data.f 6.495283, -1.240489, 0.000000
Data.f 2.894427, -1.788854, -2.102924
Data.f 2.894427, -1.788854, 2.102924
Data.f 1.240489, -5.254795, -3.817832
Data.f - 0.000000, -4.000000, 0.000000
Data.f 2.894427, -1.788854, -2.102924
Data.f 1.240489, -5.254795, -3.817832
Data.f - 1.105573, -1.788854, -3.402603
Data.f - 0.000000, -4.000000, 0.000000
Data.f 1.240489, -5.254795, -3.817832
Data.f 2.894427, -1.788854, -2.102924
Data.f - 1.105573, -1.788854, -3.402603
Data.f - 3.247642, -5.254795, -2.359550
Data.f - 0.000000, -4.000000, 0.000000
Data.f - 1.105573, -1.788854, -3.402603
Data.f - 3.247642, -5.254795, -2.359550
Data.f - 3.577708, -1.788854, 0.000000
Data.f - 0.000000, -4.000000, 0.000000
Data.f - 3.247642, -5.254795, -2.359550
Data.f - 1.105573, -1.788854, -3.402603
Data.f - 3.577708, -1.788854, 0.000000
Data.f - 3.247642, -5.254795, 2.359550
Data.f - 0.000000, -4.000000, 0.000000
Data.f - 3.577708, -1.788854, 0.000000
Data.f - 3.247642, -5.254795, 2.359550
Data.f - 1.105573, -1.788854, 3.402603
Data.f - 0.000000, -4.000000, 0.000000
Data.f - 3.247642, -5.254795, 2.359550
Data.f - 3.577708, -1.788854, 0.000000
Data.f - 1.105573, -1.788854, 3.402603
Data.f 1.240489, -5.254795, 3.817832
Data.f - 0.000000, -4.000000, 0.000000
Data.f - 1.105573, -1.788854, 3.402603
Data.f 1.240489, -5.254795, 3.817832
Data.f 2.894427, -1.788854, 2.102924
Data.f - 0.000000, -4.000000, 0.000000
Data.f 1.240489, -5.254795, 3.817832
Data.f - 1.105573, -1.788854, 3.402603
Data.f 2.894427, -1.788854, 2.102924
Data.f 4.014306, -5.254795, 0.000000
Data.f - 0.000000, -4.000000, 0.000000
Data.f 2.894427, -1.788854, 2.102924
Data.f 4.014306, -5.254795, 0.000000
Data.f 2.894427, -1.788854, -2.102924
Data.f - 0.000000, -4.000000, 0.000000
Data.f 4.014306, -5.254795, -0.000000
Data.f 2.894427, -1.788854, 2.102924
Data.f 2.894427, -1.788854, -2.102924
FacesIndexes :
Data.w 2, 1, 0
Data.w 5, 4, 3
Data.w 8, 7, 6
Data.w 11, 10, 9
Data.w 14, 13, 12
Data.w 17, 16, 15
Data.w 20, 19, 18
Data.w 23, 22, 21
Data.w 26, 25, 24
Data.w 29, 28, 27
Data.w 32, 31, 30
Data.w 35, 34, 33
Data.w 38, 37, 36
Data.w 41, 40, 39
Data.w 44, 43, 42
Data.w 47, 46, 45
Data.w 50, 49, 48
Data.w 53, 52, 51
Data.w 56, 55, 54
Data.w 59, 58, 57
Data.w 62, 61, 60
Data.w 65, 64, 63
Data.w 68, 67, 66
Data.w 71, 70, 69
Data.w 74, 73, 72
Data.w 77, 76, 75
Data.w 80, 79, 78
Data.w 83, 82, 81
Data.w 86, 85, 84
Data.w 89, 88, 87
Data.w 92, 91, 90
Data.w 95, 94, 93
Data.w 98, 97, 96
Data.w 101, 100, 99
Data.w 104, 103, 102
Data.w 107, 106, 105
Data.w 110, 109, 108
Data.w 113, 112, 111
Data.w 116, 115, 114
Data.w 119, 118, 117
Data.w 122, 121, 120
Data.w 125, 124, 123
Data.w 128, 127, 126
Data.w 131, 130, 129
Data.w 134, 133, 132
Data.w 137, 136, 135
Data.w 140, 139, 138
Data.w 143, 142, 141
Data.w 146, 145, 144
Data.w 149, 148, 147
Data.w 152, 151, 150
Data.w 155, 154, 153
Data.w 158, 157, 156
Data.w 161, 160, 159
Data.w 164, 163, 162
Data.w 167, 166, 165
Data.w 170, 169, 168
Data.w 173, 172, 171
Data.w 176, 175, 174
Data.w 179, 178, 177
TextureCoordinates :
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
Data.f 0.500000, 0.000000
Data.f 0.000000, 1.000000
Data.f 1.000000, 1.000000
EndDataSection