Principe du volume plein **[RESOLUT]**
Publié : sam. 02/mai/2009 22:55
Bonjours,
quelles sont les méthodes pour parvenir à remplir un volume 3D?
quelles sont les méthodes pour parvenir à remplir un volume 3D?
Forums PureBasic - Français
https://www.purebasic.fr/french/
facile ! un empilement de disk, ou de "pavé"Fortix a écrit :Bonjours,
quelles sont les méthodes pour parvenir à remplir un volume 3D?
ben en fait je sais pas trop , faut plutot raisonner en pointsFortix a écrit : @Dobro : donc une forme de base avec 6 facettes (pour le cas d'un pavé)?
Code : Tout sélectionner
;{ -Initialisation
If InitEngine3D()
If InitKeyboard() And InitMouse()=0
MessageRequester("Erreur","Les péripheriques utiles pour le déplacement dans l'environnement 3D sont inaccessibles!")
End
EndIf
Else
MessageRequester("Erreur","l'Initialisation 3D à échouée!")
End
EndIf
If InitPalette() And InitSprite() And InitSprite3D()
UseJPEGImageDecoder()
UsePNGImageDecoder()
UseTIFFImageDecoder()
UseTGAImageDecoder()
Else
MessageRequester("Erreur","Les éléments indispensable pour la décoration 3D sont inaccessibles!")
End
EndIf
;}
Procedure Open_Window_0(LargW,HautW,LargS,HautS)
If OpenWindow(0, 0, 0, LargW,HautW, "", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_TitleBar | #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, LargS,HautS, 0, 0, 0)
ProcedureReturn #True
EndIf
EndIf
EndProcedure
; Procedure LaserLine(IDLaser,index1,index2,teinteIndex1,teinteIndex2,x1,y1,z1,x2,y2,z2)
;
; Structure spoint
; Position.f[3]
; Couleur.l
; EndStructure
;
; Structure sline
; Index.w[3]
; EndStructure
;
; Protected Dim Sommets.spoint(2)
; Protected Dim Triangles.sline(0)
;
; CreateMesh(IDLaser, 0)
;
; Sommets(0)\Position[0] = x1
; Sommets(0)\Position[1] = y1
; Sommets(0)\Position[2] = z1
; Sommets(0)\Couleur = teinteIndex1
;
; Sommets(1)\Position[0] = x2
; Sommets(1)\Position[1] = y2
; Sommets(1)\Position[2] = z2
; Sommets(1)\Couleur = teinteIndex2
;
; Triangles(0)\Index[0] = index1
; Triangles(0)\Index[1] = index2
;
; Triangles(0)\Index[0] = index2
; Triangles(0)\Index[1] = index1
;
; SetMeshData(IDLaser, #PB_Mesh_Vertex | #PB_Mesh_Color, @Sommets(), 2)
;
; SetMeshData(IDLaser, #PB_Mesh_Face, @Triangles(), 1)
;
; ;-----------------------------------------------------------------------------------------
; CreateTexture(IDLaser, 64, 64)
; StartDrawing(TextureOutput(IDLaser))
; Box(0,0, TextureWidth(IDLaser), TextureHeight(IDLaser), RGB(255, 255, 255))
; StopDrawing()
;
; CreateMaterial(IDLaser, TextureID(IDLaser))
; MaterialAmbientColor(IDLaser, #PB_Material_AmbientColors)
;
;
; CreateEntity(IDLaser, MeshID(IDLaser), MaterialID(IDLaser))
; EntityRenderMode(IDLaser, #PB_Entity_Wireframe|#PB_Entity_CastShadow)
; ;-----------------------------------------------------------------------------------------
;
; ProcedureReturn Laser
;
; EndProcedure
Procedure Triangulation(IDStrip,index1,index2,index3,teinteIndex1,teinteIndex2,teinteIndex3,x1,y1,z1,x2,y2,z2,x3,y3,z3)
Structure s_Sommet
Position.f[3]
Couleur.l
EndStructure
Structure s_Triangle
Index.w[3]
EndStructure
Protected Dim Sommets.s_Sommet(3)
Protected Dim Triangles.s_Triangle(1)
;ReDim meshNUM.Mesh(IDStrip/4)
CreateMesh(IDStrip, 0)
Sommets(0)\Position[0] = x1
Sommets(0)\Position[1] = y1
Sommets(0)\Position[2] = z1
Sommets(0)\Couleur = teinteIndex1
Sommets(1)\Position[0] = x2
Sommets(1)\Position[1] = y2
Sommets(1)\Position[2] = z2
Sommets(1)\Couleur = teinteIndex2
Sommets(2)\Position[0] = x3
Sommets(2)\Position[1] = y3
Sommets(2)\Position[2] = z3
Sommets(2)\Couleur = teinteIndex3
Triangles(0)\Index[0] = index1
Triangles(0)\Index[1] = index2
Triangles(0)\Index[2] = index3
SetMeshData(IDStrip, #PB_Mesh_Vertex|#PB_Mesh_Color, @Sommets(), 3)
SetMeshData(IDStrip, #PB_Mesh_Face, @Triangles(), 1)
;-----------------------------------------------------------------------------------------
CreateTexture(IDStrip, 64, 64)
StartDrawing(TextureOutput(IDStrip))
Box(0,0, TextureWidth(IDStrip), TextureHeight(IDStrip), RGB(255, 255, 255))
StopDrawing()
CreateMaterial(IDStrip, TextureID(IDStrip))
MaterialAmbientColor(IDStrip, #PB_Material_AmbientColors)
CreateEntity(IDStrip, MeshID(IDStrip), MaterialID(IDStrip))
EntityRenderMode(IDStrip, #PB_Entity_CastShadow)
;-----------------------------------------------------------------------------------------
ProcedureReturn IDStrip
EndProcedure
lW=900
hW=600
Lxs=800
Hys=600
CameraSpeed = 1
If Open_Window_0(lW,hW,lW,hW)
;{ Mesh sol
;-------------------------------------------
#Mesh = 0
CreateMesh(#Mesh, 4)
Options = #PB_Mesh_Vertex | #PB_Mesh_Normal | #PB_Mesh_UVCoordinate
SetMeshData(#Mesh, Options , ?Surface, 4)
SetMeshData(#Mesh, #PB_Mesh_Face, ?Planate, 2)
#TextureSol = 0
CreateTexture(#TextureSol, 1000, 1000)
StartDrawing(TextureOutput(#TextureSol))
Box(0, 0, TextureWidth(#TextureSol), TextureHeight(#TextureSol), RGB(240,250,255))
For i = 0 To TextureHeight(#TextureSol)-1 Step 50
Line(i, 0, 0, TextureHeight(#TextureSol), RGB(230,240,255))
Line(0, i, TextureWidth(#TextureSol), 0, RGB(230,240,255))
Next i
StopDrawing()
#MatiereSol = 0
CreateMaterial(#MatiereSol, TextureID(#TextureSol))
#EntitySol = 0
CreateEntity(#EntitySol, MeshID(#Mesh), MaterialID(#MatiereSol))
ScaleEntity(#EntitySol, 10000, 0, 10000)
EntityLocate(#EntitySol, 0, -10, 0)
;--------------------------------------------------------------------
;}
For r=1 To 40
Triangulation(r,2,1,0,#Red,#Green,#Blue,76,r,-62,0,r,81,-85,r,-74)
Next
CreateCamera(1,0, 0, 100, 100)
CameraLocate(1, 0, 20, 300)
Repeat
Event = WaitWindowEvent()
WindowID = EventWindow()
GadgetID = EventGadget()
EventType = EventType()
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = CameraSpeed
Else
KeyY = 0
EndIf
If KeyboardPushed(#PB_Key_Escape)
Close=#True
EndIf
EndIf
; If ExamineMouse()
; MouseX = -(MouseDeltaX()/10)*CameraSpeed/2
; MouseY = -(MouseDeltaY()/10)*CameraSpeed/2
; EndIf
;RotateCamera(1, MouseX, MouseY, RollZ)
CameraLookAt(1,0,10,0)
MoveCamera (1, KeyX, -KeyY, 0)
; If dn=0
; LaserLine(10,1,2,$00FF00,$00FF00,14,10,16,37,30,33)
; dn=1
; EndIf
RenderWorld()
;AmbientColor(RGB(128,128,128))
CreateLight(0, RGB(188,190,192), 10, 200, 0)
FlipBuffers()
Until Event = #PB_Event_CloseWindow Or Close
Else
MessageRequester("Fortix:","Erreur, cette application ne peut pas s'executer sur cet ordinateur!")
EndIf
End
;
;----------------------------------
;{ Définition du cube
DataSection
Surface:
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,6
Data.f 0.5,0.5,0.5
Data.f 0,1,0
Data.f 6,6
Data.f -0.5,0.5,0.5
Data.f 0,1,0
Data.f 6,0
Planate:
Data.w 2,1,0
Data.w 0,3,2
EndDataSection
;}
ç'est un truc que je ne comprends d'ailleurs pas trop ...Fortix a écrit :Bizar, chez moi sa marche correctement, en fait je fonctionne toujours sur la version 4.20 de PB!!
cf : http://www.purebasic.com/news55.php3Removed: CopyTexture(), TextureOutput()