wxOgreControl Class Reference

Manages an Ogre rendering window and its viewport. More...

#include <control.h>

List of all members.

Public Member Functions

 wxOgreControl ()
 Default constructor.
 wxOgreControl (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSUNKEN_BORDER|wxTRANSPARENT_WINDOW, const wxValidator &val=wxDefaultValidator, const wxString &name=wxT("OgreControl"))
 Constructs a window, with an embedded Ogre rendering window.
virtual ~wxOgreControl ()
 Destructor, call Destroy to clean Ogre stuff.
virtual bool Create (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxSUNKEN_BORDER|wxTRANSPARENT_WINDOW, const wxValidator &val=wxDefaultValidator, const wxString &name=wxT("OgreControl"))
 Constructs a window, with an embedded Ogre rendering window.
virtual bool Destroy ()
 Destructor, deletes the camera if exists,.
virtual void Update ()
 Render a frame and update the rendering window.
virtual wxSize DoGetBestSize () const
 Returns a small 3:4 window size.
virtual Ogre::SceneManager * CreateSceneManager (const Ogre::String &tn, const Ogre::String &name="")
 Creates a scene manager instance of a given type.
virtual Ogre::SceneManager * CreateSceneManager (Ogre::SceneTypeMask tm, const Ogre::String &name="")
 Creates a SceneManager instance of a given type.
virtual void SetSceneManager (Ogre::SceneManager *sm)
 Set-up the rendering window for the given scene manager.
virtual void SetCamera (Ogre::Camera *cam)
 Creates a viewport and attach the given camera to it.
virtual void RotateCamera (float relX, float relY, float relZ)
 Rotates the camera anticlockwise, around its local x, y and z axis.
virtual void TranslateCamera (float x, float y, float z)
 Moves the camera's position by the x, y, and z offsets along it's own axes (relative to orientation).
virtual void SetPolygonMode (const Ogre::PolygonMode &pm)
 Sets the level of rendering detail required from this camera.
virtual void ProcessSelection (const wxPoint &pt)
 Virtual method called by the default mouse handler.
Ogre::Camera * GetCamera () const
 Retrieves the control's camera.
Ogre::RenderWindow * GetRenderWindow () const
 Retrieves the control's render window.
Ogre::Viewport * GetViewport () const
 Retrieves the control's viewport.
void AddViewport (Ogre::Camera *cam, int ZOrder=0, float left=0.0f, float top=0.0f, float width=1.0f, float height=1.0f)
 Adds a viewport to the rendering target.
void DestroyRenderWindow ()
 Detaches the control's render window if exists.

Protected Member Functions

virtual void OnSize (wxSizeEvent &event)
virtual void OnPaint (wxPaintEvent &event)
virtual void OnMouseMove (wxMouseEvent &event)
virtual void OnEraseBackground (wxEraseEvent &event)

Protected Attributes

Ogre::SceneManager * m_sm
Ogre::Camera * m_cam

Private Member Functions

virtual void Init ()
 Initializes private variables.
Ogre::RenderWindow * CreateRenderWindow (const Ogre::String &name)
 Creates an Ogre's rendering window.
void GetParentWindowHandle (Ogre::NameValuePairList &pl)
 Retrieves the unique window identifier of this control.

Private Attributes

Ogre::Root * m_root
Ogre::RenderWindow * m_rwin
Ogre::Viewport * m_vp
long m_x
 Last x position of the cursor.
long m_y
 Last y position of the cursor.

Static Private Attributes

static unsigned int m_instances
 Number of rendering windows instantiated.


Detailed Description

Manages an Ogre rendering window and its viewport.

Remarks:
This class creates an embedded Ogre::RenderWindow, set up and manages a Ogre::Viewport for a given Ogre::Camera and provides basic input handling to control the camera movements.
Author:
Martin Pieuchot

Definition at line 35 of file control.h.


Constructor & Destructor Documentation

wxOgreControl::wxOgreControl (  ) 

Default constructor.

wxOgreControl::wxOgreControl ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxSUNKEN_BORDER|wxTRANSPARENT_WINDOW,
const wxValidator &  val = wxDefaultValidator,
const wxString &  name = wxT("OgreControl") 
)

Constructs a window, with an embedded Ogre rendering window.

virtual wxOgreControl::~wxOgreControl (  )  [virtual]

Destructor, call Destroy to clean Ogre stuff.

Remarks:
This destructor is needed to correctly destroy ogre instances when the control is not deleted using the Destroy method, for example when destroyed by a wxNotebook::DeletePage call.
See also:
Destroy


Member Function Documentation

void wxOgreControl::AddViewport ( Ogre::Camera *  cam,
int  ZOrder = 0,
float  left = 0.0f,
float  top = 0.0f,
float  width = 1.0f,
float  height = 1.0f 
)

Adds a viewport to the rendering target.

See also:
Ogre::RenderTarget::addViewport

virtual bool wxOgreControl::Create ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = wxSUNKEN_BORDER|wxTRANSPARENT_WINDOW,
const wxValidator &  val = wxDefaultValidator,
const wxString &  name = wxT("OgreControl") 
) [virtual]

Constructs a window, with an embedded Ogre rendering window.

