first commit

This commit is contained in:
2026-06-22 11:49:35 +02:00
commit d805f2ba86
619 changed files with 126873 additions and 0 deletions

View File

@ -0,0 +1,95 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NGROUP__
#define __NGROUP__
#include "scene3d/mitem.h"
#include "motion/scene_motion_container.h"
#include "automation/automation_player.h"
#include "memory/bit_field.h"
namespace GS {
class Matrix4;
namespace Core { struct ResourceFactories; }
namespace S3D {
class MItem;
/*!
@short Group of managed items.
@Note The group root item is not part of the group.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
class Group : public SharedObject
{
MItem *root;
SharedList <MItem *> item_list;
SharedList <Group *> group_list;
public:
enum
{
Hidden = (1 << 0),
Locked = (1 << 1)
};
String name;
BitField flags;
inline MItem *GetRootItem() const { return root; }
void SetRootItem(MItem *);
/// Return the group item member list.
inline const SharedList <MItem *> &GetItemList() const { return item_list; }
/// Return the number of members in group.
inline uint GetMemberCount() const { return item_list.GetCount(); }
MItem *Item(const char *) const;
MItem *ItemFromUid(uint uid) const;
bool IsMember(const MItem *) const;
MItem *Add(MItem *, bool block_duplicate = false);
bool Remove(MItem *);
Group *GetGroup(const char *) const;
bool IsMember(const Group *) const;
Group *Add(Group *, bool block_duplicate = false);
bool Remove(Group *);
/// Append a group content to this group.
bool AppendGroup(const Group &);
/// Set the invisible flag of all items in group.
void SetInvisible(bool invisible);
void Offset(const Matrix4 &);
void Translate(float, float, float);
void Rotate(float, float, float);
Core::SceneMotionContainer motion;
/// Set motion on all group items.
void SetMotion(const char *name, Automation::SourceGroup ** = 0, float blend = Units::Sec(0.1), Automation::Player::AddSourceMode = Automation::Player::SourceSet, float weight = 1);
void RenderSetup(Core::ResourceFactories *);
void Setup();
void Reset();
Group() : root(0) {}
};
} // S3D
} // GS
#endif // __NGROUP__

View File

@ -0,0 +1,60 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NINSTANCE__
#define __NINSTANCE__
#include "scene3d/mitem.h"
namespace GS {
namespace S3D {
class Group;
/*!
@short Scene instance proxy.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct Instance : public MItem, public Core::Item
{
static MItemType GetMItemClassType() { return Type_Instance; }
String template_path;
bool do_not_parent;
Group *instance_group;
bool Instantiate(Scene *);
virtual Core::Item *GetBaseItem() { return this; }
virtual Core::Renderable *GetRenderable() { return 0; }
virtual void RenderSetup(Core::ResourceFactories * = 0);
void ComputeMinMax(MinMax &) const;
/*!
@name Editor specific.
@{
*/
AutoPtr <Scene> instance_scene; ///< Used by the editor.
void FreeEditorInstance();
/// @}
bool FromMetaTag(NML::Tag &);
NML::Tag *AsMetaTag();
Instance();
~Instance();
};
} // S3D
} // GS
#endif // __NINSTANCE__

View File

@ -0,0 +1,41 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NITEMAUTOMATEDPROPERTYPROVIDER__
#define __NITEMAUTOMATEDPROPERTYPROVIDER__
#include "automation/automated_property_provider.h"
namespace GS {
namespace Core { class Item; }
namespace S3D {
namespace Automation {
/*!
@short Item automated property provider.
@author Emmanuel Julien (ejulien@nworks.fr)
*/
struct ItemPropertyProvider : public GS::Automation::IPropertyProvider
{
Core::Item *item;
virtual bool GetProperty(Core::MotionChannel::Type, float &);
virtual bool SetProperty(Core::MotionChannel::Type, float);
virtual Quaternion GetRotation() const;
virtual bool SetRotation(const Quaternion &);
ItemPropertyProvider(Core::Item *i) : item(i) {}
};
} // Automation
} // S3D
} // GS
#endif // __NITEMAUTOMATEDPROPERTYPROVIDER__

View File

