Scene Class Reference

This reference page is linked to from the following overview topics: Mudbox 2013, Scene Graph, Traversing the Scene Graph.



Detailed Description

The Scene class is the container object for all the data in a Mudbox scene.

All the geometry, lights, cameras, etc, are accessed and maintained through this object. To get a pointer to the current Mudbox scene, call Kernel()->Scene(). The scene class provides access to functions and events related to scene objects.

Definition at line 40 of file scene.h.

#include <scene.h>

Inheritance diagram for Scene:
Inheritance graph
[legend]

List of all members.

Classes

struct   LoadData
  Data structure to hold file import/load options, and diagnostic data. More...

Public Member Functions

virtual QStringList  SelectedObjectListNames (void)
virtual mudbox::CurveBase ActiveCurve (void) const
  Returns a pointer to the curve that is currently active.
virtual void  SetActiveCurve (mudbox::CurveBase *curve)
  Sets a different curve to be active.
virtual mudbox::Camera ActiveCamera (void) const
  Returns a pointer to the camera that is currently being used.
virtual void  SetActiveCamera (mudbox::Camera *camera)
  Sets a different camera to be active.
virtual mudbox::Light ActiveLight (void) const
  Returns a pointer to the currently active light.
virtual unsigned int  CameraCount (void) const
  Returns the number of cameras in the scene.
virtual unsigned int  CurveCount (void) const
  Returns the number of Curve objects in the scene.
virtual unsigned int  SelectedCurveCount (void) const
  Returns the number of selected Curves.
virtual unsigned int  LightCount (void) const
  Returns the number of lights in the scene.
virtual unsigned int  GeometryCount (void) const
  Returns the number of Geometry objects in the scene.
virtual unsigned int  SelectedGeometryCount (void) const
  Returns the number of Geometry objects that are currently selected.
virtual mudbox::Camera AddCamera (mudbox::Camera *pCamera)
  Adds a camera to the scene.
virtual mudbox::Light AddLight (mudbox::Light *pLight)
  Adds a light to the scene.
virtual mudbox::CurveBase AddCurve (mudbox::CurveBase *pCurve, mudbox::Transformation *pTransformation=0)
  Adds a curve object to the scene.
virtual void  RemoveCurve (mudbox::CurveBase *pCurve)
  Removes a curve object from the scene.
virtual mudbox::Geometry AddGeometry (mudbox::Geometry *pGeometry, mudbox::Transformation *pTransformation=0)
  Adds a geometry object to the scene.
virtual void  RemoveGeometry (mudbox::Geometry *pGeometry)
  Removes a geometry object from the scene.
virtual mudbox::Camera Camera (unsigned int iIndex) const
  Returns a pointer to a Camera in the scene.
virtual mudbox::Light Light (unsigned int iIndex) const
  Returns a pointer to a Light in the scene.
virtual mudbox::CurveBase SelectedCurve (unsigned int iIndex) const
  Returns a pointer to a selected curve object in the scene.
virtual mudbox::CurveBase Curve (unsigned int iIndex) const
  Returns a pointer to a Curve object in the scene.
virtual mudbox::Geometry SelectedGeometry (unsigned int iIndex) const
  Returns a pointer to a selected Geometry object in the scene.
virtual mudbox::Geometry Geometry (unsigned int iIndex) const
  Returns a pointer to a Geometry object in the scene.
virtual AxisAlignedBoundingBox  BoundingBox (void) const
  Returns the bounding box of the scene.
virtual void  Render (bool bSkipMaterials=false) const
  Render the scene to the current render target using the current OpenGL pipeline settings.
virtual bool  Export (const QString &sFileName, bool bSelectedOnly=false)
  Export models in the scene to an OBJ file. Returns true if successful.
virtual bool  Load (QString sFileName, Scene::LoadData &cData)
  Load a MUD file into this scene. Returns true if successful.
virtual mudbox::Geometry Import (Scene::LoadData &cData, QString sFileName="")
  Imports data from a file, and returns a Mudbox geometry.
virtual bool  Save (QString sFileName)
  Save this scene. Returns true if successful.
mudbox::Geometry ActiveGeometry () const
  Returns a pointer to the active object (that is, the object whose layers are displayed in the UI)
void  SetActiveGeometry (mudbox::Geometry *geometry) const
  Sets the specified geometry to be active. This means that its layers will be displayed in the UI. This is unrelated to selection.
virtual void  SetActivePaintLayer (mudbox::Layer *layer)
  Sets the specified paint layer to be active.
virtual void  SetActiveTexture (mudbox::TexturePool *layer)
  Sets the layer associated with the active texture pool to be active.
virtual mudbox::Layer ActivePaintLayer () const
  Returns a pointer to the currently active paint layer.
