Hi nickske !
In version 1.3 we had an issue with object picking : the methods were visible but not usable.
As you are not the first to ask for that, I released a
new version of Brume that fixes the problem.
Now you can use PickObject and PickObjects methods directly form the Brume class (your main class) to get the object(s) that is(are) intersecting a ray.
The ray may be generated from the camera class (GetRayFromMouse method)
Here is a sample on a sphere :
- Code: Select all
BrumeFPSCamera camera1 = null;
BrumeLight directionalLight = null;
override protected void GameInit()
{
camera1 = new BrumeFPSCamera(this, "camera1", new BrumeVector(0, 0, -10.0f), new BrumeVector(0.0f, 0.0f, 1.0f), new BrumeVector(0.0f, 1.0f, 0.0f));
camera1.ChangeNearFarDistances(0.05f, 1000.0f);
this.SetActiveCamera(camera1);
this.BufferClearColor = Color.Black;
int level = 0;
this.GlobalAmbientLight = Color.FromArgb(255, level, level, level);
directionalLight = new BrumeDirectionalLight(this, "Directionnal Light", new BrumeVector(-1.0f, -1.0f, 1.0f), new BrumeVector(-1.0f, 1.0f, 1.0f), Color.FromArgb(255, 170, 170, 170));
directionalLight.Specular = Color.FromArgb(255, 255, 255, 255);
directionalLight.Enabled = true;
directionalLight.Update();
BrumeSphereColored sphere = new BrumeSphereColored(this, "sphere", 1.0f, 20, 20, Color.Red);
}
protected override void MoveScene(float fElapsedTime)
{
directionalLight.Update();
BrumeObject rayedObject = null;
int nbrIntersects = 0;
BrumeRay ray = this.ActiveCamera.GetRayFromMouse();
this.PickObject(ray, out rayedObject, out nbrIntersects );
this.ArialFont.Reset();
this.ArialFont.AddMsg(HUDX(10), HUDY(20), "Rayed object = " + rayedObject);
this.ArialFont.AddMsg(HUDX(10), HUDY(40), "Nbr Intersections = " + nbrIntersects);
// moving
base.MoveScene(fElapsedTime);
}
Don't forget that the release 1.4 is targetted for DirectX August 2006 SDK so update your libraries (you can get them
here)
Hope it helps !