I created the following code and it works correctly. In light, I’m thinking a function in my worldbuild to save extra objects in a xml(diff.xml scene file for example). Then use a function in the Manager to populate a scene with that file loading a xml. It’s some extra step but if I want to set up networking it will be super helpful.
The software is crashing at the GetSubsystem line of Manager.cpp.
Manager.h
[code]#ifndef MANAGER_H
#define MANAGER_H
namespace Urho3D
{
class Geometry;
class Drawable;
class Light;
class Material;
class Pass;
class Technique;
class Octree;
class Graphics;
class RenderPath;
class RenderSurface;
class ResourceCache;
class Skeleton;
class OcclusionBuffer;
class Texture2D;
class TextureCube;
class View;
class Zone;
class Scene;
class URHO3D_API Manager : public Object
{
OBJECT(Manager);
public:
Manager(Context* context);
int SetScene(Scene* scene);
int AddObject(int type, const char * name, float x, float y, float z, const char *filename);
virtual ~Manager();
protected:
private:
/// Scene pointer.
WeakPtr scene_;
};
}
#endif // MANAGER_H
[/code]
Manager.cpp
[code]#include “Camera.h”
#include “ResourceCache.h”
#include “Renderer.h”
#include “Camera.h”
#include “Window.h”
#include “Button.h”
#include “LineEdit.h”
#include “UIElement.h”
#include “BoundingBox.h”
#include “UIEvents.h”
#include “DebugRenderer.h”
#include “File.h”
#include “FileSystem.h”
#include “XMLFile.h”
#include “XMLElement.h”
#include “Deserializer.h”
#include “Cursor.h”
#include “FileSystem.h”
#include “ListView.h”
#include “Console.h”
#include “RigidBody.h”
#include “CollisionShape.h”
#include “PhysicsWorld.h”
#include “Animation.h”
#include “AnimatedModel.h”
#include “AnimationController.h”
#include “Character.h”
#include “Terrain.h”
#include “EngineEvents.h”
#include “Zone.h”
#include “Log.h”
#include “Skybox.h”
#include “Sprite.h”
#include “StaticModelGroup.h”
#include “BillboardSet.h”
#include “Random.h”
#include “RenderPath.h”
#include “Color.h”
#include “Graphics.h”
///C/C++ related header files
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
/// Existence Header files
#include “GameStateHandler.h”
#include “Account.h”
#include “GameObject.h”
#include “WorldBuild.h”
#include “Manager.h”
#include “…/…/Engine/Procedural/RandomNumberGenerator.h”
#include “DebugNew.h”
Manager::Manager(Context* context) :
Object(context)
{
scene_=NULL;
}
Manager::~Manager()
{
//dtor
}
int Manager::SetScene(Scene* scene)
{
scene_=scene;
}
int Manager::AddObject(int type, const char * name, float x, float y, float z, const char filename)
{
/// Get Needed SubSystems
Renderer renderer = GetSubsystem();
Graphics* graphics = GetSubsystem();
/// if no scene return 0
if(!scene_)
{
return 0;
}
/// Get scene and terrain node
Node* terrainNode = scene_->GetChild("GeneratedTerrainRule_Terrain",true);
Terrain * terrain = terrainNode -> GetComponent<Terrain>();
Vector3 terrainposition = terrainNode ->GetPosition();
IntVector2 terrainsize = terrain->GetNumVertices();
cout << terrainsize.ToString().CString() <<endl;
cout << "test" << endl;
return 1;
}
[/code]