Jump to content

  • Log In with Google      Sign In   
  • Create Account


tool_2046

Member Since 19 Feb 2002
Offline Last Active Yesterday, 08:52 AM
-----

Topics I've Started

Amateur Question

30 December 2010 - 04:23 PM

I'm not proud to admit, but this has bitten me both in my professional and in my hobby life. A good buddy of mine does art both at my day job and for side projects. My artist uses Maya and animates his models via constraints. Code at work loads joint (bone) animations, but does not load animations not explicitly specified as bone animations. At home I've been playing with Unity and it seems I've reach similar trouble.

There's a lot I could be misunderstanding here. I'm honestly not sure how joint constraint animation makes any sense. Sure, joints transform about, but whether they hit a certain threshold seems to be orthogonal to key frames set with a given transformation.

What am I missing here? Is there a way to bake joint constraint animation (whatever that means) into joint key frames? Am I simply approaching this the wrong way?

[Edited by - tool_2046 on December 30, 2010 10:44:57 PM]

#region and editor-fold

07 June 2008 - 07:34 PM

C# and Java via Netbeans allow one to wrap sections of code into regions that appear as human readable text in the IDE. I tend to use regions to wrap up using/import statements, fields, methods, constructors, helper classes and, in the case of C#, properties and events. Occasionally I'll break down each of those sections further (for example, my methods region might have sub-regions for GUI event handlers). Here's an example:
#region Using statements
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using SlimDX;
using System.Drawing;
using LevelEditor.GUI.Rendering.Cameras;
#endregion Using statements

namespace LevelEditor.GUI.States
{
    #region ViewLevel3D

    /// <summary>
    /// <c>ViewLevel3D</c> allows the user to move around the level using a first person camera.
    /// </summary>
    public class ViewLevel3D : ApplicationState
    {
        #region Fields

        /// <summary>
        /// The camera used to view the level.
        /// </summary>
        protected static ICamera camera = new FirstPersonCamera();

        /// <summary>
        /// The location that the mouse was at on the last mouse move. This
        /// is used to calculate relative mouse movement.
        /// </summary>
        protected Point previousMousePos;

        /// <summary>
        /// Whether or not the data in <c>previousMousePos</c> is valid.
        /// </summary>
        bool previousMousePosExists = false;

        #endregion Fields

        #region Methods

        #region ApplicationState methods

        /// <summary>
        /// Called when the state is entered. Overridden to install event handlers that update the camera.
        /// </summary>
        /// <param name="stateMachine">The object in charge of <c>ApplicationState</c>s.</param>
        /// <param name="lastState">The last state the state machine was in.</param>
        protected internal override void Enter(ApplicationStateMachine stateMachine, ApplicationState lastState)
        {
            RendererControl.Camera = camera;// new FirstPersonCamera();
            stateMachine.RendererControl.MouseMove += RendererControl_MouseMove;
            stateMachine.RendererControl.MouseDoubleClick += HandleMouseDoubleClick;
        }

        /// <summary>
        /// Called when the state is entered. Overridden to remove event handlers that update the camera.
        /// </summary>
        /// <param name="stateMachine">The object in charge of <c>ApplicationState</c>s.</param>
        /// <param name="nextState">The next state the state machine will be in.</param>
        protected internal override void Exit(ApplicationStateMachine stateMachine, ApplicationState nextState)
        {
            stateMachine.RendererControl.MouseMove -= RendererControl_MouseMove;
            stateMachine.RendererControl.MouseDoubleClick -= HandleMouseDoubleClick;
        }

        /// <summary>
        /// Empty.
        /// </summary>
        /// <param name="stateMachine">The state machine in charge of this state.</param>
        protected internal override void Update(ApplicationStateMachine stateMachine)
        {
        }

        #endregion ApplicationState methods

        #region Event handler methods

        /// <summary>
        /// Handles a mouse move event on a <c>RendererControl</c>.
        /// </summary>
        /// <param name="sender">The <c>RendererControl</c> that generated this call.</param>
        /// <param name="e">A description of the event.</param>
        void RendererControl_MouseMove(object sender, MouseEventArgs e)
        {
            if (!previousMousePosExists)
            {
                previousMousePos = new Point(e.X, e.Y);
                previousMousePosExists = true;
            }

            Point deltaPos = new Point(e.X - previousMousePos.X,
                                       e.Y - previousMousePos.Y);

            FirstPersonCamera fpvCamera = RendererControl.Camera as FirstPersonCamera;

            if (e.Button == MouseButtons.Right)
            {
                fpvCamera.RotateView(-deltaPos.X / 100.0f);
                fpvCamera.TiltView(-deltaPos.Y / 100.0f);
            }
            if (e.Button == MouseButtons.Middle)
            {
                fpvCamera.ZoomView(-deltaPos.Y);
            }
            if (e.Button == MouseButtons.Left)
            {
                fpvCamera.PanView(-0.25f * deltaPos.X, 0.25f * deltaPos.Y);
            }

            previousMousePos.X = e.X;
            previousMousePos.Y = e.Y;
        }