virtual mudbox::TexturePool ActiveTexture () const
  Returns a pointer to the currently active texture map.
virtual void  MakeThumbnail (QImage &image, int iSize=128)
  Creates a thumbnail of the current scene.
virtual QString  FileName () const
  Returns an absolute path to the scene's .mud file on disk, or an empty string if the scene has not been saved yet.
virtual bool  Dirty () const
  This indicates if the scene has been dirtied since the last time it was saved.
virtual void  SetDirty (bool bDirty=true)
  Sets the dirty status of the scene.
Mesh CreateMesh (Topology::FaceType eType)
  Creates an empty mesh object and returns a pointer to it.

Static Public Attributes

static aevent  MaterialChangeEvent
  This event is triggered after a new material is set to a mesh.
static aevent  ActiveCameraChangeEvent
  This event is triggered after a different camera is set as the active camera in the SetActiveCamera().
static aptr< mudbox::Geometry m_pGeometryToAdd
  This pointer contains the address of the currently mesh being imported/loaded.
static aptr
< SceneMembershipEventNotifier
SceneMembershipEvent
  This is a pointer to the latest scene membership event.
static aptr< Node SelectedNode
  This pointer contains the address of the currently selected node in the scene.
static aevent  PaintSelectionEvent
  This event is triggered when selection set of faces vary, i.e. more faces or less faces are selected.
static aevent  PaintLayerAddedEvent
  This event is triggered after a paint layer is created.
static aevent  PaintLayerRemovedEvent
  This event is triggered after a paint layer is deleted.
static aevent  PaintLayerPropertiesChangedEvent
  This event is triggered after changes happend to existing paint layers.
static aevent  GeometryTransformedEvent
  This event is triggered when a geometry is transformed by translate/rotate/scale tools.

Protected Member Functions

  Scene (void)
  Do not use the constructor directly.

Constructor & Destructor Documentation

Scene ( void  ) [protected]

Do not use the constructor directly.

It is unlikely that you would ever create your own scene in a plug-in. If you do need to, you should not call the constructor directly. Instead, use CreateInstances, like this:

        Scene *myNewScene = CreateInstance<Scene>();

Member Function Documentation

virtual QStringList SelectedObjectListNames ( void  ) [virtual]
virtual mudbox::CurveBase* ActiveCurve ( void  ) const [virtual]

Returns a pointer to the curve that is currently active.

virtual void SetActiveCurve ( mudbox::CurveBase curve ) [virtual]

Sets a different curve to be active.

virtual mudbox::Camera* ActiveCamera ( void  ) const [virtual]

Returns a pointer to the camera that is currently being used.

Examples:
SampleViewportFilter/SampleViewportFilter.cpp.
virtual void SetActiveCamera ( mudbox::Camera camera ) [virtual]

Sets a different camera to be active.

virtual mudbox::Light* ActiveLight ( void  ) const [virtual]

Returns a pointer to the currently active light.

virtual unsigned int CameraCount ( void  ) const [virtual]

Returns the number of cameras in the scene.

virtual unsigned int CurveCount ( void  ) const [virtual]

Returns the number of Curve objects in the scene.

Returns number of all objects derived from CurveBase.

virtual unsigned int SelectedCurveCount ( void  ) const [virtual]

Returns the number of selected Curves.

virtual unsigned int LightCount ( void  ) const [virtual]

Returns the number of lights in the scene.

virtual unsigned int GeometryCount ( void  ) const [virtual]

Returns the number of Geometry objects in the scene.

virtual unsigned int SelectedGeometryCount ( void  ) const [virtual]

Returns the number of Geometry objects that are currently selected.

virtual mudbox::Camera* AddCamera ( mudbox::Camera pCamera ) [virtual]

Adds a camera to the scene.

Returns a pointer to the camera you added.

Once you add a camera to the scene, the scene is responsible for deleting it.

Parameters:
[in] pCamera a pointer to an instance of a Camera
virtual mudbox::Light* AddLight ( mudbox::Light pLight ) [virtual]

Adds a light to the scene.

Returns a pointer to the light you added.

Once you add a light to the scene, the scene is responsible for deleting it.

Parameters:
[in] pLight a pointer to an instance of a Light
virtual mudbox::CurveBase* AddCurve ( mudbox::CurveBase pCurve,
mudbox::Transformation pTransformation = 0 
) [virtual]

Adds a curve object to the scene.

Returns a pointer to the object you added.

Once you add a curve object to the scene, the scene is responsible for deleting it.

Parameters:
[in] pCurve a pointer to an instance of a Curve object
[in] pTransformation a pointer to an instance of a Transformation for the Geometry
virtual void RemoveCurve ( mudbox::CurveBase pCurve ) [virtual]

Removes a curve object from the scene.

