Saturday 26 February 2011

XNA 3D Gizmo Video!

Finally a video about the Gizmo showcasing the feature-set. I've added some tunes as well this time, hope you like it...

4 comments:

  1. Hi Tom, I am working on an editor for sculpted prims in secondlife using your gizmo code, which is excelent (well done!!). My game control is in a form and is able to resize. I have noticed that the gizmo and the selection ray become un-aligned when the size changes. To select a gizmo axis you have to hover and select in some other position on the control than where the gizmo is visually located. Can you give me any pointers as to what i would need to change for the ray and gizmo to stay aligned regardless of the size of the control?
    Thanks, Tim

    ReplyDelete
  2. Hi thank, I will look into this.

    If you can't wait, the ConvertMouseToRay function is used to turn your mouse location into a ray. Your graphics.Viewport is likely different when using a form, you should be able to change that to look at the size of your form instead.

    ReplyDelete
  3. Thanks for the tip Tom and the fast reply. It helped me find a solution which also fixed another problem. It may be of intrest.

    public void picBoxResize()
    {
    PresentationParameters pp = graphics.GraphicsDevice.PresentationParameters.Clone();
    pp.BackBufferHeight = drawheight;
    pp.BackBufferWidth = drawWidth;
    graphics.GraphicsDevice.Reset(pp);
    }

    The game control is hosted in a picturebox control on my form. I call the above from the picturebox SizeChange event handler. DrawWidth and DrawHeight are the updated with and height of the picturebox.
    The other problem that this handles is that the model and grid are both drawn crisply at all sizes. Previously they were a bit blocky as if the original had been magnified.

    One issue remains. although the ray now intersects with the gizmo correctly the gizmo doesn't stay aligned to the model (in Translate mode). For every X the gizmo moves the model moves (about) X4. Do you have a tip for me on this one?

    Thanks again, Tim

    ReplyDelete
  4. This may have something to do with the scale of your model, if you try a 1.0f scale, does this still happen? (Not assuming you use a similar way to create your world matrix as in the sample)

    If that doesn't fix anything, try starting at the SetPosition() method, this is where the gizmo is placed visually. There may be something iffy going on up there :)

    Does this happen only after the re-size btw?

    ReplyDelete