@ -0,0 +1,39 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMCAMERA__
#define __NMCAMERA__
#include "core/camera.h"
#include "scene3d/mitem.h"
namespace GS {
namespace S3D {
/*!
@short Managed camera.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct MCamera: public MItem, public Core::Camera
{
static MItemType GetMItemClassType() { return Type_Camera; }
virtual Core::Item *GetBaseItem() { return this; }
virtual Core::Renderable *GetRenderable() { return 0; }
virtual bool FromMetaTag(NML::Tag &);
virtual NML::Tag *AsMetaTag();
MCamera();
};
} // S3D
} // GS
#endif // __NMCAMERA__

View File

@ -0,0 +1,41 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __MCONSTRAINT__
#define __MCONSTRAINT__
#include "scene3d/mitem.h"
#include "physic/physic_constraint.h"
namespace GS {
namespace S3D {
/// Managed physic constraint.
struct MConstraint : public MItem
{
PhysicConstraintDesc desc;
AutoPtr <PhysicConstraint> physic_data;
static MItemType GetMItemClassType() { return Type_Constraint; }
void Setup(PhysicWorld *);
virtual Core::Item *GetBaseItem() { return 0; }
virtual Core::Renderable *GetRenderable() { return 0; }
bool FromMetaTag(NML::Tag &);
NML::Tag *AsMetaTag();
MConstraint(PhysicConstraint *);
};
} // S3D
} // GS
#endif // __MCONSTRAINT__

View File

@ -0,0 +1,42 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMEMITTER__
#define __NMEMITTER__
#include "scene3d/mitem.h"
#include "core/emitter.h"
namespace GS {
namespace S3D {
/*!
@short Managed emitter.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct MEmitter : public MItem, public Core::Emitter
{
static MItemType GetMItemClassType() { return Type_Emitter; }
void Update(const Time &);
void Setup(PhysicWorld *);
virtual Core::Item *GetBaseItem() { return this; }
virtual Core::Renderable *GetRenderable() { return this; }
virtual bool FromMetaTag(NML::Tag &);
virtual NML::Tag *AsMetaTag();
MEmitter();
};
} // S3D
} // GS
#endif // __NMEMITTER__

View File

@ -0,0 +1,138 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMITEM__
#define __NMITEM__
#include "physic/physic_item_desc.h"
#include "physic/physic_item.h"
#include "scene3d/mitem_event_interface.h"
#include "scene3d/mitem_type.h"
#include "core/ace.h"
#include "core/item.h"
#include "script/scripted_object.h"
#include "automation/automation_player.h"
#include "memory/nauto_ptr.h"
namespace GS {
class Time;
namespace Script { class VM; }
namespace Core {
class Item;
struct Renderable;
}
namespace S3D {
class Scene;
class PhysicWorld;
/*!
@short Managed item.
The scene graph base node class. It also provide a mean to key frame any
base properties of derived entities such as colors, ranges, intensities, etc...
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
class MItem : public ACE::Unit, public SharedObject
{
friend class Scene;
public:
enum Flag
{
Flag_None = 0,
Flag_Billboard = (1 << 0),
Flag_SolveOverlap = (1 << 1),
Flag_Ghost = (1 << 2),
Flag_Physic = (1 << 3),
Flag_TriggerDetected = (1 << 4),
Flag_IsActive = (1 << 5),
Flag_IsStatic = (1 << 6),
Flag_IsHelper = (1 << 7),
// Non-serialized.
Flag_EditorHidden = (1 << 8),
Flag_EditorLocked = (1 << 9)
};
protected:
MItemType item_type;
bool initial_state_set; ///< Is item initial state set?
Matrix4 initial_matrix; ///< Initial matrix.
uint uid; ///< Item scene unique identifier.
float priority; ///< Heuristic bias value.
/*!
@name General section.
@{
*/
public:
String name; ///< Item name.
BitField mitem_flags;
float global_alpha;
uint GetUid() const { return uid; }
MItemType GetItemType() const { return item_type; }
virtual Core::Item *GetBaseItem() = 0;
virtual Core::Renderable *GetRenderable() = 0;
float GetPriority() const { return priority; }
void SetPriority(float p = 0.5f) { priority = p; }
/// Store the current transformation as the initial transformation.
void SetInitialTransformation();
/// Reset to initial transformation.
void ResetToInitialTransformation();
/// Return the active state of the item.
virtual inline bool isActive() const { return mitem_flags.IsSet(Flag_IsActive); }
/// Return the static state of the item.
virtual bool isStatic() const { return mitem_flags.IsSet(Flag_IsStatic); }
virtual void Update(const Time &dt);
virtual void Setup(PhysicWorld *);
void ForceUpdateMassShapePhysic(PhysicWorld *physic_world);
void Reset();
/// @}
bool ExecCommand(ACE::Command *, float dt);
PhysicItemDesc physic_item_desc;
sPhysicItem physic_item;
AutoPtr <IItemEvent> item_event;
AutoPtr <Script::ScriptedObject> scripted_object;
AutoPtr <Automation::Player> automation_player;
virtual bool FromMetaTag(NML::Tag &);
virtual NML::Tag *AsMetaTag();
MItem();
virtual ~MItem() {}
};
typedef SharedPtr <MItem> sMItem;
} // S3D
} // GS
#endif // __NMITEM__

View File

