RVO2 Library: Reciprocal Collision Avoidance DLL
Blitz3D Forums/Blitz3D Userlibs/RVO2 Library: Reciprocal Collision Avoidance DLL
| ||
Hi, This is my last stuff. WIP ;) The DLL : http://www.zinfo972.net/pubip/rvo_b3d_dll.rar This library is multicore (OpenMP). Place the dll VCOMP100.DLL in the Windows\system32 folder ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; RVO2 Library: Reciprocal Collision Avoidance For Real-Time Multi-Agent Simulation ; RVO2 dll (c) 2010 ZJP www.zinfo972.net/pubip/rvo_b3d_dll.rar ; http://gamma.cs.unc.edu/RVO2/ ; http://gamma.cs.unc.edu/RVO2/documentation/2.0/whatsnew.html ; http://gamma.cs.unc.edu/RVO2/documentation/2.0/using.html ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Graphics3D 640,480,32,2 SetBuffer BackBuffer() camera=CreateCamera() CameraClsColor camera,100,100,100 PositionEntity camera,0,200,0 RotateEntity camera,90,0,0 light=CreateLight() RotateEntity light,90,0,0 ; Create agent ******************************** AgentCub1 = CreateCube() EntityColor AgentCub1,200,0,0 AgentCub2 = CreateCube() EntityColor AgentCub2,0,200,0 AgentCub3 = CreateCube() EntityColor AgentCub3,0,0,200 AgentCub4 = CreateCube() EntityColor AgentCub4,200,200,0 ; Create goal ********************************** GoalPh1 = CreateSphere() EntityColor GoalPh1,100,0,0 GoalPh2 = CreateSphere() EntityColor GoalPh2,0,100,0 GoalPh3 = CreateSphere() EntityColor GoalPh3,0,0,100 GoalPh4 = CreateSphere() EntityColor GoalPh4,100,100,0 ; Initial Agent position ************************ PosXAG1#= -100 PosZAG1#= 100 PosXAG2#= 100 PosZAG2#= 100 PosXAG3#= 100 PosZAG3#= -100 PosXAG4#= -100 PosZAG4#= -100 ; Goal position ********************************* PosXGO1#= 100 PosZGO1#= -100 PosXGO2#= -100 PosZGO2#= -100 PosXGO3#= -100 PosZGO3#= 100 PosXGO4#= 100 PosZGO4#= 100 PositionEntity GoalPh1,PosXGO1,0,PosZGO1 PositionEntity GoalPh2,PosXGO2,0,PosZGO2 PositionEntity GoalPh3,PosXGO3,0,PosZGO3 PositionEntity GoalPh4,PosXGO4,0,PosZGO4 ;************************************************ ; init the Lib RVO_open() ; Set time step RVO_setTimeStep(1.0) ; set default agent param RVO_setAgentDefaults( 15.0, 10, 20.0, 5.0, 2.0, 2.0 ) ; Create four agent with goal position agent1% = RVO_addAgent(PosXAG1#,PosZAG1#,PosXGO1#,PosZGO1#) agent2% = RVO_addAgent(PosXAG2#,PosZAG2#,PosXGO2#,PosZGO2#) agent3% = RVO_addAgent(PosXAG3#,PosZAG3#,PosXGO3#,PosZGO3#) agent4% = RVO_addAgent(PosXAG4#,PosZAG4#,PosXGO4#,PosZGO4#) ; create obstacle (1 to 32!!!!) ; Obstacle numbre,Postion X, position Z,witdh, depth createobstacle(1,10,0,50,5) createobstacle(2,-80,0,30,47) ; Build ALL obstable RVO_processObstacles() resutl1%=0 While Not (KeyDown(1)+resutl1) RenderWorld ; All agent arrived? ; param : radius of the detection resutl1%= RVO_getReachedGoal(1.0) ; Get X and Z of the agents PosXAG1 = RVO_getAgentPositionX(agent1%) : PosZAG1 = RVO_getAgentPositionZ(agent1%) PosXAG2 = RVO_getAgentPositionX(agent2%) : PosZAG2 = RVO_getAgentPositionZ(agent2%) PosXAG3 = RVO_getAgentPositionX(agent3%) : PosZAG3 = RVO_getAgentPositionZ(agent3%) PosXAG4 = RVO_getAgentPositionX(agent4%) : PosZAG4 = RVO_getAgentPositionZ(agent4%) PositionEntity AgentCub1,PosXAG1,0,PosZAG1 PositionEntity AgentCub2,PosXAG2,0,PosZAG2 PositionEntity AgentCub3,PosXAG3,0,PosZAG3 PositionEntity AgentCub4,PosXAG4,0,PosZAG4 ; Update the lib ;RVO_Update() RVO_Update2() Flip 1 Delay 1 Wend ; clode the lib RVO_close() End ;************************************************************************** ; create obstable Function createobstacle(obs%,x#,z#,lX#,lZ#) mesh% = CreateCube() ScaleMesh mesh,lX,1,lZ PositionEntity mesh,x,0,z xN# = x - (MeshWidth(mesh)/2) xP# = x + (MeshWidth(mesh)/2) zN# = z - (MeshDepth(mesh)/2) zP# = z + (MeshDepth(mesh)/2) ; set the verticle of the obstacle RVO_setObstacleVerticle(obs, xp,zp) RVO_setObstacleVerticle(obs, xn,zp) RVO_setObstacleVerticle(obs, xn,zn) RVO_setObstacleVerticle(obs, xp,zn) ; add to the lib RVO_addObstacle(obs) End Function ;************************************************************************** 360 "Circles Agents" ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ; RVO2 Library: Reciprocal Collision Avoidance For Real-Time Multi-Agent Simulation ; RVO2 dll (c) 2010 ZJP http://www.zinfo972.net/pubip/rvo_b3d_dll.rar ; http://gamma.cs.unc.edu/RVO2/ ; http://gamma.cs.unc.edu/RVO2/documentation/2.0/whatsnew.html ; http://gamma.cs.unc.edu/RVO2/documentation/2.0/using.html ; http://www.youtube.com/watch?v=1Fn3Mz6f5xA ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Graphics3D 640,480,32,2 SetBuffer BackBuffer() ;*********************************************************************************** ; Author: Krischan Dim GradientR%(0),GradientG%(0),GradientB%(0),Percent#(0),Red%(0),Green%(0),Blue%(0) ; Create a gradient spectrum for 360 agents Restore Spectrum CreateGradient(11,360) ;*********************************************************************************** camera=CreateCamera() CameraClsColor camera,100,100,100 PositionEntity camera,0,280,0 RotateEntity camera,90,0,0 light=CreateLight() RotateEntity light,90,0,0 ; init the Lib RVO_open() ; Set time step RVO_setTimeStep(0.50) ; set default agent param RVO_setAgentDefaults( 15.0, 100, 20.0, 1.0, 1.5, 1.0 ) ;; create obstacle (1 to 32!!!!) ;; Obstacle numbre,Postion X, position Z,witdh, depth ;createobstacle(1,0,0,30,1) ;createobstacle(2,80,0,1,40) ;; Build ALL obstable ;RVO_processObstacles() ; Create agent ******************************** Dim AgtMesh(360) Dim AgtRVO(360) agm%=359 For i=0 To agm AgtMesh(i) = CreateSphere() EntityColor AgtMesh(i),GradientR(i),GradientG(i),GradientB(i) ScaleEntity AgtMesh(i),1.5,1.5,1.5 PosXAgent# = 200*Sin(i) PosZAgent# = 200*Cos(i) PosXGoal# = -PosXAgent# PosZGoal# = -PosZAgent# PositionEntity AgtMesh(i),PosXAgent,0,PosZAgent AgtRVO(i) = RVO_addAgent(PosXAgent,PosZAgent ,PosXGoal,PosZGoal) Next resutl1%=0 While Not (KeyDown(1)+resutl1) RenderWorld ; All agent arrived? ; param : radius of the detection resutl1%= RVO_getReachedGoal(1.0) ; Get X and Z of the agents For i=0 To agm PosXAgent# = RVO_getAgentPositionX(AgtRVO(i)) PosZAgent# = RVO_getAgentPositionZ(AgtRVO(i)) PositionEntity AgtMesh(i),PosXAgent#,0,PosZAgent# Next ; Update the lib RVO_Update2() ;RVO_Update() Flip 1 Delay 1 Wend ; clode the lib RVO_close() End ;************************************************************************** ; create obstable Function createobstacle(obs%,x#,z#,lX#,lZ#) mesh% = CreateCube() ScaleMesh mesh,lX,1,lZ PositionEntity mesh,x,0,z xN# = x - (MeshWidth(mesh)/2) xP# = x + (MeshWidth(mesh)/2) zN# = z - (MeshDepth(mesh)/2) zP# = z + (MeshDepth(mesh)/2) ; set the verticle of the obstacle RVO_setObstacleVerticle(obs, xp,zp) RVO_setObstacleVerticle(obs, xn,zp) RVO_setObstacleVerticle(obs, xn,zn) RVO_setObstacleVerticle(obs, xp,zn) ; add to the lib RVO_addObstacle(obs) End Function ;************************************************************************** ;*********************************************************************************** ; Author: Krischan ; Date: 2009-02-21 16:56:13 ; Title: Color Gradient ; Description: Creates a color gradient between some colors ; Photoshop Gradient Simulation ; by Krischan webmaster(at)jaas.de ; ;*********************************************************************************** Function CreateGradient(colors%,steps%) Dim GradientR(steps),GradientG(steps),GradientB(steps),Percent(colors),Red(colors),Green(colors),Blue(colors) Local i%,pos1%,pos2%,pdiff% Local rdiff%,gdiff%,bdiff% Local rstep#,gstep#,bstep# Local counter%=1 ; read color codes For i=1 To colors : Read Percent(i),Red(i),Green(i),Blue(i) : Next ; calculate gradient While counter<colors ; transform percent value into step position pos1%=Percent(counter)*steps/100 pos2%=Percent(counter+1)*steps/100 ; calculate position difference pdiff%=pos2-pos1 ; calculate color difference rdiff%=Red(counter)-Red(counter+1) gdiff%=Green(counter)-Green(counter+1) bdiff%=Blue(counter)-Blue(counter+1) ; calculate color steps rstep#=rdiff*1.0/pdiff gstep#=gdiff*1.0/pdiff bstep#=bdiff*1.0/pdiff ; calculate "in-between" color codes For i=0 To pdiff GradientR(pos1+i)=Int(Red(counter)-(rstep*i)) GradientG(pos1+i)=Int(Green(counter)-(gstep*i)) GradientB(pos1+i)=Int(Blue(counter)-(bstep*i)) Next ; increment counter counter=counter+1 Wend End Function .Spectrum Data 0.0,255, 0, 0 ; red Data 10.0,255,128, 0 ; orange Data 20.0,255,255, 0 ; yellow Data 30.0,128,255, 0 ; yellow-green Data 40.0, 0,255, 0 ; green Data 50.0, 0,255,128 ; green-cyan Data 60.0, 0,255,255 ; cyan Data 70.0, 0,128,255 ; light blue Data 80.0, 0, 0,255 ; blue Data 90.0,128, 0,255 ; violet blue Data 100.0,255, 0,255 ; violet http://www.youtube.com/watch?v=-1On2Kzb6FM Need these DLLs Package redistribuable Microsoft Visual C++ 2010 (x86) OS 32bit - 4.6Mo http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84 Package redistribuable Microsoft Visual C++ 2010 (x64) OS 64bit - 5.5Mo http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=bd512d9e-43c8-4655-81bf-9350143d5867 Brief Description The Microsoft Visual C++ 2010 Redistributable Package installs runtime components of Visual C++ Libraries required to run applications developed with Visual C++ on a computer that does not have Visual C++ 2010 installed. JP |
| ||
it looks interesting, i'm getting a UserLib not found, i made an exe and it seems like the mising dll is: msvcp100.dll. I'm testing it under Vista. thank's Juan P.D. Nice to hear about you again (where were you been?) |
| ||
Hi, .RAR updated with msvcp100.dll ;) P.D. Nice to hear about you again (where were you been?) I haunting Unity's forums . But, I am regularly on those of Blitz. ;) JP |
| ||
hi thank's but... now i'm getting a msvcr100.dll lib not found! Juan |
| ||
Hi, If you have not "Visual Studio 2010", the Dlls are here : http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&FamilyID=bd512d9e-43c8-4655-81bf-9350143d5867 Sorry. I missed it. ;) JP |
| ||
thank's i finally downloaded the x86 version http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a7b7a05e-6de6-4d3a-a423-37bf0912db84 some one else may need it Juan |
| ||
Hi, First post edited. JP |
| ||
Hi Zjp Excellent work :) But i get a random crash with the example two, when a quit the app ? any idea ? Here is the windows debug code : And just a question, i see under the decls file that the functions don't use Y position ? only X/Z ? How it is possible using agents with a 3D level ? Last edited Tuesday 5th of October 2010 07:55:46 PM GMT |
| ||
This looks very interesting, adding to my list of top 10 bits of code to play with! |
| ||
Tx ;) JP |
| ||
This is great stuff! I hope you continue work on this. Keep up the good work. Btw Im getting a MAV at the end of the second sample (the one with the circle). Running win7 64bit. Last edited 2010 |
| ||
Hi, It seems that the problems came from OpenMP. The library is now compiled without it. Download updated ;) "....And just a question, i see under the decls file that the functions don't use Y position ? only X/Z ? How it is possible using agents with a 3D level ?.." Sorry. 2D only :( ;) JP Last edited 2010 |
| ||
Thanks, it works good now :) |