XNA Game Development Forums
2012/05/18 07:16:06 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Animations! But one problem...  (Read 1413 times)
EclipsE
Full Member
***
Offline Offline

Posts: 111


View Profile
« on: 2007/04/11 07:22:03 »

I experimented a little with the skinning sample downloaded from creators.xna.com and I've managed to add it into my own engine. I had several problems like the content processor was attaching the shader while processing the model but I've managed to deal with it. My problem is this. See the bad one picture.... You see the problem Smiley
Now, see the good one picture. You're probably asking, what the hell??
When i don't scale the model, i just load it and draw it, it looks like on the bad one picture.
When i scale the model to 0.001f, 0.001f, 0.001f it displays perfectly, with no other changes! Only i have to zoom in the camera to see the model.

What could it be??

I think it's something with the camera, because it's not the first model i've had problems. And just to know, I made my own camera class, which contains some of the code from HM Engine
Here it is

Code:
    #region NCameraTPS class
    /// <summary>
    /// A third person camera
    /// </summary>
    public class NCameraTPS : NCamera, NICamera, NICameraTPS
    {
        #region Variables
        NObject parentedObject = null;

        NInput input = null;

        #region Fields
        private float CAMERA_ROTATION_Y = 0.1f;
        private float CAMERA_ROTATION_X = 0.1f;

        private float hRotation = (float)Math.PI / 2.0f;
        private float vRotation = 0.5f;
        private float radius = 1.0f;

        private bool CAMERA_OBJECT_ROTATION = true;
        private bool CAMERA_ZOOM = true;

        private float zoomInValue = 0.01f;

        private float minRadius = 0.3f;
        private float maxRadius = 3.0f;

        /// <summary>
        /// The camera radius
        /// </summary>
        public float CameraRadius
        {
            get { return radius; }
            set
            {
                radius = value;

                if (radius < minRadius) radius = minRadius;
                if (radius > maxRadius) radius = maxRadius;

            }
        }

        /// <summary>
        /// Do we want to rotate around the object??
        /// </summary>
        public bool CameraRotateAroundObject
        {
            get { return CAMERA_OBJECT_ROTATION; }
            set { CAMERA_OBJECT_ROTATION = value; }
        }
     
        /// <summary>
        /// The Y rotation of the camera
        /// </summary>
        public float CameraRotationY
        {
            get { return CAMERA_ROTATION_Y; }
            set { CAMERA_ROTATION_Y = value; }
        }

        /// <summary>
        /// The X rotation of the camera
        /// </summary>
        public float CameraRotationX
        {
            get { return CAMERA_ROTATION_X; }
            set { CAMERA_ROTATION_X = value; }
        }

        /// <summary>
        /// The horizontal camera rotation
        /// </summary>
        public float CameraHorizontalRotation
        {
            get { return hRotation; }
            set { hRotation = value; }
        }

        /// <summary>
        /// The vertical camera rotation
        /// </summary>
        public float CameraVerticalRotation
        {
            get { return vRotation; }
            set { vRotation = value; }
        }

        /// <summary>
        /// Do we want to zoom into the object??
        /// </summary>
        public bool CameraZoom
        {
            get { return CAMERA_ZOOM; }
            set { CAMERA_ZOOM = value; }
        }

        /// <summary>
        /// Amount of zooming in
        /// </summary>
        public float CameraZoomInValue
        {
            get { return zoomInValue; }
            set { zoomInValue = value; }
        }

        /// <summary>
        /// The minimum radius
        /// </summary>
        public float CameraMinRadius
        {
            get { return minRadius; }
            set { minRadius = value; }
        }

        /// <summary>
        /// The maximum radius
        /// </summary>
        public float CameraMaxRadius
        {
            get { return maxRadius; }
            set { maxRadius = value; }
        }
        #endregion

        #endregion

        #region NCameraTPS( engineInput )
        /// <summary>
        /// Third person camera
        /// </summary>
        /// <param name="engineInput">The engine input</param>
        public NCameraTPS(NInput engineInput)
        {
            input = engineInput;
        }
        #endregion

        #region UpdateSpecial()
        /// <summary>
        /// Empty...
        /// </summary>
        public void UpdateSpecial()
        {
            //empty...
        }
        #endregion

        #region UpdateSpecial( viewport )
        /// <summary>
        /// Updates the camera special abilities
        /// </summary>
        public void UpdateSpecial(Viewport viewport)
        {
            if (parentedObject == null) return;

            if (input != null)
            {
                #region Some special actions
                if (CAMERA_OBJECT_ROTATION)
                {
                    if (input.MousePosition.X <= 10.0f)
                    {
                        hRotation += CAMERA_ROTATION_Y;
                    }
                    if (input.MousePosition.X >= viewport.Width - 10.0f)
                    {
                        hRotation -= CAMERA_ROTATION_Y;
                    }
                    if (input.MousePosition.Y <= 10.0f)
                    {
                        vRotation += CAMERA_ROTATION_X;
                    }
                    if (input.MousePosition.Y >= viewport.Height - 10.0f)
                    {
                        vRotation -= CAMERA_ROTATION_X;
                    }
                }
                if (CAMERA_ZOOM)
                {
                    if (input.ScrollWheelValue != 0)
                    {
                        radius -= input.ScrollWheelValue * zoomInValue;

                        if (radius < CameraMinRadius) radius = CameraMinRadius;
                        if (radius > CameraMaxRadius) radius = CameraMaxRadius;
                    }
                }
                #endregion
            }

            if (vRotation > 1.5f) vRotation = 1.5f;
            if (vRotation < 0.0f) vRotation = 0.0f;

            CameraPositionX = (float)( radius * Math.Cos(vRotation) * Math.Cos(hRotation) );
            CameraPositionY = (float)( radius * Math.Sin(vRotation) );
            CameraPositionZ = (float)( radius * Math.Cos(vRotation) * Math.Sin(hRotation) );

            CameraPosition += parentedObject.Position;
            LookAtVector = parentedObject.Position;
        }
        #endregion

        #region SetParentObject( obj )
        /// <summary>
        /// Sets a parent object which camera will look at
        /// </summary>
        /// <param name="obj">The object to look at</param>
        public void SetParentObject(NObject obj)
        {
            parentedObject = obj;
        }
        #endregion
    }
    #endregion

