Code center > Darwinbots3
Fluid preview
Numsgil:
It's been about 5 years since I started serious work on DB3. I currently have about 100K lines of code and not a great deal to show for it... nevertheless, to mark the anniversary I've decided to release one of the more graphic experiments I've been toying around with.
The attached EXE is the test application I've been using to test fluid. It has a spinning square that moves back and forth, and little particles (circles) that react to the fluid-like forces that the box imparts on the surrounding fluid. There are 1000 particles and 24 'panels' (which are the cyan/yellow rectangles on the brown square around the edges. They're all that the fluid simulation actually knows about).
You can use left click+drag to move the camera around. The mouse wheel will zoom in and out.
There are three buttons to control the speed of the simulation. Pause is obvious, 'single step' will take a single simulation step forward in time. 'Frame lock' will cap the frame rate at 60 FPS. If you uncheck that box, it will go as fast as your computer is able. The 'reset' button on the bottom will warp everything back to the starting positions.
The core simulation is running single threaded, but the UI and graphics are all on separate threads, which is something that's important to me for DB3 so I've been experimenting with how it'll work. At the moment it's kind of hacked in there, but it works.
For the record, this is against revision 953 in the SVN repository.
...
Also, be sure that you've downloaded and installed the latest DirectX runtime: DX Runtime. It needs to be at least June 2010.
Ammeh:
:(
--- Code: ---Unhandled Exception: System.Reflection.TargetInvocationException: Exception has
been thrown by the target of an invocation. ---> SharpDX.SharpDXException: d3dco
mpiler_43.dll
at SharpDX.Utilities.LoadLibrary(String dllName)
at SharpDX.D3DCompiler.D3D.get_DllHandle0()
at SharpDX.D3DCompiler.D3D.get_D3DPreprocess_()
at SharpDX.D3DCompiler.D3D.Preprocess(IntPtr srcDataRef, PointerSize srcDataS
ize, String sourceNameRef, ShaderMacro[] definesRef, IntPtr includeRef, Blob& co
deTextOut, Blob& errorMsgsOut)
at SharpDX.D3DCompiler.ShaderBytecode.Preprocess(IntPtr shaderSourcePtr, Int3
2 shaderSourceLength, ShaderMacro[] defines, Include include, String& compilatio
nErrors)
at SharpDX.D3DCompiler.ShaderBytecode.Preprocess(String shaderSource, ShaderM
acro[] defines, Include include, String& compilationErrors)
at Blacklight.SharpDX9.Module..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOn
ly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Bo
olean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipChec
kThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean s
kipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at ModuleManager.ModuleManager`1.GetModule(String moduleName)
at Slipstream.Testbed.Program.Main(String[] args)
--- End code ---
rwill128:
Same as Ammeh. :(
Pascal666:
It works here, but shouldn't there be more velocity added to the surrounding particles?
Like this: http://nerget.com/fluidSim/
Numsgil:
--- Quote from: Ammeh on July 09, 2013, 07:27:35 AM ---:(
--- Code: ---Unhandled Exception: System.Reflection.TargetInvocationException: Exception has
been thrown by the target of an invocation. ---> SharpDX.SharpDXException: d3dco
mpiler_43.dll
at SharpDX.Utilities.LoadLibrary(String dllName)
at SharpDX.D3DCompiler.D3D.get_DllHandle0()
at SharpDX.D3DCompiler.D3D.get_D3DPreprocess_()
at SharpDX.D3DCompiler.D3D.Preprocess(IntPtr srcDataRef, PointerSize srcDataS
ize, String sourceNameRef, ShaderMacro[] definesRef, IntPtr includeRef, Blob& co
deTextOut, Blob& errorMsgsOut)
at SharpDX.D3DCompiler.ShaderBytecode.Preprocess(IntPtr shaderSourcePtr, Int3
2 shaderSourceLength, ShaderMacro[] defines, Include include, String& compilatio
nErrors)
at SharpDX.D3DCompiler.ShaderBytecode.Preprocess(String shaderSource, ShaderM
acro[] defines, Include include, String& compilationErrors)
at Blacklight.SharpDX9.Module..ctor()
--- End of inner exception stack trace ---
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOn
ly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Bo
olean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipChec
kThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean s
kipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at ModuleManager.ModuleManager`1.GetModule(String moduleName)
at Slipstream.Testbed.Program.Main(String[] args)
--- End code ---
--- End quote ---
That would be the video card shader issue I mentioned. Your video card isn't new enough :/ When I have some spare energy I'll make the shader simpler, but I'm not sure when I'll get around to it.
...
--- Quote ---It works here, but shouldn't there be more velocity added to the surrounding particles?
--- End quote ---
The fluid sim in that link is a "Velocity based Eulerian grid". Mine is a "Vorticity based Lagrangian particle" sim. Which is a fancy way of saying they work differently, at a very fundamental level, even though they're both trying to simulate the same thing.
For mine, there's no increased cost or decreased fidelity as the sim gets bigger (spatially). The particles you see are purely for visual effect and don't change the behavior of the underlying fluid at all. The behavior of the fluid is only influenced by the 24 panels you see on the square, which themselves can only attract or repel particles (imagine the panels are bar magnets, and the particles are iron flakes). It actually shares a lot in common with N-body gravity sims like this.
The downside is that you don't get any of the inertia you get from a normal grid sim. Once the body stops moving through the fluid, all the particles stop moving instantaneously. It's possible to add in fake, invisible bodies to the sim whose job is to keep the intertia of the sim going, but they're expensive, so I might just ignore them entirely. The fluid ends up behaving a little oddly, but it's really really fast. In the final DB3, the cost would scale only with the number of bots, which is my primary goal.
Navigation
[0] Message Index
[#] Next page
Go to full version