Note that the removed curve is not deleted. Once the curve is removed, it becomes the caller's responsibility to delete it.

Parameters:
[in] pCurve a pointer to the object that you want removed.
virtual mudbox::Geometry* AddGeometry ( mudbox::Geometry pGeometry,
mudbox::Transformation pTransformation = 0 
) [virtual]

Adds a geometry object to the scene.

Returns a pointer to the object you added.

Once you add a geometry object to the scene, the scene is responsible for deleting it.

Parameters:
[in] pGeometry a pointer to an instance of a Geometry object
[in] pTransformation a pointer to an instance of a Transformation for the Geometry
Examples:
MeshBuilder/MeshBuilder.cpp.
virtual void RemoveGeometry ( mudbox::Geometry pGeometry ) [virtual]

Removes a geometry object from the scene.

Note that the removed geometry is not deleted. Once the geometry is removed, it becomes the caller's responsibility to delete it.

Parameters:
[in] pGeometry a pointer to the object that you want removed.
virtual mudbox::Camera* Camera ( unsigned int  iIndex ) const [virtual]

Returns a pointer to a Camera in the scene.

(If the index is out of range, NULL is returned. To find out how many cameras are in the scene, call CameraCount().)

Parameters:
[in] iIndex the index of the camera to be returned (0-based)
virtual mudbox::Light* Light ( unsigned int  iIndex ) const [virtual]

Returns a pointer to a Light in the scene.

(If the index is out of range, NULL is returned. To find out how many lights are in the scene, call LightCount().)

Parameters:
[in] iIndex the index of the light to be returned (0-based)
virtual mudbox::CurveBase* SelectedCurve ( unsigned int  iIndex ) const [virtual]

Returns a pointer to a selected curve object in the scene.

(If the index is out of range, NULL is returned. To find out how many curve objects are selected in the scene, call SelectedCurveCount().)

Parameters:
[in] iIndex the index of the selected curve object to be returned (0-based)
virtual mudbox::CurveBase* Curve ( unsigned int  iIndex ) const [virtual]

Returns a pointer to a Curve object in the scene.

(If the index is out of range, NULL is returned. To find out how many Curve objects are in the scene, call CurveCount().)

Parameters:
[in] iIndex the index of the Curve object to be returned (0-based)
virtual mudbox::Geometry* SelectedGeometry ( unsigned int  iIndex ) const [virtual]

Returns a pointer to a selected Geometry object in the scene.

(If the index is out of range, NULL is returned. To find out how many geometry objects are selected in the scene, call SelectedGeometryCount().)

Parameters:
[in] iIndex the index of the selected geometry object to be returned (0-based)
virtual mudbox::Geometry* Geometry ( unsigned int  iIndex ) const [virtual]

Returns a pointer to a Geometry object in the scene.

(If the index is out of range, NULL is returned. To find out how many geometry objects are in the scene, call GeometryCount().)

Parameters:
[in] iIndex the index of the geometry object to be returned (0-based)
virtual AxisAlignedBoundingBox BoundingBox ( void  ) const [virtual]

Returns the bounding box of the scene.

This bounding box is axis-aligned, and in World Space.

virtual void Render ( bool  bSkipMaterials = false ) const [virtual]

Render the scene to the current render target using the current OpenGL pipeline settings.

Note: This method is not part of the regular refresh cycle. To force the screen to refresh after making changes, call Kernel->Refresh()

Use this method when you need to render the scene for purposes internal to your plug-in. For example, you can create a custom texture, make it the render target (see the Texture class defined in material.h), set up whatever special shaders you need, then call this method to render the scene into your texture.

By default, objects will be rendered with their own materials. If you want to render everything with a shader that you set up, set bSkipMaterials to true.

Parameters:
[in] bSkipMaterials If true, then the materials attached to objects in the scene are ignored. Everything uses the current shader.
virtual bool Export ( const QString sFileName,
bool  bSelectedOnly = false 
) [virtual]

Export models in the scene to an OBJ file. Returns true if successful.

Parameters:
[in] sFileName The path to the file to be saved (with a .obj extension)
[in] bSelectedOnly If true, only selected models will be saved
virtual bool Load ( QString  sFileName,
Scene::LoadData cData 
) [virtual]

Load a MUD file into this scene. Returns true if successful.

Parameters:
[in] sFileName The path to the MUD file to be loaded
[in] cData The load options
virtual mudbox::Geometry* Import ( Scene::LoadData cData,
QString  sFileName = "" 
) [virtual]

Imports data from a file, and returns a Mudbox geometry.

If cData.Merge() is true, then the contents of the file are merged into the current scene, otherwise the first geometry contained within the file is returned, but not added to the scene. If sFileName is blank, a file dialog is opened. returns a geometry corresponding to the file, or NULL on error.