Please help!
And if anyone is interested I can explain how to get the animation working...

[attachment deleted by admin]
« Last Edit: 2007/04/11 07:28:21 by EclipsE » Logged
EclipsE
Full Member
***
Offline Offline

Posts: 111


View Profile
« Reply #1 on: 2007/04/11 11:23:42 »

Nope, I guess it's not the camera, I've tried my other camera, NCameraFPS and still the same... Sad
Logged
EclipsE
Full Member
***
Offline Offline

Posts: 111


View Profile
« Reply #2 on: 2007/04/12 02:42:27 »

Yeah, it was the camera. I've always set the near clip to 0.0001f;... What a stupid guy! Smiley I've set it to 1.0f and works fine!

case closed
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
3d Engine-- Tutorial 2 problem. Hazy Mind 3D Engine ZebraHDH 4 2202 Last post 2006/12/03 14:20:43
by tuxdalinux
Got a problem with an .x file Hazy Mind XNA Engine bobbie_dache 8 2784 Last post 2007/01/16 12:26:30
by bobbie_dache
Screen Flickering problem... Hazy Mind XNA Engine simpson.jon 4 1699 Last post 2007/02/25 17:09:05
by simpson.jon
Strange Problem ( Advice/Assistance Needed Please :-) ) General Discussion DaphydTheBard 4 1778 Last post 2007/03/17 10:23:52
by DaphydTheBard
Minimize problem - app crash Hazy Mind XNA Engine nicknz 4 2240 Last post 2007/08/02 04:32:10
by Suzume
tutorial 4 problem Hazy Mind 3D Engine precious roy 3 2495 Last post 2007/08/03 12:24:26
by mikeschuld
usercontrols over gamewindow and keyboard problem General Discussion XNASorcerer 2 1463 Last post 2007/05/09 00:52:09
by Chr0n1x
Interface problem. Help!! General Discussion XNASorcerer 5 2111 Last post 2007/05/09 09:46:36
by CarlosFreitas
ObjectManagers problem Hazy Mind XNA Engine Jonotron 1 1339 Last post 2007/08/03 12:29:19
by mikeschuld
Spaceship orientation problem Hazy Mind XNA Engine murga 3 1619 Last post 2007/07/18 07:00:15
by Nemo Krad
Camera problem Hazy Mind XNA Engine Montynis 2 1685 Last post 2007/08/02 09:54:14
by Montynis
Problem with the pick Hazy Mind 3D Engine Zandman26 0 1420 Last post 2007/08/06 15:04:06
by Zandman26
Animation Problem.. Hazy Mind XNA Engine DoomMarine 10 3534 Last post 2008/04/25 19:32:58
by DoomMarine
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 0.664 seconds with 19 queries.