Advanced Mogre Framework(release 1.0 for mogre 1.7.x)

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
randomcode
Kobold
Posts: 26
Joined: Wed Nov 11, 2015 11:31 am
Location: Universe
x 1
Contact:

Advanced Mogre Framework(release 1.0 for mogre 1.7.x)

Post by randomcode » Sat Mar 24, 2018 3:21 pm

Hello, guys.

I have made an advanced framework for mogre like Advanced Ogre Framework.:
http://www.ogre3d.org/tikiwiki/tiki-ind ... +Framework

Project is there:https://github.com/cookgreen/AdvancedMogreFramework
Binary available( 0.9 ):https://github.com/cookgreen/AdvancedMo ... el_0.9.zip(binary include in the project folder)


DotNet Platform:
.Net4.0

Older Support Platform
.Net2.0(0.1~0.3)

Visual Studio Platform:
VS2010 later

Based on:

Mogre : 1.7.x
MOIS : 1.7.x

MogreBites(Part of Mogre_Procedural project) : 0.1 (thanks to andyhebear1)
SdkCameraMan(Part of Mogre_Procedural project) : 0.1 (thanks to andyhebear1)

NVorbis 0.8.5
NAudio 1.7.3

Features:
A game state system
a graphical user interface
different input modes
scene loading and
manual material manipulation
Character Controller
Ogg Sound

Change log:
Rel 0.9:
Add Ogg Sound

Rel 0.8:
Add Character Controller(Finished)

Rel 0.7:
Add Character Controller(Alpha)

Rel 0.6:
Fix some problems

Rel 0.5;
Remove useless code

Rel 0.4:

Rel 0.3:

Beta 0.2:

Alpha 0.1:
Add the code

Screenshot:
AMOF_4.jpg
AMOF_003.JPG
AMOF_002.JPG


Preview:
Original Code:

Code: Select all

#ifndef OGRE_FRAMEWORK_HPP #define OGRE_FRAMEWORK_HPP

//|||||||||||||||||||||||||||||||||||||||||||||||

#include <OgreCamera.h>
#include <OgreEntity.h>
#include <OgreLogManager.h>
#include <OgreOverlay.h>
#include <OgreOverlayElement.h>
#include <OgreOverlayManager.h>
#include <OgreRoot.h>
#include <OgreViewport.h>
#include <OgreSceneManager.h>
#include <OgreRenderWindow.h>
#include <OgreConfigFile.h>

#include <OISEvents.h>
#include <OISInputManager.h>
#include <OISKeyboard.h>
#include <OISMouse.h>

#include <SdkTrays.h>

//|||||||||||||||||||||||||||||||||||||||||||||||

class OgreFramework : public Ogre::Singleton<OgreFramework>, OIS::KeyListener, OIS::MouseListener
{
public:
OgreFramework();
~OgreFramework();

bool initOgre(Ogre::String wndTitle, OIS::KeyListener *pKeyListener = 0, OIS::MouseListener *pMouseListener = 0);
void updateOgre(double timeSinceLastFrame);

bool keyPressed(const OIS::KeyEvent &keyEventRef);
bool keyReleased(const OIS::KeyEvent &keyEventRef);

bool mouseMoved(const OIS::MouseEvent &evt);
bool mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID id);
bool mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID id);

Ogre::Root*	m_pRoot;
Ogre::RenderWindow*	m_pRenderWnd;
Ogre::Viewport*	m_pViewport;
Ogre::Log*	m_pLog;
Ogre::Timer*	m_pTimer;

OIS::InputManager*	m_pInputMgr;
OIS::Keyboard*	m_pKeyboard;
OIS::Mouse*	m_pMouse;

OgreBites::SdkTrayManager*	m_pTrayMgr;

private:
OgreFramework(const OgreFramework&);
OgreFramework& operator= (const OgreFramework&);
};

//|||||||||||||||||||||||||||||||||||||||||||||||

#endif

//|||||||||||||||||||||||||||||||||||||||||||||||

New Mogre Code:

Code: Select all