        protected virtual void HandleMouseDoubleClick(object sender, MouseEventArgs e)
        {            
        }

        #endregion Event handler methods

        #endregion Methods
    }

    #endregion ViewLevel3D
}





I find that when I use regions like this it allows me to not only easily navigate code, but also recognize areas in need of refactoring. After a couple of conversations with a coworker I'm beginning to wonder if I'm actually hindering readability. He has asked me to reduce my usage of regions as IDEs often have options to automatically collapse regions like using/import statements and helper classes (atleast in the case of Netbeans, I haven't explored Visual Studio's options enough to know if it supports this as well though I suspect it does). So, I'm curious: how do you use regions? A bit of googling didn't reveal any standard guidelines, although I did run across this negative opinion of regions. Am I over doing it? Are regions nothing more than adding a chocolate covering to a turd? Are there commonly accepted guidelines for region use? Thanks in advance for your opinion/any resources you have on the subject! [Edited by - tool_2046 on June 8, 2008 1:59:58 AM]

Locking a Surface using SlimDX

15 March 2008 - 07:39 AM

I am working on a level editor using C#/SlimDX and I'd like to render previews of models for use on various GUI elements. To do this, I am trying to render the scene to a surface and then copy the surface to a Bitmap. Unfortunately, whenever I attempt to read from the surface after locking it, I get a System.NotSupportedException with the following message:
Stream size unknown; cannot query length.
This seems to happen regardless of what memory pool I use, what usage flag I choose, what lock flags I use, and whether I create a surface using Surface.CreateRenderTarget, Surface.CreateOffscreenPlain, or get the surface from a texture. The following code will generate generate the exception:
Format format = Format.X8R8G8B8;
Surface test = Surface.CreateOffscreenPlain(device, width, height, format, Pool.Default);
LockedRect rect = t.LockRectangle(0, LockFlags.None);
long l = rect.Data.Length; // Throws System.NotSupportException.
test.UnlockRectangle();

I'm sure I'm doing something foolish here, but googling has failed me, I can't find anything on the SlimDX website that seems relevant to the problem and randomly fiddling with parameters has (not surprisingly) not helped. Any idea what I'm doing wrong? Thanks for your time!

Nvidia and ATI GDC presentations available

03 March 2008 - 01:06 PM

Nvidia has released their GDC 2008 presentations in both PDF and video formats. You can find them HERE. Sorry if this has been already posted, I couldn't find it posted anywhere.

Survey: Estimating time to complete a task

04 November 2006 - 01:02 PM

I've found that being able to estimate how long it will take take complete a programming task is very difficult. This is something I was taught about in school (and is covered in detail in The Mythical Man-Month) and have struggled with at my job. After a little over a year programming professionally, I still give my managers very inaccurate estimates. Implementing a given feature typically requires one to complete the following steps:
  • Planning. This task requires one to analyze the current state of the code and determine what exactly is going to need to be done in order to write the code. This potentially includes writing functional/technical specifications or other documentation according to your company's policies. Personally, this is a task I do not enjoy, and rarely spend much time on.
  • Coding. During this time, you actually write the code. This task is complete when it fulfulls the requirements laid out in the planning phase.
  • Testing. Here's where you find out about all of the bugs you wrote. This particular task is not usually carried out by the person that wrote the code, but (atleast at my job) programmers are often required to test features implemented by other programmers.
  • Debugging. Finally, you must fix all the problems discovered in the testing phase. In my experience, this task typically takes atleast as much time as coding, but this is likely directly related to my aversion to planning.
Given this, I'm curious:

How do you estimate the total amount of time it will take you to complete a task? Nearly everyone I've talked to has recommended taking your initial estimate and multiplying it by some constant. I've heard a lot of votes for doubling one's initial estimate, but some people recommend even tripling it. My personal experience has shown this to reasonable. What do you guys think?

What percentage of total time to implement a feature do you dedicate to each phase? I suppose this is somewhat dependent on exactly what you are implementing, but do you find that you dedicate more time to a given task than others?


PARTNERS