@ -0,0 +1,57 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __IITEMEVENT__
#define __IITEMEVENT__
namespace GS {
namespace S3D {
class MItem;
struct MTrigger;
struct CollisionPair;
/*!
@short Item event interface.
Implement this class if you wish to process item events.
The default implementation forwards events to the item active script units.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct IItemEvent
{
virtual void OnSetup(MItem *) {}
virtual void OnSetupDone(MItem *) {}
virtual void OnReset(MItem *) {}
virtual void OnActivate(MItem *, bool) {}
virtual void OnPhysicStep(MItem *, bool /*step_taken*/) {}
virtual void OnItemEnter(MTrigger *, MItem *) {}
virtual void OnItemExit(MTrigger *, MItem *) {}
virtual void OnEnterTrigger(MItem *, MTrigger *) {}
virtual void OnTrigger(MItem *, MTrigger *) {}
virtual void OnExitTrigger(MItem *, MTrigger *) {}
virtual void OnUpdate(MItem *) {}
virtual void OnDelete(MItem *) {}
virtual void OnRenderDone(MItem *) {}
virtual void OnRenderUser(MItem *) {}
virtual void OnCollision(MItem *, MItem * /*with*/, const CollisionPair &) {}
virtual ~IItemEvent() {}
};
} // S3D
} // GS
#endif // __IITEMEVENT__

View File

@ -0,0 +1,51 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NITEMSCRIPTEVENT__
#define __NITEMSCRIPTEVENT__
#include "scene3d/mitem_event_interface.h"
namespace GS {
namespace S3D {
/*!
@short Item script event.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct MItemScriptEvent : public IItemEvent
{
virtual void OnSetup(MItem *);
virtual void OnSetupDone(MItem *);
virtual void OnReset(MItem *);
virtual void OnActivate(MItem *, bool activate);
virtual void OnPhysicStep(MItem *, bool step_taken);
virtual void OnItemEnter(MTrigger *, MItem *);
virtual void OnItemExit(MTrigger *, MItem *);
virtual void OnEnterTrigger(MItem *, MTrigger *);
virtual void OnTrigger(MItem *, MTrigger *);
virtual void OnExitTrigger(MItem *, MTrigger *);
virtual void OnUpdate(MItem *);
virtual void OnDelete(MItem *);
virtual void OnRenderDone(MItem *);
virtual void OnRenderUser(MItem *);
virtual void OnCollision(MItem *, MItem *with, const CollisionPair &);
};
} // S3D
} // GS
#endif // __NITEMSCRIPTEVENT__

View File

@ -0,0 +1,46 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __MITEMSCRIPTUNIT__
#define __MITEMSCRIPTUNIT__
#include "script/script_unit.h"
#include "script/script_object.h"
#include "memory/nauto_ptr.h"
namespace GS {
namespace S3D {
/*!
@short Managed item script unit.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct MItemScriptUnit : public Script::Unit
{
AutoPtr <Script::Object>
update_callback,
trigger_callback,
activation_callback,
physic_callback,
physic_sleep_callback,
collision_callback,
collisionex_callback,
render_user_callback;
bool Open();
void Close();
MItemScriptUnit(Script::IVM *);
~MItemScriptUnit();
};
} // S3D
} // GS
#endif // __MITEMSCRIPTUNIT__

View File

@ -0,0 +1,37 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMITEMSCRIPTEDOBJECT__
#define __NMITEMSCRIPTEDOBJECT__
#include "script/scripted_object.h"
namespace GS {
namespace S3D {
class MItem;
/*!
@short Managed item scripted object.
@author Emmanuel Julien (ejulien@nworks.fr)
*/
class MItemScriptedObject : public Script::ScriptedObject
{
MItem *item;
public:
virtual Script::Unit *NewUnit() const;
MItemScriptedObject(MItem *i, Script::IVM *vm = 0) : Script::ScriptedObject(vm), item(i) {}
};
} // S3D
} // GS
#endif // __NMITEMSCRIPTEDOBJECT__

View File

@ -0,0 +1,31 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMITEMTYPE__
#define __NMITEMTYPE__
namespace GS {
namespace S3D {
enum MItemType
{
Type_None = 0,
Type_Camera,
Type_Object,
Type_Light,
Type_Trigger,
Type_Emitter,
Type_Instance,
Type_Terrain,
Type_Constraint
};
} // S3D
} // GS
#endif // __NMITEMTYPE__

View File

