Collision detection and response ( with codes )

Advanced game related topics
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Collision detection and response ( with codes )

Post by Comtois »

Last edited by Comtois on Sat Mar 25, 2006 11:32 pm, edited 2 times in total.
Please correct my english
http://purebasic.developpez.com/
pg
User
User
Posts: 75
Joined: Wed Jun 18, 2003 3:31 pm
Location: Swiss
Contact:

Post by pg »

Good work! Runs without problems. Collision detection is the most important functionality in 3D that nobody is talking about....
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post by Thalius »

:shock:

Great work Comtois !!
I ve been seekin of a simple BSP map replacement.. with some work this can be turned into a neat lil levelengine =)))

Thx for sharing!

Thalius
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post by Kale »

@Fred:
Shouldn't this http://www.purebasic.com/beta/Ogre1.0.3.zip be password'ed?
--Kale

Image
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

Kale wrote:@Fred:
Shouldn't this http://www.purebasic.com/beta/Ogre1.0.3.zip be password'ed?
Why ?
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Kale wrote:Shouldn't this http://www.purebasic.com/beta/Ogre1.0.3.zip be password'ed?
Hi Kale,

Good Q.

Its the official "unofficial" release announced here: viewtopic.php?t=16337

Perhaps not passworded so that it can be tried with the demo version of Pure? But also perhaps an oversight?


@Comtois,

