It is currently September 8th, 2010, 3:51 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: KeyMappings
PostPosted: February 17th, 2010, 1:26 pm 
Offline
3D Simulation Rookie
3D Simulation Rookie

Joined: February 16th, 2010, 5:11 pm
Posts: 5
Hi,

quick question, i've been running through the tutorials for rendering. There are clearly more control keys than those documented in the code - is there a list somewhere?

some of them seem kinda odd - eg q and d for left and right pan ?!

Thanks

David


Top
 Profile  
 
 Post subject: Re: KeyMappings
PostPosted: February 17th, 2010, 1:57 pm 
Offline
SimplySim Team
SimplySim Team
User avatar

Joined: December 11th, 2008, 7:39 pm
Posts: 75
Key Mappings could be different for each tutorial.
Actually, the key mappings are part of the tutorial codes and you could find them in the source files. For example rendering tutorials 2 make the cubes rotate when "Space" is pressed.

For camera movements, we use a SimplyCube feature named "Controllers". A controller could be attached to any SceneNode and performs an operation on each update. We provide a default controller in the engine that move a node according keyboard, mouse and gamepad inputs named "DefaultFreeController".
The mapping for this controller is :
  • LeftAlt+LeftMouse pressed => pan tilt
  • LeftAlt+RightMouse pressed => move forward, backward
  • LeftAlt+MiddleMouse pressed => move up, down, left, right
  • LeftShift => increase movement speed
  • Up,Down,Left,Right or Q,S,D,Z => move up, down, left, right

Q,S,D,Z is useful on AZERTY keyboard and not QWERTY. Our controller doesn't test the keyboard type. We will improve that for the release.

If you want to have your own binding, you could :
  • totally rewrite a controller (implement the SimplySim.Xna.Engine.Scene.Controllers.INodeController interface, and add you controller to the camera scene node)
  • write a class that implements SimplySim.Xna.Engine.Scene.Controllers.IFreeControllerDevice and add its to the "Devices" list on the DefaultFreeController. To give you an idea, I join the code for the default keyboard controller (the AZERTY one)

    Code:
    class DefaultFreeKeyboardController : IFreeControllerDevice
        {
            public void Update(EngineWindow window, EngineTime time, ref Vector3 position, ref float pan, ref float tilt, float TranslateSpeed, float RotateSensivity)
            {
                float realNodeSpeed = TranslateSpeed;
                if (window.KeyboardState.IsKeyDown(Keys.LeftShift) || window.KeyboardState.IsKeyDown(Keys.RightShift))
                {
                    realNodeSpeed *= 10;
                }
                // Forward
                if (window.KeyboardState.IsKeyDown(Keys.Up) || window.KeyboardState.IsKeyDown(Keys.Z))
                {
                    Vector3 v = new Vector3(0, 0, realNodeSpeed * (float)time.ElapsedTime.TotalMilliseconds);
                    position += v;
                }
                // Backward
                else if (window.KeyboardState.IsKeyDown(Keys.Down) || window.KeyboardState.IsKeyDown(Keys.S))
                {
                    Vector3 v = new Vector3(0, 0, -realNodeSpeed * (float)time.ElapsedTime.TotalMilliseconds);
                    position += v;
                }
                // Left
                if (window.KeyboardState.IsKeyDown(Keys.Left) || window.KeyboardState.IsKeyDown(Keys.Q))
                {
                    Vector3 v = new Vector3(realNodeSpeed * (float)time.ElapsedTime.TotalMilliseconds, 0, 0);
                    position += v;
                }
                // Right
                else if (window.KeyboardState.IsKeyDown(Keys.Right) || window.KeyboardState.IsKeyDown(Keys.D))
                {
                    Vector3 v = new Vector3(-realNodeSpeed * (float)time.ElapsedTime.TotalMilliseconds, 0, 0);
                    position += v;
                }
            }
        }

Regards

_________________
Vincent Maurin
Lead Software Engineer
SimplySim


Top
 Profile  
 
 Post subject: Re: KeyMappings
PostPosted: February 17th, 2010, 6:43 pm 
Offline
3D Simulation Rookie
3D Simulation Rookie

Joined: February 16th, 2010, 5:11 pm
Posts: 5
Thanks, thats helpful to know. I'd not heard of an AZERTY keyboard before.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group. Color scheme by ColorizeIt!