mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-02-24 00:53:47 +00:00
Initial implementation of the Scene object for handling scenes/levels in a more consistent and deliberate way.
This commit is contained in:
parent
e0627973fb
commit
1c2f90a190
37 changed files with 509 additions and 140 deletions
236
Engine/source/T3D/Scene.cpp
Normal file
236
Engine/source/T3D/Scene.cpp
Normal file
|
|
@ -0,0 +1,236 @@
|
|||
#include "Scene.h"
|
||||
|
||||
Scene * Scene::smRootScene = nullptr;
|
||||
Vector<Scene*> Scene::smSceneList;
|
||||
|
||||
IMPLEMENT_CO_NETOBJECT_V1(Scene);
|
||||
|
||||
Scene::Scene() :
|
||||
mIsSubScene(false),
|
||||
mParentScene(nullptr),
|
||||
mSceneId(-1),
|
||||
mIsEditing(false),
|
||||
mIsDirty(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Scene::initPersistFields()
|
||||
{
|
||||
Parent::initPersistFields();
|
||||
|
||||
addGroup("Internal");
|
||||
addField("isSubscene", TypeBool, Offset(mIsSubScene, Scene), "", AbstractClassRep::FIELD_HideInInspectors);
|
||||
addField("isEditing", TypeBool, Offset(mIsEditing, Scene), "", AbstractClassRep::FIELD_HideInInspectors);
|
||||
addField("isDirty", TypeBool, Offset(mIsDirty, Scene), "", AbstractClassRep::FIELD_HideInInspectors);
|
||||
endGroup("Internal");
|
||||
}
|
||||
|
||||
bool Scene::onAdd()
|
||||
{
|
||||
if (!Parent::onAdd())
|
||||
return false;
|
||||
|
||||
smSceneList.push_back(this);
|
||||
mSceneId = smSceneList.size() - 1;
|
||||
|
||||
/*if (smRootScene == nullptr)
|
||||
{
|
||||
//we're the first scene, so we're the root. woo!
|
||||
smRootScene = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
mIsSubScene = true;
|
||||
smRootScene->mSubScenes.push_back(this);
|
||||
}*/
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Scene::onRemove()
|
||||
{
|
||||
Parent::onRemove();
|
||||
|
||||
smSceneList.remove(this);
|
||||
mSceneId = -1;
|
||||
|
||||
/*if (smRootScene == this)
|
||||
{
|
||||
for (U32 i = 0; i < mSubScenes.size(); i++)
|
||||
{
|
||||
mSubScenes[i]->deleteObject();
|
||||
}
|
||||
}
|
||||
else if (smRootScene != nullptr)
|
||||
{
|
||||
for (U32 i = 0; i < mSubScenes.size(); i++)
|
||||
{
|
||||
if(mSubScenes[i]->getId() == getId())
|
||||
smRootScene->mSubScenes.erase(i);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void Scene::addObject(SimObject* object)
|
||||
{
|
||||
//Child scene
|
||||
Scene* scene = dynamic_cast<Scene*>(object);
|
||||
if (scene)
|
||||
{
|
||||
//We'll keep these principly separate so they don't get saved into each other
|
||||
mSubScenes.push_back(scene);
|
||||
return;
|
||||
}
|
||||
|
||||
SceneObject* sceneObj = dynamic_cast<SceneObject*>(object);
|
||||
if (sceneObj)
|
||||
{
|
||||
//We'll operate on the presumption that if it's being added via regular parantage means, it's considered permanent
|
||||
mPermanentObjects.push_back(sceneObj);
|
||||
Parent::addObject(object);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
//Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene?
|
||||
Parent::addObject(object);
|
||||
}
|
||||
|
||||
void Scene::removeObject(SimObject* object)
|
||||
{
|
||||
//Child scene
|
||||
Scene* scene = dynamic_cast<Scene*>(object);
|
||||
if (scene)
|
||||
{
|
||||
//We'll keep these principly separate so they don't get saved into each other
|
||||
mSubScenes.remove(scene);
|
||||
return;
|
||||
}
|
||||
|
||||
SceneObject* sceneObj = dynamic_cast<SceneObject*>(object);
|
||||
if (sceneObj)
|
||||
{
|
||||
//We'll operate on the presumption that if it's being added via regular parantage means, it's considered permanent
|
||||
|
||||
mPermanentObjects.remove(sceneObj);
|
||||
Parent::removeObject(object);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
Parent::removeObject(object);
|
||||
}
|
||||
|
||||
void Scene::addDynamicObject(SceneObject* object)
|
||||
{
|
||||
mDynamicObjects.push_back(object);
|
||||
|
||||
//Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene?
|
||||
Parent::addObject(object);
|
||||
}
|
||||
|
||||
void Scene::removeDynamicObject(SceneObject* object)
|
||||
{
|
||||
mDynamicObjects.remove(object);
|
||||
|
||||
//Do it like regular, though we should probably bail if we're trying to add non-scene objects to the scene?
|
||||
Parent::removeObject(object);
|
||||
}
|
||||
|
||||
void Scene::interpolateTick(F32 delta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Scene::processTick()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Scene::advanceTime(F32 timeDelta)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
U32 Scene::packUpdate(NetConnection *conn, U32 mask, BitStream *stream)
|
||||
{
|
||||
bool ret = Parent::packUpdate(conn, mask, stream);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void Scene::unpackUpdate(NetConnection *conn, BitStream *stream)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
Vector<SceneObject*> Scene::getObjectsByClass(String className)
|
||||
{
|
||||
return Vector<SceneObject*>();
|
||||
}
|
||||
|
||||
DefineEngineFunction(getScene, Scene*, (U32 sceneId), (0),
|
||||
"Get the root Scene object that is loaded.\n"
|
||||
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
|
||||
{
|
||||
if (Scene::smSceneList.empty() || sceneId >= Scene::smSceneList.size())
|
||||
return nullptr;
|
||||
|
||||
return Scene::smSceneList[sceneId];
|
||||
}
|
||||
|
||||
DefineEngineFunction(getRootScene, S32, (), ,
|
||||
"Get the root Scene object that is loaded.\n"
|
||||
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
|
||||
{
|
||||
Scene* root = Scene::getRootScene();
|
||||
|
||||
if (root)
|
||||
return root->getId();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DefineEngineMethod(Scene, getRootScene, S32, (),,
|
||||
"Get the root Scene object that is loaded.\n"
|
||||
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
|
||||
{
|
||||
Scene* root = Scene::getRootScene();
|
||||
|
||||
if (root)
|
||||
return root->getId();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DefineEngineMethod(Scene, addDynamicObject, void, (SceneObject* sceneObj), (nullAsType<SceneObject*>()),
|
||||
"Get the root Scene object that is loaded.\n"
|
||||
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
|
||||
{
|
||||
object->addDynamicObject(sceneObj);
|
||||
}
|
||||
|
||||
DefineEngineMethod(Scene, removeDynamicObject, void, (SceneObject* sceneObj), (nullAsType<SceneObject*>()),
|
||||
"Get the root Scene object that is loaded.\n"
|
||||
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
|
||||
{
|
||||
object->removeDynamicObject(sceneObj);
|
||||
}
|
||||
|
||||
DefineEngineMethod(Scene, getObjectsByClass, String, (String className), (""),
|
||||
"Get the root Scene object that is loaded.\n"
|
||||
"@return The id of the Root Scene. Will be 0 if no root scene is loaded")
|
||||
{
|
||||
if (className == String::EmptyString)
|
||||
return "";
|
||||
|
||||
//return object->getObjectsByClass(className);
|
||||
return "";
|
||||
}
|
||||
79
Engine/source/T3D/Scene.h
Normal file
79
Engine/source/T3D/Scene.h
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
#pragma once
|
||||
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#ifndef _NETOBJECT_H_
|
||||
#include "sim/netObject.h"
|
||||
#endif
|
||||
|
||||
#ifndef _ITICKABLE_H_
|
||||
#include "core/iTickable.h"
|
||||
#endif
|
||||
|
||||
#include "scene/sceneObject.h"
|
||||
|
||||
/// Scene
|
||||
/// This object is effectively a smart container to hold and manage any relevent scene objects and data
|
||||
/// used to run things.
|
||||
class Scene : public NetObject, public virtual ITickable
|
||||
{
|
||||
typedef NetObject Parent;
|
||||
|
||||
bool mIsSubScene;
|
||||
|
||||
Scene* mParentScene;
|
||||
|
||||
Vector<Scene*> mSubScenes;
|
||||
|
||||
Vector<SceneObject*> mPermanentObjects;
|
||||
|
||||
Vector<SceneObject*> mDynamicObjects;
|
||||
|
||||
S32 mSceneId;
|
||||
|
||||
bool mIsEditing;
|
||||
|
||||
bool mIsDirty;
|
||||
|
||||
protected:
|
||||
static Scene * smRootScene;
|
||||
|
||||
DECLARE_CONOBJECT(Scene);
|
||||
|
||||
public:
|
||||
Scene();
|
||||
~Scene();
|
||||
|
||||
static void initPersistFields();
|
||||
|
||||
virtual bool onAdd();
|
||||
virtual void onRemove();
|
||||
|
||||
virtual void interpolateTick(F32 delta);
|
||||
virtual void processTick();
|
||||
virtual void advanceTime(F32 timeDelta);
|
||||
|
||||
virtual void addObject(SimObject* object);
|
||||
virtual void removeObject(SimObject* object);
|
||||
|
||||
void addDynamicObject(SceneObject* object);
|
||||
void removeDynamicObject(SceneObject* object);
|
||||
|
||||
//
|
||||
//Networking
|
||||
U32 packUpdate(NetConnection *conn, U32 mask, BitStream *stream);
|
||||
void unpackUpdate(NetConnection *conn, BitStream *stream);
|
||||
|
||||
//
|
||||
Vector<SceneObject*> getObjectsByClass(String className);
|
||||
|
||||
static Scene *getRootScene()
|
||||
{
|
||||
if (Scene::smSceneList.empty())
|
||||
return nullptr;
|
||||
|
||||
return Scene::smSceneList[0];
|
||||
}
|
||||
|
||||
static Vector<Scene*> smSceneList;
|
||||
};
|
||||
|
|
@ -34,6 +34,8 @@
|
|||
#include "T3D/physics/physicsShape.h"
|
||||
#include "core/util/path.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
// We use this locally ( within this file ) to prevent infinite recursion
|
||||
// while loading prefab files that contain other prefabs.
|
||||
static Vector<String> sPrefabFileStack;
|
||||
|
|
@ -269,11 +271,11 @@ void Prefab::setFile( String file )
|
|||
|
||||
SimGroup* Prefab::explode()
|
||||
{
|
||||
SimGroup *missionGroup;
|
||||
Scene* scene = Scene::getRootScene();
|
||||
|
||||
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
if ( !scene)
|
||||
{
|
||||
Con::errorf( "Prefab::explode, MissionGroup was not found." );
|
||||
Con::errorf( "Prefab::explode, Scene was not found." );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -295,7 +297,7 @@ SimGroup* Prefab::explode()
|
|||
smChildToPrefabMap.erase( child->getId() );
|
||||
}
|
||||
|
||||
missionGroup->addObject(group);
|
||||
scene->addObject(group);
|
||||
mChildGroup = NULL;
|
||||
mChildMap.clear();
|
||||
|
||||
|
|
@ -468,10 +470,10 @@ Prefab* Prefab::getPrefabByChild( SimObject *child )
|
|||
|
||||
bool Prefab::isValidChild( SimObject *simobj, bool logWarnings )
|
||||
{
|
||||
if ( simobj->getName() && dStricmp(simobj->getName(),"MissionGroup") == 0 )
|
||||
if ( simobj->getName() && simobj == Scene::getRootScene() )
|
||||
{
|
||||
if ( logWarnings )
|
||||
Con::warnf( "MissionGroup is not valid within a Prefab." );
|
||||
Con::warnf( "root Scene is not valid within a Prefab." );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ public:
|
|||
void setFile( String file );
|
||||
|
||||
/// Removes all children from this Prefab and puts them into a SimGroup
|
||||
/// which is added to the MissionGroup and returned to the caller.
|
||||
/// which is added to the Scene and returned to the caller.
|
||||
SimGroup* explode();
|
||||
|
||||
bool buildPolyList(PolyListContext context, AbstractPolyList* polyList, const Box3F &box, const SphereF& sphere);
|
||||
|
|
|
|||
|
|
@ -45,6 +45,8 @@
|
|||
#include "materials/materialDefinition.h"
|
||||
#include "T3D/prefab.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiMeshRoadEditorCtrl);
|
||||
|
||||
ConsoleDocClass( GuiMeshRoadEditorCtrl,
|
||||
|
|
@ -420,12 +422,14 @@ void GuiMeshRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
|
|||
|
||||
newRoad->registerObject();
|
||||
|
||||
// Add to MissionGroup
|
||||
SimGroup *missionGroup;
|
||||
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
Con::errorf( "GuiMeshRoadEditorCtrl - could not find MissionGroup to add new MeshRoad" );
|
||||
// Add to scene
|
||||
Scene *scene;
|
||||
|
||||
scene = Scene::getRootScene();
|
||||
if ( !scene)
|
||||
Con::errorf( "GuiMeshRoadEditorCtrl - could not find Scene to add new MeshRoad" );
|
||||
else
|
||||
missionGroup->addObject( newRoad );
|
||||
scene->addObject( newRoad );
|
||||
|
||||
Point3F pos( endPnt );
|
||||
pos.z += mDefaultDepth * 0.5f;
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@
|
|||
#include "T3D/gameBase/gameConnection.h"
|
||||
#include "T3D/prefab.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiRiverEditorCtrl);
|
||||
|
||||
ConsoleDocClass( GuiRiverEditorCtrl,
|
||||
|
|
@ -444,12 +446,12 @@ void GuiRiverEditorCtrl::_process3DMouseDown( const Gui3DMouseEvent& event )
|
|||
return;
|
||||
}
|
||||
|
||||
// Add to MissionGroup
|
||||
SimGroup *missionGroup;
|
||||
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
Con::errorf( "GuiRiverEditorCtrl - could not find MissionGroup to add new River" );
|
||||
// Add to Scene
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( !scene )
|
||||
Con::errorf( "GuiRiverEditorCtrl - could not find root Scene to add new River" );
|
||||
else
|
||||
missionGroup->addObject( newRiver );
|
||||
scene->addObject( newRiver );
|
||||
|
||||
Point3F pos( endPnt );
|
||||
pos.z += mDefaultDepth * 0.5f;
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@
|
|||
#include "gui/worldEditor/undoActions.h"
|
||||
#include "materials/materialDefinition.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(GuiRoadEditorCtrl);
|
||||
|
||||
ConsoleDocClass( GuiRoadEditorCtrl,
|
||||
|
|
@ -407,12 +409,12 @@ void GuiRoadEditorCtrl::on3DMouseDown(const Gui3DMouseEvent & event)
|
|||
|
||||
newRoad->registerObject();
|
||||
|
||||
// Add to MissionGroup
|
||||
SimGroup *missionGroup;
|
||||
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
Con::errorf( "GuiDecalRoadEditorCtrl - could not find MissionGroup to add new DecalRoad" );
|
||||
// Add to scene
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( !scene )
|
||||
Con::errorf( "GuiDecalRoadEditorCtrl - could not find scene to add new DecalRoad" );
|
||||
else
|
||||
missionGroup->addObject( newRoad );
|
||||
scene->addObject( newRoad );
|
||||
|
||||
newRoad->insertNode( tPos, mDefaultWidth, 0 );
|
||||
U32 newNode = newRoad->insertNode( tPos, mDefaultWidth, 1 );
|
||||
|
|
@ -722,7 +724,7 @@ void GuiRoadEditorCtrl::renderScene(const RectI & updateRect)
|
|||
// Draw the spline based from the client-side road
|
||||
// because the serverside spline is not actually reliable...
|
||||
// Can be incorrect if the DecalRoad is before the TerrainBlock
|
||||
// in the MissionGroup.
|
||||
// in the scene.
|
||||
|
||||
if ( mHoverRoad && mHoverRoad != mSelRoad )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@
|
|||
#include "scene/sceneRenderState.h"
|
||||
#include "renderInstance/renderBinManager.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(EditTSCtrl);
|
||||
ConsoleDocClass( EditTSCtrl,
|
||||
|
|
@ -795,15 +796,15 @@ void EditTSCtrl::_renderScene( ObjectRenderInst*, SceneRenderState *state, BaseM
|
|||
GFXTransformSaver saver;
|
||||
|
||||
// render through console callbacks
|
||||
SimSet * missionGroup = static_cast<SimSet*>(Sim::findObject("MissionGroup"));
|
||||
if(missionGroup)
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if(scene)
|
||||
{
|
||||
mConsoleRendering = true;
|
||||
|
||||
// [ rene, 27-Jan-10 ] This calls onEditorRender on the server objects instead
|
||||
// of on the client objects which seems a bit questionable to me.
|
||||
|
||||
for(SimSetIterator itr(missionGroup); *itr; ++itr)
|
||||
for(SimSetIterator itr(scene); *itr; ++itr)
|
||||
{
|
||||
SceneObject* object = dynamic_cast< SceneObject* >( *itr );
|
||||
if( object && object->isRenderEnabled() && !object->isHidden() )
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@
|
|||
#include "T3D/portal.h"
|
||||
#include "math/mPolyhedron.impl.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT( GuiConvexEditorCtrl );
|
||||
|
||||
ConsoleDocClass( GuiConvexEditorCtrl,
|
||||
|
|
@ -121,12 +123,12 @@ bool GuiConvexEditorCtrl::onWake()
|
|||
if ( !Parent::onWake() )
|
||||
return false;
|
||||
|
||||
SimGroup *missionGroup;
|
||||
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( !scene )
|
||||
return true;
|
||||
|
||||
SimGroup::iterator itr = missionGroup->begin();
|
||||
for ( ; itr != missionGroup->end(); itr++ )
|
||||
SimGroup::iterator itr = scene->begin();
|
||||
for ( ; itr != scene->end(); itr++ )
|
||||
{
|
||||
if ( dStrcmp( (*itr)->getClassName(), "ConvexShape" ) == 0 )
|
||||
{
|
||||
|
|
@ -166,8 +168,8 @@ void GuiConvexEditorCtrl::setVisible( bool val )
|
|||
mSavedGizmoFlags = -1;
|
||||
}
|
||||
|
||||
SimGroup* misGroup;
|
||||
if (Sim::findObject("MissionGroup", misGroup))
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (scene != nullptr)
|
||||
{
|
||||
//Make our proxy objects "real" again
|
||||
for (U32 i = 0; i < mProxyObjects.size(); ++i)
|
||||
|
|
@ -184,7 +186,7 @@ void GuiConvexEditorCtrl::setVisible( bool val )
|
|||
|
||||
SceneObject* polyObj = createPolyhedralObject(mProxyObjects[i].targetObjectClass.c_str(), mProxyObjects[i].shapeProxy);
|
||||
|
||||
misGroup->addObject(polyObj);
|
||||
scene->addObject(polyObj);
|
||||
|
||||
//Now, remove the convex proxy
|
||||
mProxyObjects[i].shapeProxy->deleteObject();
|
||||
|
|
@ -222,19 +224,19 @@ void GuiConvexEditorCtrl::setVisible( bool val )
|
|||
updateGizmoPos();
|
||||
mSavedGizmoFlags = mGizmoProfile->flags;
|
||||
|
||||
SimGroup* misGroup;
|
||||
if (Sim::findObject("MissionGroup", misGroup))
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (scene != nullptr)
|
||||
{
|
||||
for (U32 c = 0; c < misGroup->size(); ++c)
|
||||
for (U32 c = 0; c < scene->size(); ++c)
|
||||
{
|
||||
bool isTrigger = (misGroup->at(c)->getClassName() == StringTable->insert("Trigger"));
|
||||
bool isZone = (misGroup->at(c)->getClassName() == StringTable->insert("Zone"));
|
||||
bool isPortal = (misGroup->at(c)->getClassName() == StringTable->insert("Portal"));
|
||||
bool isOccluder = (misGroup->at(c)->getClassName() == StringTable->insert("OcclusionVolume"));
|
||||
bool isTrigger = (scene->at(c)->getClassName() == StringTable->insert("Trigger"));
|
||||
bool isZone = (scene->at(c)->getClassName() == StringTable->insert("Zone"));
|
||||
bool isPortal = (scene->at(c)->getClassName() == StringTable->insert("Portal"));
|
||||
bool isOccluder = (scene->at(c)->getClassName() == StringTable->insert("OcclusionVolume"));
|
||||
|
||||
if (isZone || isPortal || isOccluder)
|
||||
{
|
||||
SceneObject* sceneObj = static_cast<SceneObject*>(misGroup->at(c));
|
||||
SceneObject* sceneObj = static_cast<SceneObject*>(scene->at(c));
|
||||
if (!sceneObj)
|
||||
{
|
||||
Con::errorf("WorldEditor::createConvexShapeFrom - Invalid object");
|
||||
|
|
@ -1350,9 +1352,9 @@ void GuiConvexEditorCtrl::setupShape( ConvexShape *shape )
|
|||
shape->registerObject();
|
||||
updateShape( shape );
|
||||
|
||||
SimGroup *group;
|
||||
if ( Sim::findObject( "missionGroup", group ) )
|
||||
group->addObject( shape );
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( scene )
|
||||
scene->addObject( shape );
|
||||
}
|
||||
|
||||
void GuiConvexEditorCtrl::updateShape( ConvexShape *shape, S32 offsetFace )
|
||||
|
|
@ -1929,10 +1931,8 @@ ConvexEditorTool::EventResult ConvexEditorCreateTool::on3DMouseUp( const Gui3DMo
|
|||
}
|
||||
else if ( mStage == 0 )
|
||||
{
|
||||
SimGroup *mg;
|
||||
Sim::findObject( "MissionGroup", mg );
|
||||
|
||||
mg->addObject( mNewConvex );
|
||||
SimGroup *scene = Scene::getRootScene();
|
||||
scene->addObject( mNewConvex );
|
||||
|
||||
mStage = -1;
|
||||
|
||||
|
|
@ -2128,9 +2128,9 @@ ConvexShape* ConvexEditorCreateTool::extrudeShapeFromFace( ConvexShape *inShape,
|
|||
newShape->registerObject();
|
||||
mEditor->updateShape( newShape );
|
||||
|
||||
SimGroup *group;
|
||||
if ( Sim::findObject( "missionGroup", group ) )
|
||||
group->addObject( newShape );
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( scene )
|
||||
scene->addObject( newShape );
|
||||
|
||||
return newShape;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
#include "gui/worldEditor/terrainActions.h"
|
||||
#include "terrain/terrMaterial.h"
|
||||
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT(TerrainEditor);
|
||||
|
||||
|
|
@ -2405,10 +2405,10 @@ void TerrainEditor::reorderMaterial( S32 index, S32 orderPos )
|
|||
|
||||
DefineEngineMethod( TerrainEditor, attachTerrain, void, (const char * terrain), (""), "(TerrainBlock terrain)")
|
||||
{
|
||||
SimSet * missionGroup = dynamic_cast<SimSet*>(Sim::findObject("MissionGroup"));
|
||||
if (!missionGroup)
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (!scene)
|
||||
{
|
||||
Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: no mission group found");
|
||||
Con::errorf(ConsoleLogEntry::Script, "TerrainEditor::attach: no scene found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2417,7 +2417,7 @@ DefineEngineMethod( TerrainEditor, attachTerrain, void, (const char * terrain),
|
|||
// attach to first found terrainBlock
|
||||
if (dStrcmp (terrain,"")==0)
|
||||
{
|
||||
for(SimSetIterator itr(missionGroup); *itr; ++itr)
|
||||
for(SimSetIterator itr(scene); *itr; ++itr)
|
||||
{
|
||||
TerrainBlock* terrBlock = dynamic_cast<TerrainBlock*>(*itr);
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@
|
|||
|
||||
#include "tools/editorTool.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
IMPLEMENT_CONOBJECT( WorldEditor );
|
||||
|
||||
ConsoleDocClass( WorldEditor,
|
||||
|
|
@ -455,19 +457,20 @@ bool WorldEditor::pasteSelection( bool dropSel )
|
|||
return false;
|
||||
}
|
||||
|
||||
SimGroup *missionGroup = NULL;
|
||||
SimGroup *targetGroup = NULL;
|
||||
if( isMethod( "getNewObjectGroup" ) )
|
||||
{
|
||||
const char* targetGroupName = Con::executef( this, "getNewObjectGroup" );
|
||||
if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, missionGroup ) )
|
||||
if( targetGroupName && targetGroupName[ 0 ] && !Sim::findObject( targetGroupName, targetGroup) )
|
||||
Con::errorf( "WorldEditor::pasteSelection() - no SimGroup called '%s'", targetGroupName );
|
||||
}
|
||||
|
||||
if( !missionGroup )
|
||||
if( !targetGroup)
|
||||
{
|
||||
if( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
targetGroup = Scene::getRootScene();
|
||||
if( !targetGroup)
|
||||
{
|
||||
Con::errorf( "WorldEditor::pasteSelection() - MissionGroup not found" );
|
||||
Con::errorf( "WorldEditor::pasteSelection() - Scene not found" );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
@ -481,8 +484,8 @@ bool WorldEditor::pasteSelection( bool dropSel )
|
|||
if ( !obj )
|
||||
continue;
|
||||
|
||||
if ( missionGroup )
|
||||
missionGroup->addObject( obj );
|
||||
if (targetGroup)
|
||||
targetGroup->addObject( obj );
|
||||
|
||||
action->addObject( obj );
|
||||
|
||||
|
|
@ -594,7 +597,7 @@ void WorldEditor::hideObject(SceneObject* serverObj, bool hide)
|
|||
|
||||
void WorldEditor::hideSelection(bool hide)
|
||||
{
|
||||
SimGroup* pGroup = dynamic_cast<SimGroup*>(Sim::findObject("MissionGroup"));
|
||||
Scene* scene = Scene::getRootScene();
|
||||
|
||||
// set server/client objects hide field
|
||||
for(U32 i = 0; i < mSelected->size(); i++)
|
||||
|
|
@ -605,7 +608,7 @@ void WorldEditor::hideSelection(bool hide)
|
|||
|
||||
// Prevent non-mission group objects (i.e. Player) from being hidden.
|
||||
// Otherwise it is difficult to show them again.
|
||||
if(!serverObj->isChildOfGroup(pGroup))
|
||||
if(!serverObj->isChildOfGroup(scene))
|
||||
continue;
|
||||
|
||||
hideObject(serverObj, hide);
|
||||
|
|
@ -2437,7 +2440,7 @@ void WorldEditor::renderScene( const RectI &updateRect )
|
|||
}
|
||||
|
||||
// Render the paths
|
||||
renderPaths(Sim::findObject("MissionGroup"));
|
||||
renderPaths(Scene::getRootScene());
|
||||
|
||||
// walk selected
|
||||
Selection* selection = getActiveSelectionSet();
|
||||
|
|
@ -3653,10 +3656,10 @@ void WorldEditor::makeSelectionPrefab( const char *filename )
|
|||
return;
|
||||
}
|
||||
|
||||
SimGroup *missionGroup;
|
||||
if ( !Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if ( !scene)
|
||||
{
|
||||
Con::errorf( "WorldEditor::makeSelectionPrefab - Could not find MissionGroup." );
|
||||
Con::errorf( "WorldEditor::makeSelectionPrefab - Could not find root Scene." );
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -3746,7 +3749,7 @@ void WorldEditor::makeSelectionPrefab( const char *filename )
|
|||
fabMat.inverse();
|
||||
fab->setTransform( fabMat );
|
||||
fab->registerObject();
|
||||
missionGroup->addObject( fab );
|
||||
scene->addObject( fab );
|
||||
|
||||
// Select it, mark level as dirty.
|
||||
clearSelection();
|
||||
|
|
@ -3812,10 +3815,10 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
|||
return;
|
||||
}
|
||||
|
||||
SimGroup *missionGroup;
|
||||
if (!Sim::findObject("MissionGroup", missionGroup))
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (!scene)
|
||||
{
|
||||
Con::errorf("WorldEditor::makeSelectionAMesh - Could not find MissionGroup.");
|
||||
Con::errorf("WorldEditor::makeSelectionAMesh - Could not find root Scene.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -3965,7 +3968,7 @@ void WorldEditor::makeSelectionAMesh(const char *filename)
|
|||
fabMat.inverse();
|
||||
ts->setTransform(fabMat);
|
||||
ts->registerObject();
|
||||
missionGroup->addObject(ts);
|
||||
scene->addObject(ts);
|
||||
|
||||
// Select it, mark level as dirty.
|
||||
clearSelection();
|
||||
|
|
|
|||
|
|
@ -35,6 +35,8 @@
|
|||
#include "renderInstance/renderPassManager.h"
|
||||
#include "console/engineAPI.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
extern bool gEditingMission;
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
|
|
@ -59,13 +61,13 @@ DefineEngineFunction(pathOnMissionLoadDone, void, (),,
|
|||
"@ingroup Networking")
|
||||
{
|
||||
// Need to load subobjects for all loaded interiors...
|
||||
SimGroup* pMissionGroup = dynamic_cast<SimGroup*>(Sim::findObject("MissionGroup"));
|
||||
AssertFatal(pMissionGroup != NULL, "Error, mission done loading and no mission group?");
|
||||
Scene* scene = Scene::getRootScene();
|
||||
AssertFatal(scene != NULL, "Error, mission done loading and no scene?");
|
||||
|
||||
U32 currStart = 0;
|
||||
U32 currEnd = 1;
|
||||
Vector<SimGroup*> groups;
|
||||
groups.push_back(pMissionGroup);
|
||||
groups.push_back(scene);
|
||||
|
||||
while (true) {
|
||||
for (U32 i = currStart; i < currEnd; i++) {
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
#include "util/noise2d.h"
|
||||
#include "core/volume.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
using namespace Torque;
|
||||
|
||||
DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32 resolution, String materialName, bool genNoise),,
|
||||
|
|
@ -108,9 +110,9 @@ DefineEngineStaticMethod( TerrainBlock, createNew, S32, (String terrainName, U32
|
|||
terrain->registerObject( terrainName.c_str() );
|
||||
|
||||
// Add to mission group!
|
||||
SimGroup *missionGroup;
|
||||
if( Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
missionGroup->addObject( terrain );
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if(scene)
|
||||
scene->addObject( terrain );
|
||||
|
||||
return terrain->getId();
|
||||
}
|
||||
|
|
@ -245,10 +247,10 @@ DefineEngineStaticMethod( TerrainBlock, import, S32, (String terrainName, String
|
|||
terrain->import( (*heightmap), heightScale, metersPerPixel, layerMap, materials, flipYAxis );
|
||||
terrain->registerObject();
|
||||
|
||||
// Add to mission group!
|
||||
SimGroup *missionGroup;
|
||||
if ( Sim::findObject( "MissionGroup", missionGroup ) )
|
||||
missionGroup->addObject( terrain );
|
||||
// Add to scene!
|
||||
Scene* scene = Scene::getRootScene();
|
||||
if (scene)
|
||||
scene->addObject( terrain );
|
||||
}
|
||||
|
||||
return terrain->getId();
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@
|
|||
#include "T3D/pointLight.h"
|
||||
#include "T3D/spotLight.h"
|
||||
|
||||
#include "T3D/Scene.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Collada <light> elements are very similar, but are arranged as separate, unrelated
|
||||
|
|
@ -140,11 +141,11 @@ static void processNodeLights(AppNode* appNode, const MatrixF& offset, SimGroup*
|
|||
|
||||
// Load lights from a collada file and add to the scene.
|
||||
DefineEngineFunction( loadColladaLights, bool, (const char * filename, const char * parentGroup, const char * baseObject), ("", ""),
|
||||
"(string filename, SimGroup parentGroup=MissionGroup, SimObject baseObject=-1)"
|
||||
"(string filename, SimGroup parentGroup=Scene, SimObject baseObject=-1)"
|
||||
"Load all light instances from a COLLADA (.dae) file and add to the scene.\n"
|
||||
"@param filename COLLADA filename to load lights from\n"
|
||||
"@param parentGroup (optional) name of an existing simgroup to add the new "
|
||||
"lights to (defaults to MissionGroup)\n"
|
||||
"lights to (defaults to root Scene)\n"
|
||||
"@param baseObject (optional) name of an object to use as the origin (useful "
|
||||
"if you are loading the lights for a collada scene and have moved or rotated "
|
||||
"the geometry)\n"
|
||||
|
|
@ -165,16 +166,16 @@ DefineEngineFunction( loadColladaLights, bool, (const char * filename, const cha
|
|||
Torque::Path path(filename);
|
||||
|
||||
// Optional group to add the lights to. Create if it does not exist, and use
|
||||
// the MissionGroup if not specified.
|
||||
SimGroup* missionGroup = dynamic_cast<SimGroup*>(Sim::findObject("MissionGroup"));
|
||||
// the root Scene if not specified.
|
||||
Scene* scene = Scene::getRootScene();
|
||||
SimGroup* group = 0;
|
||||
if (!String::isEmpty(parentGroup)){
|
||||
if (!Sim::findObject(parentGroup, group)) {
|
||||
// Create the group if it could not be found
|
||||
group = new SimGroup;
|
||||
if (group->registerObject(parentGroup)) {
|
||||
if (missionGroup)
|
||||
missionGroup->addObject(group);
|
||||
if (scene)
|
||||
scene->addObject(group);
|
||||
}
|
||||
else {
|
||||
delete group;
|
||||
|
|
@ -183,7 +184,7 @@ DefineEngineFunction( loadColladaLights, bool, (const char * filename, const cha
|
|||
}
|
||||
}
|
||||
if (!group)
|
||||
group = missionGroup;
|
||||
group = scene;
|
||||
|
||||
// Optional object to provide the base transform
|
||||
MatrixF offset(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue