Selecting a sphere

All about the core api and animation, input, sound, effect, collision and physics engines.
You can also post here your feature requests.

Moderator: Brume Dev Team

Selecting a sphere

Postby nickske on Tue Oct 10, 2006 7:07 am

Hi,

I've always been interested in designing 3D games and I think that I finally can start creating my own simple game with help of the Brume engine.

Before I explore the engine further, I want to know if it is for example possible to render a scene with a couple of spheres and then select a sphere with the mouse? Say for example I have 3 spheres, can I then select one of these sphere by clicking it with the mouse?


Best regards,

nickske
nickske
Brume Rookie
 
Posts: 1
Joined: Tue Oct 10, 2006 7:01 am

Postby Silmaryls on Tue Oct 10, 2006 11:02 pm

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 !
User avatar
Silmaryls
Brume Team Member
 
Posts: 340
Joined: Tue Feb 21, 2006 10:09 pm
Location: Paris - France


Return to Technical discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron