MercuryScreen.h

Go to the documentation of this file.
00001 #ifndef MERCURYSCREEN_H
00002 #define MERCURYSCREEN_H
00003 
00004 #include "MercuryObject.h"
00005 #include "MercuryModel.h"
00006 #include "MercurySprite.h"
00007 #include "MercuryCamera.h"
00008 #include "MercuryDisplay.h"
00009 
00011 class MercuryScreen : public MercuryObject
00012 {
00013 public:
00014     MercuryScreen( const MercuryScreen & MercuryScreen );
00015     MercuryScreen();
00016     MercuryScreen( const MString &name );
00017     virtual ~MercuryScreen();
00018     virtual void Init();
00019     virtual void Update(const float dTime);
00020     virtual void Message( int Message, PStack & data, const MString & name );
00021     virtual void Render();
00022 
00023     virtual bool RemoveObject(MercuryObject* object, bool bAllowDelete = true );
00024 
00025     void AddPerspObject(MercuryObject* object, bool bParentDelete = false);
00026     void AddOrthoObject(MercuryObject* object, bool bParentDelete = false);
00027 
00028     virtual MercuryObject * Spawn( const MString & sClass, const MString & sName, PROJECTIONTYPE projection = PERSPECTIVE );
00029 
00030     MercuryCamera* GetCamera() { return m_pCamera; }
00031     
00032     CLASS_RTTI( MercuryScreen, MercuryObject );
00033 
00034 protected:
00035     void UpdatePerspectiveObjects(float dTime);
00036     void UpdateOrthoObjects(float dTime);
00037 
00038     void RenderPerspectiveObjects();
00039     void RenderOrthoObjects();
00040 
00041     void CreateProjections();
00042 
00043     MercuryObject* m_pBackground;
00044     MercuryCamera* m_pCamera;
00045 
00046     bool m_useLighting;
00047 
00048     Projection m_perspProjection;
00049     Projection m_orthoProjection;
00050 private:
00051     //Do not delete from these only erase, delete from m_objects
00052     MercuryObject m_PerspObjects;
00053     MercuryObject m_OrthoObjects;
00054 };
00055 
00056 
00057 //NOTE: This type of self-registering screen system is almost an
00058 //exact rip-off of the one in Rage (for StepMania). The following
00059 //few lines are (c) MIT 2001-2005 Chris Danford, Glenn Maynard
00060 typedef MercuryScreen* (*NewScreenFunction)(const MString& sClassName);
00061 void RegisterMercuryScreen( const MString& sClassName, NewScreenFunction pfn );
00062 
00063 #define REGISTER_SCREEN_CLASS( className ) \
00064     static MercuryScreen* Create##className( const MString &sName ) \
00065     { MercuryScreen *pRet = new className( sName ); pRet->Init(); return pRet; } \
00066     struct Register##className { \
00067         Register##className() { RegisterMercuryScreen( #className,Create##className); } \
00068     }; \
00069     static Register##className register_##className; \
00070     REGISTER_OBJECT_TYPE( className );
00071 
00072 extern std::map< MString, NewScreenFunction >  *ToMakeScreens;
00073 
00074 //End of Rage-based registering system.
00075 
00076 #endif
00077 
00078 /* 
00079  * (c) 2005 Joshua Allen, Charles Lohr
00080  * All rights reserved.
00081  *
00082  * Certain parts of the code (as noted)
00083  * (c) MIT 2001-2005 Chris Danford, Glenn Maynard
00084  * All rights reserved.
00085  *
00086  * Redistribution and use in source and binary forms, with or
00087  * without modification, are permitted provided that the following
00088  * conditions are met:
00089  *  -   Redistributions of source code must retain the above
00090  *      copyright notice, this list of conditions and the following disclaimer.
00091  *  -   Redistributions in binary form must reproduce the above copyright
00092  *      notice, this list of conditions and the following disclaimer in
00093  *      the documentation and/or other materials provided with the distribution.
00094  *  -   Neither the name of the Mercury Engine nor the names of its
00095  *      contributors may be used to endorse or promote products derived from
00096  *      this software without specific prior written permission.
00097  *
00098  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00099  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00100  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00101  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
00102  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00103  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00104  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00105  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00106  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00107  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00108  */

Hosted by SourceForge.net Logo