Hi Zachary,

You can use the GraphicsWindowEmbedded class in conjunction with an
osgViewer to use the .NET wrappers.  I'm attaching an example control that
uses Tao that seems to work for me pretty well.

If the particle system/transform issue that I posted on the osgDotNet trac
website gets fixed, I'm very happy so far with the wrappers.  Just about
everything sensible I've tried "just works" the way I thought it should.

Thanks!

Jason

On 8/3/07, Zachary Hilbun <[EMAIL PROTECTED]> wrote:
>
> I am using C# under Windows XP and thinking about
> using OpenSceneGraph.  I want to have the Viewer use a
> Panel on a Form rather than create its own Window.
> The osgDotNet: Managed Wrappers for OpenSceneGraph
> have a problem with accessing member variables and
> this affects GraphicsContent::Traits.  I saw that
> Traits was put on the ToDoList about a month ago.  Is
> there an estimate on when Traits is going to be fixed?
>
> Thanks
>
> ===============================
> Zachary Hilbun
> Software Contractor
> Dallas, Tx
>
>
>
> ____________________________________________________________________________________Ready
> for the edge of your seat?
> Check out tonight's top picks on Yahoo! TV.
> http://tv.yahoo.com/
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;


using Tao.Platform.Windows;
using OsgViewer;
using OsgGA;

namespace OSGTesting
{
  public partial class OSGControl : SimpleOpenGlControl
  {
    public OSGControl()
    {
      InitializeComponent();
      InitializeContexts();

      _gw = _viewer.setUpViewerAsEmbeddedInWindow(0, 0, Width, Height);
      _viewer.setCameraManipulator(new TrackballManipulator());
      _viewer.realize();
    }

    public Viewer Viewer
    {
      get {return _viewer;}
    }

    protected override void OnMouseMove(MouseEventArgs e)
    {
      if (!DesignMode)
      {
        _gw.getEventQueue().mouseMotion(e.X, e.Y);
      }
      base.OnMouseMove(e);
    }


    protected override void OnKeyPress(KeyPressEventArgs e)
    {
      if (!DesignMode)
      {
        _gw.getEventQueue().keyPress((int)e.KeyChar);
      }
      base.OnKeyPress(e);
    }

    protected override void OnMouseDown(MouseEventArgs e)
    {
      _gw.getEventQueue().mouseButtonPress(e.X, e.Y, ConvertMouse(e.Button));
      base.OnMouseDown(e);
    }

    protected override void OnMouseUp(MouseEventArgs e)
    {
      _gw.getEventQueue().mouseButtonRelease(e.X, e.Y, ConvertMouse(e.Button));
      base.OnMouseUp(e);
    }

    protected override void OnResize(EventArgs e)
    {
      if (!DesignMode && _gw != null)
      {
        _gw.getEventQueue().windowResize(0, 0, ClientSize.Width, 
ClientSize.Height);
        _gw.resized(0, 0, Width, Height);
      }
      base.OnResize(e);
    }

    private void OSGControl_Paint(object sender, PaintEventArgs e)
    {
      if (!DesignMode)
      {
        _viewer.frame(_timer.time_s());
      }
    }

    private static uint ConvertMouse(MouseButtons button)
    {
      uint result = 0;
      switch (button)
      {
        case MouseButtons.Left: result = 1; break;
        case MouseButtons.Middle: result = 2; break;
        case MouseButtons.Right: result = 3; break;
      }
      return result;
    }

    private Osg.Timer _timer = new Osg.Timer();
    private GraphicsWindow _gw;
    private Viewer _viewer = new Viewer();
  }
}
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to