@ -0,0 +1,41 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMLIGHT__
#define __NMLIGHT__
#include "core/light.h"
#include "scene3d/mitem.h"
namespace GS {
namespace S3D {
/*!
@short Managed light.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct MLight : public MItem, public Core::Light
{
static MItemType GetMItemClassType() { return Type_Light; }
bool isActive() const;
virtual Core::Item *GetBaseItem() { return this; }
virtual Core::Renderable *GetRenderable() { return 0; }
virtual bool FromMetaTag(NML::Tag &);
virtual NML::Tag *AsMetaTag();
MLight();
};
} // S3D
} // GS
#endif // __NMLIGHT__

View File

@ -0,0 +1,41 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMOBJECT__
#define __NMOBJECT__
#include "core/object.h"
#include "scene3d/mitem.h"
namespace GS {
namespace S3D {
/*!
@short Managed object.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct MObject : public MItem, public Core::Object
{
static MItemType GetMItemClassType() { return Type_Object; }
virtual inline bool IsRenderable() const { return isActive(); }
virtual Core::Item *GetBaseItem() { return this; }
virtual Core::Renderable *GetRenderable() { return this; }
virtual bool FromMetaTag(NML::Tag &);
virtual NML::Tag *AsMetaTag();
MObject();
};
} // S3D
} // GS
#endif // __NMOBJECT__

View File

@ -0,0 +1,39 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMTERRAIN__
#define __NMTERRAIN__
#include "core/terrain.h"
#include "scene3d/mitem.h"
namespace GS {
namespace S3D {
/*!
@short Managed terrain.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct MTerrain : public MItem, public Core::Terrain
{
static MItemType GetMItemClassType() { return Type_Terrain; }
virtual Core::Item *GetBaseItem() { return this; }
virtual Core::Renderable *GetRenderable() { return 0; }
virtual bool FromMetaTag(NML::Tag &);
virtual NML::Tag *AsMetaTag();
MTerrain();
};
} // S3D
} // GS
#endif // __NMTERRAIN__

View File

@ -0,0 +1,53 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NMTRIGGER__
#define __NMTRIGGER__
#include "scene3d/mitem.h"
#include "core/trigger.h"
namespace GS {
namespace S3D {
struct MTrigger;
/// Managed trigger proxy item.
class MTriggerProxy : public Core::Trigger
{
MTrigger *mtrigger;
public:
virtual void MarkItem(Core::Item *);
virtual void DropItem(Core::Item *);
MTriggerProxy(MTrigger *t) : mtrigger(t) {}
};
/*!
@short Managed trigger.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct MTrigger : public MItem, public MTriggerProxy
{
static MItemType GetMItemClassType() { return Type_Trigger; }
virtual Core::Item *GetBaseItem() { return this; }
virtual Core::Renderable *GetRenderable() { return 0; }
virtual bool FromMetaTag(NML::Tag &);
virtual NML::Tag *AsMetaTag();
MTrigger();
};
} // S3D
} // GS
#endif // __NMTRIGGER__

View File

@ -0,0 +1,336 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NSCENE__
#define __NSCENE__
#include "scene3d/scene_message.h"
#include "scene3d/scene_event_interface.h"
#include "scene3d/group.h"
#include "scene3d/scene_io_flag.h"
#include "scene3d/scene_profiler.h"
#include "core/core_profiler.h"
#include "core/renderer_environment_interface.h"
#include "core/simple_list_renderable.h"
#include "core/octree_renderable.h"
#include "core/tool_mode.h"
#include "core/clock.h"
#include "script/script_vm.h"
#include "timing/profiler.h"
#include "reflection/c_refl.h"
/// Debug display flags.
#define SceneDebugDisplayItems (1 << 0)
#define SceneDebugDisplayBones (1 << 1)
#define SceneDebugDisplayBoundingVolumes (1 << 2)
#define SceneDebugDisplayOctreeVolumes (1 << 3)
#define SceneDebugDisplayMotions (1 << 4)
/// Scene update flags.
#define SceneUpdateNone 0
#define SceneUpdateMotion (1 << 0)
#define SceneUpdatePhysic (1 << 1)
#define SceneUpdateEvent (1 << 2)
#define SceneUpdateTrigger (1 << 3)
#define SceneUpdateAll uint(~0)
namespace GS {
namespace GPU { class TriangleBatch; }
namespace S2D { class Scene; }
namespace S3D {
struct MLight;
struct MObject;
struct MTrigger;
struct IPhysicWorld;
class PhysicWorld;
using Render::Renderer;
using Render::RasterFont;
/*!
@short Scene object.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
class Scene : public SharedObject
{
uint current_item_uid;
struct RenderData
{
Render::sShader skybox_shader;
Render::sTexture skybox_layer[2];
Render::sTexture irradiance_probe, radiance_probe;
};
public:
/// Scene-wide flag.
enum SceneFlag
{
FlagNone = 0,
FlagEnd = (1 << 0),
FlagRenderless = (1 << 1),
FlagDebugPhysics = (1 << 2)
};
protected:
Core::sClock clock;
SharedList <MItem *> activation_queue, deactivation_queue;
SharedList <MItem *> item_list, removal_queue;
SharedArrayList <MItem *> active_list; // faster traversal than a shared list
SharedList <Group *> group_list;
List <MLight *> light_list;
List <MTrigger *> trigger_list;
/// Evaluate item.
void UpdateItem(float dt, MItem *, Core::Item *, uint eval_flag = SceneUpdateAll);
public:
String name;
BitField flags; ///< Scene flags.
AutoPtr <S2D::Scene> ui;
void Render(Renderer &);
void RenderUI(Renderer &, GPU::TriangleBatch * = 0);
Core::Clock *GetClock() const { return clock; }
void SetClock(Core::Clock * = 0, bool set_ui = true);
/// Dump scene content to log.
void DumpContentToLog() const;
Core::Camera *current_camera;
/*!
@name Core::Item management.
@{
*/
void SetupItemComponents(MItem *);
void AddItem(MItem *, bool setup_components);
bool RemoveItem(MItem *);
void QueueItemRemoval(MItem *);
void ProcessItemRemovalQueue();
bool ActivateItem(MItem *, bool activate);
void SetItemStatic(MItem *, bool is_static = true);
void QueueItemActivation(MItem *, bool activate = true, bool propagate = false);
void ProcessItemActivationQueue();
MItem *DuplicateItem(MItem *);
MItemType LocateItem(const Core::Item *, MItem **entity = 0) const;
static MItem *LocateManagedItem(Core::Item *);
MItem *Item(const char *name, MItem * = 0) const;
MItem *ItemFromUid(uint uid) const;
const List <MLight *> &GetLightList() const { return light_list; }
const SharedList <MItem *> &GetItemList() const { return item_list; }
const SharedArrayList <MItem *> &GetActiveList() const { return active_list; }
uint GetItemCountByType(MItemType type) const;
// Filter item list and extract items of a give type.
template <class C> uint GetItemListByType(SharedList <C *> &out) const
{
out.Clear();
ListForeachPtr(MItem *, i, item_list)
if (i->GetItemType() == C::GetMItemClassType())
out.Add((C *)i);
return out.GetCount();
}
// Find item by type.
template <class C> C *FindItemByType(const char *name) const
{
ListForeachPtr(MItem *, i, item_list)
if (i->GetItemType() == C::GetMItemClassType())
if (i->name == name)
return (C *)i;
return 0;
}
/*!
@}
@name Group management.
@{
*/
Group *AddGroup(Group *);
bool RemoveGroup(Group *);
Group *FindGroup(const char *name) const;
uint GetItemGroupList(const MItem *, SharedList <Group *> &) const;
void UnregisterItemFromGroups(MItem *) const;
const SharedList <Group *> &GetGroupList() const { return group_list; }
void GroupMembersSetActive(Group *, bool = true);
void DeleteGroupAndMembers(Group *);
/*!
@}
@name Profiling.
@{
*/
SceneProfiler profiler;
/// Display the profiler to screen using the renderer writer.
void DrawProfilerText(Renderer &, RasterFont *font[2], float &x, float &y);
/*!
@}
@name Culling system.
@{
*/
protected:
Core::SimpleCullingSystem simple_culling_system;
Core::OctreeCullingSystem octree_culling_system;
public:
void AddRenderable(Core::Renderable *, bool is_static = false);
void RemoveRenderable(Core::Renderable *);
/// Push this scene renderable onto the renderer display queue.
void PushRenderable(Renderer &);
/*!
@}
@name Environment.
@{
*/
Color background_color, ambient_color;
float ambient_intensity, target_exposure;
float time_of_day;
String skybox_shader;
String skybox_layer[2];
String irradiance_probe, radiance_probe;
float fog_near, fog_far;
Color fog_color;
AutoPtr <Render::IEnvironment> irenderer_environment;
/*!
@}
@name Script system.
@{
*/
protected:
Script::sVM vm;
public:
Script::IVM *GetVM() const { return vm; }
AutoPtr <ISceneEvent> scene_event;
AutoPtr <Script::ScriptedObject> scripted_object;
/// Set as the script master global scene.
void SetAsScriptGlobalScene(Script::IVM * = 0);
/// @}
/*!
@name Motion system.
@{
*/
Core::SceneMotionContainer motion;
/*!
@short Start a motion on the scene items.
@note Request an animation source group if you need control on the
started animation sources.
*/
void SetMotion(const char *name, Automation::SourceGroup ** = 0, float blend = Units::Sec(0.1), Automation::Player::AddSourceMode = Automation::Player::SourceSet, float weight = 1);
/*!
@}
@name Physic system.
@{
*/
void SynchronizePhysics();
AutoPtr <PhysicWorld> physic_world;
AutoPtr <IPhysicWorld> iphysic_world;
MTrigger *RaytraceTriggerList(Vector4 &s, Vector4 &d, float l = -1.f, Vector4 *i = 0);
/*
@}
@name Scene Management.
@{
*/
bool Create(PhysicWorld *);
void Reset();
void Clear(bool keep_script = false);
void InstanceSetup();
void RenderSetup(Core::ResourceFactories *, bool setup_items = true);
void Setup(ToolMode);
void RecordAllItemLocation();
/// @}
void GetMinMax(MinMax &) const;
protected:
void TestOptimizeGeometry(Render::Geometry *, uint octree_node_size);
void UpdateItemTransformation(MItem *, const Time &dt);
public:
void OptimizeForRealtime(uint octree_node_size = 1024);
void UpdateTriggers();
void Update(uint = SceneUpdateAll);
/*!
@name Scene serialization
@{
*/
protected:
bool IsItemToBeSaved(MItem *, const Group *, uint flag) const;
NML::Tag *LinkInfoAsMetaTag(MItem *, const Group * = 0, uint = SceneIOAll) const;
NML::Tag *SkinInfoAsMetaTag(MObject *o, const Group * = 0, uint = SceneIOAll) const;
public:
/// Load all scene resources in render cache.
static bool PreloadResources(Render::ResourceFactory &, const char *uri);
/// Load scene from meta file, store content to group.
bool FromMetaTagStoreGroup(const NML::Tag &, Group ** = 0, uint = SceneIOAll, ToolMode = NoTool, int load_level = 0);
bool FromMetaFileStoreGroup(const char *, Group ** = 0, uint = SceneIOAll, ToolMode = NoTool, int load_level = 0);
bool FromMetaTag(const NML::Tag &tag, ToolMode tool = NoTool) { return FromMetaTagStoreGroup(tag, 0, SceneIOAll, tool); }
NML::Tag *AsMetaTag(const Group *, uint = SceneIOAll, ToolMode = NoTool) const;
NML::Tag *AsMetaTag() const { return AsMetaTag(0); }
/// @}
AutoPtr <RenderData> render_data;
Scene(Script::IVM *vm = 0);
virtual ~Scene();
};
} // S3D
} // GS
#endif // __NSCENE__

