Integrate dtEntity with a MFC/MDI application

16 views
Skip to first unread message

emeric....@gmail.com

unread,
Dec 22, 2014, 12:19:37 PM12/22/14
to dtenti...@googlegroups.com
Hi,
 
I'm new to dtEntity, so may ask really dumb questions!
 
(Is there a dtentity-users list, ala osg-users one, focused on user's problem/experience rather than on dtEntity development?)
 
I'm trying to integrate dtEntity with a MFC/MDI application, similar to OSG's osgviewerMFC example [1].
 
While all dtEntity examples rely upon InitOSGViewer to integrate with OSG, I cannot use it directly with a MFC/MDI application. As outlined in InitOSGViewer documentation, I need to write my own initialization function. So, looking at dtEntityEditor code that doesn't use InitOSGViewer either, I was trying to determine what should be created/initialized.
 
One big difference that I can immediately see between the dtEntity examples/dtEntityEditor vs. osgviewerMFC is that the OSG viewer is not initialized at application startup in the case of MFC/MDI. The viewer is initialized once a model/scene has been loaded, so that the child frame is created beforehand and the size/attributes of the child window(s) can be obtained to initialize the OSG viewer's traits. And there's one separate OSG viewer per loaded model/scene. By contrast, in the dtEntity examples/dtEntityEditor, the OSG viewer is set up right away by InitOSGViewer, as argc/argv data is used to set up some elements, like OSGSystemInterface.
 
For a MFC/MDI application, I'll thus need to break the initializations performed in InitOSGViewer into several pieces and places. But I don't know what's legit to do. As alluded to earlier, in the classical Document/View approach of the MFC/MDI architecture, there's one OSG viewer per view. Is it thus correct to have one unique entity manager (maybe as a member variable of the application itself) shared by the different OSG viewer's instances? How to create the link between the entity manager and the different viewer's instances? Is it through OSGSystemInterface::SetViewer? But in this case, I'll have as much OSGSystemInterface instances as OSG viewer's instances, right? Similarly, do I have to create one OSGInputInterface per viewer's instance, or only one for all the OSG viewer's instances? And what about OSGWindowInterface? In short, what's the absolute minimum set of dtEntity elements that must be set up and how to manually interface them with one or more OSG viewer's instance(s) without relying upon InitOSGViewer?
 
Thanks,
 
     Émeric
 

emeric....@gmail.com

unread,
Jan 6, 2015, 3:09:20 PM1/6/15
to dtenti...@googlegroups.com
Hi,
 
I've managed to successfully integrate dtEntity with OSG's osgviewerMFC example [1].
 
All the required modifications take place in the cOSG class of the MFC_OSG.h/.cpp unit. Please find them attached.
 
As I'm new to dtEntity, don't hesitate to comment on the code if some things are missing/unneeded.
MFC_OSG.h
MFC_OSG.cpp
Reply all
Reply to author
Forward
0 new messages