Multiple Renderers

May 20, 2013 at 8:13 PM
Hi,
Im trying to figure out OOP again, so im trying to seperate the Terrain Demo into another class so i can build on it; Should i create a new rendererDX11 for that class? If so, would i just return that object and draw it using ->present from the main class? If no, what should i be doing?
Coordinator
May 21, 2013 at 10:57 AM
No, the RendererDX11 class is intended to be part of the engine that doesn't change, but rather is just configured to how it is needed. What you would probably want to do is make a copy of the Terrain Demo application, rename the *.vcxproj files to your desired application name, and then modify it.

In general, the engine is set up so that each application can customize or add new functionality, without having to recreate portions of the engine. Give this a try, and we can discuss it further if you run into any trouble.
May 21, 2013 at 7:36 PM
I'm not sure i wrote what my problem is very well - So I have my application, let's say TestApp, I want to render a scene with some terrain, a skybox and ocean (probably from nvidia SDK 11). Obviously, having all of these functions in one function can get a little hectic, so I want to separate them into classes Terrain, Sky and Ocean; all of these functions will need to invoke the RendererDX11 in the TestApp class (Or should i put this in another class?), so how would i do this?
Coordinator
May 23, 2013 at 1:43 AM
In that case, you will want to create Actors and then populate the actors' Body with appropriate geometry and material objects. I would recommend to start out with one of those items you want to add, and then step through the process to understand what needs to be added. You can follow along from some of the sample programs, and of course ask questions here if you get stuck. Just find an Actor instance that is doing something different and trace how the object is configured. That will give you a good idea of what needs to be done.
May 29, 2013 at 8:59 PM
Ok, so I've been trying to do that using the VolumeActor demo one as it looked simple enough:

VolumeAc.h
#include "VolumeActor.h"

class VolumeAc
{
public:

    VolumeAc();

    void Initialize();

    Glyph3::VolumeActor*    m_pActor1;
    Glyph3::VolumeActor*    m_pActor2;

};
void VolumeAc::Initialize()
{
    m_pActor1 = new VolumeActor();
    //m_pScene->AddActor( m_pActor1 );

    // Throw a rotation onto the actor to slowly rotate it about the Y-axis.
    RotationController* pRotController = new RotationController( Vector3f( -1.0f, 1.0f, 0.0f ), 0.2f );
    m_pActor1->GetNode()->AttachController( pRotController );



    m_pActor2 = new VolumeActor();
    //m_pScene->AddActor( m_pActor2 );

    // Throw a rotation onto the actor to slowly rotate it about the Y-axis.
    RotationController* pRotController2 = new RotationController( Vector3f( 1.0f, 1.0f, 0.0f ), -0.1f );
    m_pActor2->GetNode()->AttachController( pRotController2 );


    m_pActor1->GetNode()->Position() = Vector3f( -1.2f, 0.0f, 0.0f );
    m_pActor2->GetNode()->Position() = Vector3f( 1.2f, 0.0f, 0.0f );
}
I call ->Initialize() from the App::Initialize and add the two actors which i made public (probably bad practice right?) and the binary "stops working" on startup, Initially the debugger got stuck on "m_pActor1 = new VolumeActor();" but now it doesnt load any symbols for whatever reason, what am I doing wrong?
Coordinator
May 30, 2013 at 10:54 AM
Did you create a new project for these tests, or are you modifying the existing sample program? If you haven't done so yet, you should create a new project by copying one of the existing ones and renaming the relevant project files (you will also have to remove the source files from the project within the IDE and then add your new files, but that shouldn't be too difficult).

Also, are you building in debug or release mode? In release mode there are no debugging symbols loaded, so maybe that has something to do with it?
May 31, 2013 at 4:16 PM
Yeah, Ive just copied one of the other projects and changed its name. So when i debug it breaks on the Init() function and for both actors - "unable to read memory" (null pointer or just not created yet?)

http://pastebin.com/5C4n1U3D
http://pastebin.com/gCPR1sdi
Coordinator
Jun 1, 2013 at 4:26 PM
Sounds really strange - can you post a screenshot of the error? The only way that error should happen is if you are trying to use the actor pointers before the objects have been created, so it doesn't make sense to get an error when you are trying to create them...

Please post a screenshot and show the IDE when the error occurs, maybe that can give us some clues.
Jun 1, 2013 at 8:37 PM
Don't worry - I think my brain died. I created the two Actors but i forgot to create the Scene ;) Also, can i have more than one Scene but only one camera right? Also, would this be a good opportunity to use SceneRenderTask?
Coordinator
Jun 3, 2013 at 10:54 AM
Actually you can have multiple scenes and multiple cameras if you want to. I haven't ever tried to use one camera in two different scenes, but I can't think of a reason off the top of my head why it wouldn't work.

The SceneRenderTask is indeed the object that you need to supply to the camera class so it can render the scene. This is typically done with one of SceneRenderTask's subclasses. If you take a look at the RenderApplication base class, you can see how to create and set up one of these objects for your camera.