View File

@ -0,0 +1,34 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __SCENEACEMANAGER__
#define __SCENEACEMANAGER__
namespace GS {
namespace ACE { class Manager; }
namespace S3D {
enum
{
ACESN_toposition = 0,
ACESN_offsetposition,
ACESN_tooffset,
ACESN_toscale,
ACESN_torotation,
ACESN_toalpha
};
struct ACEManager
{
static ACE::Manager *Get();
};
} // S3D
} // GS
#endif // __SCENEACEMANAGER__

View File

@ -0,0 +1,62 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __SCENE_DEBUG__
#define __SCENE_DEBUG__
#include "memory/nshared_ptr.h"
#include "core/geometry.h"
namespace GS {
namespace Render { class Renderer; }
namespace S3D {
class MItem;
class Scene;
using Render::Renderer;
/*!
@short Scene debugger interface.
@author Emmanuel Julien (ejulien@nworks.fr)
*/
class SceneDebugger
{
protected:
Scene *scene;
Core::sGeometry pointlight, spotlight, linearlight, camera, object, trigger;
/// Draw item bounding volume.
void DrawItemBoundingVolume(Renderer &, MItem *, uint display_flags = ~0);
/// Draw figure.
void DrawFigure(Renderer &, Core::Geometry *, const Matrix4 &, Color &);
/// Display managed item informations.
void DrawItem(Renderer &, MItem *, uint display_flags = ~0, Color * = 0);
/// Display item identifier.
void DrawItemName(Renderer &, MItem *);
public:
float scale;
/// Display scene items schematics.
void DrawScene(Renderer &, const List <MItem *> * = 0, const List <MItem *> *blacklist = 0, uint display_flags = ~0);
/// Load schematic figures.
bool LoadSchematicFigures(const char *pointlight, const char *spotlight, const char *linearlight, const char *camera, const char *object, const char *trigger);
/// Set scene.
void SetScene(Scene *);
SceneDebugger();
};
} // S3D
} // GS
#endif // __SCENE_DEBUG__

