Page 1 of 1

Door and camera

Posted: Sun Dec 22, 2013 3:57 pm
by mr_join
Hello. I try to make the door like "amnesia" style. I create alter camera for grabber that activated when player click button and rotate door without change of player camera.
But after opening on some degree (90) the door start closing. I know that this is happened because start look at the other side. Has a way to rotate doot by direction but with physics and mouse acceleration ?? Now it's look like that ->
[youtube]
http://www.youtube.com/watch?v=0AIWu6UII20
[/youtube]

Re: Door and camera

Posted: Sun Dec 22, 2013 6:03 pm
by Norbo
I'm not clear on exactly what the control mechanism is.

-If it's a grabber like in the demos and the 'grab point' local to the door is picked at the beginning of the interaction and the 'goal' is moved with mouse movement, then this behavior would imply the goal is being positioned incorrectly. Somehow, the goal got moved to the wrong side of the door. Rotating the goal around the hinge axis based on user input might be a good option.

-If it's a grabber but the 'grab point' is being reset every single frame such that it grabs the other side of the door and the interaction controls flip, I would recommend picking the 'grab point' at the beginning of the interaction one time.

-If you're looking for a non-grabber-based approach, a RevoluteMotor could be used. Activate the motor and set the initial goal upon initial click. Change the goal according to user input. Since this requires a door-specialized system, I'd probably lean towards using the more general grabber.

Re: Door and camera

Posted: Sun Dec 22, 2013 6:29 pm
by mr_join
Thx for reply ! Yes, it's a grabber like in the demos. The model has a right offset (has some offset in 3d max from start axis)
Aaaand this is a code for rotate alter camera (for grabber. User camera is static while mouse key is pressed).
Can you give me some sample, plz ?

Code: Select all

if (mouseState != oldMouse)
{
  float dX = mouseState.X - Camera.Viewport.Width / 2;
  _yawB -= dX * Camera.Speed * dt;

  float dY = mouseState.Y - Camera.Viewport.Height / 2;
  _pitchB -= dY * Camera.Speed * dt;
//cut pitch when it more, less 90 degrees
  if (_pitchB > 90.0f)
      _pitchB = 90.0f;
  if (_pitchB < -90.0f)
       _pitchB = -90.0f;
}
    //cam for grabber
    //grab camera moved with player camera
    //GrabCamera.Position = Camera.Position;
    GrabCamera.Transform = Matrix.CreateRotationX(MathHelper.ToRadians(_pitchB))
           * Matrix.CreateRotationY(MathHelper.ToRadians(_yawB)) * Matrix.CreateTranslation(Camera.Position);
    ////player cam can move but can't view around
    Camera.Transform = Matrix.CreateRotationX(MathHelper.ToRadians(_pitch))
           * Matrix.CreateRotationY(MathHelper.ToRadians(_yaw)) * Matrix.CreateTranslation(Camera.Position);
}

                //set mouse position to center of window
                Mouse.SetPosition(Camera.Viewport.Width / 2, Camera.Viewport.Height / 2);

                oldMouse = mouseState;

Re: Door and camera

Posted: Sun Dec 22, 2013 7:14 pm
by Norbo
A separate camera isn't really needed to manage the grabber. If the control scheme is such that the player's camera doesn't move while opening doors, the grabber goal update should probably not be based on new ray cast results or anything related to a hidden camera's facing direction.

It would be easier to just use the user input to move the goal around directly. It is just a point in space, after all- you can do whatever you want with it. The only reason the BEPUphysicsDemos uses the camera to control the goal is that the user is 'carrying' the objects around.

I'm not sure what I would create a sample about, since the choice of how to move the goal is just about trying things out to find a nice 'feel'.