Thanks! Your work is inspiring and insightful for me.
@}--`--,-- A rose by any other name ..
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

Please correct my english
http://purebasic.developpez.com/
benny
Enthusiast
Enthusiast
Posts: 465
Joined: Fri Apr 25, 2003 7:44 pm
Location: end of www
Contact:

Post by benny »

Comtois wrote:Thank's all :)

New demos using PB4.0 And http://www.delgine.com/

http://perso.wanadoo.fr/comtois/sources/Test3D.zip
Wohw. That's what I call fast sources for PB4.0 :!: Very good and thanks
for sharing :!:
regards,
benny!
-
pe0ple ar3 str4nge!!!
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

The source is the same , just needed PB4 for material script :)
Please correct my english
http://purebasic.developpez.com/
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post by Thalius »

Thx for Sharing ! Your Stuff is always so inspiring :D

Tho this one i dont seem to get running. And Yup i copyd the Engine3d.dll and
stlport_vc646.dll into the exe dir.

Start exe.
- Quick hd access
- nothing =P

Am i missing something?

Thalius
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

engine3D.dll from PB4.0 beta 1 ?

i try Castle.exe , and here is the Ogre.log
you can compare.
18:08:30: Creating resource group General
18:08:30: Registering ResourceManager for type Material
18:08:30: Registering ResourceManager for type Mesh
18:08:30: Registering ResourceManager for type Skeleton
18:08:30: OverlayElementFactory for type Panel registered.
18:08:30: OverlayElementFactory for type BorderPanel registered.
18:08:30: OverlayElementFactory for type TextArea registered.
18:08:30: Registering ResourceManager for type Font
18:08:30: ArchiveFactory for archive type FileSystem registered.
18:08:30: ArchiveFactory for archive type Zip registered.
18:08:30: DevIL version: Developer's Image Library (DevIL) 1.6.7 Aug 15 2005
18:08:30: DevIL image formats: jpg jpe jpeg pcx png tga vda icb vst raw
18:08:30: Registering ResourceManager for type HighLevelGpuProgram
18:08:30: Direct3D7 Rendering Subsystem created.
18:08:30: ----- DirectDraw Detection Starts
18:08:30: Detected DirectDraw driver Pilote d'affichage principal
18:08:30: Detected DirectDraw driver RADEON 9800 SERIES
18:08:30: ----- DirectDraw Detection Ends
18:08:30: Particle Emitter Type 'Point' registered
18:08:30: Particle Emitter Type 'Box' registered
18:08:30: Particle Emitter Type 'Ellipsoid' registered
18:08:30: Particle Emitter Type 'Cylinder' registered
18:08:30: Particle Emitter Type 'Ring' registered
18:08:30: Particle Emitter Type 'HollowEllipsoid' registered
18:08:30: Particle Affector Type 'LinearForce' registered
18:08:30: Particle Affector Type 'ColourFader' registered
18:08:30: Particle Affector Type 'ColourFader2' registered
18:08:30: Particle Affector Type 'ColourImage' registered
18:08:30: Particle Affector Type 'ColourInterpolator' registered
18:08:30: Particle Affector Type 'Scaler' registered
18:08:30: Particle Affector Type 'Rotator' registered
18:08:30: TerrainSceneManager: Registered a new PageSource for type Heightmap
18:08:30: Registering ResourceManager for type BspLevel
18:08:30: *-*-* OGRE Initialising
18:08:30: *-*-* Version 1.0.6 (Azathoth)
18:08:30: ***************************************
*** Direct3D Subsystem Initialising ***
***************************************
18:08:30: *****************************************
18:08:30: *** Direct3D Subsystem Initialised Ok ***
18:08:30: *****************************************
18:08:30: Registering ResourceManager for type GpuProgram
18:08:30: ResourceBackgroundQueue - threading disabled
18:08:30: Added resource location './Data/' of type 'FileSystem' to resource group 'General'
18:08:30: Added resource location './Data/skybox.zip' of type 'Zip' to resource group 'General'
18:08:30: Parsing scripts for resource group General
18:08:30: Parsing script Castle.material
18:08:30: Parsing script WareHouse.material
18:08:30: Parsing script waterworld.material
18:08:30: Finished parsing scripts for resource group General
18:08:30: D3D7 : Created D3D7 Rendering Window 'PureBasic Ogre' : 1280x1024, 32bpp
18:08:30: Creating DirectDraw surfaces for window with dimensions:
18:08:30: FULLSCREEN w:1280 h:1024 bpp:32
18:08:30: Successfully created full screen rendering surface / flipping chain.
18:08:30: ----- Direct3D Detection Starts
18:08:30: Detected Direct3D Device Microsoft Direct3D RGB Software Emulation
18:08:30: Direct3D Device Capabilities:
18:08:30: Hardware Accelerated: 0
18:08:30: Mipmapping: 1
18:08:30: Bilinear Filtering: 1
18:08:30: Trilinear Filtering: 1
18:08:30: Hardware Transform & Light: 0
18:08:30: Max rendering colour depth: 32
18:08:30: Max single-pass texture layers: 8
18:08:30: Pixel fog supported: 256
18:08:30: Vertex fog supported: 128
18:08:30: This device needs a Z-Buffer
18:08:30: Detected Direct3D Device Microsoft Direct3D Hardware acceleration through Direct3D HAL
18:08:30: Direct3D Device Capabilities:
18:08:30: Hardware Accelerated: 1
18:08:30: Mipmapping: 1
18:08:30: Bilinear Filtering: 1
18:08:30: Trilinear Filtering: 1
18:08:30: Hardware Transform & Light: 0
18:08:30: Max rendering colour depth: 32
18:08:30: Max single-pass texture layers: 8
18:08:30: Pixel fog supported: 256
18:08:30: Vertex fog supported: 128
18:08:30: This device needs a Z-Buffer
18:08:30: Detected Direct3D Device Microsoft Direct3D Hardware Transform and Lighting acceleration capable device
18:08:30: Direct3D Device Capabilities:
18:08:30: Hardware Accelerated: 1
18:08:30: Mipmapping: 1
18:08:30: Bilinear Filtering: 1
18:08:30: Trilinear Filtering: 1
18:08:30: Hardware Transform & Light: 1
18:08:30: Max rendering colour depth: 32
18:08:30: Max single-pass texture layers: 8
18:08:30: Pixel fog supported: 256
18:08:30: Vertex fog supported: 128
18:08:30: This device needs a Z-Buffer
18:08:30: ----- Direct3D Detection Ends
18:08:30: Determining best 3D Device...
18:08:30: Best 3D Device is: Microsoft Direct3D Hardware Transform and Lighting acceleration capable device
18:08:30: Direct3D - Creating Z-Buffer
18:08:30: Depth-Buffer created (32-bit, 8-bit stencil)
18:08:30: Registering ResourceManager for type Texture
18:08:30: RenderSystem capabilities
18:08:30: -------------------------
18:08:30: * Hardware generation of mipmaps: no
18:08:30: * Texture blending: yes
18:08:30: * Anisotropic texture filtering: yes
18:08:30: * Dot product texture operation: yes
18:08:30: * Cube mapping: yes
18:08:30: * Hardware stencil buffer: yes
18:08:30: - Stencil depth: 8
18:08:30: - Two sided stencil support: no
18:08:30: - Wrap stencil values: yes
18:08:30: * Hardware vertex / index buffers: no
18:08:30: * Vertex programs: no
18:08:30: * Fragment programs: no
18:08:30: * Texture Compression: no
18:08:30: * Scissor Rectangle: no
18:08:30: * Hardware Occlusion Query: no
18:08:30: * User clip planes: no
18:08:30: * VET_UBYTE4 vertex element type: no
18:08:30: * Infinite far plane projection: no
18:08:30: * Hardware render-to-texture: no
18:08:30: * Floating point textures: no
18:08:30: * Non-power-of-two textures: no
18:08:30: * Volume textures: no
18:08:30: Particle Renderer Type 'billboard' registered
18:08:30: Creating viewport on target 'PureBasic Ogre', rendering from camera 'MyCam', relative dimensions L: 0.00 T: 0.00 W: 1.00 H: 1.00 ZOrder: 0
18:08:30: Viewport for camera 'MyCam', actual dimensions L: 0 T: 0 W: 1280 H: 1024
18:08:30: Texture: Stevecube_fr.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
18:08:30: Texture: Stevecube_bk.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
18:08:30: Texture: Stevecube_lf.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
18:08:31: Texture: Stevecube_rt.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
18:08:31: Texture: Stevecube_up.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
18:08:31: Texture: Stevecube_dn.jpg: Loading 1 faces(PF_B8G8R8,512x512x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,512x512x1.
18:08:31: Mesh: Loading Castle.mesh.
18:08:31: Texture: Wall01.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
18:08:31: Texture: Wood01.jpg: Loading 1 faces(PF_B8G8R8,253x299x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x512x1.
18:08:31: Texture: Wood02.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
18:08:31: Texture: Floor02.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
18:08:31: Texture: Roof03.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
18:08:31: Texture: Wall02.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
18:08:31: Texture: Floor04.jpg: Loading 1 faces(PF_B8G8R8,256x256x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,256x256x1.
18:08:31: Texture: spot_shadow_fade.png: Loading 1 faces(PF_B8G8R8,128x128x1) with 0 generated mipmaps from Image. Internal format is PF_X8R8G8B8,128x128x1.
Please correct my english
http://purebasic.developpez.com/
Thalius
Enthusiast
Enthusiast
Posts: 711
Joined: Thu Jul 17, 2003 4:15 pm
Contact:

Post by Thalius »

Thx Comtois.


Mine stops suddenly .. eg just writes this:
18:16:39: Creating resource group General
18:16:39: Registering ResourceManager for type Material
18:16:39: Registering ResourceManager for type Mesh
18:16:39: Registering ResourceManager for type Skeleton
18:16:39: OverlayElementFactory for type Panel registered.
18:16:39: OverlayElementFactory for type BorderPanel registered.
18:16:39: OverlayElementFactory for type TextArea registered.
18:16:39: Registering ResourceManager for type Font
18:16:39: ArchiveFactory for archive type FileSystem registered.
18:16:39: ArchiveFactory for archive type Zip registered.
18:16:39: DevIL version: Developer's Image Library (DevIL) 1.6.7 Aug 15 2005
18:16:39: DevIL image formats: jpg jpe jpeg pcx png tga vda icb vst raw
18:16:39: Registering ResourceManager for type HighLevelGpuProgram
18:16:39: Direct3D7 Rendering Subsystem created.
18:16:39: ----- DirectDraw Detection Starts
18:16:39: Detected DirectDraw driver Primärer Anzeigetreiber
18:16:39: ----- DirectDraw Detection Ends
18:16:39: Particle Emitter Type 'Point' registered
18:16:39: Particle Emitter Type 'Box' registered
18:16:39: Particle Emitter Type 'Ellipsoid' registered
18:16:39: Particle Emitter Type 'Cylinder' registered
18:16:39: Particle Emitter Type 'Ring' registered
18:16:39: Particle Emitter Type 'HollowEllipsoid' registered
18:16:39: Particle Affector Type 'LinearForce' registered
18:16:39: Particle Affector Type 'ColourFader' registered
18:16:39: Particle Affector Type 'ColourFader2' registered
18:16:39: Particle Affector Type 'ColourImage' registered
18:16:39: Particle Affector Type 'ColourInterpolator' registered
18:16:39: Particle Affector Type 'Scaler' registered
18:16:39: Particle Affector Type 'Rotator' registered
18:16:39: TerrainSceneManager: Registered a new PageSource for type Heightmap
18:16:39: Registering ResourceManager for type BspLevel
18:16:39: *-*-* OGRE Initialising
18:16:39: *-*-* Version 1.0.6 (Azathoth)
The Buggy Example runs fine on teh otehr hand. Registers Textures and Objects nicely.

EDIT: hmmm.. starting to wonder if the d3d9dx lib is needed... since i just noticed i am missing that, however the other examples run fine on the other hand. *scratches head*
EDIT2: Updated dll s .. still nothing.. same on my other Machine ... hmm and yes i use the Beta 1 Engine3d.dll and the stl from /beta dir


Thalius
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Post by Comtois »

here is a simple source (without collision) , can you try ?

Code: Select all

;Comtois 07/02/06
;PB4.0 Beta 1

;-Initialisation
If ExamineDesktops()
  ScreenWidth  = DesktopWidth(0)
  ScreenHeight = DesktopHeight(0)
  ScreenDepth  = DesktopDepth(0)
Else
  End
EndIf
  
If InitEngine3D() = 0
  MessageRequester( "Erreur" , "Impossible d'initialiser la 3D , vérifiez la présence de engine3D.dll" , 0 )
  End
EndIf

 Add3DArchive("Data\"        , #PB_3DArchive_FileSystem)  
 Add3DArchive("Data\skybox.zip", #PB_3DArchive_Zip)
 Parse3DScripts()
If InitSprite() = 0 Or InitKeyboard() = 0 Or InitMouse() = 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

#PlayerSpeed = 7

;- Camera
CreateCamera(0, 0, 0 , 100 , 100)
CameraLocate(0,200,130,300)

AmbientColor(RGB(5,5,5))

;-Light
CreateLight(0,RGB(255,255,0))

;-SkyBox
SkyBox("Stevecube.jpg")

;-Mesh
Castle = LoadMesh(#PB_Any, "Castle.Mesh")
CreateEntity(#PB_Any, MeshID(Castle), 0) 


Define.f KeyX,KeyY,MouseX,MouseY
Repeat
	;ClearScreen(0)
	If ExamineKeyboard()
        
          If KeyboardPushed(#PB_Key_Left)
            KeyX = -#PlayerSpeed
          ElseIf KeyboardPushed(#PB_Key_Right)
            KeyX = #PlayerSpeed
          Else
            KeyX = 0
          EndIf
                    
          If KeyboardPushed(#PB_Key_Up)
            KeyY = -#PlayerSpeed
          ElseIf KeyboardPushed(#PB_Key_Down)
            KeyY = #PlayerSpeed
          Else
            KeyY = 0
          EndIf
          
        EndIf
        
        ExamineMouse()
        MouseX = -(MouseDeltaX()/5)*#PlayerSpeed/2
        MouseY =  -(MouseDeltaY()/5)*#PlayerSpeed/2
        
        RotateCamera(0, MouseX, MouseY, 0)
        MoveCamera(0, KeyX, 0, KeyY)
        RenderWorld()
        
        FlipBuffers()
   
Until KeyboardPushed(#PB_Key_Escape)
Please correct my english
http://purebasic.developpez.com/
User avatar
J. Baker
Addict
Addict
Posts: 2181
Joined: Sun Apr 27, 2003 8:12 am
Location: USA
Contact:

Post by J. Baker »

Nice examples Comtois. :D Looking forward to working with 3D in PB myself. Been waiting for this for some time now. Also, here's a cool terain editor that exports to the mesh format, http://freeworld3d.org/ .
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.
THCM
Enthusiast
Enthusiast
Posts: 276
Joined: Fri Apr 25, 2003 5:06 pm
Location: Gummersbach - Germany
Contact:

Post by THCM »

@Comtois - Do you know what "Parse3DScripts()" do? Does it load the existing .material scripts?
The Human Code Machine / Masters' Design Group
Post Reply