RVO Library: Reciprocal Collision Avoidance (DLL)

Hi,

This is my last stuff. WIP :wink:

This library is multi-core (OpenMP). Place VCOMP100.DLL and RVODLL.dll in the Windows\system32 folder
The orginal video and web site

http://gamma.cs.unc.edu/RVO2/
http://gamma.cs.unc.edu/CA/

My Blitz3D version Video : http://www.youtube.com/watch?v=-1On2Kzb6FM

I’m working on some Unity3D demo :smile:

Win32 Standalone. Unity 2.6.1 PRO and Indie.
Unity 3 PRO only. System.Runtime.InteropServices is deactivate in the free version.
:evil: :evil: As far i know, this is the ONLY development tool under Windows (2d or 3d, Free or Not), which does not allow access to native DLLs.:evil: :evil: Mesquinerie !!!

//***************************************************************************
// RVO2 Library: Reciprocal Collision Avoidance DLL (c) ZJP //
//***************************************************************************
using UnityEngine;
using System;
using System.Collections;
using System.Runtime.InteropServices;

public class RVO_DLL : MonoBehaviour 
{
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_setTimeStep@4")]	private static extern void RVO_setTimeStep(float RVOTime);
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_setAgentDefaults@24")]private static extern void RVO_setAgentDefaults(float neighborDist,
													int maxNeighbors,float timeHorizon,
													float timeHorizonObst,float radius,float maxSpeed);
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_addAgent@16")]     private static extern int   RVO_addAgent(float PosX,float PosZ,float GoalX,float GoalZ);
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_getGlobalTime@0")] private static extern float RVO_getGlobalTime();
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_getNumAgents@0")]  private static extern int   RVO_getNumAgents();

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_getAgentPositionX@4")]  private static extern float RVO_getAgentPositionX(int agent);
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_getAgentPositionZ@4")]  private static extern float RVO_getAgentPositionZ(int agent);

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_open@0")]   private static extern void RVO_open();
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_close@0")]  private static extern void RVO_close();

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_Update@0")]  private static extern void RVO_Update();
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_Update2@0")] private static extern void RVO_Update2();

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_getReachedGoal@4")]  private static extern int RVO_getReachedGoal(float radius);

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_setObstacleVerticle@12")]  private static extern void RVO_setObstacleVerticle(int obstacle,float VerticleX,float VerticleZ);

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_addObstacle@4")]  private static extern void RVO_addObstacle(int obstacle);

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_processObstacles@0")]  private static extern void RVO_processObstacles();

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_setAgentGoalPosition@12")]  private static extern void RVO_setAgentGoalPosition(int agent,float GoalPX,float GoalPZ);

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_getGoalPositionX@4")]  private static extern float RVO_getGoalPositionX(int agent);
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_getGoalPositionZ@4")]  private static extern float RVO_getGoalPositionZ(int agent);

	[DllImport ("RVODLL.dll", EntryPoint="_RVO_setAgentPosition@12")]   private static extern void RVO_setAgentPosition(int agent, float PosX, float PosZ);
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_setAgentVelocity@12")]  private static extern void RVO_setAgentVelocity(int agent, float VelX, float VelZ);
	[DllImport ("RVODLL.dll", EntryPoint="_RVO_setAgentRadius@8")]      private static extern void RVO_setAgentRadius(int agent, float radius);

	void Start ()
	{
		RVO_open();
	}
	
    void OnDisable()
	{ 
		RVO_close();
    } 
}

Edit :
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.

393484–13504–$rvo_unity_dll_141.rar (40.8 KB)

1 Like

any example?

I’m working on it :wink:

JP

Public apology to Unity Techology for having treated them as ā€œpettinessā€ for disabling the ā€œSystem.Runtime.InteropServicesā€ allowing access to native DLLs.
It works again. Thanks guys :wink: :wink:

JP

any update on the example ? I’m anxiously awaiting it = ]

Also quite interested in watching a demo of this…

Wow, the demo is very impressive, great work guys!

This could be of interest: http://www.youtube.com/watch?v=9YH1fJ6XQno

Code available once I clarify licensing issues. It is a pure C# version (meaning it will work on all platforms / Unity editions), but you loose parallelism…

[Edit: source code released at http://rvo-unity.chezslan.fr]

Nice :wink:

Hey Slan,

I was checking the source, it seems there’s no scene file in there.
Is it supose to be that way ?

thanks,
Bruno

After importing the unitypackage, you have to load the main scene (creatively named ā€˜Main’) from the project pane before you can hit ā€˜Play’

I know how to load a scene :stuck_out_tongue:
Doesn’t open with Unity 2.6, only with 3.0., isn’t it compatible with 2.6 ?
thanks

Unfortunately, it is not. It should not be very difficult to backport to 2.6 but to be honest I have not tried it myself.

Anyway, for those interested, Version 2.0 has just been made available (with Multithreading and rendering optimizations).

Looks amazing, I grabbed the demo scene but haven’t been able to pick it apart enough to use it in a game idea I have. With everything happening in the Main.cs and no examples of setting up a character moving using the scripts I just can’t figure out how to use this for other purposes.

Has anyone been able to use this in a more game-ish example? I’d love to check it out if so. A scene with more interactivity and transparency as to how everything is setup would go a long way.

If you dare to share more details I’d be happy to help. Basically the plugin has the same interface as the original code: you add agents, obstacles and draw each agent after stepping the simulation…

I’ve did a quick run of your demo and man this is great! Been looking for crowd/RVO in true C# for my navmesh pathfinding (hobby thing)

I only have a rough understanding of RVO and I did not read all your code. What is the best way to implement RVO with a navmesh? Is it as simple as targeting inner holes and make them convex obstacles? I don’t really care about 1000+ agent, I would only use about 20-50 max.

I’m also really interested in ā€œā€œbreaking itā€ā€ appart to build Monobehavior around it.

List of MonoBehavior that would be more suitable for Unity-scenes

  • Simulation (empty GameObject)
  • Agent (one per agent, capsule / character / etc)
  • Obstacles (one per obstacle, could also project collider into 2D convex polygon)

I want to ask, is it possible if I just want to use Collison avoidance from RVO using the library from : Collision Avoidance ? And if it’s possible can you tell me how ?, since I just need the obstacle avoidance part.

Please whoever know about it, please tell me.