Voici le source d'un économiseur d'écran complet, avec écran de configuration, preview dans la petite fenêtre, et tout et tout.
Ce code est une compilation de pleins d'informations et snippets trouvés sur ce forum et d'autres. Son but est justement de collationner toutes ces infos pour en faire quelque chose de clair, compréhensible, et facilement modifiable afin que tout un chacun puisse créer son propre screensaver.
Marche à suivre pour faire fonctionner le code:
-------------------------------------------------------
1) Vous aurez besoin des deux fichiers suivants:
- une skybox: http://keleb.free.fr/absdancesky.zip
- une image de titre : http://keleb.free.fr/title.bmp
2) Compilez le code (en désactivant le debugger, c'est mieux) sous le nom "absdance.scr".
3) Placez ce .scr dans votre répertoire Windows ou Windows\system32, ainsi que la skybox (ne la dézippez pas)
4) Placez dans ce même répertoire les DLL "engine3D.dll" et "stlport_vc646.dll" que vous trouverez dans le répertoire "compiler" de PureBasic. (Nécessaire parce que c'est de la 3D)
5) Allez dans les propriétés de l'affichage de Windows, onglet "Ecran de veille"; vous devriez trouver "absdance" dans la liste. Sélectionnez-le.
6) C'est tout! Si je n'ai rien oublié, ça devrait marcher.

