How to make the mouse related to the 3d space?

Oct 18, 2009 at 5:41 AM
I wanna get the mouse position related the the Balder 3D space.
 So I wrote the code below:
void MouseManager_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
            Point p = e.GetPosition(????);
??? = what? 
I want to get the mouse position related to the camera's shadow onto the screen.thanks very much. 
Oct 19, 2009 at 3:56 PM

Is there a function like gluUnProject of openGL in balder?

Oct 20, 2009 at 6:20 AM


We've been designing the input system for Balder since summer, but haven't landed everything yet. It will provide support for Mouse, Keyboard for Silverlight and other inputs for future platform support. For now we do not have a good solution for this.

Oct 20, 2009 at 6:21 AM
bleastrind wrote:

Is there a function like gluUnProject of openGL in balder?

Sorry, we don't have this yet.   I'll hand this over to the guy in charge of the maths these days and see how fast he can get it in there. This would help a lot for manipulating objects by Mouse, and would probably help out Botma a bit as well. 

Oct 31, 2009 at 2:25 PM

I have a similar question....hit detection.  If I am trying to select an object on screen, how do I detect which object I have clicked on?

Oct 31, 2009 at 9:53 PM
Edited Oct 31, 2009 at 10:11 PM

We have this on our issue list, tomorrow the team will have a skype meeting to prioritize the tasks and assign them to each other. This is a natural part of the input system we're designing. Sorry it has taken this long. We're a bit understaffed with the N1H1 virus going around. 

Nov 1, 2009 at 5:46 PM

We had a meeting today about prioritizing the remaining features we want in for version 1.0 and chose to put this very high, resulting in me implementing some of it already.

I've added a Unproject() extension method found in Balder.Core.Extensions that takes a Vector being the source (Typically you'll set the 2D X,Y and leave Z to be Zero or NearPlane distance), the projection matrix (Found in Camera), View Matrix (Also in Camera) and a World Matrix, for this type of thing use the Matrix.Identity for World.

That will at least give you the 3D coordinate that was pressed.


The next step for me is to implement a Ray class that can be used to calculate Object intersection and find what object was pressed.


When it is all implemented though, you'll have the luxury of adding an eventhandler on an object, typically:

MouseClick, MouseDrag and such. 


Our prioritized list is over at GitHub under Issues.

Nov 1, 2009 at 9:16 PM

A little note here. 

I've found something wrong with the Matrix.Invert() method - so this new Unproject() method doesn't really work that well.

I'm looking at it and at the same time getting the Ray class and all its dependencies up and running. Hopefully I'll have this one nailed tomorrow, including the event model as described.

Nov 3, 2009 at 3:12 PM

Just to keep you guys posted on the progress.

I've been working intensively with this the last couple of days, but can't seem to shake a bug in the calculations.
I've implemented a Ray class, BoundSphere, BoundingBox and BoundingFrustum and implemented intersections for all this.

Also added a method on Scene that is called GetNodeAtScreenCoordinate() taking the viewport in as parameter.

Hopefully I'll hunt it down soon and commit to the repository at GitHub. 

I'll keep you all posted.

Nov 4, 2009 at 7:05 PM

After quite a bit of struggle with this, it is finally working. 

The method on Scene is now working as it should. But one should be careful to use this from a Mouse event in Silverlight, as you might get into Threading issues. Instead, there is now a Hover event for Nodes one can use. I will over the next couple of days clean up a bit and add more events. 

It has been pushed to the Development branch over at GitHub:

There are other changes there as well. The coordinate system is now about to make a little bit more sense. Positive Y is now upwards. Yippppi.  :)

BoundingSpheres can be visualized by adding the following line of code to the Initialize() method of your game : 
EngineRuntime.Instance.DebugLevel |= DebugLevel.BoundingSpheres;


Also, the rendering pipeline has been optimized a little bit.

Hope this helps. I'll keep you all posted on the new events when they're ready and good to go. 



Nov 4, 2009 at 8:32 PM

Awesome work!!! Thanks....

Nov 5, 2009 at 6:40 PM


This is so much fun, I can't wait to get back from work to continue working on the project. :) 

Apr 30, 2010 at 12:29 AM
Edited Apr 30, 2010 at 12:21 PM


public MainPage()
            this.MouseLeftButtonDown += new MouseButtonEventHandler(MainPage_MouseLeftButtonDown);

        void MainPage_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
            Point p = e.GetPosition(SceneClass);	//SceneClass is Control that represent Game Class
            MessageBox.Show(p.X.ToString() + "," + p.Y.ToString());

it may be useful for 2D


May 1, 2010 at 2:31 AM

All Nodes has Mouse events, so you only need to hook up to those. And in fact, Nodes also has a Tooltip property if you want to have tooltips on them.  All this is for the latest source code, not the release. 

There will soon be a new binary release with all these features in it.

Oct 27, 2010 at 6:07 AM


    I am trying to drag the mesh object and put it to the position on mouse button up. But the object does not budge. Tried using Matrix, successfully used createrotation method, but couldn't find out how to explore Ray class more. Can you please direct me to a proper tutorial/sample or anything that would be helpful . FYI, my balder version is