Ogre::RenderWindow* wxOgreControl::CreateRenderWindow ( const Ogre::String &  name  )  [private]

Creates an Ogre's rendering window.

Parameters:
name the internal name of the Ogre::RenderWindow

virtual Ogre::SceneManager* wxOgreControl::CreateSceneManager ( Ogre::SceneTypeMask  tm,
const Ogre::String &  name = "" 
) [virtual]

Creates a SceneManager instance of a given type.

See also:
Ogre::createSceneManager

virtual Ogre::SceneManager* wxOgreControl::CreateSceneManager ( const Ogre::String &  tn,
const Ogre::String &  name = "" 
) [virtual]

Creates a scene manager instance of a given type.

See also:
Ogre::createSceneManager

virtual bool wxOgreControl::Destroy (  )  [virtual]

Destructor, deletes the camera if exists,.

void wxOgreControl::DestroyRenderWindow (  ) 

Detaches the control's render window if exists.

See also:
Ogre::Root:detachRenderTarget

virtual wxSize wxOgreControl::DoGetBestSize (  )  const [virtual]

Returns a small 3:4 window size.

Returns:
A size of 320x240.

Definition at line 82 of file control.h.

Ogre::Camera* wxOgreControl::GetCamera (  )  const

Retrieves the control's camera.

Definition at line 155 of file control.h.

References m_cam.

void wxOgreControl::GetParentWindowHandle ( Ogre::NameValuePairList &  pl  )  [private]

Retrieves the unique window identifier of this control.

Remarks:
This is *the* platform independent method of the library.
Parameters:
pl an Ogre pair list passed to the createRenderWinow function.
See also:
Ogre::Root::createRenderWindow

Ogre::RenderWindow* wxOgreControl::GetRenderWindow (  )  const

Retrieves the control's render window.

Definition at line 158 of file control.h.

References m_rwin.

Ogre::Viewport* wxOgreControl::GetViewport (  )  const

Retrieves the control's viewport.

Definition at line 161 of file control.h.

References m_vp.

virtual void wxOgreControl::Init (  )  [private, virtual]

Initializes private variables.

virtual void wxOgreControl::OnEraseBackground ( wxEraseEvent &  event  )  [protected, virtual]

virtual void wxOgreControl::OnMouseMove ( wxMouseEvent &  event  )  [protected, virtual]

virtual void wxOgreControl::OnPaint ( wxPaintEvent &  event  )  [protected, virtual]

virtual void wxOgreControl::OnSize ( wxSizeEvent &  event  )  [protected, virtual]

virtual void wxOgreControl::ProcessSelection ( const wxPoint &  pt  )  [virtual]

Virtual method called by the default mouse handler.

Parameters:
pt the position clicked by the user.
Remarks:
This method is defined in order to simplify the selection of 3D components. Just define here, in your custom subcontrol, the action associated with the left click mouse button.
See also:
OnMouseMove

Tutorial 3

virtual void wxOgreControl::RotateCamera ( float  relX,
float  relY,
float  relZ 
) [virtual]

Rotates the camera anticlockwise, around its local x, y and z axis.

See also:
Ogre::Camera::roll

Ogre::Camera::yaw

Ogre::Camera::pitch

virtual void wxOgreControl::SetCamera ( Ogre::Camera *  cam  )  [virtual]

Creates a viewport and attach the given camera to it.

Remarks:
If an old camera was used it is destroyed. The aspect ration of the camera is automatically updated.
See also:
AddViewport

virtual void wxOgreControl::SetPolygonMode ( const Ogre::PolygonMode &  pm  )  [virtual]

Sets the level of rendering detail required from this camera.

See also:
Ogre::Camera::setPolygonMode

virtual void wxOgreControl::SetSceneManager ( Ogre::SceneManager *  sm  )  [virtual]

Set-up the rendering window for the given scene manager.

This method creates a camera and attaches a viewport to the rendering window for the given scene manager.

See also:
SetCamera

AddViewport

virtual void wxOgreControl::TranslateCamera ( float  x,
float  y,
float  z 
) [virtual]

Moves the camera's position by the x, y, and z offsets along it's own axes (relative to orientation).

See also:
Ogre::Camera::moveRelative

virtual void wxOgreControl::Update (  )  [virtual]

Render a frame and update the rendering window.


Member Data Documentation

Ogre::Camera* wxOgreControl::m_cam [protected]

Definition at line 184 of file control.h.

Referenced by GetCamera().

unsigned int wxOgreControl::m_instances [static, private]

Number of rendering windows instantiated.

Definition at line 221 of file control.h.

Ogre::Root* wxOgreControl::m_root [private]

Definition at line 210 of file control.h.

Ogre::RenderWindow* wxOgreControl::m_rwin [private]

Definition at line 211 of file control.h.

Referenced by GetRenderWindow().

Ogre::SceneManager* wxOgreControl::m_sm [protected]

Definition at line 183 of file control.h.

Ogre::Viewport* wxOgreControl::m_vp [private]

Definition at line 212 of file control.h.

Referenced by GetViewport().

long wxOgreControl::m_x [private]

Last x position of the cursor.

Definition at line 216 of file control.h.

long wxOgreControl::m_y [private]

Last y position of the cursor.

Definition at line 218 of file control.h.


The documentation for this class was generated from the following file: