Should have noticed it was missing the Data folder.Comtois wrote:you need demo made by Thalius, i use his mesh for the last demo.
http://www.code5.ch/temp/test3d2.zip
Collision detection and response ( with codes )
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
@Comtois
hohoho the Collision version works nicely ! =)
altho i wonder =) ( my French is very very rusty .. still trying to translate/figure your collision code ) how did you get the gemoetry of the temple model so fast ? Did you write a converter do read out the .xml or .mesh formats to get the geometry info?
Thalius
hohoho the Collision version works nicely ! =)
altho i wonder =) ( my French is very very rusty .. still trying to translate/figure your collision code ) how did you get the gemoetry of the temple model so fast ? Did you write a converter do read out the .xml or .mesh formats to get the geometry info?
Thalius
Fred has posted some source with collision done with the latest commands in this thread... viewtopic.php?t=19353
www.posemotion.com
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
PureBasic Tools for OS X: PureMonitor, plist Tool, Data Maker & App Chef
Even the vine knows it surroundings but the man with eyes does not.
It's so awesome I think, It seems to be defintely possible to do a good shooter game in PB now...
Visit www.sceneproject.org
if someone can do that , i will be happy to see how he doesNik wrote:how about a sphere racer on the track provided wiith thze example
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
I use Xml to get geometry info .Thalius wrote: how did you get the gemoetry of the temple model so fast ? Did you write a converter do read out the .xml or .mesh formats to get the geometry info?
If I do not have time to correct my code by Sunday, I will post it just as it is.
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
ok fixed a version now to work with win2k etc. the bug was in :
curent beta ExamineDesktops() *fixed* .
same url:
Example Exe / Source / Data.
http://www.code5.ch/temp/test3d2.zip
Comtois Exe with Collision:
http://perso.wanadoo.fr/comtois/sources/Temple.zip
Now to look into camera Collision !
Thalius
curent beta ExamineDesktops() *fixed* .
same url:
Example Exe / Source / Data.
http://www.code5.ch/temp/test3d2.zip
Comtois Exe with Collision:
http://perso.wanadoo.fr/comtois/sources/Temple.zip
Now to look into camera Collision !
Thalius
"In 3D there is never enough Time to do Things right,
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!
"
but there's always enough Time to make them *look* right."
"psssst! i steal signatures... don't tell anyone!
i use this code to get the geometry of the mesh
Code: Select all
;Comtois 10/02/06
;PB4.0 Beta 2
Source$="D:\Test3D\temple.xml" ; <<<< Fichier du mesh dans le format Xml
Destination$="D:\Test3D\TempleTriangles.HD" ; <<<< Fichier contenant la liste des triangles
Structure Face
v1.l
v2.l
v3.l
EndStructure
Structure Vertex
x.f
y.f
z.f
EndStructure
Structure Point3D
x.f
y.f
z.f
EndStructure
Structure Vecteur
x.f
y.f
z.f
EndStructure
Structure Triangle
P1.Point3D
P2.Point3D
P3.Point3D
Constante.f
Normale.Vecteur
EndStructure
NewList Face.Face()
Global NewList ListTriangle.Triangle()
Procedure.s StringFieldPerso(T$,Index)
Champ=0
Deb=0
Chaine$=""
For i=1 To Len(T$)
Car$=Mid(T$,i,1)
If Car$=Chr(34)
If Deb=0
Deb=1
Champ + 1
Continue
Else
Deb=0
EndIf
EndIf
If Champ=Index And Deb
Chaine$=Chaine$+Car$
EndIf
Next i
ProcedureReturn Chaine$
EndProcedure
OpenConsole()
SubMesh = 0
If OpenFile(0,Source$)
PrintN("Ouverture du fichier Xml : " + Source$)
While Eof(0)=0
Ligne$=ReadString(0)
If FindString(Ligne$,"<faces count=",1)
Pos=FindString(Ligne$,"count=",1)
Pos + 7
NbFace=Val(Mid(Ligne$,Pos,Len(Ligne$)-Pos-1))
SubMesh + 1
PrintN("SubMesh No : " + Str(SubMesh))
PrintN("Nombre de triangles : " + Str(NbFace))
;Lecture des Faces
ClearList(Face())
For i=1 To NbFace
Ligne$=ReadString(0)
AddElement(Face())
Face()\v1=Val(StringFieldPerso(Ligne$,1))
Face()\v2=Val(StringFieldPerso(Ligne$,2))
Face()\v3=Val(StringFieldPerso(Ligne$,3))
Next i
EndIf
;Cherche les vertices
If FindString(Ligne$,"<geometry vertexcount=",1)
Pos=FindString(Ligne$,"count=",1)
Pos + 7
NbVertex=Val(Mid(Ligne$,Pos,Len(Ligne$)-Pos-1))
PrintN("Nombre de sommets : " + Str(NbVertex))
Dim Vertex.Vertex(NbVertex)
EndIf
If FindString(Ligne$,"<vertexbuffer",1)
Index=0
EndIf
;Lecture des vertex
If FindString(Ligne$,"<position",1)
Vertex(Index)\x=ValF(StringFieldPerso(Ligne$,1))
Vertex(Index)\y=ValF(StringFieldPerso(Ligne$,2))
Vertex(Index)\z=ValF(StringFieldPerso(Ligne$,3))
Index + 1
EndIf
;On peut enregistrer ce submesh
If FindString(Ligne$,"</vertexbuffer>",1)
ForEach Face()
AddElement(ListTriangle())
;v1
ListTriangle()\P1\x=Vertex(Face()\v1)\x
ListTriangle()\P1\y=Vertex(Face()\v1)\y
ListTriangle()\P1\z=Vertex(Face()\v1)\z
;v2
ListTriangle()\P2\x=Vertex(Face()\v2)\x
ListTriangle()\P2\y=Vertex(Face()\v2)\y
ListTriangle()\P2\z=Vertex(Face()\v2)\z
;v3
ListTriangle()\P3\x=Vertex(Face()\v3)\x
ListTriangle()\P3\y=Vertex(Face()\v3)\y
ListTriangle()\P3\z=Vertex(Face()\v3)\z
Next
EndIf
Wend
CloseFile(0)
PrintN("Total triangles : " + Str(CountList(ListTriangle())))
EndIf
;Génère un fichier contenant la liste des triangles
If CreateFile(0,Destination$)
PrintN("Creation du fichier triangle : " + Destination$)
ForEach ListTriangle()
WriteData(0,@ListTriangle(),SizeOf(Triangle))
Next
CloseFile(0)
PrintN("Operation terminee")
PrintN("Pressez la touche [Entree] pour quitter")
EndIf
Input()
CloseConsole()
End
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
i made a library CAR_Collision3D
The archiv is about 2Mo (included all meshes i use for demo)
http://perso.wanadoo.fr/comtois/sources/Collision3D.zip
Now ,with library , the code is :
here is the code to get geometry :
On the todo list : an octree or BSP tree 
The archiv is about 2Mo (included all meshes i use for demo)
http://perso.wanadoo.fr/comtois/sources/Collision3D.zip
Now ,with library , the code is :
Code: Select all
;Comtois le 21/02/06
;PB4.0 beta 3
;Je me suis grandement inspiré du tutoriel de Fauerby http://www.peroxide.dk
#Focale = 38
Structure Parametres
AngleX.f
AngleY.f
AngleZ.f
EndStructure
;-Initialisation
If ExamineDesktops()
ScreenWidth = DesktopWidth(0)
ScreenHeight = DesktopHeight(0)
ScreenDepth = DesktopDepth(0)
EndIf
If InitEngine3D() = 0
MessageRequester( "Erreur" , "Impossible d'initialiser la 3D , vérifiez la présence de engine3D.dll" , 0 )
End
ElseIf InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 0 Or InitSound() = 0
MessageRequester( "Erreur" , "Impossible d'initialiser DirectX 7 Ou plus" , 0 )
End
ElseIf OpenScreen( ScreenWidth , ScreenHeight , ScreenDepth , "Demo 3D" ) = 0
MessageRequester( "Erreur" , "Impossible d'ouvrir l'écran " , 0 )
End
EndIf
Add3DArchive("Data\" , #PB_3DArchive_FileSystem)
Add3DArchive("Data\skybox.zip", #PB_3DArchive_Zip)
Parse3DScripts()
;-Informations de l'entity
InfosNinja.Car_Collision
;-Information Monde 3D
World3D.Car_WorldCollision
;-Entity
LoadPreference("Collision3D.ini",@World3D,@InfosNinja)
CreateListeTriangles(@InfosNinja,@World3D)
WorldMesh = LoadMesh(#PB_Any, World3D\FichierMesh)
CreateEntity(#PB_Any, MeshID(WorldMesh), 0)
;-SkyBox
If World3D\FichierSkyBox
SkyBox(World3D\FichierSkyBox)
EndIf
;-Camera
CreateCamera(0,0,0,100,100)
Camera.Parametres
With InfosNinja
CameraLocate(0,\PositionDansR3\x, \PositionDansR3\y + \RayonEllipsoide\y , \PositionDansR3\z)
CameraLookAt(0,\PositionDansR3\x + M3D_Cos(0) * 80, \PositionDansR3\y + \RayonEllipsoide\y ,\PositionDansR3\z - M3D_Sin(0) * 80)
EndWith
Define.f MouseX,MouseY,PasX,PasZ,Fov
Fov = #Focale
;/
;-La boucle principale
;/
Repeat
If ExamineMouse()
MouseX = -(MouseDeltaX()/10) * InfosNinja\Vitesse/2
MouseY = -(MouseDeltaY()/10) * InfosNinja\Vitesse/2
If MouseButton(1)
If InfosNinja\VitesseDansR3\y<#Epsilon
InfosNinja\VitesseDansR3\y = InfosNinja\Vitesse * 2
Else
InfosNinja\VitesseDansR3\y *1.1
EndIf
EndIf
If MouseButton(2)
Fov=M3D_CurveValue(Fov,5,50)
Else
Fov=M3D_CurveValue(Fov,#Focale,50)
EndIf
EndIf
Camera\AngleX = M3D_WrapValue( Camera\AngleX + MouseX)
RotateCamera(0,MouseX,0,0)
If MouseY > 0 And Camera\AngleY < 75
Camera\AngleY + MouseY
RotateCamera(0,0,MouseY,0)
ElseIf MouseY < 0 And Camera\AngleY > -75
Camera\AngleY + MouseY
RotateCamera(0,0,MouseY,0)
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_PageUp)
Fov + 0.1
EndIf
If KeyboardPushed(#PB_Key_PageDown)
Fov - 0.1
EndIf
;Touches du joueur
If KeyboardPushed(#PB_Key_Left)
InfosNinja\VitesseDansR3\x + M3D_Cos(Camera\AngleX+90) * InfosNinja\Vitesse
InfosNinja\VitesseDansR3\z - M3D_Sin(Camera\AngleX+90) * InfosNinja\Vitesse
ElseIf KeyboardPushed(#PB_Key_Right)
InfosNinja\VitesseDansR3\x + M3D_Cos(Camera\AngleX-90) * InfosNinja\Vitesse
InfosNinja\VitesseDansR3\z - M3D_Sin(Camera\AngleX-90) * InfosNinja\Vitesse
EndIf
If KeyboardPushed(#PB_Key_Up)
InfosNinja\VitesseDansR3\x + M3D_Cos(Camera\AngleX) * InfosNinja\Vitesse
InfosNinja\VitesseDansR3\z - M3D_Sin(Camera\AngleX) * InfosNinja\Vitesse
ElseIf KeyboardPushed(#PB_Key_Down)
InfosNinja\VitesseDansR3\x + M3D_Cos(Camera\AngleX) * -InfosNinja\Vitesse
InfosNinja\VitesseDansR3\z - M3D_Sin(Camera\AngleX) * -InfosNinja\Vitesse
EndIf
EndIf
GestionDeplacement1(@InfosNinja,@World3D)
Cx.f = M3D_CurveValue(CameraX(0),InfosNinja\PositionDansR3\x,200)
Cy.f = M3D_CurveValue(CameraY(0),InfosNinja\PositionDansR3\y+48,200)
Cz.f = M3D_CurveValue(CameraZ(0),InfosNinja\PositionDansR3\z,200)
CameraLocate(0,Cx, Cy, Cz)
CameraFOV(0,fov*0.0174533)
RenderWorld()
StartDrawing(ScreenOutput())
DrawText(0,0,StrF(Engine3DFrameRate(#PB_Engine3D_Current),0))
StopDrawing()
InfosNinja\VitesseDansR3\x = 0.0
InfosNinja\VitesseDansR3\z = 0.0
If InfosNinja\VitesseDansR3\y > 0
InfosNinja\VitesseDansR3\y + World3D\Gravite\y
ElseIf InfosNinja\VitesseDansR3\y < 1
InfosNinja\VitesseDansR3\y = 0
EndIf
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)Code: Select all
;Comtois 21/02/06
;PB4.0 Beta 3
Source$="D:\Ogre\OgreCommandLineTools-1.0.6\WaterWorld.xml" ; <<<< Fichier du mesh dans le format Xml
Destination$="D:\Ogre\OgreCommandLineTools-1.0.6\WaterWorldTriangles.HD" ; <<<< Fichier contenant la liste des triangles
Structure Face
v1.l
v2.l
v3.l
EndStructure
Structure Point3D
x.f
y.f
z.f
EndStructure
Structure Vecteur
x.f
y.f
z.f
EndStructure
Structure Triangle
P1.Point3D
P2.Point3D
P3.Point3D
Constante.f
Normale.Vecteur
EndStructure
NewList Face.Face()
Global NewList ListTriangle.Triangle()
Define.f MiniX,MiniY,MiniZ,MaxiX,MaxiY,MaxiZ
Procedure.s StringFieldPerso(T$,Index)
Champ=0
Deb=0
Chaine$=""
For i=1 To Len(T$)
Car$=Mid(T$,i,1)
If Car$=Chr(34)
If Deb=0
Deb=1
Champ + 1
Continue
Else
Deb=0
EndIf
EndIf
If Champ=Index And Deb
Chaine$=Chaine$+Car$
EndIf
Next i
ProcedureReturn Chaine$
EndProcedure
OpenConsole()
SubMesh = 0
If OpenFile(0,Source$)
PrintN("Ouverture du fichier Xml : " + Source$)
While Eof(0)=0
Ligne$=ReadString(0)
If FindString(Ligne$,"<faces count=",1)
Pos=FindString(Ligne$,"count=",1)
Pos + 7
NbFace=Val(Mid(Ligne$,Pos,Len(Ligne$)-Pos-1))
SubMesh + 1
PrintN("SubMesh No : " + Str(SubMesh))
PrintN("Nombre de triangles : " + Str(NbFace))
;Lecture des Faces
ClearList(Face())
For i=1 To NbFace
Ligne$=ReadString(0)
AddElement(Face())
Face()\v1=Val(StringFieldPerso(Ligne$,1))
Face()\v2=Val(StringFieldPerso(Ligne$,2))
Face()\v3=Val(StringFieldPerso(Ligne$,3))
Next i
EndIf
;Cherche les vertices
If FindString(Ligne$,"<geometry vertexcount=",1)
Pos=FindString(Ligne$,"count=",1)
Pos + 7
NbVertex=Val(Mid(Ligne$,Pos,Len(Ligne$)-Pos-1))
PrintN("Nombre de sommets : " + Str(NbVertex))
Dim Vertex.Vecteur(NbVertex)
Dim Normale.Vecteur(NbVertex)
EndIf
If FindString(Ligne$,"<vertexbuffer",1)
Index=0
EndIf
;Lecture des vertex
If FindString(Ligne$,"<position",1)
Vertex(Index)\x=ValF(StringFieldPerso(Ligne$,1))
Vertex(Index)\y=ValF(StringFieldPerso(Ligne$,2))
Vertex(Index)\z=ValF(StringFieldPerso(Ligne$,3))
If Vertex(Index)\x < MiniX
MiniX = Vertex(Index)\x
ElseIf Vertex(Index)\x > MaxiX
MaxiX = Vertex(Index)\x
EndIf
If Vertex(Index)\y < MiniY
MiniY = Vertex(Index)\y
ElseIf Vertex(Index)\y > MaxiY
MaxiY = Vertex(Index)\y
EndIf
If Vertex(Index)\z < MiniZ
MiniZ = Vertex(Index)\z
ElseIf Vertex(Index)\z > MaxiZ
MaxiZ = Vertex(Index)\z
EndIf
EndIf
;Lecture des normales
If FindString(Ligne$,"<normal",1)
Normale(Index)\x=ValF(StringFieldPerso(Ligne$,1))
Normale(Index)\y=ValF(StringFieldPerso(Ligne$,2))
Normale(Index)\z=ValF(StringFieldPerso(Ligne$,3))
Index + 1
EndIf
;On peut enregistrer ce submesh
If FindString(Ligne$,"</vertexbuffer>",1)
ForEach Face()
AddElement(ListTriangle())
;v1
ListTriangle()\P1\x=Vertex(Face()\v1)\x
ListTriangle()\P1\y=Vertex(Face()\v1)\y
ListTriangle()\P1\z=Vertex(Face()\v1)\z
;v2
ListTriangle()\P2\x=Vertex(Face()\v2)\x
ListTriangle()\P2\y=Vertex(Face()\v2)\y
ListTriangle()\P2\z=Vertex(Face()\v2)\z
;v3
ListTriangle()\P3\x=Vertex(Face()\v3)\x
ListTriangle()\P3\y=Vertex(Face()\v3)\y
ListTriangle()\P3\z=Vertex(Face()\v3)\z
ListTriangle()\Normale\x=(Normale(Face()\v1)\x + Normale(Face()\v2)\x +Normale(Face()\v3)\x)/3
ListTriangle()\Normale\y=(Normale(Face()\v1)\y + Normale(Face()\v2)\y +Normale(Face()\v3)\y)/3
ListTriangle()\Normale\z=(Normale(Face()\v1)\z + Normale(Face()\v2)\z +Normale(Face()\v3)\z)/3
Next
EndIf
Wend
CloseFile(0)
PrintN("Total triangles : " + Str(CountList(ListTriangle())))
EndIf
;Génère un fichier contenant la liste des triangles
If CreateFile(0,Destination$)
PrintN("Creation du fichier triangle : " + Destination$)
WriteLong(0,CountList(ListTriangle()))
ForEach ListTriangle()
WriteData(0,@ListTriangle(),SizeOf(Triangle))
Next
CloseFile(0)
PrintN("Operation terminee")
PrintN("Pressez la touche [Entree] pour quitter")
EndIf
PrintN("MiniX = " + StrF(MiniX,3))
PrintN("MaxiX = " + StrF(MaxiX,3))
PrintN("MiniY = " + StrF(MiniY,3))
PrintN("MaxiY = " + StrF(MaxiY,3))
PrintN("MiniZ = " + StrF(MiniZ,3))
PrintN("MaxiZ = " + StrF(MaxiZ,3))
Input()
CloseConsole()
EndPlease correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
Added octree (First one)
http://perso.wanadoo.fr/comtois/sources ... Octree.zip
all the source codes are included in the file
Any suggestions are welcome
[EDIT]
You need the lib M3D_Matrix3D to test
http://perso.wanadoo.fr/comtois/sources ... x3DV2i.zip
[EDIT2]
Update (11 ko)
http://perso.wanadoo.fr/comtois/sources/Include.zip
http://perso.wanadoo.fr/comtois/sources ... Octree.zip
all the source codes are included in the file
Any suggestions are welcome
[EDIT]
You need the lib M3D_Matrix3D to test
http://perso.wanadoo.fr/comtois/sources ... x3DV2i.zip
[EDIT2]
Update (11 ko)
http://perso.wanadoo.fr/comtois/sources/Include.zip
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/
The lib M3D_Matrix3D is useless
I copied the functions used of the lib M3D_Matrix3D in the Math.pbi file.
Now the lib is useless.
http://perso.wanadoo.fr/comtois/sources/Include.zip
[EDIT]
Archiv (147 ko) without DATA
http://perso.wanadoo.fr/comtois/sources ... nsData.zip
Now the lib is useless.
http://perso.wanadoo.fr/comtois/sources/Include.zip
[EDIT]
Archiv (147 ko) without DATA
http://perso.wanadoo.fr/comtois/sources ... nsData.zip
Please correct my english
http://purebasic.developpez.com/
http://purebasic.developpez.com/