View File

@ -0,0 +1,41 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NISCENEEVENT__
#define __NISCENEEVENT__
namespace GS {
namespace S3D {
class Scene;
/*!
@short Scene event handler.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct ISceneEvent
{
virtual void OnSetup(Scene *) {}
virtual void OnSetupDone(Scene *) {}
virtual void OnDelete(Scene *) {}
virtual void OnRender(Scene *) {}
virtual void OnRenderDone(Scene *) {}
virtual void OnRenderUser(Scene *) {}
virtual void OnRenderUIDone(Scene *) {}
virtual void OnReset(Scene *) {}
virtual void OnUpdate(Scene *) {}
virtual void OnPhysicStep(Scene *, bool /*step_taken*/) {}
virtual ~ISceneEvent() {}
};
} // S3D
} // GS
#endif // __NISCENEEVENT__

View File

@ -0,0 +1,41 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NSCENESCRIPTEVENT__
#define __NSCENESCRIPTEVENT__
#include "scene3d/scene_event_interface.h"
namespace GS {
namespace S3D {
/*!
@short Scene script event.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
struct SceneScriptEvent : public ISceneEvent
{
virtual void OnSetup(Scene *);
virtual void OnSetupDone(Scene *);
virtual void OnDelete(Scene *);
virtual void OnRender(Scene *);
virtual void OnRenderDone(Scene *);
virtual void OnRenderUser(Scene *);
virtual void OnRenderUIDone(Scene *);
virtual void OnReset(Scene *);
virtual void OnUpdate(Scene *);
virtual void OnPhysicStep(Scene *, bool step_taken);
};
} // S3D
} // GS
#endif // __NSCENESCRIPTEVENT__

View File

@ -0,0 +1,20 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NSCENEINFO__
#define __NSCENEINFO__
namespace GS {
namespace S3D {
void DumpMemoryLayout();
} // S3D
} // GS
#endif // __NSCENEINFO__

View File

@ -0,0 +1,35 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NSCENEIOFLAG__
#define __NSCENEIOFLAG__
#define SceneIONone uint(0)
#define SceneIOCamera uint(1 << 0)
#define SceneIOLight uint(1 << 1)
#define SceneIOObject uint(1 << 2)
#define SceneIOTrigger uint(1 << 3)
#define SceneIOInstance uint(1 << 4)
#define SceneIOGroup uint(1 << 5)
#define SceneIOMotion uint(1 << 6)
#define SceneIOSettings uint(1 << 7)
#define SceneIOGlobals uint(1 << 8)
#define SceneIOCollision uint(1 << 9)
#define SceneIOPhysic uint(1 << 10)
#define SceneIOPath uint(1 << 11)
#define SceneIOHelper uint(1 << 12)
#define SceneIOScript uint(1 << 13)
#define SceneIOEmitter uint(1 << 14)
#define SceneIOTerrain uint(1 << 15)
#define SceneIOConstraint uint(1 << 16)
#define SceneIOSprite uint(1 << 17)
#define SceneIOWindow uint(1 << 18)
#define SceneIOAll uint(~0)
#endif // __NSCENEIOFLAG__

View File

@ -0,0 +1,65 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NSCENE_MESSAGE__
#define __NSCENE_MESSAGE__
#include "messaging/messaging.h"
namespace GS {
namespace S3D {
class Scene;
/*
@short Scene message enum.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
enum SceneMessage
{
SceneMsg_None = 0, ///< No message.
SceneMsg_AddingItem,
SceneMsg_ItemAdded,
SceneMsg_DeletingItem,
SceneMsg_ItemDeleted,
SceneMsg_AddingGroup,
SceneMsg_GroupAdded,
SceneMsg_DeletingGroup,
SceneMsg_GroupDeleted,
SceneMsg_Clearing,
SceneMsg_Cleared,
SceneMsg_Loading,
SceneMsg_Loaded,
SceneMsg_LastMessage
};
/*
@short Scene message return value.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
enum SceneReturnValue
{
SceneReturn_Ok = 0
};
/// Scene listener.
struct SceneListener
{
virtual SceneReturnValue ProcessMessage(SceneMessage, const Scene *, const void *) = 0;
};
extern Messaging::Broadcaster <SceneMessage, SceneListener, Scene *> g_scene_messenger;
} // S3D
} // GS
#endif // __NSCENE_MESSAGE__

View File

@ -0,0 +1,36 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __SCENEPHYSICWORLDINTERFACE__
#define __SCENEPHYSICWORLDINTERFACE__
#include "physic/physic_world_interface.h"
namespace GS {
namespace S3D {
class Scene;
/*!
@short The scene physic world interface.
*/
class IScenePhysicWorld : public IPhysicWorld
{
Scene *scene;
public:
void PhysicStep(float, bool = true);
IScenePhysicWorld(Scene *s) : scene(s) {}
};
} // S3D
} // GS
#endif // __SCENEPHYSICWORLDINTERFACE__