Parameters:
[in] cData Import options
[in] sFileName Path to the file
virtual bool Save ( QString  sFileName ) [virtual]

Save this scene. Returns true if successful.

Parameters:
[in] sFileName The path to the MUD file to be saved (with a .mud extension )
mudbox::Geometry* ActiveGeometry ( ) const

Returns a pointer to the active object (that is, the object whose layers are displayed in the UI)

Note that the 'active' object is unrelated to 'selected' objects. 'Active' refers to the object that is currently the focus of the user interface. For example, only one object at a time displays its layer information --- this is the active object.

void SetActiveGeometry ( mudbox::Geometry geometry ) const

Sets the specified geometry to be active. This means that its layers will be displayed in the UI. This is unrelated to selection.

Parameters:
[in] geometry a pointer to the geometry to be made active
Examples:
MeshBuilder/MeshBuilder.cpp.
virtual void SetActivePaintLayer ( mudbox::Layer layer ) [virtual]

Sets the specified paint layer to be active.

Parameters:
[in] layer A pointer to the layer to be made active
virtual void SetActiveTexture ( mudbox::TexturePool layer ) [virtual]

Sets the layer associated with the active texture pool to be active.

Parameters:
[in] layer A pointer to the texture to be made active
virtual mudbox::Layer* ActivePaintLayer ( ) const [virtual]

Returns a pointer to the currently active paint layer.

The active paint layer can be used in different ways, Use TexturePool::Usage to determine how a paint layer is being used.

virtual mudbox::TexturePool* ActiveTexture ( ) const [virtual]

Returns a pointer to the currently active texture map.

virtual void MakeThumbnail ( QImage image,
int  iSize = 128 
) [virtual]

Creates a thumbnail of the current scene.

virtual QString FileName ( ) const [virtual]

Returns an absolute path to the scene's .mud file on disk, or an empty string if the scene has not been saved yet.

virtual bool Dirty ( ) const [virtual]

This indicates if the scene has been dirtied since the last time it was saved.

virtual void SetDirty ( bool  bDirty = true ) [virtual]

Sets the dirty status of the scene.

When set to true, the user will be prompted to save the scene when he closes the file, or exits Mudbox.

Mesh* CreateMesh ( Topology::FaceType  eType )

Creates an empty mesh object and returns a pointer to it.

Mesh objects must be entirely triangles, or entirely quads.

Parameters:
[in] eType The mesh type, one of Topology::typeTriangular or Topology::typeQuadric
Examples:
MeshBuilder/MeshBuilder.cpp, and PLYImport/Importer.cpp.

Member Data Documentation

This event is triggered after a new material is set to a mesh.

Definition at line 388 of file scene.h.

This event is triggered after a different camera is set as the active camera in the SetActiveCamera().

Plugins can connect to this event to get informed when the active camera is changed to a different one.

Definition at line 392 of file scene.h.

This pointer contains the address of the currently mesh being imported/loaded.

This pointer will be set to 0 right after the import fineshed. Plugins can connect their own pointer of the same type to this attribute if they want to respond to brush activation events.

See also:
Attribute::Connect(). In the future this aptr will be moved to the Scene class, but the problem currently is that if the plugin connect to this aptr of a scene, the plugin will catch the node event after the scene is different, for example new scene is created.

Definition at line 399 of file scene.h.

This is a pointer to the latest scene membership event.

Plugins can use this pointer to catch scene membership event. When a new scene membership event is triggered, for example, when a geometry is removed from the scene, this pointer will change its value to the new scene membership event. Plugins can also have their own pointer with the same type. At startup they can connect their pointer to this pointer in kernel by calling the Connect() function on their pointer. This means that when the SceneMembershipEvent pointer in kernel changes, their own pointer will also change. They can then catch this in their OnNodeEvent() function. Using this pointer to anything else than connecting an own pointer to it is forbidden.

Definition at line 409 of file scene.h.

aptr<Node> SelectedNode [static]

This pointer contains the address of the currently selected node in the scene.

Plugins can connect their own pointers of the same type to this attribute to respond to selection related events.

See also:
Attribute::Connect().

Definition at line 413 of file scene.h.

This event is triggered when selection set of faces vary, i.e. more faces or less faces are selected.

Definition at line 416 of file scene.h.

This event is triggered after a paint layer is created.

Definition at line 419 of file scene.h.

This event is triggered after a paint layer is deleted.

Definition at line 422 of file scene.h.

This event is triggered after changes happend to existing paint layers.

Definition at line 425 of file scene.h.

This event is triggered when a geometry is transformed by translate/rotate/scale tools.

Definition at line 428 of file scene.h.


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

Scene Scene Scene Scene Scene Scene Scene Scene Scene Scene
Scene Scene Scene Scene Scene Scene Scene Scene Scene Scene