Original Post
How do you like it?
Quote:
Original post by Johnkol
That is superb stuff!! That looks so optimized! I am trying to do something similar. I am implementing the flock behavior based off Craig Reynold's paper. I was able to achieve it in 2d, however in 3d space I have a few bugs. Can you tell me how you are calculating the visibility of each of the boids in 3d space? Is it using a solid angle? Any help would be greatly appreciated! Thank you!
@HanzDog: Nice! I'm impressed by the sheer number of agents. This is running on the CPU (not GPU)?
@Johnkol: I obviously can't say how precisely HanzDog did it, but I can tell you how I would.
1. Visibility: If player i has position pi and player j has position pj, then player j is visible from player i iff
dot(pj-pi, vi) > ||pj-pi|| ||vi|| cos(thetamax)
and
||pj-pi|| < Rmax
where vi is the heading vector for the ith agent and thetamax, Rmax are the angle and radius of the visibility cone.
2. Turning
2a. Method 1:
If h is the desired heading angle, v is the current velocity, and defining
d = h - v
u = d - dot(d,v)/dot(v,v) v
then the differential equation
dv/dt = f(||u||) u
describes the vector v turning continuously to face h, where f is any positive function. For instance,
f(||u||) = 1
describes proportional control (steer at a rate proportional to how far from the desired heading you are), and,
f(||u||) = w/||u||
for some positive constant 'w' describes bang-bang control (steer at a constant rate 'w').
I would simulate this ODE with a simple predictor-corrector scheme. E.g., use basic Euler integration, but occasionally renormalize 'v' so it has the correct length.
2b. The axis of rotation is given by the cross product of h and v. Rotate v by an appropriate amount about this axis. This is basically the exact version of 2a.
Hi, I do steering behavior in 3D too, and I only have one problem: I can't calculate right rotations for my flying objects.
If I understand from your post, I need find cross product via old velocity-vector (v) and new velocity-vector (h), and use it for rotation quaternion?
[attachment=1847:flock.jpg]
float angle = atan2(velocity.y, velocity.x) * RAD2DEG;
I might have time later to post one.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more