Code : Tout sélectionner
; A complete screensaver
; Purpose: With a little time, it's quite easy to find a lot of infos on how to make a screensaver.
; But it may be a little more difficult to merge all these informations and snippets to
; make something that actually works. :)
; In this source, I've tried to establish a clear separation between the main program (the
; code you want to be launched when your computer is idle) and what makes it a screensaver
; (all the nuts and bolts which lead Windows to recognize it and execute it as a *real*
; screensaver). Also, I've tried to comment exhaustively all important points in the code.
; Now, go for it! Make your own screensaver, diffuse it worldwide! The more PB apps there
; will be out there, the more support Fred and his team will receive from the coders
; community, and the more features we'll get in the next versions of PB... ;)
; Note: As I said, this code is a compilation of many things I've found in PB and C++ forums
; => Kudos And thanks to all of you Kale, Netmaestro, Comtois, cpl_Bator, etc..
; Author: Kelebrindae
; Date: march,25, 2006
; PB version: v4.00
; OS: Windows XP
;- Variables for main code
; These are for mesh construction
Structure Vertex
px.f
py.f
pz.f
nx.f
ny.f
nz.f
Couleur.l
U.f
V.f
EndStructure
Structure FaceTri
f1.w
f2.w
f3.w
EndStructure
Enumeration
#tetrahedron
#cube
#octahedron
#dodecahedron
#icosahedron
EndEnumeration
; These are for rotations/translations without gimbal lock
Structure quaternion
x.f
y.f
z.f
w.f
EndStructure
Structure vector3
x.f
y.f
z.f
EndStructure
Global cQuat.quaternion
Global pResultVector.vector3
; This is for position/angle storage in memory
Structure posAngle
x.f
y.f
z.f
xangle.f
yangle.f
zangle.f
EndStructure
Global nbobjects.l ; This determine the number of objects on screen
Global t.l=1,tmax.l=2000 ; number of loops before switching between forward/backward motion
Global *PtrPosAngle.posAngle,*OldPtrPosAngle.posAngle,*posAngleBuffer.l ; used to store pos and rotations
Global sizeofPosAngle.l = SizeOf(posAngle),oldPtrOffset.l ; used to store pos and rotations
;- Variables for screensaver mechanisms
Enumeration
#ScreenSaverMode
#PreviewMode
EndEnumeration
Structure Config_struct
resolution.s
shape.b
nbobjects.l
showFPS.b
EndStructure
Global Parameter.s
Global previewWndHandleStr.s
Global config.config_struct
Global saverMode.b
Global screensaverName.s = "Abstract Dance"
Global screensaverExe.s = "AbsDance"
;- Gadgets enum for config screen
Enumeration
#Window_0
#Button_OK
#Button_Annuler
#Combo_res
#Label_res
#Combo_shape
#Label_shape
#ShowFpsBox
#TrackBar_detail
#Label_detail
#Image_title
#Text_detail
#Hyperlink_home
#Hyperlink_PB
#Button_info
#Button_licence
#Editor
#Hyperlink_paypal
EndEnumeration
;- Fonts
Global FontID1
FontID1 = LoadFont(1, "MS Sans Serif", 12)
Global FontID2
FontID2 = LoadFont(2, "MS Sans Serif", 10)
Global FontID3
FontID3 = LoadFont(3, "MS Sans Serif", 10, #PB_Font_Underline)
;- Languages
; 0 = français , 1 = english
; Yep, its a pre-compiled setting, meaning you've got a different exe for each language.
; But it's easy to make it dynamic (ie. store the language setting in the INI file
; and read it at startup)
#language=0
Global Dim tradstring.s(2,100)
i.l=0
j.l=-1
Restore languageData
For i=0 To 1
j=-1
Repeat
j+1
Read tradstring(i,j)
Until tradstring(i,j)="#####"
Next i
;************************************************************************************
;- ---- What makes it a screensaver ----
;************************************************************************************
;************************************************************************************
; Name: PreviewCallback
; Purpose: callback for the preview window -> quit program when this window is closed
; Parameters: preview window handle
; Message caught
; wParam, lParam -> additional message information. The content of these
; parameters depends on the value of the Message parameter.
; Return-Value: none
;************************************************************************************
Procedure PreviewCallback(hWnd, Message, wParam, lParam)
; we just trap the "Close window" message
Select Message
Case #WM_CLOSE
FreeMemory(*posAngleBuffer)
End
EndSelect
; Calls the default window procedure to process all other messages
Result = DefWindowProc_(hWnd, Message, wParam, lParam)
ProcedureReturn Result
EndProcedure
;************************************************************************************
; Name: OnlyOneSaverStart
; Purpose: Ensures that only one instance of the program will be launched
; Parameters: Saver name (used to name the mutex)
; Return-Value: none
;************************************************************************************
Procedure OnlyOneSaverStart(saverName.s)
;repris entièrement d'un code de Kale
Shared OnlyOneStartMutex.l
Protected OnlyOneStartError.l
*MutexName = @saverName
OnlyOneStartMutex = CreateMutex_(0, 1, *MutexName)
OnlyOneStartError = GetLastError_()
If OnlyOneStartMutex <> 0 And OnlyOneStartError = 0
ProcedureReturn 1
Else
CloseHandle_(OnlyOneStartMutex)
End
EndIf
EndProcedure
;************************************************************************************
; Name: OnlyOneSaverStart
; Purpose: Free the mutex to allow another instance to be launched
; Parameters: none
; Return-Value: none
;************************************************************************************
Procedure OnlyOneSaverStop()
CloseHandle_(OnlyOneStartMutex)
EndProcedure
;************************************************************************************
; Name: CheckStatus
; Purpose: in Screensaver mode, look for any action from the user
; Parameters: none
; Return-Value: 1 if anything moved since the last loop
;************************************************************************************
Procedure.l CheckStatus()
If saverMode = #ScreenSaverMode
ExamineKeyboard() : ExamineMouse()
If MouseDeltaX() Or MouseDeltaY() Or KeyboardPushed(#PB_Key_All) Or MouseButton(#PB_MouseButton_Left) Or MouseButton(#PB_MouseButton_Right)
ProcedureReturn 1
EndIf
If GetFocus_() <> ScreenID()
ProcedureReturn 1
EndIf
EndIf
ProcedureReturn 0
EndProcedure
;************************************************************************************
; Name: SavePreferences
; Purpose: Write the content of the "Config" structure to an INI file
; Parameters: none
; Return-Value: none
;************************************************************************************
Procedure SavePreferences()
Protected iniFilePath.s
Protected iniFileName.s
; Get path to current program
iniFilePath = Space(255)
GetModuleFileName_(0, @iniFilePath, 255)
iniFilePath = GetPathPart(iniFilePath)
; Add "\" to the end
If Right(iniFilePath, 1) <> "\"
iniFilePath + "\"
EndIf
; Construct INI file name
iniFileName = iniFilePath + screensaverExe + ".ini"
; Write preferences to INI file
If CreatePreferences(iniFileName)
PreferenceGroup("PARAM")
PreferenceComment("Screen resolution")
WritePreferenceString("Resolution", Config\resolution)
PreferenceComment(" ")
PreferenceComment("Objects shape")
WritePreferenceLong("Shape", Config\shape)
PreferenceComment(" ")
PreferenceComment("Number of objects")
WritePreferenceLong("ObjectNumber", Config\nbobjects)
PreferenceComment(" ")
PreferenceComment("Show frame rate")
WritePreferenceLong("showFPS", Config\showFPS)
ClosePreferences()
Else
MessageRequester("Error","Can't save preferences !")
EndIf
EndProcedure
;************************************************************************************
; Name: LoadPreferences
; Purpose: load the content of the INI file and store it into the "Config" structure
; Parameters: none
; Return-Value: none
;************************************************************************************
Procedure LoadPreferences()
Protected iniFilePath.s
Protected iniFileName.s
Protected iniOk.b
; Get path to current program
iniFilePath = Space(255)
GetModuleFileName_(0, @iniFilePath, 255)
iniFilePath = GetPathPart(iniFilePath)
; Add "\" to the end
If Right(iniFilePath, 1) <> "\"
iniFilePath + "\"
EndIf
; Construct INI file name
iniFileName = iniFilePath + screensaverExe + ".ini"
; Read content
If OpenPreferences(iniFileName)
ExaminePreferenceGroups()
NextPreferenceGroup()
Config\resolution = ReadPreferenceString("Resolution", "1024 x 768")
Config\shape = ReadPreferenceLong("Shape", 2)
Config\nbobjects = ReadPreferenceLong("ObjectNumber", 2)
Config\showFPS = ReadPreferenceLong("showFPS", 0)
ClosePreferences()
Else
Config\resolution = "1024 x 768"
Config\shape = 2
Config\nbobjects = 2
EndIf
EndProcedure
;************************************************************************************
; Name: ConfigScreen
; Purpose: This screen is called to set screen resolution, detail level, etc..
; Parameters: none
; Return-Value: none
;************************************************************************************
Procedure ConfigScreen()
Protected infovis.b
Protected licencevis.b
Protected ligneInfo.s
Protected ligneLicence.s
; labels for each detail level
Protected Dim detailcomment.s(4)
detailcomment(0)=tradstring(#language,0)
detailcomment(1)=tradstring(#language,1)
detailcomment(2)=tradstring(#language,2)
detailcomment(3)=tradstring(#language,3)
detailcomment(4)=tradstring(#language,4)
Image0 = CatchImage(0, ?TitleImage)
If OpenWindow(#Window_0, 217, 169, 460, 380, screenSaverName + " - Configuration", #PB_Window_SystemMenu | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
ImageGadget(#Image_title, 20, 10, 420, 130, Image0, #PB_Image_Border)
ComboBoxGadget(#Combo_res, 110, 155, 190, 120)
SetGadgetFont(#Combo_res, FontID2)
TextGadget(#Label_res, 30, 155, 80, 20, tradstring(#language,7))
SetGadgetFont(#Label_res, FontID2)
CheckBoxGadget(#ShowFpsBox, 110, 180, 270, 20, tradstring(#language,8))
GadgetToolTip(#ShowFpsBox, tradstring(#language,9))
SetGadgetFont(#ShowFpsBox, FontID2)
ComboBoxGadget(#Combo_shape, 110, 210, 190, 120)
SetGadgetFont(#Combo_shape, FontID2)
AddGadgetItem( #Combo_shape,0,"Tetrahedron" )
AddGadgetItem( #Combo_shape,1,"Cube" )
AddGadgetItem( #Combo_shape,2,"Octahedron" )
AddGadgetItem( #Combo_shape,3,"Dodecahedron" )
AddGadgetItem( #Combo_shape,4,"Icosahedron" )
TextGadget(#Label_shape, 50, 210, 50, 20, tradstring(#language,22))
SetGadgetFont(#Label_shape, FontID2)
TrackBarGadget(#TrackBar_detail, 90, 250, 230, 20, 0, 4, #PB_TrackBar_Ticks)
GadgetToolTip(#TrackBar_detail, tradstring(#language,10))
TextGadget(#Label_detail, 15, 251, 90, 18, tradstring(#language,11))
SetGadgetFont(#Label_detail, FontID2)
TextGadget(#Text_detail, 90, 270, 240, 20, "")
SetGadgetFont(#Text_detail, FontID2)
; An editor to show additional informations
EditorGadget(#Editor,460,10,530,340)
SetGadgetFont(#Editor, FontID2)
HideGadget(#Editor,1)
ligneInfo = tradstring(#language,16)
ligneLicence = tradstring(#language,17)
; Buttons to show these additional informations
ButtonGadget(#Button_info, 335, 230, 120, 25, tradstring(#language,14))
ButtonGadget(#Button_licence, 335, 256, 120, 25, tradstring(#language,15))
; Hyperlink to your homepage
HyperLinkGadget(#Hyperlink_home, 130, 300, 220, 20, tradstring(#language,12), RGB(0, 127, 255))
SetGadgetFont(#Hyperlink_home, FontID3)
GadgetToolTip(#Hyperlink_home, tradstring(#language,13))
SetGadgetColor(#Hyperlink_home, #PB_Gadget_FrontColor, $CC0000)
; Hyperlink to PB homepage (pay tribute, man!)
HyperLinkGadget(#Hyperlink_PB, 110, 320, 260, 20, tradstring(#language,23), RGB(0, 127, 255))
SetGadgetFont(#Hyperlink_PB, FontID3)
GadgetToolTip(#Hyperlink_PB, tradstring(#language,24))
SetGadgetColor(#Hyperlink_PB, #PB_Gadget_FrontColor, $CC0000)
; Hyperlink to a paypal page (well, maybe someone will love your work very much... ;)
HyperLinkGadget(#Hyperlink_paypal, 655, 350, 200, 20, tradstring(#language,19), RGB(0, 127, 255))
SetGadgetFont(#Hyperlink_paypal, FontID3)
GadgetToolTip(#Hyperlink_paypal, tradstring(#language,20))
SetGadgetColor(#Hyperlink_paypal, #PB_Gadget_FrontColor, $CC0000)
HideGadget(#Hyperlink_paypal,1)
ButtonGadget(#Button_OK, 130, 345, 100, 30, tradstring(#language,5))
ButtonGadget(#Button_Annuler, 240, 345, 100, 30, tradstring(#language,6))
; List all available screen resolutions
If InitSprite() = 0
MessageRequester( "Error" , "Can't find DirectX 7.0 or above" , 0 )
End
EndIf
If ExamineScreenModes()
Structure resmode_struct
width.l
height.l
depth.c
formated.s
EndStructure
Protected NewList resmode.resmode_struct()
While NextScreenMode()>0
; Limit the list to width larger than 600 and 32 bits color depth (short list => easy to browse)
If ScreenModeWidth()>=600 And ScreenModeDepth()=32
; check that the current resolution isn't in the list already
found=0
ForEach resmode()
If resmode()\width=ScreenModeWidth() And resmode()\height=ScreenModeHeight()
found=1
Break
EndIf
Next
; Add it to the list
If found=0
AddElement(resmode())
resmode()\width = ScreenModeWidth()
resmode()\height = ScreenModeHeight()
resmode()\depth = ScreenModeDepth()
; the "formatted" field is used to sort the list
If resmode()\width<1000
resmode()\formated = "0" + Str(resmode()\width)
Else
resmode()\formated =Str(resmode()\width)
EndIf
If resmode()\height<1000
resmode()\formated = resmode()\formated + "0" + Str(resmode()\height)
Else
resmode()\formated = resmode()\formated + Str(resmode()\height)
EndIf
EndIf
EndIf
Wend
SortStructuredList(resmode(), 0, OffsetOf(resmode_struct\formated),#PB_Sort_String)
; Put the list into a combo-box
ForEach resmode()
AddGadgetItem( #Combo_res,-1,Str(resmode()\width)+ " x " +Str(resmode()\height) )
Next
EndIf
; load preferences from INI file and put values into the gadgets
LoadPreferences()
SetGadgetText(#Combo_res, config\resolution)
SetGadgetState(#ShowFpsBox, config\showfps)
SetGadgetState(#Combo_shape, config\shape)
SetGadgetState(#TrackBar_detail, config\nbobjects)
SetGadgetText(#Text_detail, detailcomment(config\nbobjects))
Repeat
EventID.l = WaitWindowEvent()
Select EventID
Case 0
Delay(1)
Case #PB_Event_CloseWindow
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case #Button_annuler
LoadPreferences()
Quit = 1
Case #Button_Ok
SavePreferences()
Quit = 1
Case #Button_info
If infovis=0
If licencevis=1
SetGadgetText(#Button_licence, ReplaceString(GetGadgetText(#Button_licence),"<<",">>") )
HideGadget(#Editor,0)
HideGadget(#Hyperlink_paypal,1)
ResizeWindow(#Window_0,#PB_Ignore,#PB_Ignore,460,#PB_Ignore)
licencevis=0
EndIf
ResizeWindow(#Window_0,#PB_Ignore,#PB_Ignore,1000,#PB_Ignore)
SetGadgetText(#Button_info, ReplaceString(GetGadgetText(#Button_info),">>","<<"))
ClearGadgetItemList(#Editor)
AddGadgetItem(#Editor,1,ligneInfo)
HideGadget(#Editor,0)
infovis=1
Else
HideGadget(#Editor,0)
ResizeWindow(#Window_0,#PB_Ignore,#PB_Ignore,460,#PB_Ignore)
SetGadgetText(#Button_info, ReplaceString(GetGadgetText(#Button_info),"<<",">>"))
infovis=0
EndIf
Case #Button_licence
If licencevis=0
If infovis=1
SetGadgetText(#Button_info, ReplaceString(GetGadgetText(#Button_info),"<<",">>") )
HideGadget(#Editor,0)
ResizeWindow(#Window_0,#PB_Ignore,#PB_Ignore,460,#PB_Ignore)
infovis=0
EndIf
ResizeWindow(#Window_0,#PB_Ignore,#PB_Ignore,1000,#PB_Ignore)
SetGadgetText(#Button_Licence, ReplaceString(GetGadgetText(#Button_licence),">>","<<"))
ClearGadgetItemList(#Editor)
AddGadgetItem(#Editor,1,ligneLicence)
HideGadget(#Editor,0)
HideGadget(#Hyperlink_paypal,0)
licencevis=1
Else
HideGadget(#Editor,0)
ResizeWindow(#Window_0,#PB_Ignore,#PB_Ignore,460,#PB_Ignore)
SetGadgetText(#Button_licence, ReplaceString(GetGadgetText(#Button_licence),"<<",">>"))
licencevis=0
EndIf
Case #ShowFpsBox
config\showfps = GetGadgetState(#ShowFpsBox)
Case #Combo_res
config\resolution = GetGadgetItemText(#Combo_res,GetGadgetState(#Combo_res),0)
Case #Combo_shape
config\shape = GetGadgetState(#Combo_shape)
Case #TrackBar_detail
config\nbobjects = GetGadgetState(#TrackBar_detail)
SetGadgetText(#Text_detail, detailcomment(config\nbobjects))
Case #Hyperlink_home
RunProgram(tradstring(#language,18), "", "")
Case #Hyperlink_PB
RunProgram(tradstring(#language,25), "", "")
Case #Hyperlink_paypal
RunProgram(tradstring(#language,21), "", "")
EndSelect
EndSelect
Until Quit
EndIf ; if creategadgetlist...
EndIf ; if openwindow...
End
EndProcedure
;-Datas used by configuration screen
DataSection
TitleImage:
IncludeBinary "title.bmp"
languageData:
Data.s "Rapide, mais peu d'objets affichés..."
Data.s "Qualité inférieure"
Data.s "Bon compromis entre rapidité et qualité"
Data.s "Qualité supérieure"
Data.s "Wow! Votre PC est si rapide que ça!?"
Data.s "OK"
Data.s "Annuler"
Data.s "Résolution:"
Data.s "Afficher le nombre d'images par seconde"
Data.s "Donne une indication de la fluidité"
Data.s "Définit le nombre d'objets à l'écran"
Data.s "Nb. objets:"
Data.s "Visitez le site Keleb's Code Corner..."
Data.s "Trouvez d'autres économiseurs d'écran, des programmes, et plus encore..."
Data.s "Détails >>"
Data.s "Licence >>"
Data.s "I) Description:"+Chr(10)+"-------------------------"+Chr(10)+"[Insérez ici la description de votre oeuvre]"+Chr(10)+" Blah Blah Blah "+Chr(10)+"Blah Blah "+Chr(10)+Chr(10)+"II) Configuration requise:"+Chr(10)+"------------------------------------"+Chr(10)+"[Config. requise pour un bon fonctionnement]"+Chr(10)+""+Chr(10)+"III) Bugs connus:"+Chr(10)+"---------------------------"+Chr(10)+"[S'il y en a, autant prévenir...]"
Data.s "[Insérez ici le prix du produit, son mode de distribution, sa licence, etc..]"+Chr(10)+Chr(10)+"License:"+Chr(10)+"------------------"+Chr(10)+"DISCLAIMER And AGREEMENT"+Chr(10)+""+Chr(10)+"Tout utilisateur de ce screensaver doit accepter cette déclaration de "+Chr(10)+"garantie. Si vous n'acceptez pas cette déclaration de garantie, n'utilisez pas "+Chr(10)+"ce screensaver."+Chr(10)+Chr(10)+"CE SCREENSAVER EST FOURNI TEL QUEL. PARCE QUE L'UTILI-"+Chr(10)+"-SATION DE CE PROGRAMME EST LIBRE ET GRATUITE, AUCUNE GARANTIE "+Chr(10)+"N'EST FOURNIE, COMME LE PERMET LA LOI. SAUF MENTION ECRITE, LES "+Chr(10)+"DETENTEURS DU COPYRIGHT ET/OU LES TIERS FOURNISSENT LE "+Chr(10)+"PROGRAMME EN L'ETAT, SANS AUCUNE SORTE DE GARANTIE EXPLICITE OU "+Chr(10)+"IMPLICITE, Y COMPRIS LES GARANTIES DE COMMERCIALISATION OU D'ADAP-"+Chr(10)+"-TATION DANS UN BUT PARTICULIER. VOUS ASSUMEZ TOUS LES RISQUES "+Chr(10)+"QUANT A LA QUALITE ET AUX EFFETS DU PROGRAMME. SI LE PROGRAMME "+Chr(10)+"EST DEFECTUEUX, VOUS ASSUMEZ LE COUT DE TOUS LES SERVICES, "+Chr(10)+"CORRECTIONS OU REPARATIONS NECESSAIRES."+Chr(10)+"SAUF LORSQU'EXPLICITEMENT PREVU PAR LA LOI OU ACCEPTE PAR ECRIT, "+Chr(10)+"NI LE DETENTEUR DES DROITS, NI QUICONQUE AUTORISE A MODIFIER ET/OU"+Chr(10)+"REDISTRIBUER LE PROGRAMME COMME IL EST PERMIS CI-DESSUS NE "+Chr(10)+"POURRA ETRE TENU POUR RESPONSABLE DE TOUT DOMMAGE DIRECT, "+Chr(10)+"INDIRECT, SECONDAIRE OU ACCESSOIRE (PERTES FINANCIERES DUES AU "+Chr(10)+"MANQUE A GAGNER, A L'INTERRUPTION D'ACTIVITES OU A LA PERTE DE "+Chr(10)+"DONNEES, ETC., DECOULANT DE L'UTILISATION DU PROGRAMME OU DE "+Chr(10)+"L'IMPOSSIBILITE D'UTILISER CELUI-CI)."
Data.s "http://keleb.free.fr/codecorner/screensavers.htm"
Data.s "Si vous appréciez ce produit..."
Data.s "...pensez à donner un petit coup de pouce à Keleb's Code Corner."
Data.s "http://keleb.free.fr/codecorner/paypal.htm"
Data.s "Forme:"
Data.s "Ce programme a été fait en PureBasic v4.0"
Data.s "Un langage de programmation puissant et facile à apprendre!"
Data.s "http://www.purebasic.com/french/"
Data.s "#####"
Data.s "Fast, but not many objects..."
Data.s "Low quality"
Data.s "Medium speed and quality"
Data.s "High quality"
Data.s "Wow! Your PC is that fast !?"
Data.s "OK"
Data.s "Cancel"
Data.s "Resolution:"
Data.s "Show number of frames per second"
Data.s "Give an indication of smoothness"
Data.s "Set number of objects on screen"
Data.s "Nb. objects:"
Data.s "Take a look at Keleb's Code Corner..."
Data.s "Find other screensavers, programs, and more..."
Data.s "Details >>"
Data.s "License >>"
Data.s "I) Description:"+Chr(10)+"-------------------------"+Chr(10)+"[Insert here a description]"+Chr(10)+" Blah Blah Blah "+Chr(10)+"Blah Blah "+Chr(10)+Chr(10)+"II) Configuration:"+Chr(10)+"------------------------------------"+Chr(10)+"[Required configuration]"+Chr(10)+""+Chr(10)+"III) Known bugs:"+Chr(10)+"---------------------------"+Chr(10)+"[If there's some bugs, it would be kind to warn the user...]"
Data.s "[Insert here the price, its distribution mode, its license, etc..]"+Chr(10)+""+Chr(10)+"License:"+Chr(10)+"-------------------"+Chr(10)+"DISCLAIMER AND AGREEMENT"+Chr(10)+""+Chr(10)+"Users of this screensaver must accept this disclaimer of warranty. If you do"+Chr(10)+"not accept this disclaimer, do not use this screensaver."+Chr(10)+""+Chr(34)+"THIS SCREENSAVER IS SUPPLIED AS IS. THE AUTHOR DISCLAIMS."+Chr(10)+"ALL WARRANTIES, EXPRESSED OR IMPLIED,INCLUDING, WITHOUT LIMITATION,"+Chr(10)+"THE WARRANTIES OF MERCHANTABILITY AND OF FITNESS FOR ANY "+Chr(10)+"PURPOSE. THE AUTHOR ASSUMES NO LIABILITY FOR DAMAGES, DIRECT OR "+Chr(10)+"CONSEQUENTIAL, WHICH MAY RESULT FROM THE USE OF THIS "+Chr(10)+"SCREENSAVER, EVEN IF THE AUTHOR HAS BEEN ADVISED OF THE POSSIBI-"+Chr(10)+"-LITY OF SUCH DAMAGES."+Chr(10)+""+Chr(34)+"THE LICENCE AGREEMENT AND WARRANTY SHALL BE CONSTRUED, INTER-"+Chr(10)+"-PRETED AND GOVERNED BY THE LAWS OF FRANCE. YOU MAY HAVE OTHER"+Chr(10)+"RIGHTS WHICH VARY FROM ONE COUNTRY TO ANOTHER."+Chr(34)+""
Data.s "http://keleb.free.fr/codecorner/screensavers-en.htm"
Data.s "If you like this product..."
Data.s "... please consider giving a little help to Keleb's Code Corner."
Data.s "http://keleb.free.fr/codecorner/paypal-en.htm"
Data.s "Shape:"
Data.s "This program is powered by PureBasic v4.0"
Data.s "A powerful and easy to learn programming language!"
Data.s "http://www.purebasic.com"
Data.s "#####"
EndDataSection
;************************************************************************************
;- ---- Main program ----
;************************************************************************************
;- Parse command line
Parameter = UCase(ProgramParameter())
If Len(Parameter) > 2
previewWndHandleStr = RemoveString(Parameter, Left(Parameter, 3), 1)
Parameter = RemoveString(Parameter, Left(Parameter, 1), 1)
Parameter = Left(Parameter, 1)
Else
Parameter = RemoveString(Parameter, Left(Parameter, 1), 1)
previewWndHandleStr = ProgramParameter()
If FindString(previewWndHandleStr, "-", 0) <> 0 : previewWndHandleStr = RemoveString(previewWndHandleStr, "-", 1) : EndIf
If FindString(previewWndHandleStr, "/", 0) <> 0 : previewWndHandleStr = RemoveString(previewWndHandleStr, "/", 1) : EndIf
EndIf
Select Parameter
Case "","C" ;no parameter (double click), or "C" => configuration screen
ConfigScreen()
Case "A" ; Password => do nothing
End
Case "P" ; Preview. This parameter is followed by another one: the handle of the preview window
saverMode = #PreviewMode
Case "S" ; Screensaver mode
saverMode = #ScreensaverMode
EndSelect
;- Init Engine 3D, keyboard, mouse...
If InitEngine3D() = 0
MessageRequester( "Error" , "Can't initialize 3D, check if engine3D.dll is available" , 0 )
End
ElseIf InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0
MessageRequester( "Error" , "Can't find DirectX 7.0 or above" , 0 )
End
EndIf
; Allow only one instance of this program
OnlyOneSaverStart(ScreensaverName)
; Tell the system that a screensaver is running
If saverMode = #ScreensaverMode
SystemParametersInfo_(#SPI_SCREENSAVERRUNNING, 1, @oldval, 0)
EndIf
;- Load preferences
LoadPreferences()
nbobjects = Pow(2, (7+config\nbobjects) )
oldPtrOffset = nbobjects * sizeofPosAngle
*posAngleBuffer = AllocateMemory(sizeofPosAngle*nbobjects*(tmax+100))
*oldPtrPosAngle = *posAngleBuffer
*PtrPosAngle = *posAngleBuffer + sizeofPosAngle
;- Switch preview / fullscreen
If saverMode = #PreviewMode
DisplayHwnd = Val(previewWndHandleStr)
GetClientRect_(DisplayHwnd, @PSize.RECT)
OpenWindow(0,0,0,PSize\right,PSize\bottom,"",#WS_CHILD,DisplayHwnd)
width = PSize\right
height = PSize\bottom
OpenWindowedScreen(WindowID(0),0,0,width,height,0,0,0)
SetWindowCallback(@PreviewCallback())
Else
width = Val( Trim(StringField(config\resolution,1,"x")) )
height = Val( Trim(StringField(config\resolution,2,"x")) )
OpenScreen(width,height,32,"")
EndIf
;********* From this point, there's no more difference with a standard program. ************
;-Procs declarations
; (here, to avoid mixing them with the ones used by screensaver mechanisms)
Declare.l CreatePlatonicMesh(solid.l,sizeX.f,sizeY.f,sizeZ.f,Uorigin.f,Vorigin.f,Uscale.f,Vscale.f,color.l)
Declare EulerAnglesToQuat(anglex.f,angley.f,anglez.f)
Declare QuaternionTransform(x.f,y.f,z.f)
Declare.f CurveValue(target.f,current.f,p.f)
Declare.f WrapValueF(angle.f)
;-Texture
; Create a "rainbowy" 64x64 texture
CreateTexture(0,64,64)
StartDrawing(TextureOutput(0))
numstep.w=171
value.f=0
x.w=0:y.w=0
couleur.l
For mode=1 To 6
For i=1 To numstep
value=i*(255.00/numstep)
If value>255
value=255
EndIf
Select mode
Case 1
couleur = RGB(255,value,0)
Case 2
couleur = RGB(255-value,255,0)
Case 3
couleur = RGB(0,255,value)
Case 4
couleur = RGB(0,255-value,255)
Case 5
couleur = RGB(value,0,255)
Case 6
couleur = RGB(255,value,255)
EndSelect
Box(x,y,2,2,couleur)
x=x+2
If x=64
x=0
y=y+2
EndIf
Next i
Next mode
StopDrawing()
;-Material
; convert it into a semi-transparent material
CreateMaterial(0,TextureID(0))
MaterialBlendingMode(0,#PB_Material_Add)
;-Entity
; Create a bunch of platonic solids
colorConv.f =1024.00/nbobjects
Define numcolor.l,xt.l,yt.l,u.f,v.f
dotsize.f = 1.0/32.0
For i=0 To nbobjects-1
numcolor = i*colorConv
If numcolor < 32
numcolor=32
ElseIf numcolor > 1023
numcolor=1023
EndIf
yt=numcolor/32
xt=numcolor-(yt*32)
u=(xt/32.00)
v=(yt/32.00)
myCubeMesh = CreatePlatonicMesh(config\shape,1,1,1,u,v,dotsize,dotsize,$FFFFFF)
CreateEntity(i+1,MeshID(myCubeMesh),MaterialID(0))
FreeMesh(myCubeMesh)
Next i
;-Skybox
; Get path to current program
currentPath.s = Space(255)
GetModuleFileName_(0, @currentPath, 255)
currentPath = GetPathPart(currentPath)
; Add "\" to the end
If Right(currentPath, 1) <> "\"
currentPath + "\"
EndIf
; Add a nice space skybox
Add3DArchive(currentPath + "absdancesky.zip", #PB_3DArchive_Zip)
SkyBox("space.jpg")
;-Camera
CreateCamera(0, 0, 0 , 100 , 100)
MoveCamera(0,0,0,-40)
CameraLookAt(0,0,0,0)
xtarget=1:ytarget=-30:ztarget=-8
xcam.f=CameraX(0):ycam.f=CameraY(0):zcam.f=CameraZ(0)
xcamd.f=0:ycamd.f=0:zcamd.f=0
xcamdt.f=(xtarget-xcam)/500.00:ycamdt.f=(ytarget-ycam)/500.00:zcamdt.f=(ztarget-zcam)/500.00
;-Light
; strong ambient light, for a flashy look
AmbientColor(RGB(200,200,200))
;- Variables
Define mode.l=0 ; forward or reverse motion
Define vmax.l=100,vcur.l=100,v.f=1 ; motion speed modificator
Define speed.f=0.3,var1.f=1,var2.f=2.5,var3.f=2.5 ; speed and rotation values
Define xmean.f,ymean.f,zmean.f ; Used to compute the center of the entity "swarm"
; store objects initial position/angle
For i=1 To nbobjects
*ptrPosAngle\x = 0
*ptrPosAngle\y = 0
*ptrPosAngle\z = 0
*ptrPosAngle\xangle = 0
*ptrPosAngle\yangle = 0
*ptrPosAngle\zangle = 0
*ptrPosAngle+sizeOfPosAngle
Next i
;- Main loop
Repeat
ev = WaitWindowEvent(1)
; "Forward motion" mode
If mode=0
v=vcur/100.00
For i=1 To nbobjects
*oldPtrPosAngle = *ptrPosAngle - oldPtrOffset
*ptrPosAngle\xangle = wrapvalueF( *oldPtrPosAngle\xangle+(var1*v) )
*ptrPosAngle\yangle = wrapvalueF( *oldPtrPosAngle\yangle+(((i/100)-var2)*v) )
*ptrPosAngle\zangle = wrapvalueF( *oldPtrPosAngle\zangle+(((i/100)-var3)*v) )
EulerAnglesToQuat(*ptrPosAngle\xangle * 0.0174533,*ptrPosAngle\yangle * 0.0174533,*ptrPosAngle\zangle * 0.0174533 )
QuaternionTransform(0,0,-speed*v)
MoveEntity( i,pResultVector\x,pResultVector\y,pResultVector\z )
RotateEntity(i,*ptrPosAngle\yangle,*ptrPosAngle\xangle,*ptrPosAngle\zangle)
*ptrPosAngle\x=EntityX(i)
*ptrPosAngle\y=EntityY(i)
*ptrPosAngle\z=EntityZ(i)
xmean+*ptrPosAngle\x
ymean+*ptrPosAngle\y
zmean+*ptrPosAngle\z
*ptrPosAngle+sizeOfPosAngle
Next i
; After tmax loops, the motion slows down until it stops
t+1
If t = tmax
vmax=-vmax
EndIf
If vmax>0 And vcur<vmax
vcur+1
EndIf
If vmax<0 And vcur>vmax
vcur-1
EndIf
; when the motion is stopped, switch to "reverse motion" mode
If vcur=0
mode=1
vcur=vmax
EndIf
Else
; "Reverse motion" mode => re-use stored positions and rotations
t-1
*ptrPosAngle-oldPtrOffset
For i=1 To nbobjects
EntityLocate( i,*ptrPosAngle\x,*ptrPosAngle\y,*ptrPosAngle\z )
RotateEntity( i,*ptrPosAngle\yangle,*ptrPosAngle\xangle,*ptrPosAngle\zangle )
xmean+*ptrPosAngle\x
ymean+*ptrPosAngle\y
zmean+*ptrPosAngle\z
*ptrPosAngle+sizeOfPosAngle
Next i
*ptrPosAngle-oldPtrOffset
If t=1
mode=0
var1=-2 + (Random(40)/10.00)
var2=-4 + (Random(80)/10.00)
var3=-4 + (Random(80)/10.00)
EndIf
EndIf
; The camera constantly flies toward random destinations
xcamd=curvevalue(xcamdt,xcamd,500.0)
ycamd=curvevalue(ycamdt,ycamd,500.0)
zcamd=curvevalue(zcamdt,zcamd,500.0)
xcam+xcamd
ycam+ycamd
zcam+zcamd
CameraLocate(0,xcam,ycam,zcam)
; Every 500 loops, the destination change
campos+1
If campos=500
xtarget=EntityX(1)+25-Random(50)
ytarget=EntityY(1)+25-Random(50)
ztarget=EntityZ(1)+25-Random(50)
xcamdt=(xtarget-xcam)/500.00
ycamdt=(ytarget-ycam)/500.00
zcamdt=(ztarget-zcam)/500.00
campos=0
EndIf
; But it always looks at the center of the entity "swarm"
xmean/nbobjects
ymean/nbobjects
zmean/nbobjects
CameraLookAt(0,xmean,ymean,zmean)
; show it all
RenderWorld()
; show FPS
If saverMode = #ScreenSaverMode And config\showFPS = 1
StartDrawing(ScreenOutput())
DrawText(0,0,Str(Engine3DFrameRate(#PB_Engine3D_Average)) + " FPS / " + Str(CountRenderedTriangles()) + " triangles", $00FFFF, $BB0000)
StopDrawing()
EndIf
; Flip buffers to avoid tearing
FlipBuffers()
Until CheckStatus()=1
FreeMemory(*posAngleBuffer)
; Tell the system that the screensaver is no longer running
If saverMode = #ScreensaverMode
SystemParametersInfo_(#SPI_SCREENSAVERRUNNING, 0, @oldval, 0)
EndIf
OnlyOneSaverStop()
;************************************************************************************
;- ---- 3D functions for main program ----
;************************************************************************************
;************************************************************************************
; Name: CreatePlatonicMesh
; Purpose: Create a platonic solid mesh, scaled
; Parameters:
; - solide: #tetrahedron,#cube,#octahedron,#dodecahedron, or #icosahedron
; - X size
; - Y size
; - Z size
; - origin of mapping coord U
; - origin of mapping coord V
; - Vertices color
; Return value: mesh number, or -1 if an error occurs
;************************************************************************************
Procedure.l CreatePlatonicMesh(solid.l,sizeX.f,sizeY.f,sizeZ.f,Uorigin.f,Vorigin.f,Uscale.f,Vscale.f,color.l)
Protected nbVert.l , nbTri.l ; Number of vertices and faces
Protected x.f,y.f,z.f ; vertex position
Protected nx.f,ny.f,nz.f ; vertex normals
Protected u.f,v.f ; vertex UV coords (texture mapping)
Protected *PtrV.Vertex,*vertexBuffer.l ; vertices buffer in memory
Protected *PtrF.FaceTri,*facetriBuffer.l ; Faces buffer in memory
Protected newmesh.l ; Procedure Result
; Restore the good set of meshdatas
Select solid
Case #tetrahedron
Restore tetrahedron
Case #cube
Restore cube
Case #octahedron
Restore octahedron
Case #dodecahedron
Restore dodecahedron
Case #icosahedron
Restore icosahedron
Default
ProcedureReturn -1
EndSelect
; Read number of vertices and triangles
Read nbVert
Read nbTri
; Allocate the needed memory for vertices
*vertexBuffer = AllocateMemory(SizeOf(Vertex)*nbVert)
*PtrV = *vertexBuffer
; Read and store vertices position, normals, uv coords
For i = 1 To nbVert
Read x
Read y
Read z
Read nx
Read ny
Read nz
Read u
Read v
*PtrV\px = x * sizex
*PtrV\py = y * sizey
*PtrV\pz = z * sizez
*PtrV\nx = nx
*PtrV\ny = ny
*PtrV\nz = nz
*PtrV\couleur = Color
*PtrV\u = uorigin + (u * uscale)
*PtrV\v = vorigin + (v * vscale)
*PtrV + SizeOf(Vertex)
Next i
; Allocate the needed memory for faces
*facetriBuffer=AllocateMemory(SizeOf(FaceTri)*nbTri)
*PtrF=*facetriBuffer
;Read and store faces infos
For i=1 To nbTri
Read v1
Read v2
Read v3
*PtrF\f1=v1
*PtrF\f2=v2
*PtrF\f3=v3
*PtrF + SizeOf(FaceTri)
Next i
; Create mesh from stored infos
newmesh = CreateMesh(#PB_Any,100)
If IsMesh(newmesh)
SetMeshData(newmesh,#PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_UVCoordinate | #PB_Mesh_Color,*vertexBuffer,nbVert)
SetMeshData(newmesh,#PB_Mesh_Face,*facetriBuffer,nbTri)
; and don't forget to free memory
FreeMemory(*vertexBuffer)
FreeMemory(*facetriBuffer)
ProcedureReturn newmesh
Else
; even if "createMesh" has failed
FreeMemory(*vertexBuffer)
FreeMemory(*facetriBuffer)
ProcedureReturn -1
EndIf
EndProcedure
;************************************************************************************
; Name: EulerAnglesToQuat
; Purpose: convert three Euler angles X,Y,Z to a quaternion
; Parameters: X,Y,Z angles, in radians
; Return-Value: nothing, but store the result in the quaternion called "cQuat"
;************************************************************************************
Procedure EulerAnglesToQuat(x.f,y.f,z.f)
Protected roll.f,pitch.f,yaw.f
Protected cyaw.f, cpitch.f, croll.f, syaw.f, spitch.f, sroll.f
Protected cyawcpitch.f, syawspitch.f, cyawspitch.f, syawcpitch.f
Protected norm.f
roll = x
pitch= y
yaw = z
cyaw = Cos(0.5 * yaw)
cpitch = Cos(0.5 * pitch)
croll = Cos(0.5 * roll)
syaw = Sin(0.5 * yaw)
spitch = Sin(0.5 * pitch)
sroll = Sin(0.5 * roll)
cyawcpitch = cyaw*cpitch
syawspitch = syaw*spitch
cyawspitch = cyaw*spitch
syawcpitch = syaw*cpitch
norm = (cyawcpitch * croll + syawspitch * sroll)
cQuat\x = (cyawcpitch * sroll - syawspitch * croll)
cQuat\y = (cyawspitch * croll + syawcpitch * sroll)
cQuat\z = (syawcpitch * croll - cyawspitch * sroll)
cQuat\w = norm
EndProcedure
;************************************************************************************
; Name: QuaternionTransform
; Purpose: apply a vector3 transform to the quaternion cQuat (=> translation)
; Parameters: X,Y,Z values
; Return-Value: nothing, but store the result in the vector3 called "pResult"
;************************************************************************************
Procedure QuaternionTransform(x.f,y.f,z.f)
pResultVector\x = cQuat\w*cQuat\w*x + 2*cQuat\y*cQuat\w*z - 2*cQuat\z*cQuat\w*y + cQuat\x*cQuat\x*x + 2*cQuat\y*cQuat\x*y + 2*cQuat\z*cQuat\x*z - cQuat\z*cQuat\z*x - cQuat\y*cQuat\y*x
pResultVector\y = 2*cQuat\x*cQuat\y*x + cQuat\y*cQuat\y*y + 2*cQuat\z*cQuat\y*z + 2*cQuat\w*cQuat\z*x - cQuat\z*cQuat\z*y + cQuat\w*cQuat\w*y - 2*cQuat\x*cQuat\w*z - cQuat\x*cQuat\x*y;
pResultVector\z = 2*cQuat\x*cQuat\z*x + 2*cQuat\y*cQuat\z*y + cQuat\z*cQuat\z*z - 2*cQuat\w*cQuat\y*x - cQuat\y*cQuat\y*z + 2*cQuat\w*cQuat\x*y - cQuat\x*cQuat\x*z + cQuat\w*cQuat\w*z;
EndProcedure
;************************************************************************************
; Name: CurveValue
; Purpose: provide a smooth transition between "actuelle" and "Cible" values
; Parameters:
; - Cible : target value
; - actuelle: current value
; - P : nb steps between the two values
; Return-Value: result
;************************************************************************************
Procedure.f CurveValue(Cible.f, actuelle.f, P.f)
;Calcule une valeur progressive allant de la valeur actuelle à la valeur cible
Protected Delta.f
Delta = Cible - actuelle
If P > 1000.0
P = 1000.0
EndIf
ProcedureReturn (actuelle + ( Delta * P / 1000.0))
EndProcedure
;************************************************************************************
; Name: WrapValueF
; Purpose: provide a modulo(360) operation for floats => useful for angles
; Parameters: angle
; Return-Value: result (0 >= result < 360)
;************************************************************************************
Procedure.f wrapValueF(angle.f)
If angle < 0
ProcedureReturn angle+360
ElseIf angle >= 360
ProcedureReturn angle-360
EndIf
ProcedureReturn angle
EndProcedure
;-Datas used by main program
DataSection
tetrahedron:
; Nb sommets / Nb faces
Data.l 10,4
; Vertices: pos / normals / uv
Data.f 0.817497,0.578350,0
Data.f 0,1,0
Data.f 0.5,0.5
Data.f -0.815497,0.578350,0
Data.f 0,1,0
Data.f 0.5,1.5
Data.f 0,-0.576350,0.817497
Data.f 0,0.577351,0.816496
Data.f -0.5,1
Data.f 0,-0.576350,-0.815497
Data.f 0,0.577351,-0.816496
Data.f -0.5,1
Data.f 0,-0.576350,-0.815497
Data.f 0.816496,-0.577351,0
Data.f -0.5,1.5
Data.f 0,-0.576350,0.817497
Data.f 0.816496,-0.577351,0
Data.f 0.5,1.5
Data.f 0.817497,0.578350,0
Data.f 0.816496,-0.577351,0
Data.f 0,0.5
Data.f 0,-0.576350,-0.815497
Data.f -0.816496,-0.577351,0
Data.f -0.5,1.5
Data.f -0.815497,0.578350,0
Data.f -0.816496,-0.577351,0
Data.f 0,0.5
Data.f 0,-0.576350,0.817497
Data.f -0.816496,-0.577351,0
Data.f 0.5,1.5
; Faces
Data.l 0,1,2
Data.l 1,0,3
Data.l 4,6,5
Data.l 7,9,8
cube:
; Nb sommets / Nb faces
Data.l 24,12
; Vertices: pos / normals / uv
Data.f -0.5,0.5,-0.5
Data.f 0,1,0
Data.f 0,0
Data.f 0.5,0.5,-0.5
Data.f 0,1,0
Data.f 0,1
Data.f 0.5,0.5,0.5
Data.f 0,1,0
Data.f 1,1
Data.f -0.5,0.5,0.5
Data.f 0,1,0
Data.f 1,0
Data.f -0.5,-0.5,0.5
Data.f 0,-1,0
Data.f 0,0
Data.f 0.5,-0.5,0.5
Data.f 0,-1,0
Data.f 0,1
Data.f 0.5,-0.5,-0.5
Data.f 0,-1,0
Data.f 1,1
Data.f -0.5,-0.5,-0.5
Data.f 0,-1,0
Data.f 1,0
Data.f -0.5,0.5,0.5
Data.f 0,0,1
Data.f 0,0
Data.f 0.5,0.5,0.5
Data.f 0,0,1
Data.f 0,1
Data.f 0.5,-0.5,0.5
Data.f 0,0,1
Data.f 1,1
Data.f -0.5,-0.5,0.5
Data.f 0,0,1
Data.f 1,0
Data.f 0.5,0.5,-0.5
Data.f 0,0,-1
Data.f 0,0
Data.f -0.5,0.5,-0.5
Data.f 0,0,-1
Data.f 0,1
Data.f -0.5,-0.5,-0.5
Data.f 0,0,-1
Data.f 1,1
Data.f 0.5,-0.5,-0.5
Data.f 0,0,-1
Data.f 1,0
Data.f -0.5,0.5,-0.5
Data.f -1,0,0
Data.f 0,0
Data.f -0.5,0.5,0.5
Data.f -1,0,0
Data.f 0,1
Data.f -0.5,-0.5,0.5
Data.f -1,0,0
Data.f 1,1
Data.f -0.5,-0.5,-0.5
Data.f -1,0,0
Data.f 1,0
Data.f 0.5,0.5,0.5
Data.f 1,0,0
Data.f 0,0
Data.f 0.5,0.5,-0.5
Data.f 1,0,0
Data.f 0,1
Data.f 0.5,-0.5,-0.5
Data.f 1,0,0
Data.f 1,1
Data.f 0.5,-0.5,0.5
Data.f 1,0,0
Data.f 1,0
; Faces
Data.l 2,1,0
Data.l 0,3,2
Data.l 6,5,4
Data.l 4,7,6
Data.l 10,9,8
Data.l 8,11,10
Data.l 14,13,12
Data.l 12,15,14
Data.l 18,17,16
Data.l 16,19,18
Data.l 22,21,20
Data.l 20,23,22
octahedron:
; Nb sommets / Nb faces
Data.l 18,8
; Vertices: pos / normals / uv
Data.f 0,0.708107,0.708107
Data.f 0,1,0
Data.f 0,0.5
Data.f 0,0.708107,-0.706107
Data.f 0,1,0
Data.f 0,1.5
Data.f 1.001000,0,0
Data.f 1,0,0
Data.f 0.5,1
Data.f 0,-0.706107,0.708107
Data.f 0,0,1
Data.f -0.5,1
Data.f -0.999000,0,0
Data.f -1,0,0
Data.f 0,1.5
Data.f 0,-0.706107,-0.706107
Data.f 0,0,-1
Data.f -0.5,1
Data.f 1.001000,0,0
Data.f 0.577350,0,0.816496
Data.f 0,0.5
Data.f 0,0.708107,0.708107
Data.f 0.577350,0,0.816496
Data.f 0.5,1
Data.f 0,0.708107,0.708107
Data.f -0.577350,0,0.816496
Data.f 0.5,1
Data.f -0.999000,0,0
Data.f -0.577350,0.816496,0
Data.f -0.5,1
Data.f 0,0.708107,-0.706107
Data.f -0.577350,0,-0.816496
Data.f 0.5,1
Data.f 1.001000,0,0
Data.f 0.577350,0,-0.816496
Data.f 0,0.5
Data.f 0,0.708107,-0.706107
Data.f 0.577350,0,-0.816496
Data.f 0.5,1
Data.f 0,-0.706107,-0.706107
Data.f 0.577350,-0.816496,0
Data.f 0,1.5
Data.f 0,-0.706107,0.708107
Data.f 0.577350,-0.816496,0
Data.f 0,0.5
Data.f -0.999000,0,0
Data.f -0.577350,-0.816496,0
Data.f -0.5,1
Data.f 0,-0.706107,0.708107
Data.f -0.577350,-0.816496,0
Data.f 0,0.5
Data.f 0,-0.706107,-0.706107
Data.f -0.577350,-0.816496,0
Data.f 0,1.5
; Faces
Data.l 1,0,2
Data.l 6,7,3
Data.l 3,8,4
Data.l 9,0,1
Data.l 4,10,5
Data.l 5,12,11
Data.l 2,14,13
Data.l 15,17,16
dodecahedron:
; Nb sommets / Nb faces
Data.l 72,36
; Vertices: pos / normals / uv
Data.f 0.357822,0.935172,0
Data.f 0,0.955423,0.295242
Data.f 0.190983,1
Data.f -0.355822,0.935172,0
Data.f 0,0.955423,-0.295242
Data.f -0.190983,1
Data.f 0.578350,0.578350,0.578350
Data.f 0.688191,0.587785,0.425325
Data.f 0.309017,0.690983
Data.f 0,0.357822,0.935172
Data.f 0,0.850651,0.525731
Data.f 0,0.5
Data.f -0.576350,0.578350,0.578350
Data.f 0,0.850651,0.525731
Data.f -0.309017,0.690983
Data.f -0.576350,0.578350,-0.576350
Data.f 0,0.850651,-0.525731
Data.f -0.309017,1.309020
Data.f 0,0.357822,-0.933172
Data.f 0,0.850651,-0.525731
Data.f 0,1.5
Data.f 0.578350,0.578350,-0.576350
Data.f 0,0.850651,-0.525731
Data.f 0.309017,1.309020
Data.f 0.935172,0,0.357822
Data.f 1,0,0
Data.f 0.190983,1
Data.f 0.935172,0,-0.355822
Data.f 1,0,0
Data.f -0.190983,1
Data.f 0,-0.355822,-0.933172
Data.f 0,0,-1
Data.f -0.190983,1
Data.f 0.578350,-0.576350,-0.576350
Data.f 0.525731,0,-0.850651
Data.f -0.309017,0.690983
Data.f 0.578350,-0.576350,0.578350
Data.f 0.850651,-0.525731,0
Data.f 0.309017,1.309020
Data.f 0.357822,-0.933172,0
Data.f 0.850651,-0.525731,0
Data.f 0,1.5
Data.f -0.576350,-0.576350,-0.576350
Data.f -0.425325,-0.688191,-0.587785
Data.f -0.309017,1.309020
Data.f -0.355822,-0.933172,0
Data.f 0,-0.992447,0.122673
Data.f -0.190983,1
Data.f 0,-0.355822,0.935172
Data.f 0,-0.850651,0.525731
Data.f 0,0.5
Data.f -0.576350,-0.576350,0.578350
Data.f 0,-0.850651,0.525731
Data.f -0.309017,0.690983
Data.f -0.933172,0,-0.355822
Data.f -0.979432,-0.201774,0
Data.f -0.190983,1
Data.f -0.933172,0,0.357822
Data.f -0.992447,0.122673,0
Data.f 0.190983,1
Data.f 0.578350,0.578350,-0.576350
Data.f 0.850651,0.525731,0
Data.f -0.309017,0.690983
Data.f 0.578350,0.578350,-0.576350
Data.f 0.850651,0.525731,0
Data.f -0.309017,0.690983
Data.f 0.578350,0.578350,-0.576350
Data.f 0.850651,0.525731,0
Data.f -0.309017,0.690983
Data.f 0.357822,0.935172,0
Data.f 0.850651,0.525731,0
Data.f 0,0.5
Data.f 0.578350,0.578350,-0.576350
Data.f 0.525731,0,-0.850651
Data.f 0.309017,0.690983
Data.f 0,0.357822,-0.933172
Data.f 0.525731,0,-0.850651
Data.f 0.190983,1
Data.f 0.578350,0.578350,-0.576350
Data.f 0.525731,0,-0.850651
Data.f 0.309017,0.690983
Data.f 0.578350,0.578350,-0.576350
Data.f 0.525731,0,-0.850651
Data.f 0.309017,0.690983
Data.f 0.935172,0,-0.355822
Data.f 0.525731,0,-0.850651
Data.f 0,0.5
Data.f 0.578350,-0.576350,-0.576350
Data.f 0.850651,-0.525731,0
Data.f -0.309017,1.309020
Data.f 0.578350,-0.576350,-0.576350
Data.f 0.850651,-0.525731,0
Data.f -0.309017,1.309020
Data.f 0.578350,-0.576350,-0.576350
Data.f 0.850651,-0.525731,0
Data.f -0.309017,1.309020
Data.f 0.578350,-0.576350,-0.576350
Data.f 0,-0.850651,-0.525731
Data.f 0.309017,1.309020
Data.f 0,-0.355822,-0.933172
Data.f 0,-0.850651,-0.525731
Data.f 0,1.5
Data.f 0.578350,-0.576350,-0.576350
Data.f 0,-0.850651,-0.525731
Data.f 0.309017,1.309020
Data.f 0.578350,-0.576350,-0.576350
Data.f 0,-0.850651,-0.525731
Data.f 0.309017,1.309020
Data.f 0.357822,-0.933172,0
Data.f 0,-0.850651,-0.525731
Data.f 0.190983,1
Data.f 0.578350,-0.576350,0.578350
Data.f 0,-0.850651,0.525731
Data.f 0.309017,0.690983
Data.f 0.578350,-0.576350,0.578350
Data.f 0,-0.850651,0.525731
Data.f 0.309017,0.690983
Data.f 0.357822,-0.933172,0
Data.f 0,-0.850651,0.525731
Data.f 0.190983,1
Data.f -0.355822,-0.933172,0
Data.f -0.850651,-0.525731,0
Data.f 0,1.5
Data.f -0.355822,-0.933172,0
Data.f -0.850651,-0.525731,0
Data.f 0,1.5
Data.f -0.355822,-0.933172,0
Data.f -0.850651,-0.525731,0
Data.f 0,1.5
Data.f -0.576350,-0.576350,0.578350
Data.f -0.850651,-0.525731,0
Data.f 0.309017,1.309020
Data.f -0.933172,0,0.357822
Data.f -0.525731,0,0.850651
Data.f 0,1.5
Data.f -0.576350,0.578350,0.578350
Data.f -0.525731,0,0.850651
Data.f 0.309017,1.309020
Data.f 0,0.357822,0.935172
Data.f -0.525731,0,0.850651
Data.f 0.190983,1
Data.f -0.933172,0,0.357822
Data.f -0.525731,0,0.850651
Data.f 0,1.5
Data.f 0,0.357822,0.935172
Data.f -0.525731,0,0.850651
Data.f 0.190983,1
Data.f 0,-0.355822,0.935172
Data.f -0.525731,0,0.850651
Data.f -0.190983,1
Data.f -0.933172,0,0.357822
Data.f -0.525731,0,0.850651
Data.f 0,1.5
Data.f 0,-0.355822,0.935172
Data.f -0.525731,0,0.850651
Data.f -0.190983,1
Data.f -0.576350,-0.576350,0.578350
Data.f -0.525731,0,0.850651
Data.f -0.309017,1.309020
Data.f -0.576350,0.578350,-0.576350
Data.f -0.850651,0.525731,0
Data.f -0.309017,0.690983
Data.f -0.576350,0.578350,-0.576350
Data.f -0.850651,0.525731,0
Data.f -0.309017,0.690983
Data.f -0.355822,0.935172,0
Data.f -0.850651,0.525731,0
Data.f 0,0.5
Data.f -0.355822,0.935172,0
Data.f -0.850651,0.525731,0
Data.f 0,0.5
Data.f -0.576350,0.578350,0.578350
Data.f -0.850651,0.525731,0
Data.f 0.309017,0.690983
Data.f -0.933172,0,-0.355822
Data.f -0.525731,0,-0.850651
Data.f 0,1.5
Data.f -0.933172,0,-0.355822
Data.f -0.525731,0,-0.850651
Data.f 0,1.5
Data.f 0,0.357822,-0.933172
Data.f -0.525731,0,-0.850651
Data.f 0.190983,1
Data.f -0.933172,0,-0.355822
Data.f -0.525731,0,-0.850651
Data.f 0,1.5
Data.f 0,0.357822,-0.933172
Data.f -0.525731,0,-0.850651
Data.f 0.190983,1
Data.f -0.576350,0.578350,-0.576350
Data.f -0.525731,0,-0.850651
Data.f 0.309017,1.309020
Data.f 0,0.357822,0.935172
Data.f 0.525731,0,0.850651
Data.f 0.190983,1
Data.f 0.935172,0,0.357822
Data.f 0.525731,0,0.850651
Data.f 0,0.5
Data.f 0,0.357822,0.935172
Data.f 0.525731,0,0.850651
Data.f 0.190983,1
Data.f 0.935172,0,0.357822
Data.f 0.525731,0,0.850651
Data.f 0,0.5
Data.f 0.578350,-0.576350,0.578350
Data.f 0.525731,0,0.850651
Data.f -0.309017,0.690983
Data.f 0,0.357822,0.935172
Data.f 0.525731,0,0.850651
Data.f 0.190983,1
Data.f 0.578350,-0.576350,0.578350
Data.f 0.525731,0,0.850651
Data.f -0.309017,0.690983
Data.f 0,-0.355822,0.935172
Data.f 0.525731,0,0.850651
Data.f -0.190983,1
; Faces
Data.l 0,3,2
Data.l 0,4,3
Data.l 0,1,4
Data.l 1,6,5
Data.l 1,7,6
Data.l 1,0,7
Data.l 20,8,9
Data.l 21,2,8
Data.l 22,23,2
Data.l 24,10,25
Data.l 26,11,10
Data.l 27,28,11
Data.l 29,12,13
Data.l 30,8,12
Data.l 31,9,8
Data.l 32,14,33
Data.l 34,15,14
Data.l 35,36,15
Data.l 15,16,17
Data.l 15,37,16
Data.l 15,39,38
Data.l 40,18,14
Data.l 41,19,18
Data.l 42,43,19
Data.l 44,46,45
Data.l 47,49,48
Data.l 50,52,51
Data.l 19,53,18
Data.l 19,55,54
Data.l 19,57,56
Data.l 58,10,14
Data.l 59,60,10
Data.l 61,63,62
Data.l 64,65,2
Data.l 66,68,67
Data.l 69,71,70
icosahedron:
; Nb sommets / Nb faces
Data.l 42,20
; Vertices: pos / normals / uv
Data.f 0,0.851651,0.526731
Data.f 0,1,0
Data.f 0,0.690983
Data.f 0,0.851651,-0.524731
Data.f 0,1,0
Data.f 0,1.309020
Data.f 0.851651,0.526731,0
Data.f 0.356822,0.934172,0
Data.f 0.5,1
Data.f 0.526731,0,0.851651
Data.f 0.810146,0,0.586227
Data.f 0.5,1
Data.f -0.524731,0,0.851651
Data.f 0,0,1
Data.f 0,1.309020
Data.f -0.849651,0.526731,0
Data.f -0.934172,0.356822,0
Data.f 0,0.690983
Data.f -0.524731,0,-0.849651
Data.f -0.810146,0,-0.586227
Data.f -0.5,1
Data.f 0.526731,0,-0.849651
Data.f 0,0,-1
Data.f 0,0.690983
Data.f 0.851651,-0.524731,0
Data.f 0.934172,-0.356822,0
Data.f 0,1.309020
Data.f 0,-0.849651,-0.524731
Data.f 0,-0.356822,-0.934172
Data.f -0.5,1
Data.f 0,-0.849651,0.526731
Data.f 0,-0.707107,0.707107
Data.f 0.309017,1.5
Data.f -0.849651,-0.524731,0
Data.f -0.934172,-0.356822,0
Data.f 0,1.309020
Data.f 0.851651,0.526731,0
Data.f 0.577350,0.577350,0.577350
Data.f 0,0.690983
Data.f 0,0.851651,0.526731
Data.f 0.577350,0.577350,0.577350
Data.f 0.309017,0.5
Data.f 0.526731,0,0.851651
Data.f 0,0.356822,0.934172
Data.f 0,0.690983
Data.f 0,0.851651,0.526731
Data.f 0,0.356822,0.934172
Data.f 0.5,1
Data.f -0.524731,0,0.851651
Data.f -0.577350,0.577350,0.577350
Data.f 0.5,1
Data.f 0,0.851651,0.526731
Data.f -0.577350,0.577350,0.577350
Data.f 0.309017,0.5
Data.f -0.849651,0.526731,0
Data.f -0.356822,0.934172,0
Data.f -0.5,1
Data.f 0,0.851651,-0.524731
Data.f -0.577350,0.577350,-0.577350
Data.f -0.309017,0.5
Data.f -0.524731,0,-0.849651
Data.f 0,0.356822,-0.934172
Data.f 0,1.309020
Data.f 0,0.851651,-0.524731
Data.f 0,0.356822,-0.934172
Data.f 0.5,1
Data.f 0.526731,0,-0.849651
Data.f 0.577350,0.577350,-0.577350
Data.f -0.5,1
Data.f 0.851651,0.526731,0
Data.f 0.577350,0.577350,-0.577350
Data.f 0,0.690983
Data.f 0,0.851651,-0.524731
Data.f 0.577350,0.577350,-0.577350
Data.f -0.309017,0.5
Data.f 0.851651,0.526731,0
Data.f 0.934172,0,0.356822
Data.f 0,0.690983
Data.f 0.851651,0.526731,0
Data.f 0.934172,0,-0.356822
Data.f 0,0.690983
Data.f 0.526731,0,-0.849651
Data.f 0.934172,0,-0.356822
Data.f -0.5,1
Data.f -0.524731,0,-0.849651
Data.f 0,-0.356822,-0.934172
Data.f 0,1.309020
Data.f 0,-0.849651,-0.524731
Data.f 0.577350,-0.577350,-0.577350
Data.f -0.309017,1.5
Data.f 0.526731,0,-0.849651
Data.f 0.577350,-0.577350,-0.577350
Data.f -0.5,1
Data.f 0.851651,-0.524731,0
Data.f 0.356822,-0.934172,0
Data.f 0.5,1
Data.f 0,-0.849651,-0.524731
Data.f 0.356822,-0.934172,0
Data.f 0,1.309020
Data.f 0,-0.849651,0.526731
Data.f 0.356822,-0.934172,0
Data.f 0,0.690983
Data.f 0,-0.849651,-0.524731
Data.f -0.577350,-0.577350,-0.577350
Data.f -0.309017,1.5
Data.f -0.849651,-0.524731,0
Data.f -0.356822,-0.934172,0
Data.f -0.5,1
Data.f 0,-0.849651,0.526731
Data.f -0.356822,-0.934172,0
Data.f 0,0.690983
Data.f 0,-0.849651,-0.524731
Data.f -0.356822,-0.934172,0
Data.f 0,1.309020
Data.f 0,-0.849651,0.526731
Data.f 0,-0.356822,0.934172
Data.f -0.5,1
Data.f 0.526731,0,0.851651
Data.f 0,-0.356822,0.934172
Data.f 0,0.690983
Data.f -0.524731,0,0.851651
Data.f -0.577350,-0.577350,0.577350
Data.f 0.5,1
Data.f -0.524731,0,0.851651
Data.f -0.934172,0,0.356822
Data.f 0.5,1
; Faces
Data.l 1,0,2
Data.l 12,13,3
Data.l 14,15,4
Data.l 16,17,5
Data.l 18,0,1
Data.l 5,19,6
Data.l 20,21,7
Data.l 22,24,23
Data.l 25,3,8
Data.l 26,8,27
Data.l 28,7,9
Data.l 29,30,8
Data.l 8,3,10
Data.l 31,33,32
Data.l 6,34,11
Data.l 35,37,36
Data.l 38,39,4
Data.l 10,40,11
Data.l 6,11,5
Data.l 5,11,41
EndDataSection