namespace Mogre_Advanced_Framework {
class AdvancedMogreFramework 
{
public static Root m_pRoot=new Root();
public static RenderWindow m_pRenderWnd;
public static Viewport m_pViewport;
public static Log m_pLog;
public static Timer m_pTimer;

public static InputManager m_pInputMgr;
public static Keyboard m_pKeyboard;
public static Mouse m_pMouse;

public static SdkTrayManager m_pTrayMgr;
public AdvancedMogreFramework()
{
m_pRoot = null;
m_pRenderWnd = null;
m_pViewport = null;
m_pLog = null;
m_pTimer = null;

m_pInputMgr = null;
m_pKeyboard = null;
m_pMouse = null;
m_pTrayMgr = null;
}
~AdvancedMogreFramework()
{
LogManager.Singleton.LogMessage("Shutdown OGRE...");
if (AdvancedMogreFramework.m_pTrayMgr != null) m_pTrayMgr = null;
if (AdvancedMogreFramework.m_pInputMgr != null) InputManager.DestroyInputSystem(m_pInputMgr);
if (AdvancedMogreFramework.m_pRoot != null) m_pRoot = null;
}

public static bool initOgre(String wndTitle)
{
LogManager logMgr = new LogManager();

m_pLog = LogManager.Singleton.CreateLog("OgreLogfile.log", true, true, false);
m_pLog.SetDebugOutputEnabled(true);

m_pRoot = new Root();

if(!m_pRoot.ShowConfigDialog())
return false;
m_pRenderWnd = m_pRoot.Initialise(true, wndTitle);

m_pViewport = m_pRenderWnd.AddViewport(null);
ColourValue cv=new ColourValue(0.5f,0.5f,0.5f);
m_pViewport.BackgroundColour=cv;

m_pViewport.Camera=null;

int hWnd = 0;
//ParamList paramList;
m_pRenderWnd.GetCustomAttribute("WINDOW", out hWnd);

m_pInputMgr = InputManager.CreateInputSystem((uint)hWnd);
m_pKeyboard = (MOIS.Keyboard)m_pInputMgr.CreateInputObject(MOIS.Type.OISKeyboard, true);
m_pMouse = (MOIS.Mouse)m_pInputMgr.CreateInputObject(MOIS.Type.OISMouse, true);

m_pMouse.MouseMoved+=new MouseListener.MouseMovedHandler(mouseMoved);
m_pMouse.MousePressed += new MouseListener.MousePressedHandler(mousePressed);
m_pMouse.MouseReleased += new MouseListener.MouseReleasedHandler(mouseReleased);

m_pKeyboard.KeyPressed += new KeyListener.KeyPressedHandler(keyPressed);
m_pKeyboard.KeyReleased += new KeyListener.KeyReleasedHandler(keyReleased);

MOIS.MouseState_NativePtr mouseState = m_pMouse.MouseState;
mouseState.width = m_pViewport.ActualWidth;
mouseState.height = m_pViewport.ActualHeight;
//m_pMouse.MouseState = tempMouseState;


String secName, typeName, archName;
ConfigFile cf=new ConfigFile();
cf.Load("resources.cfg","\t:=",true);

ConfigFile.SectionIterator seci = cf.GetSectionIterator();
while (seci.MoveNext())
{
secName = seci.CurrentKey;
ConfigFile.SettingsMultiMap settings = seci.Current;
foreach (KeyValuePair<string, string> pair in settings)
{
typeName = pair.Key;
archName = pair.Value;
ResourceGroupManager.Singleton.AddResourceLocation(archName, typeName, secName);
}
}
TextureManager.Singleton.DefaultNumMipmaps=5;
ResourceGroupManager.Singleton.InitialiseAllResourceGroups(); 

m_pTrayMgr = new SdkTrayManager("AOFTrayMgr", m_pRenderWnd, m_pMouse, null);

m_pTimer = new Timer();
m_pTimer.Reset();

m_pRenderWnd.IsActive=true;

return true;
}
public static void updateOgre(double timeSinceLastFrame)
{
}

public static bool keyPressed(KeyEvent keyEventRef)
{
if(m_pKeyboard.IsKeyDown(MOIS.KeyCode.KC_V))
{
m_pRenderWnd.WriteContentsToTimestampedFile("AMOF_Screenshot_", ".jpg");
return true;
}

if(m_pKeyboard.IsKeyDown(KeyCode.KC_O))
{
if(m_pTrayMgr.isLogoVisible())
{
m_pTrayMgr.hideFrameStats();
m_pTrayMgr.hideLogo();
}
else
{
m_pTrayMgr.showFrameStats(TrayLocation.TL_BOTTOMLEFT);
m_pTrayMgr.showLogo(TrayLocation.TL_BOTTOMRIGHT);
}
}

return true;
}
public static bool keyReleased(KeyEvent keyEventRef)
{
return true;
}

public static bool mouseMoved(MouseEvent evt)
{
return true;
}
public static bool mousePressed(MouseEvent evt, MouseButtonID id)
{
return true;
}
public static bool mouseReleased(MouseEvent evt, MouseButtonID id)
{
return true;
}
//AdvancedMogreFramework(const AdvancedMogreFramework);
//AdvancedMogreFramework operator= (const AdvancedMogreFramework);
}
}

License:
GPLv2+LGPL(Because Mogre_Procedural based on GPLv2 license)+Ms-PL(Because NVorbis and NAudio based on Ms-PL)

please give me your feedback(comment under the topic or post a issue on Github) :D
1 x
AMGE(Open Source C# Role-play Engine)
https://github.com/cookgreen/AMGE

Post Reply