View File

@ -0,0 +1,62 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NSCENEPROFILER__
#define __NSCENEPROFILER__
#include "timing/profiler.h"
namespace GS {
namespace S3D { class Scene; }
/*!
@short Scene profiler.
@author Emmanuel Julien (ejulien@owloh.com)
*/
struct SceneProfiler : public Profiler
{
S3D::Scene &scene;
public:
System *update, *process_queues, *update_triggers, *update_item_transformation, *update_skin, *scene_on_update, *items_on_update, *physic_step, *synchronize_physics, *ui_update;
System *push_to_render, *push_active_list, *push_simple_culling, *push_octree_culling;
virtual void ResetProfiles();
SceneProfiler(S3D::Scene &s) : scene(s)
{
// Update
update = DeclareSystem("Update");
process_queues = DeclareSystem("Process queues", update);
update_triggers = DeclareSystem("Update triggers", update);
update_item_transformation = DeclareSystem("Update item transformation", update);
update_skin = DeclareSystem("Update item skin", update);
scene_on_update = DeclareSystem("Script scene OnUpdate()", update);
items_on_update = DeclareSystem("Script items OnUpdate()", update);
physic_step = DeclareSystem("Physic step", update);
synchronize_physics = DeclareSystem("Physics synchronization", update);
ui_update = DeclareSystem("Update UI", update);
// Push to render
push_to_render = DeclareSystem("Push to render");
push_active_list = DeclareSystem("Push active list", push_to_render);
push_simple_culling = DeclareSystem("Push simple renderable", push_to_render);
push_octree_culling = DeclareSystem("Push octree renderable", push_to_render);
}
};
} // GS
#endif // __NSCENEPROFILER__

