help with 2d drawing and camera movement in C# (2.0)

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Loki
Posts: 7
Joined: Fri Jul 14, 2006 1:09 pm
Location: Otherworld
Contact:

help with 2d drawing and camera movement in C# (2.0)

Post by Loki »

I'm trying to use the engine to draw a visual gridded representation of data.

I have a table of data, which includes coordinates and other data.

Using the coordinates I want to place a box of a predetermined size (16 pixels x 16 pixels) to a computed location on the screen. This is the easy part.

later I want to capture mouseovers, translate from the mouse x,y back to my coordinate system, and pull out data for that record.

The problem is that this data map is too large to fit on the screen (we are talking about 100,000 - 500,000 records in the data set.) I need a way to let the user move horizontal and vertical, but I want the data map to always face the camera.

I looked at some of the examples and I am stumped as to how to use the BillboardSceneNode and a camera to make it work.

here's what I have for code to set up the camera so far.

Code: Select all

node = device.SceneManager.AddBillboardSceneNode(null, new Dimension2Df(800f, 600f), new Vector3D(0, 0, 0), 0);

            ICameraSceneNode camera = device.SceneManager.AddCameraSceneNodeFPS(null, 100, 100, 0);
            camera.Position = new Vector3D(0, 0, 0);
The map is drawn out just fine, but the camera won't move. Here's the code for catching keyboard events to move the camera. I took this from one of the tutorials.

Code: Select all

public bool OnEvent(Event e)
        {
            if (node != null && e.Type == EventType.KeyInput &&
                !e.KeyPressedDown)
            {
                switch (e.Key)
                {
                    case KeyCode.KEY_ESCAPE:
                        device.CloseDevice();
                        break;
                    case KeyCode.KEY_KEY_W:
                    case KeyCode.KEY_KEY_S:
                        {
                            Vector3D v = node.Position;
                            v.Y += e.Key == KeyCode.KEY_KEY_W ? 2.0f : -2.0f;
                            node.Position = v;
                        }
                        return true;
                }
            }

            return false;
        }
I als tried using the regular camera scene node. This doesn't wok either. I also tried, in both cases, adding the node as the first parameter to the camera creation. This did not yield any results.

Code: Select all

ICameraSceneNode camera = device.SceneManager.AddCameraSceneNode(null, new Vector3D(0, 0, 0), new Vector3D(0, 0, 0), 1);
Here's what it looks like when I add the boxes.

Code: Select all

int rowId = maximumRange - y;
int columnId = z;

Position2D startPosition = new Position2D((columnId * padding) + (columnId * size) + horizontalOffset, (rowId * padding) + (rowId * size) + verticalOffset);
Position2D endPosition = new Position2D((columnId * padding) + (columnId * size) + size + horizontalOffset, (rowId * padding) + (rowId * size) + size + verticalOffset);

Rect plotBox = new Rect(startPosition, endPosition);

driver.Draw2DRectangle(brushColor, plotBox);
My only real desire to draw an image that is scrollable. Can anyone point me in the right direction? Thanks.
Teh Loki

Broken Bokken Productions
http://otherworld-rpg.com
Dances
Posts: 454
Joined: Sat Jul 02, 2005 1:45 am
Location: Canada
Contact:

Post by Dances »

Personally I wouldn't use a billboard at all; because it turns to face the camera.

I suppose you could create a plane and place your texture on that....

What I would do, though, is use draw2DImage and change the texture's co-ords when the mouse is on the edge of the screen...
Post Reply