View File

@ -0,0 +1,53 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NSCENERENDERERENVINTERFACE__
#define __NSCENERENDERERENVINTERFACE__
#include "core/renderer_environment_interface.h"
namespace GS {
namespace S3D {
class Scene;
/*
@short Scene renderer environment.
Used to query environment informations.
*/
struct IEnvironment : public Render::IEnvironment
{
Scene *scene;
virtual float GetClock() const;
virtual float GetTimeOfDay() const;
virtual Render::Shader *GetSkyboxShader() const;
virtual bool GetSkyboxLayers(Render::sTexture [2]) const;
virtual Color GetClearColor() const;
virtual Color GetAmbientColor() const;
virtual void GetEnvironmentProbe(Render::sTexture &/*radiance*/, Render::sTexture &/*irradiance*/) const;
virtual Core::Camera *GetCurrentCamera() const;
virtual void GetLightsInFrustum(const Vector4 &/*world_pos*/, const Frustum &/*frustum*/, List <Core::Light *> &/*list*/, uint /*limit*/ = 0) const;
virtual void GetClosestLights(const Vector4 &/*world_pos*/, List <Core::Light *> &/*list*/, uint /*limit*/ = 0) const;
virtual bool IsFogEnabled() const;
virtual bool GetFogConfiguration(Color &color, float &fog_near, float &fog_far) const;
virtual void OnRenderUser(Render::Renderer *) const;
IEnvironment(Scene *s) : scene(s) {}
};
} // S3D
} // GS
#endif // __NSCENERENDERERENVINTERFACE__

View File

@ -0,0 +1,56 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __SCENESCRIPTUNIT__
#define __SCENESCRIPTUNIT__
#include "script/script_unit.h"
#include "script/script_object.h"
#include "memory/nauto_ptr.h"
namespace GS {
namespace S3D {
/*!
@short Scene script unit.
@author Emmanuel Julien (ejulien@gsworks.fr)
*/
class SceneScriptUnit : public Script::Unit
{
int suspend_update;
public:
AutoPtr <Script::Object>
render_callback,
render_done_callback,
render_user_callback,
render_ui_done_callback,
physic_step_callback,
update_callback;
/// Update and return the state of the suspend flag.
bool IsSuspended(int dt);
/*!
@short Suspend update calls for a given duration.
Resume updates by passing a zero delay.
*/
void SuspendUpdate(int ms = 0);
bool Open();
void Close();
SceneScriptUnit(Script::IVM *);
~SceneScriptUnit();
};
} // S3D
} //GS
#endif // __SCENESCRIPTUNIT__

View File

@ -0,0 +1,37 @@
/* -----------------------------------------------------------------------------
GSFramework
Copyright 2001-2013 Emmanuel Julien. All Rights Reserved.
----------------------------------------------------------------------------- */
#ifndef __NSCENESCRIPTEDOBJECT__
#define __NSCENESCRIPTEDOBJECT__
#include "script/scripted_object.h"
namespace GS {
namespace S3D {
class Scene;
/*!
@short Scene scripted object.
@author Emmanuel Julien (ejulien@nworks.fr)
*/
class SceneScriptedObject : public Script::ScriptedObject
{
Scene *scene;
public:
virtual Script::Unit *NewUnit() const;
SceneScriptedObject(Script::IVM *vm, Scene *s) : Script::ScriptedObject(vm), scene(s) {}
};
} // S3D
} // GS
#endif // __NSCENESCRIPTEDOBJECT__