*.obj
*.ncb
*.sdf
+*.exe
*.o
+*.pdb
+src/build*
+sample/build*
+bin/
+lib/
+include/
make_rotation make_scaling *** test
make_rotation make_scaling *** impl
doxygen
+
+
+Windows\82Å\83R\83\93\83p\83C\83\8b\89Â\94\\82É\82·\82é
+*testbin\82Ísrc/\82Ì\92\86\82Å\82¢\82¢\82©\81H
+*test\83R\81[\83h\82Ì\83R\83\93\83p\83C\83\8b\82ª\92Ê\82ç\82È\82¢
+*test\82ð\8eÀ\8ds\82·\82é\82É\82Í\81H
+*numeric -> numeric_performance
+
+
+Visual Studio 10 on Windows----
+vcvarsall.bat
+cmake .. -G "Visual Studio 10"
+
+TODO *test\82Ì\8fo\97Í\82Ì\95\\8e¦\82Ì\82³\82¹\82©\82½
+windows\82Ìboost/operations\82Å\82Í N = N1 * N2\82Åcopy\83R\83\93\83X\83g\83\89\83N\83^\82ª\8cÄ\82Î\82ê\82é\81H
+vector,matrix\82É\82Â\82¢\82Äconst\95Ï\90\94\82Å\82à\83R\83\93\83p\83C\83\8b\82Í\92Ê\82é\82æ\82¤\82É\82·\82é
\ No newline at end of file
-#include "mof/AbstractScene.h"\r
-#include "mof/ConsoleIO.h"\r
-\r
-\r
-\r
-\r
-mof::AbstractScene::AbstractScene() {\r
- //m_state = mof::AbstractScene::UNINITIALIZED;\r
- //m_beginEffect = NULL;\r
- //m_endEffect = NULL;\r
- m_active = true;\r
- //m_initialized = false;\r
-}\r
-\r
-\r
-mof::AbstractScene::~AbstractScene(){\r
- //delete m_beginEffect;\r
- //delete m_endEffect;\r
- \r
-}\r
-/*\r
-bool mof::AbstractScene::isInitialized(){\r
- return (m_state != mof::AbstractScene::UNINITIALIZED);\r
-}*/\r
-\r
-\r
-bool mof::AbstractScene::isActive(){\r
- return m_active;//(m_state == mof::AbstractScene::ACTIVE || m_state == mof::AbstractScene::OPENING || m_state == mof::AbstractScene::CLOSING);\r
-}\r
-\r
-/*\r
-bool mof::AbstractScene::isClosing(){\r
- return m_state == mof::AbstractScene::CLOSING;\r
-}\r
-\r
-\r
-bool mof::AbstractScene::isOpening(){\r
- return m_state == mof::AbstractScene::OPENING;\r
-}*/\r
-/*\r
-void mof::AbstractScene::setBeginEffect(Effect* effect){\r
- delete m_beginEffect;\r
- m_beginEffect = effect;\r
- if(effect != NULL)effect->addEffectListener(this);\r
-}\r
-\r
-mof::Effect* mof::AbstractScene::getBeginEffect(){\r
- return m_beginEffect;\r
-}\r
-\r
-\r
-void mof::AbstractScene::setEndEffect(Effect* effect){\r
- delete m_endEffect;\r
- m_endEffect = effect;\r
- if(effect != NULL)effect->addEffectListener(this);\r
-}\r
-\r
-mof::Effect* mof::AbstractScene::getEndEffect(){\r
- return m_endEffect;\r
-}*/\r
-\r
-/*\r
-bool mof::AbstractScene::initialize(){\r
- m_state = mof::AbstractScene::INITIALIZED;\r
- //Activate(true);\r
- return true;\r
-}*/\r
-\r
-void mof::AbstractScene::activate(bool activate){\r
- m_active = activate;\r
- /*if(activate){\r
- m_state = mof::AbstractScene::ACTIVE;\r
- //playBeginEffect();\r
- //InputCore::getInstance()->addListener(this);\r
- }\r
- else {\r
- m_state = mof::AbstractScene::UNACTIVE;\r
- //playEndEffect();\r
- ////InputCore::getInstance()->removeListener(this);\r
- \r
- }*/\r
-}\r
-\r
-/*\r
-void mof::AbstractScene::notifyEffectEvent(EffectEvent& effectEvent){\r
- if(effectEvent.object == m_beginEffect && effectEvent.type == EffectEvent::FINISHED){\r
- m_state = mof::AbstractScene::ACTIVE;\r
- }\r
- if(effectEvent.object == m_endEffect && effectEvent.type == EffectEvent::FINISHED){\r
- m_state = mof::AbstractScene::UNACTIVE;\r
- }\r
-}\r
-\r
-\r
-void mof::AbstractScene::playBeginEffect(){\r
- if(m_beginEffect == NULL){\r
- m_state = mof::AbstractScene::ACTIVE;\r
- return;\r
- }\r
- m_state = mof::AbstractScene::OPENING;\r
- m_beginEffect->play();\r
-}\r
-\r
-\r
-void mof::AbstractScene::playEndEffect(){\r
- if(m_endEffect == NULL){\r
- m_state = mof::AbstractScene::UNACTIVE;\r
- return;\r
- }\r
- m_state = mof::AbstractScene::CLOSING;\r
- m_endEffect->play();\r
-}*/\r
+#include "mof/AbstractScene.h"
+#include "mof/ConsoleIO.h"
+
+
+
+
+mof::AbstractScene::AbstractScene() {
+ //m_state = mof::AbstractScene::UNINITIALIZED;
+ //m_beginEffect = NULL;
+ //m_endEffect = NULL;
+ m_active = true;
+ //m_initialized = false;
+}
+
+
+mof::AbstractScene::~AbstractScene(){
+ //delete m_beginEffect;
+ //delete m_endEffect;
+
+}
+/*
+bool mof::AbstractScene::isInitialized(){
+ return (m_state != mof::AbstractScene::UNINITIALIZED);
+}*/
+
+
+bool mof::AbstractScene::isActive(){
+ return m_active;//(m_state == mof::AbstractScene::ACTIVE || m_state == mof::AbstractScene::OPENING || m_state == mof::AbstractScene::CLOSING);
+}
+
+/*
+bool mof::AbstractScene::isClosing(){
+ return m_state == mof::AbstractScene::CLOSING;
+}
+
+
+bool mof::AbstractScene::isOpening(){
+ return m_state == mof::AbstractScene::OPENING;
+}*/
+/*
+void mof::AbstractScene::setBeginEffect(Effect* effect){
+ delete m_beginEffect;
+ m_beginEffect = effect;
+ if(effect != NULL)effect->addEffectListener(this);
+}
+
+mof::Effect* mof::AbstractScene::getBeginEffect(){
+ return m_beginEffect;
+}
+
+
+void mof::AbstractScene::setEndEffect(Effect* effect){
+ delete m_endEffect;
+ m_endEffect = effect;
+ if(effect != NULL)effect->addEffectListener(this);
+}
+
+mof::Effect* mof::AbstractScene::getEndEffect(){
+ return m_endEffect;
+}*/
+
+/*
+bool mof::AbstractScene::initialize(){
+ m_state = mof::AbstractScene::INITIALIZED;
+ //Activate(true);
+ return true;
+}*/
+
+void mof::AbstractScene::activate(bool activate){
+ m_active = activate;
+ /*if(activate){
+ m_state = mof::AbstractScene::ACTIVE;
+ //playBeginEffect();
+ //InputCore::getInstance()->addListener(this);
+ }
+ else {
+ m_state = mof::AbstractScene::UNACTIVE;
+ //playEndEffect();
+ ////InputCore::getInstance()->removeListener(this);
+
+ }*/
+}
+
+/*
+void mof::AbstractScene::notifyEffectEvent(EffectEvent& effectEvent){
+ if(effectEvent.object == m_beginEffect && effectEvent.type == EffectEvent::FINISHED){
+ m_state = mof::AbstractScene::ACTIVE;
+ }
+ if(effectEvent.object == m_endEffect && effectEvent.type == EffectEvent::FINISHED){
+ m_state = mof::AbstractScene::UNACTIVE;
+ }
+}
+
+
+void mof::AbstractScene::playBeginEffect(){
+ if(m_beginEffect == NULL){
+ m_state = mof::AbstractScene::ACTIVE;
+ return;
+ }
+ m_state = mof::AbstractScene::OPENING;
+ m_beginEffect->play();
+}
+
+
+void mof::AbstractScene::playEndEffect(){
+ if(m_endEffect == NULL){
+ m_state = mof::AbstractScene::UNACTIVE;
+ return;
+ }
+ m_state = mof::AbstractScene::CLOSING;
+ m_endEffect->play();
+}*/
-#include "mof/AmbientLight.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-\r
-struct mof::AmbientLight::Impl{\r
- mof::Color lastAmbient;\r
- bool enable;\r
-\r
- Impl();\r
- ~Impl();\r
- void reflect( mof::Color color , bool force = false);\r
-};\r
-\r
-mof::AmbientLight::Impl::Impl()\r
-: enable(true)\r
-{\r
-}\r
-\r
-mof::AmbientLight::Impl::~Impl(){\r
- \r
-}\r
-\r
-mof::AmbientLight::AmbientLight( mof::Color4f color )\r
-: m_pImpl( new Impl() ) , mof::Light() \r
-{\r
- setDiffuseColor(color);\r
- m_pImpl->reflect( m_diffuseColor->getValue(m_frame).toColorCode() , true);\r
-}\r
-\r
-\r
-mof::AmbientLight::~AmbientLight(){\r
- try{\r
- setEnable(false);//\97á\8aO\82ð\93\8a\82°\82é\82©\82à\r
- }catch(std::exception& ){\r
- }\r
-}\r
-\r
-void mof::AmbientLight::setFrameNumber(mof::FrameNumber frame){\r
- m_frame = frame;\r
- m_pImpl->reflect( m_diffuseColor->getValue(m_frame).toColorCode() );\r
- \r
-}\r
-\r
-void mof::AmbientLight::nextFrame(){\r
- setFrameNumber(m_frame + 1);\r
-}\r
-\r
-void mof::AmbientLight::prevFrame(){\r
- if(m_frame > 0)setFrameNumber(m_frame - 1);\r
-}\r
-\r
-\r
-void mof::AmbientLight::setEnable(bool enable){\r
- if(!m_pImpl->enable && enable){\r
- m_pImpl->enable = enable;\r
- m_pImpl->reflect( m_diffuseColor->getValue(m_frame).toColorCode() );\r
- }\r
- else if(m_pImpl->enable && !enable){\r
- m_pImpl->enable = enable;\r
- m_pImpl->reflect( m_diffuseColor->getValue(m_frame).toColorCode() );\r
- }\r
-}\r
-\r
-\r
-void mof::AmbientLight::Impl::reflect(mof::Color color , bool force){\r
- //\95¡\90\94\82Ì\83A\83\93\83r\83G\83\93\83g\82ð\83T\83|\81[\83g\82·\82é\82×\82«\r
- mof::Color ambient = color;\r
- if(!enable)ambient = mof::createColor(0 , 0 , 0);\r
-\r
- if(ambient != lastAmbient || force){\r
- mof::GraphicsDevice::getRawDevice()->SetRenderState(D3DRS_AMBIENT , ambient);\r
- lastAmbient = ambient;\r
- }\r
-}\r
+#include "mof/AmbientLight.hpp"
+#include "mof/ConsoleIO.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+
+struct mof::AmbientLight::Impl{
+ mof::Color lastAmbient;
+ bool enable;
+
+ Impl();
+ ~Impl();
+ void reflect( mof::Color color , bool force = false);
+};
+
+mof::AmbientLight::Impl::Impl()
+: enable(true)
+{
+}
+
+mof::AmbientLight::Impl::~Impl(){
+
+}
+
+mof::AmbientLight::AmbientLight( mof::Color4f color )
+: m_pImpl( new Impl() ) , mof::Light()
+{
+ setDiffuseColor(color);
+ m_pImpl->reflect( m_diffuseColor->getValue(m_frame).toColorCode() , true);
+}
+
+
+mof::AmbientLight::~AmbientLight(){
+ try{
+ setEnable(false);//\97á\8aO\82ð\93\8a\82°\82é\82©\82à
+ }catch(std::exception& ){
+ }
+}
+
+void mof::AmbientLight::setFrameNumber(mof::FrameNumber frame){
+ m_frame = frame;
+ m_pImpl->reflect( m_diffuseColor->getValue(m_frame).toColorCode() );
+
+}
+
+void mof::AmbientLight::nextFrame(){
+ setFrameNumber(m_frame + 1);
+}
+
+void mof::AmbientLight::prevFrame(){
+ if(m_frame > 0)setFrameNumber(m_frame - 1);
+}
+
+
+void mof::AmbientLight::setEnable(bool enable){
+ if(!m_pImpl->enable && enable){
+ m_pImpl->enable = enable;
+ m_pImpl->reflect( m_diffuseColor->getValue(m_frame).toColorCode() );
+ }
+ else if(m_pImpl->enable && !enable){
+ m_pImpl->enable = enable;
+ m_pImpl->reflect( m_diffuseColor->getValue(m_frame).toColorCode() );
+ }
+}
+
+
+void mof::AmbientLight::Impl::reflect(mof::Color color , bool force){
+ //\95¡\90\94\82Ì\83A\83\93\83r\83G\83\93\83g\82ð\83T\83|\81[\83g\82·\82é\82×\82«
+ mof::Color ambient = color;
+ if(!enable)ambient = mof::createColor(0 , 0 , 0);
+
+ if(ambient != lastAmbient || force){
+ mof::GraphicsDevice::getRawDevice()->SetRenderState(D3DRS_AMBIENT , ambient);
+ lastAmbient = ambient;
+ }
+}
-#ifndef MOF_AMBIENT_LIGHT\r
-#define MOF_AMBIENT_LIGHT\r
-\r
-#include "mof/Light.hpp"\r
-#include "mof/Color.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-\r
-namespace mof{\r
-\r
-\r
-\r
-class AmbientLight : public Light{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
-public:\r
- AmbientLight( mof::Color4f color = mof::Color4f(1 , 1 , 1));\r
- virtual ~AmbientLight();\r
-\r
- virtual void setEnable(bool enable);\r
-\r
- virtual void setFrameNumber(mof::FrameNumber frame);\r
- virtual void nextFrame();\r
- virtual void prevFrame();\r
-\r
-};\r
-\r
-}\r
-\r
-\r
-#endif\r
+#ifndef MOF_AMBIENT_LIGHT
+#define MOF_AMBIENT_LIGHT
+
+#include "mof/Light.hpp"
+#include "mof/Color.hpp"
+#include <boost/scoped_ptr.hpp>
+
+
+namespace mof{
+
+
+
+class AmbientLight : public Light{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+public:
+ AmbientLight( mof::Color4f color = mof::Color4f(1 , 1 , 1));
+ virtual ~AmbientLight();
+
+ virtual void setEnable(bool enable);
+
+ virtual void setFrameNumber(mof::FrameNumber frame);
+ virtual void nextFrame();
+ virtual void prevFrame();
+
+};
+
+}
+
+
+#endif
-#include "mof/Application.hpp"\r
-#include "mof/GraphicsDevice.hpp"\r
-#include "mof/Window.hpp"\r
-#include "mof/SceneGraph.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/Timer.hpp"\r
-#include <stdexcept>\r
-#include "mof/Captor.hpp"\r
-#include "mof/InputDevice.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/Finalizer.hpp"\r
-\r
-namespace \r
-{\r
- int m_frameInterval;\r
- int m_nUpdatingPerFrame;\r
- mof::Window* m_pWindow = NULL;\r
-}\r
-\r
-namespace mof\r
-{\r
- void Application::initialize\r
- ( \r
- const mof::tstring& appname , \r
- int width , \r
- int height ,\r
- bool fullscreen ,\r
- int frameInterval , \r
- int nUpdatingPerFrame\r
- )\r
- {\r
- m_frameInterval = frameInterval;\r
- m_nUpdatingPerFrame = nUpdatingPerFrame; \r
- m_pWindow = new mof::Window( appname , width , height , fullscreen );\r
- mof::GraphicsDevice::initialize( *m_pWindow , width , height , fullscreen );\r
- mof::InputDevice::initialize( );\r
- \r
- }\r
- \r
- void Application::finalize( )\r
- {\r
- mof::GraphicsDevice::finalize();\r
- mof::InputDevice::finalize();\r
- delete m_pWindow;\r
- }\r
- \r
- \r
- void Application::run( Scene& scene ) \r
- {\r
- scene.initialize();\r
- mof::Finalizer finalizer( scene.finalize ); //run\82ð\94²\82¯\82é\82Æ\82«\82É\89ð\95ú\8f\88\97\9d\82ð\8ds\82¤\r
- MSG msg;\r
- ZeroMemory( &msg, sizeof(msg) );\r
- mof::Timer timer;\r
- mof::Timer fpsTimer;\r
- int frameCount = 0;\r
-\r
- mof::Captor Captor( _T("output"));\r
- int sleepingTime = 0;\r
- for( ; ; )\r
- {\r
- while( PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE ) )\r
- {\r
- if( msg.message == WM_QUIT )return;\r
- GetMessage( &msg , NULL , 0 , 0 );\r
- TranslateMessage( &msg );\r
- DispatchMessage( &msg );\r
- }\r
- \r
- for( int i = 0 ; i < m_nUpdatingPerFrame ; i++ )scene.update();//\83V\81[\83\93\82Ì\8f\88\97\9d\r
-\r
- \r
- mof::GraphicsDevice::beginScene();\r
- scene.draw();//\83V\81[\83\93\82Ì\95`\89æ\r
- //Captor.capture();\r
- mof::GraphicsDevice::endScene();\r
- \r
- \r
-\r
- //FPS\82Ì\8cv\91ª\r
- int frameTime = timer.getTime();\r
- if(m_frameInterval > frameTime)\r
- {\r
- Sleep(m_frameInterval - frameTime);\r
- sleepingTime += m_frameInterval - frameTime;\r
- }\r
- \r
- timer.reset();\r
- \r
- if(++frameCount % 500 == 0)\r
- {\r
- float fps = 500.0f / static_cast<float>(fpsTimer.getTime() - sleepingTime) * 1000;\r
- fpsTimer.reset();\r
- sleepingTime = 0;\r
- DEBUG_PRINT( "FPS --- " << fps );\r
- }\r
- } // for\r
- \r
-\r
- } // function run\r
- \r
- void Application::quit( )\r
- {\r
- PostQuitMessage(0);\r
- }\r
-\r
-\r
-}\r
-\r
-\r
+#include "mof/Application.hpp"
+#include "mof/GraphicsDevice.hpp"
+#include "mof/Window.hpp"
+#include "mof/SceneGraph.hpp"
+#include "mof/ConsoleIO.hpp"
+#include "mof/Timer.hpp"
+#include <stdexcept>
+#include "mof/Captor.hpp"
+#include "mof/InputDevice.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include "mof/utilities.hpp"
+#include "mof/Finalizer.hpp"
+
+namespace
+{
+ int m_frameInterval;
+ int m_nUpdatingPerFrame;
+ mof::Window* m_pWindow = NULL;
+}
+
+namespace mof
+{
+ void Application::initialize
+ (
+ const mof::tstring& appname ,
+ int width ,
+ int height ,
+ bool fullscreen ,
+ int frameInterval ,
+ int nUpdatingPerFrame
+ )
+ {
+ m_frameInterval = frameInterval;
+ m_nUpdatingPerFrame = nUpdatingPerFrame;
+ m_pWindow = new mof::Window( appname , width , height , fullscreen );
+ mof::GraphicsDevice::initialize( *m_pWindow , width , height , fullscreen );
+ mof::InputDevice::initialize( );
+
+ }
+
+ void Application::finalize( )
+ {
+ mof::GraphicsDevice::finalize();
+ mof::InputDevice::finalize();
+ delete m_pWindow;
+ }
+
+
+ void Application::run( Scene& scene )
+ {
+ scene.initialize();
+ mof::Finalizer finalizer( scene.finalize ); //run\82ð\94²\82¯\82é\82Æ\82«\82É\89ð\95ú\8f\88\97\9d\82ð\8ds\82¤
+ MSG msg;
+ ZeroMemory( &msg, sizeof(msg) );
+ mof::Timer timer;
+ mof::Timer fpsTimer;
+ int frameCount = 0;
+
+ mof::Captor Captor( _T("output"));
+ int sleepingTime = 0;
+ for( ; ; )
+ {
+ while( PeekMessage( &msg, NULL, 0U, 0U, PM_NOREMOVE ) )
+ {
+ if( msg.message == WM_QUIT )return;
+ GetMessage( &msg , NULL , 0 , 0 );
+ TranslateMessage( &msg );
+ DispatchMessage( &msg );
+ }
+
+ for( int i = 0 ; i < m_nUpdatingPerFrame ; i++ )scene.update();//\83V\81[\83\93\82Ì\8f\88\97\9d
+
+
+ mof::GraphicsDevice::beginScene();
+ scene.draw();//\83V\81[\83\93\82Ì\95`\89æ
+ //Captor.capture();
+ mof::GraphicsDevice::endScene();
+
+
+
+ //FPS\82Ì\8cv\91ª
+ int frameTime = timer.getTime();
+ if(m_frameInterval > frameTime)
+ {
+ Sleep(m_frameInterval - frameTime);
+ sleepingTime += m_frameInterval - frameTime;
+ }
+
+ timer.reset();
+
+ if(++frameCount % 500 == 0)
+ {
+ float fps = 500.0f / static_cast<float>(fpsTimer.getTime() - sleepingTime) * 1000;
+ fpsTimer.reset();
+ sleepingTime = 0;
+ DEBUG_PRINT( "FPS --- " << fps );
+ }
+ } // for
+
+
+ } // function run
+
+ void Application::quit( )
+ {
+ PostQuitMessage(0);
+ }
+
+
+}
+
+
-#pragma once\r
-#include "mof/tstring.hpp"\r
-\r
-namespace mof{\r
-\r
- struct Scene\r
- {\r
- void ( *initialize ) ();\r
- void ( *finalize ) ();\r
- void ( *update ) ();\r
- void ( *draw ) ();\r
- };\r
- \r
- namespace Application\r
- {\r
- //private\r
- \r
- //public\r
- void initialize\r
- ( \r
- const mof::tstring& appname , \r
- int width , \r
- int height ,\r
- bool fullscreen ,\r
- int frameInterval , \r
- int nUpdatingPerFrame\r
- );\r
- void finalize();\r
- void run( Scene& scene );\r
- void quit();\r
- }\r
-\r
-\r
-}\r
+#pragma once
+#include "mof/tstring.hpp"
+
+namespace mof{
+
+ struct Scene
+ {
+ void ( *initialize ) ();
+ void ( *finalize ) ();
+ void ( *update ) ();
+ void ( *draw ) ();
+ };
+
+ namespace Application
+ {
+ //private
+
+ //public
+ void initialize
+ (
+ const mof::tstring& appname ,
+ int width ,
+ int height ,
+ bool fullscreen ,
+ int frameInterval ,
+ int nUpdatingPerFrame
+ );
+ void finalize();
+ void run( Scene& scene );
+ void quit();
+ }
+
+
+}
-#include "mof/Board.hpp"\r
-#include "mof/Camera.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/Constant.hpp"\r
-\r
-struct mof::Board::Impl{\r
- boost::shared_ptr<mof::Texture> pTexture;\r
- mof::Animation<mof::Matrix3D>::Handler worldMatrix;\r
- mof::Animation<mof::Color4f>::Handler color;\r
- mof::Animation<mof::Rectangle<float>>::Handler textureCoordinates;\r
-\r
- Impl( )\r
- : \r
- worldMatrix(mof::makeConstantHandler(mof::Matrix3D::createIdentity())) ,\r
- textureCoordinates(mof::makeConstantHandler(mof::Rectangle<float>(0 , 0 , 1 , 1))) ,\r
- color(mof::makeConstantHandler(mof::Color4f(1 , 1 , 1)))\r
- {\r
- }\r
-\r
- ~Impl(){}\r
-};\r
-\r
-\r
-\r
-mof::Board::Board() : m_pImpl(new Impl()){\r
-}\r
-\r
-mof::Board::~Board(){\r
-}\r
- \r
-\r
-\r
-\r
-void mof::Board::setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler){\r
- m_pImpl->worldMatrix = handler;\r
-\r
-}\r
-\r
-\r
-\r
-void mof::Board::setColor(const mof::Animation<mof::Color4f>::Handler& handler){\r
- m_pImpl->color = handler;\r
-}\r
-\r
-\r
-\r
-\r
-void mof::Board::setTextureCoordinates(const mof::Animation<mof::Rectangle<float>>::Handler& handler){\r
- m_pImpl->textureCoordinates = handler;\r
-}\r
-\r
-void mof::Board::setTextureCoordinates(const mof::Rectangle<float>& coordinates){\r
- setTextureCoordinates(mof::makeConstantHandler(coordinates));\r
-}\r
-\r
-void mof::Board::setTexture( const boost::shared_ptr<mof::Texture>& pTexture ){\r
- m_pImpl->pTexture = pTexture;\r
-}\r
-\r
-\r
-bool mof::Board::isVisible() const{\r
- return true;\r
-}\r
-\r
-void mof::Board::update(){\r
- nextFrame();\r
-}\r
-\r
-void mof::Board::draw() const{\r
- mof::FrameNumber frame = m_frame;\r
- mof::Rectangle<float> textureCoordinates = m_pImpl->textureCoordinates->getValue(frame);\r
- mof::Color color = m_pImpl->color->getValue(frame).toColorCode();\r
- static mof::VertexXYZCUV vertices[4];\r
- vertices[0].x = -0.5f;\r
- vertices[0].y = 0.5f;\r
- vertices[0].z = 0;\r
- vertices[0].color = color;\r
- vertices[0].tu = textureCoordinates.beginX;\r
- vertices[0].tv = textureCoordinates.beginY;\r
-\r
- vertices[1].x = 0.5f;\r
- vertices[1].y = 0.5f;\r
- vertices[1].z = 0;\r
- vertices[1].color = color;\r
- vertices[1].tu = textureCoordinates.endX;\r
- vertices[1].tv = textureCoordinates.beginY;\r
-\r
- vertices[2].x = -0.5f;\r
- vertices[2].y = -0.5f;\r
- vertices[2].z = 0;\r
- vertices[2].color = color;\r
- vertices[2].tu = textureCoordinates.beginX;\r
- vertices[2].tv = textureCoordinates.endY;\r
-\r
- vertices[3].x = 0.5f;\r
- vertices[3].y = -0.5f;\r
- vertices[3].z = 0;\r
- vertices[3].color = color;\r
- vertices[3].tu = textureCoordinates.endX;\r
- vertices[3].tv = textureCoordinates.endY;\r
-\r
- mof::GraphicsDevice::setTexture(m_pImpl->pTexture.get());\r
- mof::GraphicsDevice::setWorldTransform(m_pImpl->worldMatrix->getValue(frame));\r
- mof::GraphicsDevice::drawVertexArray(vertices[0] , vertices[3] , PRIMITIVE_TYPE_TRIANGLESTRIP);\r
-\r
- \r
-}\r
-\r
-\r
+#include "mof/Board.hpp"
+#include "mof/Camera.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include "mof/ConsoleIO.hpp"
+#include "mof/Constant.hpp"
+
+struct mof::Board::Impl{
+ boost::shared_ptr<mof::Texture> pTexture;
+ mof::Animation<mof::Matrix3D>::Handler worldMatrix;
+ mof::Animation<mof::Color4f>::Handler color;
+ mof::Animation<mof::Rectangle<float>>::Handler textureCoordinates;
+
+ Impl( )
+ :
+ worldMatrix(mof::makeConstantHandler(mof::Matrix3D::createIdentity())) ,
+ textureCoordinates(mof::makeConstantHandler(mof::Rectangle<float>(0 , 0 , 1 , 1))) ,
+ color(mof::makeConstantHandler(mof::Color4f(1 , 1 , 1)))
+ {
+ }
+
+ ~Impl(){}
+};
+
+
+
+mof::Board::Board() : m_pImpl(new Impl()){
+}
+
+mof::Board::~Board(){
+}
+
+
+
+
+void mof::Board::setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler){
+ m_pImpl->worldMatrix = handler;
+
+}
+
+
+
+void mof::Board::setColor(const mof::Animation<mof::Color4f>::Handler& handler){
+ m_pImpl->color = handler;
+}
+
+
+
+
+void mof::Board::setTextureCoordinates(const mof::Animation<mof::Rectangle<float>>::Handler& handler){
+ m_pImpl->textureCoordinates = handler;
+}
+
+void mof::Board::setTextureCoordinates(const mof::Rectangle<float>& coordinates){
+ setTextureCoordinates(mof::makeConstantHandler(coordinates));
+}
+
+void mof::Board::setTexture( const boost::shared_ptr<mof::Texture>& pTexture ){
+ m_pImpl->pTexture = pTexture;
+}
+
+
+bool mof::Board::isVisible() const{
+ return true;
+}
+
+void mof::Board::update(){
+ nextFrame();
+}
+
+void mof::Board::draw() const{
+ mof::FrameNumber frame = m_frame;
+ mof::Rectangle<float> textureCoordinates = m_pImpl->textureCoordinates->getValue(frame);
+ mof::Color color = m_pImpl->color->getValue(frame).toColorCode();
+ static mof::VertexXYZCUV vertices[4];
+ vertices[0].x = -0.5f;
+ vertices[0].y = 0.5f;
+ vertices[0].z = 0;
+ vertices[0].color = color;
+ vertices[0].tu = textureCoordinates.beginX;
+ vertices[0].tv = textureCoordinates.beginY;
+
+ vertices[1].x = 0.5f;
+ vertices[1].y = 0.5f;
+ vertices[1].z = 0;
+ vertices[1].color = color;
+ vertices[1].tu = textureCoordinates.endX;
+ vertices[1].tv = textureCoordinates.beginY;
+
+ vertices[2].x = -0.5f;
+ vertices[2].y = -0.5f;
+ vertices[2].z = 0;
+ vertices[2].color = color;
+ vertices[2].tu = textureCoordinates.beginX;
+ vertices[2].tv = textureCoordinates.endY;
+
+ vertices[3].x = 0.5f;
+ vertices[3].y = -0.5f;
+ vertices[3].z = 0;
+ vertices[3].color = color;
+ vertices[3].tu = textureCoordinates.endX;
+ vertices[3].tv = textureCoordinates.endY;
+
+ mof::GraphicsDevice::setTexture(m_pImpl->pTexture.get());
+ mof::GraphicsDevice::setWorldTransform(m_pImpl->worldMatrix->getValue(frame));
+ mof::GraphicsDevice::drawVertexArray(vertices[0] , vertices[3] , PRIMITIVE_TYPE_TRIANGLESTRIP);
+
+
+}
+
+
-#ifndef BILLBOARD_HPP\r
-#define BILLBOARD_HPP\r
-\r
-#include "mof/Component3D.hpp"\r
-#include "mof/SceneGraph.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/Texture.hpp"\r
-#include "mof/DefaultAnimationPlayer.hpp"\r
-\r
-namespace mof{\r
- \r
-\r
-class Camera;\r
-\r
-class Board : public Component3D , public SceneGraph , public DefaultAnimationPlayer{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
-public :\r
- \r
- Board( );\r
- virtual ~Board();\r
-\r
- \r
- virtual void setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler);\r
- virtual void setTextureCoordinates(const mof::Animation<mof::Rectangle<float>>::Handler& handler);\r
- virtual void setTextureCoordinates(const mof::Rectangle<float>& coordinates);\r
- virtual void setTexture( const boost::shared_ptr<mof::Texture>& pTexture );\r
-\r
- void setColor(const mof::Animation<mof::Color4f>::Handler& handler);\r
-\r
- virtual bool isVisible() const;\r
- virtual void update();\r
- virtual void draw() const;\r
-};\r
-\r
-}\r
-\r
-#endif\r
+#ifndef BILLBOARD_HPP
+#define BILLBOARD_HPP
+
+#include "mof/Component3D.hpp"
+#include "mof/SceneGraph.hpp"
+#include "mof/Rectangle.hpp"
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+#include "mof/Texture.hpp"
+#include "mof/DefaultAnimationPlayer.hpp"
+
+namespace mof{
+
+
+class Camera;
+
+class Board : public Component3D , public SceneGraph , public DefaultAnimationPlayer{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+public :
+
+ Board( );
+ virtual ~Board();
+
+
+ virtual void setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler);
+ virtual void setTextureCoordinates(const mof::Animation<mof::Rectangle<float>>::Handler& handler);
+ virtual void setTextureCoordinates(const mof::Rectangle<float>& coordinates);
+ virtual void setTexture( const boost::shared_ptr<mof::Texture>& pTexture );
+
+ void setColor(const mof::Animation<mof::Color4f>::Handler& handler);
+
+ virtual bool isVisible() const;
+ virtual void update();
+ virtual void draw() const;
+};
+
+}
+
+#endif
-#include "mof/CSVFile.h"\r
-#include <exception>\r
-#include <stdlib.h>\r
-#include "mof/ConsoleIO.h"\r
-\r
-mof::CSVFile::CSVFile(mof::tstring& filename)\r
-: m_ifs(filename.c_str() , std::ios::in) , m_bufferSize(1024){\r
- if(!m_ifs)throw std::invalid_argument("can't open file");\r
- m_buffer = new TCHAR[m_bufferSize+1];//\92Ç\89Á\83k\83\8b\95¶\8e\9a\82Ì\82½\82ß\82É\82P\82Â\97]\95ª\82É\8am\95Û\r
- m_buffer[m_bufferSize] = '\0';\r
- m_topOfBuffer = m_bufferSize-1;\r
- m_hasBufferedValue = false;\r
- m_ignoreNL = true;\r
- m_pBufferedValue = NULL;\r
- nextLine();\r
-}\r
-\r
-\r
-\r
-mof::CSVFile::CSVFile(const TCHAR* filename)\r
-: m_ifs(filename , std::ios::in) , m_bufferSize(1024){\r
- if(!m_ifs)throw std::invalid_argument("can't open file");\r
- m_buffer = new TCHAR[m_bufferSize+1];//\92Ç\89Á\83k\83\8b\95¶\8e\9a\82Ì\82½\82ß\82É\82P\82Â\97]\95ª\82É\8am\95Û\r
- m_buffer[m_bufferSize] = '\0';\r
- m_topOfBuffer = m_bufferSize-1;\r
- m_hasBufferedValue = false;\r
- m_ignoreNL = true;\r
- m_pBufferedValue = NULL;\r
-\r
-\r
- nextLine();\r
-}\r
-\r
-\r
-mof::CSVFile::~CSVFile(){\r
- delete[] m_buffer;\r
- \r
-}\r
-\r
-bool mof::CSVFile::hasNextValue(){\r
- if(m_hasBufferedValue)return true;//Value\82Ì\83o\83b\83t\83@\82ª\82 \82é\r
- \r
- //if(m_topOfBuffer == m_bufferSize && !nextLine())return false;//\82±\82ê\82ª\82È\82¢\82Æ\83o\83O\82é\82ª\81A\89º\82Ì\83\8b\81[\83`\83\93\82Æ\88ê\96{\89»\82Å\82«\82È\82¢\82©\r
-\r
- while(!updateNextValue() && m_ignoreNL){\r
- if( m_topOfBuffer >= m_bufferSize || m_buffer[m_topOfBuffer] == '\0'){\r
- //\83o\83b\83t\83@\82ð\93Ç\82Ý\8d\9e\82Þ\r
- m_topOfBuffer = m_ifs.getline(m_buffer , m_bufferSize) ? 0 : m_bufferSize;\r
- if(m_topOfBuffer >= m_bufferSize)return false;\r
- }\r
- }\r
- return m_pBufferedValue != NULL;\r
-\r
- //if(m_topOfBuffer == m_bufferSize)\r
-}\r
-\r
-\r
-\r
-const TCHAR* mof::CSVFile::getNextValue(){\r
- if(m_hasBufferedValue && hasNextValue()){//Value\82Ì\83o\83b\83t\83@\82ª\82 \82ê\82Î\82»\82ê\82ð\8eg\82¤\r
- m_hasBufferedValue = false;\r
- return m_pBufferedValue;\r
- }\r
-\r
- //\8e\9f\82Ì\92l\82ª\82È\82¢\8fê\8d\87\r
- return NULL;\r
-\r
-}\r
-\r
-\r
-\r
-\r
-bool mof::CSVFile::nextLine(){\r
- m_hasBufferedValue = false;\r
- m_topOfBuffer = m_ifs.getline(m_buffer , m_bufferSize) ? 0 : m_bufferSize;\r
- return m_topOfBuffer == 0;\r
-}\r
-\r
-\r
-void mof::CSVFile::setIgnoreNL(bool ignore){\r
- m_ignoreNL = ignore;\r
-}\r
-\r
-\r
-\r
-bool mof::CSVFile::updateNextValue(){\r
-\r
- if(m_topOfBuffer == m_bufferSize){\r
- //\92l\82È\82µ\r
- m_pBufferedValue = NULL;\r
- m_hasBufferedValue = false;\r
- return false;\r
- }\r
-\r
- enum{\r
- ISPACE , ICOMMA , IQUOTE , IWORD , IEOF\r
- };\r
- enum{\r
- S , NQV , QV , NQE , QE , QVQ ,\r
- //\8f\89\8aú\8fó\91Ô\81A\94ñ\83N\83H\81[\83g\92l\81A\83N\83H\81[\83g\92l\81A\94ñ\83N\83H\81[\83g\83G\83X\83P\81[\83v\81A\83N\83H\81[\83g\83G\83X\83P\81[\83v\81A\83N\83H\81[\83g\82Å\88Í\82Ü\82ê\82½\92l\r
- _NULL , _EMP , _V , _ERR , _QVQ\r
- //\92l\82È\82µ\81A\8bó\95¶\8e\9a\97ñ\81A\92l\81A\83G\83\89\81[\81A\83N\83H\81[\83g\82Å\88Í\82Ü\82ê\82½\92l\r
- };\r
- static const int stateChangeTable[][5] = {\r
- { S , _EMP , QV , NQV , _NULL } ,\r
- { NQV , _V , NQE , NQV , _V} ,\r
- { QV , QV , QE , QV , _ERR} ,\r
- { _ERR , _ERR , NQV , _ERR , _ERR} ,\r
- { QVQ , _QVQ , QV , _ERR , _QVQ} ,\r
- { QVQ , _QVQ , _ERR , _ERR , _QVQ}\r
- \r
- };\r
- \r
-\r
- int state = S;\r
- int lastInput = IEOF;\r
- int begin = m_topOfBuffer;\r
- while( state < _NULL ){//\8fI\97¹\8fó\91Ô\82É\82È\82Á\82½\82ç\94²\82¯\82é\r
- lastInput = IWORD;\r
- if( m_buffer[m_topOfBuffer] == '\0'){\r
- lastInput = IEOF;\r
- }\r
- else if( m_buffer[m_topOfBuffer] == ' ')lastInput = ISPACE;\r
- else if(m_buffer[m_topOfBuffer] == '"')lastInput = IQUOTE;\r
- else if(m_buffer[m_topOfBuffer] == ',')lastInput = ICOMMA;\r
- state = stateChangeTable[state][lastInput];\r
- m_topOfBuffer++;\r
- }\r
- m_hasBufferedValue = true;\r
-\r
- if(state == _NULL){\r
- //\92l\82È\82µ\r
- m_pBufferedValue = NULL;\r
- m_topOfBuffer = m_bufferSize;\r
- m_hasBufferedValue = false;\r
- return false;\r
- }\r
- else if(state == _EMP){\r
- m_pBufferedValue = "";\r
- return true;\r
- }\r
- else if(state == _V || state == _QVQ){\r
- int end = m_topOfBuffer-2;\r
- //\91O\8cã\82©\82ç\83g\83\8a\83~\83\93\83O\r
- while(m_buffer[begin] == ' ')begin++;\r
- while(m_buffer[end] == ' ' )end--;\r
-\r
- if(state == _QVQ){\r
- //\97¼\92[\82Ì\81h\82ð\8f\9c\8b\8e\r
- begin++;\r
- end--;\r
- }\r
- \r
- //"\82Ì\83G\83X\83P\81[\83v\8f\88\97\9d\r
- //\8cã\82ë\82©\82ç\8c©\82Ä\82¢\82Á\82Ä"\82ª\82 \82ê\82Î\83R\83s\81[\82·\82é\r
- m_buffer[end+1] = '\0';\r
- for(int tmp = end ; begin < tmp ; tmp--){\r
- if(m_buffer[tmp] == '"'){\r
- memmove(m_buffer + tmp-1 , m_buffer+ tmp , sizeof(TCHAR)*(end-tmp+2));\r
- tmp--;\r
- }\r
-\r
- }\r
- m_pBufferedValue = m_buffer + begin;\r
- return true;\r
- }\r
- else {\r
- //\83G\83\89\81[(\8e\9f\82Ì,\82Ü\82Å\93Ç\82Ý\90i\82ß\82é) m_buffer\82Ì\96\96\94ö\82Í\83k\83\8b\95¶\8e\9a\82È\82Ì\82Å\95K\82¸\92â\8e~\82·\82é\r
- while(lastInput != ',' && lastInput != '\0'){\r
- lastInput = m_buffer[++m_topOfBuffer];\r
- }\r
- m_topOfBuffer++;\r
- m_pBufferedValue = "ERROR";\r
- return true;\r
- }\r
- \r
-}\r
+#include "mof/CSVFile.h"
+#include <exception>
+#include <stdlib.h>
+#include "mof/ConsoleIO.h"
+
+mof::CSVFile::CSVFile(mof::tstring& filename)
+: m_ifs(filename.c_str() , std::ios::in) , m_bufferSize(1024){
+ if(!m_ifs)throw std::invalid_argument("can't open file");
+ m_buffer = new TCHAR[m_bufferSize+1];//\92Ç\89Á\83k\83\8b\95¶\8e\9a\82Ì\82½\82ß\82É\82P\82Â\97]\95ª\82É\8am\95Û
+ m_buffer[m_bufferSize] = '\0';
+ m_topOfBuffer = m_bufferSize-1;
+ m_hasBufferedValue = false;
+ m_ignoreNL = true;
+ m_pBufferedValue = NULL;
+ nextLine();
+}
+
+
+
+mof::CSVFile::CSVFile(const TCHAR* filename)
+: m_ifs(filename , std::ios::in) , m_bufferSize(1024){
+ if(!m_ifs)throw std::invalid_argument("can't open file");
+ m_buffer = new TCHAR[m_bufferSize+1];//\92Ç\89Á\83k\83\8b\95¶\8e\9a\82Ì\82½\82ß\82É\82P\82Â\97]\95ª\82É\8am\95Û
+ m_buffer[m_bufferSize] = '\0';
+ m_topOfBuffer = m_bufferSize-1;
+ m_hasBufferedValue = false;
+ m_ignoreNL = true;
+ m_pBufferedValue = NULL;
+
+
+ nextLine();
+}
+
+
+mof::CSVFile::~CSVFile(){
+ delete[] m_buffer;
+
+}
+
+bool mof::CSVFile::hasNextValue(){
+ if(m_hasBufferedValue)return true;//Value\82Ì\83o\83b\83t\83@\82ª\82 \82é
+
+ //if(m_topOfBuffer == m_bufferSize && !nextLine())return false;//\82±\82ê\82ª\82È\82¢\82Æ\83o\83O\82é\82ª\81A\89º\82Ì\83\8b\81[\83`\83\93\82Æ\88ê\96{\89»\82Å\82«\82È\82¢\82©
+
+ while(!updateNextValue() && m_ignoreNL){
+ if( m_topOfBuffer >= m_bufferSize || m_buffer[m_topOfBuffer] == '\0'){
+ //\83o\83b\83t\83@\82ð\93Ç\82Ý\8d\9e\82Þ
+ m_topOfBuffer = m_ifs.getline(m_buffer , m_bufferSize) ? 0 : m_bufferSize;
+ if(m_topOfBuffer >= m_bufferSize)return false;
+ }
+ }
+ return m_pBufferedValue != NULL;
+
+ //if(m_topOfBuffer == m_bufferSize)
+}
+
+
+
+const TCHAR* mof::CSVFile::getNextValue(){
+ if(m_hasBufferedValue && hasNextValue()){//Value\82Ì\83o\83b\83t\83@\82ª\82 \82ê\82Î\82»\82ê\82ð\8eg\82¤
+ m_hasBufferedValue = false;
+ return m_pBufferedValue;
+ }
+
+ //\8e\9f\82Ì\92l\82ª\82È\82¢\8fê\8d\87
+ return NULL;
+
+}
+
+
+
+
+bool mof::CSVFile::nextLine(){
+ m_hasBufferedValue = false;
+ m_topOfBuffer = m_ifs.getline(m_buffer , m_bufferSize) ? 0 : m_bufferSize;
+ return m_topOfBuffer == 0;
+}
+
+
+void mof::CSVFile::setIgnoreNL(bool ignore){
+ m_ignoreNL = ignore;
+}
+
+
+
+bool mof::CSVFile::updateNextValue(){
+
+ if(m_topOfBuffer == m_bufferSize){
+ //\92l\82È\82µ
+ m_pBufferedValue = NULL;
+ m_hasBufferedValue = false;
+ return false;
+ }
+
+ enum{
+ ISPACE , ICOMMA , IQUOTE , IWORD , IEOF
+ };
+ enum{
+ S , NQV , QV , NQE , QE , QVQ ,
+ //\8f\89\8aú\8fó\91Ô\81A\94ñ\83N\83H\81[\83g\92l\81A\83N\83H\81[\83g\92l\81A\94ñ\83N\83H\81[\83g\83G\83X\83P\81[\83v\81A\83N\83H\81[\83g\83G\83X\83P\81[\83v\81A\83N\83H\81[\83g\82Å\88Í\82Ü\82ê\82½\92l
+ _NULL , _EMP , _V , _ERR , _QVQ
+ //\92l\82È\82µ\81A\8bó\95¶\8e\9a\97ñ\81A\92l\81A\83G\83\89\81[\81A\83N\83H\81[\83g\82Å\88Í\82Ü\82ê\82½\92l
+ };
+ static const int stateChangeTable[][5] = {
+ { S , _EMP , QV , NQV , _NULL } ,
+ { NQV , _V , NQE , NQV , _V} ,
+ { QV , QV , QE , QV , _ERR} ,
+ { _ERR , _ERR , NQV , _ERR , _ERR} ,
+ { QVQ , _QVQ , QV , _ERR , _QVQ} ,
+ { QVQ , _QVQ , _ERR , _ERR , _QVQ}
+
+ };
+
+
+ int state = S;
+ int lastInput = IEOF;
+ int begin = m_topOfBuffer;
+ while( state < _NULL ){//\8fI\97¹\8fó\91Ô\82É\82È\82Á\82½\82ç\94²\82¯\82é
+ lastInput = IWORD;
+ if( m_buffer[m_topOfBuffer] == '\0'){
+ lastInput = IEOF;
+ }
+ else if( m_buffer[m_topOfBuffer] == ' ')lastInput = ISPACE;
+ else if(m_buffer[m_topOfBuffer] == '"')lastInput = IQUOTE;
+ else if(m_buffer[m_topOfBuffer] == ',')lastInput = ICOMMA;
+ state = stateChangeTable[state][lastInput];
+ m_topOfBuffer++;
+ }
+ m_hasBufferedValue = true;
+
+ if(state == _NULL){
+ //\92l\82È\82µ
+ m_pBufferedValue = NULL;
+ m_topOfBuffer = m_bufferSize;
+ m_hasBufferedValue = false;
+ return false;
+ }
+ else if(state == _EMP){
+ m_pBufferedValue = "";
+ return true;
+ }
+ else if(state == _V || state == _QVQ){
+ int end = m_topOfBuffer-2;
+ //\91O\8cã\82©\82ç\83g\83\8a\83~\83\93\83O
+ while(m_buffer[begin] == ' ')begin++;
+ while(m_buffer[end] == ' ' )end--;
+
+ if(state == _QVQ){
+ //\97¼\92[\82Ì\81h\82ð\8f\9c\8b\8e
+ begin++;
+ end--;
+ }
+
+ //"\82Ì\83G\83X\83P\81[\83v\8f\88\97\9d
+ //\8cã\82ë\82©\82ç\8c©\82Ä\82¢\82Á\82Ä"\82ª\82 \82ê\82Î\83R\83s\81[\82·\82é
+ m_buffer[end+1] = '\0';
+ for(int tmp = end ; begin < tmp ; tmp--){
+ if(m_buffer[tmp] == '"'){
+ memmove(m_buffer + tmp-1 , m_buffer+ tmp , sizeof(TCHAR)*(end-tmp+2));
+ tmp--;
+ }
+
+ }
+ m_pBufferedValue = m_buffer + begin;
+ return true;
+ }
+ else {
+ //\83G\83\89\81[(\8e\9f\82Ì,\82Ü\82Å\93Ç\82Ý\90i\82ß\82é) m_buffer\82Ì\96\96\94ö\82Í\83k\83\8b\95¶\8e\9a\82È\82Ì\82Å\95K\82¸\92â\8e~\82·\82é
+ while(lastInput != ',' && lastInput != '\0'){
+ lastInput = m_buffer[++m_topOfBuffer];
+ }
+ m_topOfBuffer++;
+ m_pBufferedValue = "ERROR";
+ return true;
+ }
+
+}
-#pragma once\r
-#include "mof/tstring.h"\r
-#include <fstream>\r
-\r
-namespace mof{\r
-\r
- class CSVFile{\r
- //bool m_trimming;\r
- std::basic_ifstream<TCHAR> m_ifs;\r
- TCHAR* m_buffer;\r
- const int m_bufferSize;\r
- int m_topOfBuffer;\r
- bool m_hasBufferedValue;\r
- TCHAR* m_pBufferedValue;\r
- bool m_ignoreNL;\r
- bool updateNextValue();\r
- public:\r
- CSVFile(mof::tstring& filename);\r
- CSVFile(const TCHAR* filename);\r
- ~CSVFile();\r
- \r
- bool hasNextValue();\r
- const TCHAR* getNextValue();\r
- bool nextLine();\r
- void setIgnoreNL(bool ignore);\r
- };\r
-\r
+#pragma once
+#include "mof/tstring.h"
+#include <fstream>
+
+namespace mof{
+
+ class CSVFile{
+ //bool m_trimming;
+ std::basic_ifstream<TCHAR> m_ifs;
+ TCHAR* m_buffer;
+ const int m_bufferSize;
+ int m_topOfBuffer;
+ bool m_hasBufferedValue;
+ TCHAR* m_pBufferedValue;
+ bool m_ignoreNL;
+ bool updateNextValue();
+ public:
+ CSVFile(mof::tstring& filename);
+ CSVFile(const TCHAR* filename);
+ ~CSVFile();
+
+ bool hasNextValue();
+ const TCHAR* getNextValue();
+ bool nextLine();
+ void setIgnoreNL(bool ignore);
+ };
+
};
\ No newline at end of file
-#include "mof/Camera.hpp"\r
-#include "mof/Constant.hpp"\r
-#include <d3d9.h>\r
-\r
-struct mof::Camera::Impl{\r
- mof::Animation<mof::Vector3D>::Handler eye;\r
- mof::Animation<mof::Vector3D>::Handler center;\r
- mof::Animation<mof::Vector3D>::Handler up;\r
- mof::FrameNumber frame;\r
-\r
- Impl(\r
- const mof::Animation<mof::Vector3D>::Handler& eye_ ,\r
- const mof::Animation<mof::Vector3D>::Handler& center_ ,\r
- const mof::Animation<mof::Vector3D>::Handler& up_ \r
- ) : eye(eye_) , center(center_) , up(up_) , frame(0){}\r
-\r
- ~Impl(){}\r
-};\r
-\r
-\r
-mof::Camera::Camera(\r
- const mof::Animation<mof::Vector3D>::Handler& eye , \r
- const mof::Animation<mof::Vector3D>::Handler& center ,\r
- const mof::Animation<mof::Vector3D>::Handler& up \r
- ) : m_pImpl(new Impl(eye , center , up)){\r
-}\r
-\r
-mof::Camera::Camera(\r
- const mof::Vector3D& eye , \r
- const mof::Vector3D& center , \r
- const mof::Vector3D& up\r
- ) : m_pImpl(new Impl(\r
- mof::makeConstantHandler(eye) ,\r
- mof::makeConstantHandler(center) ,\r
- mof::makeConstantHandler(up) \r
- )){\r
-}\r
-\r
-mof::Camera::~Camera(){\r
-}\r
-\r
-mof::Matrix3D mof::Camera::getViewMatrix() const{\r
- return mof::Matrix3D::createLookAtLH(\r
- m_pImpl->eye->getValue(m_pImpl->frame) ,\r
- m_pImpl->center->getValue(m_pImpl->frame) ,\r
- m_pImpl->up->getValue(m_pImpl->frame) \r
- );\r
-}\r
-\r
-void mof::Camera::setEye(const mof::Animation<mof::Vector3D>::Handler& eye){\r
- m_pImpl->eye = eye;\r
-}\r
-\r
-\r
-void mof::Camera::setEye(const mof::Vector3D& eye){\r
- m_pImpl->eye = mof::makeConstantHandler(eye);\r
-}\r
-\r
-void mof::Camera::setCenter(const mof::Animation<mof::Vector3D>::Handler& center){\r
- m_pImpl->center = center;\r
-}\r
-\r
-\r
-void mof::Camera::setCenter(const mof::Vector3D& center){\r
- m_pImpl->center = mof::makeConstantHandler(center);\r
-}\r
-\r
-\r
-void mof::Camera::setUp(const mof::Animation<mof::Vector3D>::Handler& up){\r
- m_pImpl->up = up;\r
-}\r
-\r
-\r
-void mof::Camera::setUp(const mof::Vector3D& up){\r
- m_pImpl->up = mof::makeConstantHandler(up);\r
-}\r
-\r
- \r
-mof::Vector3D mof::Camera::getEye() const{\r
- return m_pImpl->eye->getValue(m_pImpl->frame);\r
-}\r
-\r
- \r
-mof::Vector3D mof::Camera::getCenter() const{\r
- return m_pImpl->center->getValue(m_pImpl->frame);\r
-}\r
-\r
- \r
-mof::Vector3D mof::Camera::getUp() const{\r
- return m_pImpl->up->getValue(m_pImpl->frame);\r
-}\r
-\r
-\r
-\r
-\r
-void mof::Camera::setFrameNumber(mof::FrameNumber frame){\r
- m_pImpl->frame = frame;\r
-}\r
-\r
-\r
-void mof::Camera::nextFrame(){\r
- m_pImpl->frame++;\r
-}\r
-\r
-void mof::Camera::prevFrame(){\r
- if(m_pImpl->frame > 0)m_pImpl->frame--;\r
-}\r
-\r
+#include "mof/Camera.hpp"
+#include "mof/Constant.hpp"
+#include <d3d9.h>
+
+struct mof::Camera::Impl{
+ mof::Animation<mof::Vector3D>::Handler eye;
+ mof::Animation<mof::Vector3D>::Handler center;
+ mof::Animation<mof::Vector3D>::Handler up;
+ mof::FrameNumber frame;
+
+ Impl(
+ const mof::Animation<mof::Vector3D>::Handler& eye_ ,
+ const mof::Animation<mof::Vector3D>::Handler& center_ ,
+ const mof::Animation<mof::Vector3D>::Handler& up_
+ ) : eye(eye_) , center(center_) , up(up_) , frame(0){}
+
+ ~Impl(){}
+};
+
+
+mof::Camera::Camera(
+ const mof::Animation<mof::Vector3D>::Handler& eye ,
+ const mof::Animation<mof::Vector3D>::Handler& center ,
+ const mof::Animation<mof::Vector3D>::Handler& up
+ ) : m_pImpl(new Impl(eye , center , up)){
+}
+
+mof::Camera::Camera(
+ const mof::Vector3D& eye ,
+ const mof::Vector3D& center ,
+ const mof::Vector3D& up
+ ) : m_pImpl(new Impl(
+ mof::makeConstantHandler(eye) ,
+ mof::makeConstantHandler(center) ,
+ mof::makeConstantHandler(up)
+ )){
+}
+
+mof::Camera::~Camera(){
+}
+
+mof::Matrix3D mof::Camera::getViewMatrix() const{
+ return mof::Matrix3D::createLookAtLH(
+ m_pImpl->eye->getValue(m_pImpl->frame) ,
+ m_pImpl->center->getValue(m_pImpl->frame) ,
+ m_pImpl->up->getValue(m_pImpl->frame)
+ );
+}
+
+void mof::Camera::setEye(const mof::Animation<mof::Vector3D>::Handler& eye){
+ m_pImpl->eye = eye;
+}
+
+
+void mof::Camera::setEye(const mof::Vector3D& eye){
+ m_pImpl->eye = mof::makeConstantHandler(eye);
+}
+
+void mof::Camera::setCenter(const mof::Animation<mof::Vector3D>::Handler& center){
+ m_pImpl->center = center;
+}
+
+
+void mof::Camera::setCenter(const mof::Vector3D& center){
+ m_pImpl->center = mof::makeConstantHandler(center);
+}
+
+
+void mof::Camera::setUp(const mof::Animation<mof::Vector3D>::Handler& up){
+ m_pImpl->up = up;
+}
+
+
+void mof::Camera::setUp(const mof::Vector3D& up){
+ m_pImpl->up = mof::makeConstantHandler(up);
+}
+
+
+mof::Vector3D mof::Camera::getEye() const{
+ return m_pImpl->eye->getValue(m_pImpl->frame);
+}
+
+
+mof::Vector3D mof::Camera::getCenter() const{
+ return m_pImpl->center->getValue(m_pImpl->frame);
+}
+
+
+mof::Vector3D mof::Camera::getUp() const{
+ return m_pImpl->up->getValue(m_pImpl->frame);
+}
+
+
+
+
+void mof::Camera::setFrameNumber(mof::FrameNumber frame){
+ m_pImpl->frame = frame;
+}
+
+
+void mof::Camera::nextFrame(){
+ m_pImpl->frame++;
+}
+
+void mof::Camera::prevFrame(){
+ if(m_pImpl->frame > 0)m_pImpl->frame--;
+}
+
-#ifndef MOF_CAMERA_HPP\r
-#define mOF_CAMERA_HPP\r
-#include "mof/Vector3D.hpp"\r
-#include "mof/AnimationPlayer.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/Matrix3D.hpp"\r
-\r
-namespace mof{\r
-\r
-\r
- class Camera : public mof::AnimationPlayer{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
- public:\r
- Camera(\r
- const mof::Animation<mof::Vector3D>::Handler& eye , \r
- const mof::Animation<mof::Vector3D>::Handler& center ,\r
- const mof::Animation<mof::Vector3D>::Handler& up );\r
- Camera(const mof::Vector3D& eye , const mof::Vector3D& center , const mof::Vector3D& up);\r
- virtual ~Camera();\r
-\r
- mof::Matrix3D getViewMatrix() const;\r
-\r
- void setEye(const mof::Animation<mof::Vector3D>::Handler& eye);\r
- void setEye(const mof::Vector3D& eye);\r
- void setCenter(const mof::Animation<mof::Vector3D>::Handler& center);\r
- void setCenter(const mof::Vector3D& center);\r
- void setUp(const mof::Animation<mof::Vector3D>::Handler& up);\r
- void setUp(const mof::Vector3D& up);\r
-\r
- mof::Vector3D getEye() const; \r
- mof::Vector3D getCenter() const; \r
- mof::Vector3D getUp() const; \r
-\r
- virtual void setFrameNumber(mof::FrameNumber frame);\r
- virtual void nextFrame();\r
- virtual void prevFrame();\r
-\r
- };\r
-\r
-}\r
-\r
-#endif\r
+#ifndef MOF_CAMERA_HPP
+#define mOF_CAMERA_HPP
+#include "mof/Vector3D.hpp"
+#include "mof/AnimationPlayer.hpp"
+#include <boost/scoped_ptr.hpp>
+#include "mof/Matrix3D.hpp"
+
+namespace mof{
+
+
+ class Camera : public mof::AnimationPlayer{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ public:
+ Camera(
+ const mof::Animation<mof::Vector3D>::Handler& eye ,
+ const mof::Animation<mof::Vector3D>::Handler& center ,
+ const mof::Animation<mof::Vector3D>::Handler& up );
+ Camera(const mof::Vector3D& eye , const mof::Vector3D& center , const mof::Vector3D& up);
+ virtual ~Camera();
+
+ mof::Matrix3D getViewMatrix() const;
+
+ void setEye(const mof::Animation<mof::Vector3D>::Handler& eye);
+ void setEye(const mof::Vector3D& eye);
+ void setCenter(const mof::Animation<mof::Vector3D>::Handler& center);
+ void setCenter(const mof::Vector3D& center);
+ void setUp(const mof::Animation<mof::Vector3D>::Handler& up);
+ void setUp(const mof::Vector3D& up);
+
+ mof::Vector3D getEye() const;
+ mof::Vector3D getCenter() const;
+ mof::Vector3D getUp() const;
+
+ virtual void setFrameNumber(mof::FrameNumber frame);
+ virtual void nextFrame();
+ virtual void prevFrame();
+
+ };
+
+}
+
+#endif
-#include "mof/Captor.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include "mof/FilePath.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include <sstream>\r
-\r
-\r
-mof::Captor::Captor(const mof::tstring& output)\r
-: m_output(output) \r
-{\r
- m_num = 0;\r
-}\r
-\r
-mof::Captor::~Captor(){\r
-\r
-}\r
-\r
-bool mof::Captor::capture(){\r
- mof::otstringstream os;\r
- os << m_output.c_str() << _T("/") << m_num << _T(".bmp");\r
- return capture(os.str().c_str());\r
-}\r
-\r
-\r
-\r
-bool mof::Captor::capture(const mof::tstring& filename){\r
- \r
- LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();\r
- \r
- LPDIRECT3DSURFACE9 pBackBuffer;\r
- HRESULT hr = pDevice->GetBackBuffer(0 , 0 , D3DBACKBUFFER_TYPE_MONO , &pBackBuffer);\r
- if(FAILED(hr))throw std::runtime_error("Failed --- GetBackBuffer");\r
- D3DSURFACE_DESC desc;\r
- pBackBuffer->GetDesc(&desc);\r
-\r
- hr = D3DXSaveSurfaceToFile(\r
- filename.c_str() , D3DXIFF_BMP , pBackBuffer ,\r
- NULL , NULL);\r
- pBackBuffer->Release();\r
- if(FAILED(hr)){\r
- \r
- throw std::runtime_error("Failed -- D3DXSaveSurfaceToFile");\r
- }\r
- m_num++;\r
- return true;\r
- \r
-\r
-}\r
+#include "mof/Captor.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include "mof/FilePath.hpp"
+#include "mof/ConsoleIO.hpp"
+#include <sstream>
+
+
+mof::Captor::Captor(const mof::tstring& output)
+: m_output(output)
+{
+ m_num = 0;
+}
+
+mof::Captor::~Captor(){
+
+}
+
+bool mof::Captor::capture(){
+ mof::otstringstream os;
+ os << m_output.c_str() << _T("/") << m_num << _T(".bmp");
+ return capture(os.str().c_str());
+}
+
+
+
+bool mof::Captor::capture(const mof::tstring& filename){
+
+ LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();
+
+ LPDIRECT3DSURFACE9 pBackBuffer;
+ HRESULT hr = pDevice->GetBackBuffer(0 , 0 , D3DBACKBUFFER_TYPE_MONO , &pBackBuffer);
+ if(FAILED(hr))throw std::runtime_error("Failed --- GetBackBuffer");
+ D3DSURFACE_DESC desc;
+ pBackBuffer->GetDesc(&desc);
+
+ hr = D3DXSaveSurfaceToFile(
+ filename.c_str() , D3DXIFF_BMP , pBackBuffer ,
+ NULL , NULL);
+ pBackBuffer->Release();
+ if(FAILED(hr)){
+
+ throw std::runtime_error("Failed -- D3DXSaveSurfaceToFile");
+ }
+ m_num++;
+ return true;
+
+
+}
-#pragma once\r
-#include "mof/tstring.hpp"\r
-\r
-namespace mof{\r
-\r
- class Captor\r
- {\r
- mof::tstring m_output;\r
- int m_num;\r
-\r
- public :\r
- Captor( const mof::tstring& output);\r
- ~Captor();\r
- bool capture();\r
- bool capture(const mof::tstring& filename);\r
-\r
- };\r
-\r
-}\r
+#pragma once
+#include "mof/tstring.hpp"
+
+namespace mof{
+
+ class Captor
+ {
+ mof::tstring m_output;
+ int m_num;
+
+ public :
+ Captor( const mof::tstring& output);
+ ~Captor();
+ bool capture();
+ bool capture(const mof::tstring& filename);
+
+ };
+
+}
-#include "mof/Color.hpp"\r
-#include <d3dx9.h>\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/tstring.hpp"\r
-\r
-\r
-mof::Color4f::Color4f() : \r
- alpha(0) , red(1) , green(1) , blue(1)\r
-{\r
-}\r
-\r
-mof::Color4f::Color4f(float alpha_ , float red_ , float green_ , float blue_) : \r
- alpha(alpha_) , red(red_) , green(green_) , blue(blue_)\r
-{\r
-}\r
-\r
-mof::Color4f::Color4f( float red_ , float green_ , float blue_) : \r
- alpha(1) , red(red_) , green(green_) , blue(blue_) \r
-{\r
-}\r
-\r
-mof::Color4f::Color4f(mof::Color color) : \r
- alpha(static_cast<float>(getAlpha(color)) / 255) ,\r
- red(static_cast<float>(getRed(color)) / 255) , \r
- green(static_cast<float>(getGreen(color)) / 255) ,\r
- blue(static_cast<float>(getBlue(color)) / 255 )\r
-{\r
-}\r
-\r
-mof::Color mof::Color4f::toColorCode() const{\r
- return createColor(\r
- static_cast<ColorChannel>(alpha * 255) ,\r
- static_cast<ColorChannel>(red * 255) ,\r
- static_cast<ColorChannel>(green * 255) ,\r
- static_cast<ColorChannel>(blue * 255) \r
- );\r
-}\r
-\r
-mof::Color4f mof::Color4f::operator +(const mof::Color4f& rhs) const{\r
- return mof::Color4f(\r
- alpha + rhs.alpha , \r
- red + rhs.red ,\r
- green + rhs.green ,\r
- blue + rhs.blue );\r
-}\r
-\r
-mof::Color4f mof::Color4f::operator -(const mof::Color4f& rhs) const{\r
- return mof::Color4f(\r
- alpha - rhs.alpha , \r
- red - rhs.red ,\r
- green - rhs.green ,\r
- blue - rhs.blue );\r
-}\r
-\r
-mof::Color4f mof::Color4f::operator *(const Color4f& color ) const\r
-{\r
- return mof::Color4f(color.alpha * alpha , color.red * red , color.green * green , color.blue * blue );\r
-}\r
-\r
-mof::Color4f mof::operator *(const Color4f& color , float f){\r
- return mof::Color4f(color.alpha * f , color.red * f , color.green * f , color.blue * f);\r
-}\r
- \r
-mof::Color4f mof::operator *(float f , const mof::Color4f & color){\r
- return mof::Color4f(color.alpha * f , color.red * f , color.green * f , color.blue * f);\r
-}\r
-\r
-\r
-\r
-unsigned char hex2Decimal(const TCHAR* code){\r
- unsigned char a = *code;\r
- if(a < '0')return 0;//error\r
- else if( a <= '9')return a - '0';\r
- else if( a < 'A')return 0;//error\r
- else if( a <= 'Z')return a - 'A'+10;\r
- else if( a < 'a')return 0;//error\r
- else if( a <= 'z')return a - 'a'+10;\r
- else return 0;//error\r
-}\r
-\r
-char decimal2hex(unsigned char n){\r
- if( n >= 16)return '-';//error\r
- return "0123456789abcdef"[n];\r
-}\r
-\r
-mof::Color mof::createColor(unsigned char r , unsigned char g , unsigned char b){\r
- return D3DCOLOR_XRGB(r , g , b);\r
-}\r
-\r
-mof::Color mof::createColor(unsigned char a , unsigned char r , unsigned char g , unsigned char b){\r
- return D3DCOLOR_ARGB(a , r , g , b);\r
-}\r
-\r
-\r
-mof::Color mof::createColor(const mof::tstring& code){\r
- const TCHAR* pBuffer = code.c_str();\r
- unsigned char a , r , g , b;\r
- if(code.size() == 8)a = ( hex2Decimal(pBuffer++) << 4 ) + hex2Decimal(pBuffer++);\r
- else if(code.size() != 6)return 0;//error\r
- else a = 0xff;\r
- r = (hex2Decimal(pBuffer++) << 4) + hex2Decimal(pBuffer++);\r
- g = (hex2Decimal(pBuffer++) << 4) + hex2Decimal(pBuffer++);\r
- b = (hex2Decimal(pBuffer++) << 4) + hex2Decimal(pBuffer++);\r
- return createColor(a , r , g , b);\r
-}\r
-\r
-unsigned char mof::getAlpha(const mof::Color& color){\r
- return (unsigned char)((color >> 24) & 0xff);\r
-}\r
-\r
-\r
-unsigned char mof::getRed(const mof::Color& color){\r
- return (unsigned char)((color >> 16) & 0xff);\r
-}\r
-\r
-unsigned char mof::getGreen(const mof::Color& color){\r
- return (unsigned char)((color >> 8) & 0xff);\r
-}\r
-\r
-\r
-unsigned char mof::getBlue(const mof::Color& color){\r
- return (unsigned char)(color & 0xff);\r
-}\r
-\r
-\r
-mof::Color mof::blendColor( mof::Color a , mof::Color b , float rate ){\r
- return createColor(\r
- static_cast<unsigned char>(getAlpha(a) * rate + getAlpha(b) * (1 - rate)) , //alpha\r
- static_cast<unsigned char>(getRed(a) * rate + getRed(b) * (1 - rate)) , //red\r
- static_cast<unsigned char>(getGreen(a) * rate + getGreen(b) * (1 - rate)) , //green\r
- static_cast<unsigned char>(getBlue(a) * rate + getBlue(b) * (1 - rate)) ); //blue\r
-}\r
-\r
-mof::Color mof::inverseColor(mof::Color src){\r
- return createColor(\r
- 255 - getAlpha(src) , //alpha\r
- 255 - getRed(src) , //red\r
- 255 - getGreen(src) , //green\r
- 255 - getBlue(src) ); //blue\r
-}\r
-\r
-\r
-mof::tstring mof::toColorCode(mof::Color color){\r
- mof::otstringstream os;\r
- unsigned char a = getAlpha(color);\r
- unsigned char r = getRed(color);\r
- unsigned char g = getGreen(color);\r
- unsigned char b = getBlue(color);\r
- os << decimal2hex(a >> 4) << decimal2hex(a & 0x0f) \r
- << decimal2hex(r >> 4) << decimal2hex(r & 0x0f) \r
- << decimal2hex(g >> 4) << decimal2hex(g & 0x0f) \r
- << decimal2hex(b >> 4) << decimal2hex(b & 0x0f) ;\r
- return os.str();\r
-\r
-}\r
+#include "mof/Color.hpp"
+#include <d3dx9.h>
+#include "mof/ConsoleIO.hpp"
+#include "mof/tstring.hpp"
+
+
+mof::Color4f::Color4f() :
+ alpha(0) , red(1) , green(1) , blue(1)
+{
+}
+
+mof::Color4f::Color4f(float alpha_ , float red_ , float green_ , float blue_) :
+ alpha(alpha_) , red(red_) , green(green_) , blue(blue_)
+{
+}
+
+mof::Color4f::Color4f( float red_ , float green_ , float blue_) :
+ alpha(1) , red(red_) , green(green_) , blue(blue_)
+{
+}
+
+mof::Color4f::Color4f(mof::Color color) :
+ alpha(static_cast<float>(getAlpha(color)) / 255) ,
+ red(static_cast<float>(getRed(color)) / 255) ,
+ green(static_cast<float>(getGreen(color)) / 255) ,
+ blue(static_cast<float>(getBlue(color)) / 255 )
+{
+}
+
+mof::Color mof::Color4f::toColorCode() const{
+ return createColor(
+ static_cast<ColorChannel>(alpha * 255) ,
+ static_cast<ColorChannel>(red * 255) ,
+ static_cast<ColorChannel>(green * 255) ,
+ static_cast<ColorChannel>(blue * 255)
+ );
+}
+
+mof::Color4f mof::Color4f::operator +(const mof::Color4f& rhs) const{
+ return mof::Color4f(
+ alpha + rhs.alpha ,
+ red + rhs.red ,
+ green + rhs.green ,
+ blue + rhs.blue );
+}
+
+mof::Color4f mof::Color4f::operator -(const mof::Color4f& rhs) const{
+ return mof::Color4f(
+ alpha - rhs.alpha ,
+ red - rhs.red ,
+ green - rhs.green ,
+ blue - rhs.blue );
+}
+
+mof::Color4f mof::Color4f::operator *(const Color4f& color ) const
+{
+ return mof::Color4f(color.alpha * alpha , color.red * red , color.green * green , color.blue * blue );
+}
+
+mof::Color4f mof::operator *(const Color4f& color , float f){
+ return mof::Color4f(color.alpha * f , color.red * f , color.green * f , color.blue * f);
+}
+
+mof::Color4f mof::operator *(float f , const mof::Color4f & color){
+ return mof::Color4f(color.alpha * f , color.red * f , color.green * f , color.blue * f);
+}
+
+
+
+unsigned char hex2Decimal(const TCHAR* code){
+ unsigned char a = *code;
+ if(a < '0')return 0;//error
+ else if( a <= '9')return a - '0';
+ else if( a < 'A')return 0;//error
+ else if( a <= 'Z')return a - 'A'+10;
+ else if( a < 'a')return 0;//error
+ else if( a <= 'z')return a - 'a'+10;
+ else return 0;//error
+}
+
+char decimal2hex(unsigned char n){
+ if( n >= 16)return '-';//error
+ return "0123456789abcdef"[n];
+}
+
+mof::Color mof::createColor(unsigned char r , unsigned char g , unsigned char b){
+ return D3DCOLOR_XRGB(r , g , b);
+}
+
+mof::Color mof::createColor(unsigned char a , unsigned char r , unsigned char g , unsigned char b){
+ return D3DCOLOR_ARGB(a , r , g , b);
+}
+
+
+mof::Color mof::createColor(const mof::tstring& code){
+ const TCHAR* pBuffer = code.c_str();
+ unsigned char a , r , g , b;
+ if(code.size() == 8)a = ( hex2Decimal(pBuffer++) << 4 ) + hex2Decimal(pBuffer++);
+ else if(code.size() != 6)return 0;//error
+ else a = 0xff;
+ r = (hex2Decimal(pBuffer++) << 4) + hex2Decimal(pBuffer++);
+ g = (hex2Decimal(pBuffer++) << 4) + hex2Decimal(pBuffer++);
+ b = (hex2Decimal(pBuffer++) << 4) + hex2Decimal(pBuffer++);
+ return createColor(a , r , g , b);
+}
+
+unsigned char mof::getAlpha(const mof::Color& color){
+ return (unsigned char)((color >> 24) & 0xff);
+}
+
+
+unsigned char mof::getRed(const mof::Color& color){
+ return (unsigned char)((color >> 16) & 0xff);
+}
+
+unsigned char mof::getGreen(const mof::Color& color){
+ return (unsigned char)((color >> 8) & 0xff);
+}
+
+
+unsigned char mof::getBlue(const mof::Color& color){
+ return (unsigned char)(color & 0xff);
+}
+
+
+mof::Color mof::blendColor( mof::Color a , mof::Color b , float rate ){
+ return createColor(
+ static_cast<unsigned char>(getAlpha(a) * rate + getAlpha(b) * (1 - rate)) , //alpha
+ static_cast<unsigned char>(getRed(a) * rate + getRed(b) * (1 - rate)) , //red
+ static_cast<unsigned char>(getGreen(a) * rate + getGreen(b) * (1 - rate)) , //green
+ static_cast<unsigned char>(getBlue(a) * rate + getBlue(b) * (1 - rate)) ); //blue
+}
+
+mof::Color mof::inverseColor(mof::Color src){
+ return createColor(
+ 255 - getAlpha(src) , //alpha
+ 255 - getRed(src) , //red
+ 255 - getGreen(src) , //green
+ 255 - getBlue(src) ); //blue
+}
+
+
+mof::tstring mof::toColorCode(mof::Color color){
+ mof::otstringstream os;
+ unsigned char a = getAlpha(color);
+ unsigned char r = getRed(color);
+ unsigned char g = getGreen(color);
+ unsigned char b = getBlue(color);
+ os << decimal2hex(a >> 4) << decimal2hex(a & 0x0f)
+ << decimal2hex(r >> 4) << decimal2hex(r & 0x0f)
+ << decimal2hex(g >> 4) << decimal2hex(g & 0x0f)
+ << decimal2hex(b >> 4) << decimal2hex(b & 0x0f) ;
+ return os.str();
+
+}
-#pragma once\r
-#include "mof/tstring.hpp"\r
-#include "mof/real.hpp"\r
-\r
-namespace mof{\r
- typedef unsigned int Color;\r
- typedef unsigned char ColorChannel;\r
- Color createColor(ColorChannel r , ColorChannel g , ColorChannel b);\r
- Color createColor(ColorChannel a , ColorChannel r , ColorChannel g , ColorChannel b);\r
- Color createColor(const mof::tstring& code);\r
- ColorChannel getRed(const Color& color);\r
- ColorChannel getGreen(const Color& color);\r
- ColorChannel getBlue(const Color& color);\r
- ColorChannel getAlpha(const Color& color);\r
- Color blendColor( Color a , Color b , real rate );\r
- Color inverseColor( Color color );\r
- mof::tstring toColorCode( Color color );\r
-\r
- struct Color4f{\r
- real red;\r
- real green;\r
- real blue;\r
- real alpha;\r
-\r
- Color4f();\r
- Color4f(real alpha_ , real red_ , real green_ , real blue_);\r
- Color4f( real red_ , real green_ , real blue_);\r
- explicit Color4f(mof::Color color);\r
- mof::Color toColorCode() const;\r
-\r
- mof::Color4f operator +( const mof::Color4f& rhs ) const ;\r
- mof::Color4f operator -( const mof::Color4f& rhs ) const ;\r
- mof::Color4f operator *( const Color4f& rhs ) const;\r
-\r
- friend mof::Color4f operator *(const Color4f& color , real f);\r
- friend mof::Color4f operator *(real f , const mof::Color4f & color);\r
-\r
- };\r
-\r
- \r
-\r
- \r
-};\r
+#pragma once
+#include "mof/tstring.hpp"
+#include "mof/real.hpp"
+
+namespace mof{
+ typedef unsigned int Color;
+ typedef unsigned char ColorChannel;
+ Color createColor(ColorChannel r , ColorChannel g , ColorChannel b);
+ Color createColor(ColorChannel a , ColorChannel r , ColorChannel g , ColorChannel b);
+ Color createColor(const mof::tstring& code);
+ ColorChannel getRed(const Color& color);
+ ColorChannel getGreen(const Color& color);
+ ColorChannel getBlue(const Color& color);
+ ColorChannel getAlpha(const Color& color);
+ Color blendColor( Color a , Color b , real rate );
+ Color inverseColor( Color color );
+ mof::tstring toColorCode( Color color );
+
+ struct Color4f{
+ real red;
+ real green;
+ real blue;
+ real alpha;
+
+ Color4f();
+ Color4f(real alpha_ , real red_ , real green_ , real blue_);
+ Color4f( real red_ , real green_ , real blue_);
+ explicit Color4f(mof::Color color);
+ mof::Color toColorCode() const;
+
+ mof::Color4f operator +( const mof::Color4f& rhs ) const ;
+ mof::Color4f operator -( const mof::Color4f& rhs ) const ;
+ mof::Color4f operator *( const Color4f& rhs ) const;
+
+ friend mof::Color4f operator *(const Color4f& color , real f);
+ friend mof::Color4f operator *(real f , const mof::Color4f & color);
+
+ };
+
+
+
+
+};
-#pragma once\r
-#include "mof/stream/utilities.hpp"\r
-\r
-namespace mof\r
-{\r
-\r
- class ColorComponent\r
- {\r
- public:\r
- virtual ~ColorComponent( ){}\r
-\r
- virtual void setColorStream( const ColorStream& stream )\r
- {\r
- m_colorStream = stream;\r
- }\r
-\r
- virtual const ColorStream& getColorStream( ) const\r
- {\r
- return m_colorStream;\r
- }\r
- \r
- virtual ColorStream& getColorStream( )\r
- {\r
- return m_colorStream;\r
- }\r
-\r
- \r
- protected:\r
- ColorStream m_colorStream;\r
-\r
- ColorComponent( )\r
- : \r
- m_colorStream( makeConstantHandler( Color4f( 1 , 1 , 1 ) ) ) \r
- {\r
- }\r
- \r
- ColorComponent( const Color4f& color )\r
- : \r
- m_colorStream( makeConstantHandler( color ) ) \r
- {\r
- }\r
-\r
- ColorComponent( const ColorStream& stream )\r
- : \r
- m_colorStream( stream ) \r
- {\r
- }\r
-\r
- };\r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/utilities.hpp"
+
+namespace mof
+{
+
+ class ColorComponent
+ {
+ public:
+ virtual ~ColorComponent( ){}
+
+ virtual void setColorStream( const ColorStream& stream )
+ {
+ m_colorStream = stream;
+ }
+
+ virtual const ColorStream& getColorStream( ) const
+ {
+ return m_colorStream;
+ }
+
+ virtual ColorStream& getColorStream( )
+ {
+ return m_colorStream;
+ }
+
+
+ protected:
+ ColorStream m_colorStream;
+
+ ColorComponent( )
+ :
+ m_colorStream( makeConstantHandler( Color4f( 1 , 1 , 1 ) ) )
+ {
+ }
+
+ ColorComponent( const Color4f& color )
+ :
+ m_colorStream( makeConstantHandler( color ) )
+ {
+ }
+
+ ColorComponent( const ColorStream& stream )
+ :
+ m_colorStream( stream )
+ {
+ }
+
+ };
+} // namespace mof
-#pragma once\r
-#include "mof/RectangleModel.h"\r
-#include "mof/Vector2D.h"\r
-#include "mof/GraphicsObject.h"\r
-\r
-namespace mof{\r
-\r
- class Component2D : public GraphicsObject\r
- {\r
- \r
- public:\r
- Component2D(void);\r
- virtual ~Component2D(void);\r
- \r
- virtual void setPosition(Vector2D& position) = 0;\r
- virtual int getWidth() = 0;\r
- virtual int getHeight() = 0;\r
- virtual mof::Vector2D getPosition() = 0;\r
- \r
- virtual void setVisible(bool visible) = 0;\r
- virtual RectangleModel getBounds() = 0;\r
- };\r
-\r
+#pragma once
+#include "mof/RectangleModel.h"
+#include "mof/Vector2D.h"
+#include "mof/GraphicsObject.h"
+
+namespace mof{
+
+ class Component2D : public GraphicsObject
+ {
+
+ public:
+ Component2D(void);
+ virtual ~Component2D(void);
+
+ virtual void setPosition(Vector2D& position) = 0;
+ virtual int getWidth() = 0;
+ virtual int getHeight() = 0;
+ virtual mof::Vector2D getPosition() = 0;
+
+ virtual void setVisible(bool visible) = 0;
+ virtual RectangleModel getBounds() = 0;
+ };
+
};
\ No newline at end of file
-#pragma once\r
-#include "mof/stream/utilities.hpp"\r
-\r
-namespace mof\r
-{\r
-\r
- class Component2D\r
- {\r
- public:\r
- virtual ~Component2D( ){}\r
-\r
- /** コンポーネントの左上の位置を指定する\r
- * @note このメソッドで指定するハンドラとgetPosition()で\r
- * 得られるハンドラは同一であると扱える\r
- * @retval このウィジェットの左上の位置を得るためのハンドラ \r
- */\r
- /*virtual void setPositionStream( const Vector2DStream& stream )\r
- {\r
- m_positionStream = stream;\r
- }*/\r
-\r
- /** コンポーネントの左上の位置を得る\r
- * @note このメソッドで得られるハンドラとsetPosition()で\r
- * 指定したハンドラは同一であると扱える\r
- * @retval このウィジェットの左上の位置を得るためのハンドラ \r
- */\r
- virtual const Vector2DStream& getPositionStream( ) const\r
- {\r
- return m_positionStream;\r
- }\r
- \r
- /** コンポーネントの左上の位置を得る\r
- * @note このメソッドで得られるハンドラとsetPosition()で\r
- * 指定したハンドラは同一であると扱える\r
- * @retval このウィジェットの左上の位置を得るためのハンドラ \r
- */\r
- virtual Vector2DStream& getPositionStream( ) \r
- {\r
- return m_positionStream;\r
- }\r
-\r
-\r
- /** コンポーネントの左上の位置を指定する\r
- * @note このメソッドで指定するハンドラとgetPosition()で\r
- * 得られるハンドラは同一であると扱える\r
- * @retval このウィジェットの左上の位置を得るためのハンドラ \r
- */\r
- /*virtual void setSizeStream( const Vector2DStream& stream )\r
- {\r
- m_sizeStream = stream;\r
- }*/\r
- \r
- /** コンポーネントの大きさを得る\r
- * @note このメソッドで得られるハンドラとsetSize()で\r
- * 指定したハンドラは同一であると扱える\r
- * @retval このウィジェットの大きさを得るためのハンドラ \r
- */\r
- virtual const Vector2DStream& getSizeStream( ) const\r
- {\r
- return m_sizeStream;\r
- }\r
- \r
- /** コンポーネントの大きさを得る\r
- * @note このメソッドで得られるハンドラとsetSize()で\r
- * 指定したハンドラは同一であると扱える\r
- * @retval このウィジェットの大きさを得るためのハンドラ \r
- */\r
- virtual Vector2DStream& getSizeStream( ) \r
- {\r
- return m_sizeStream;\r
- }\r
-\r
-\r
- protected:\r
- Vector2DStream m_positionStream;\r
- Vector2DStream m_sizeStream;\r
-\r
- Component2D( )\r
- : \r
- m_positionStream( makeConstantHandler( Vector2D( 0 , 0 ) ) ) ,\r
- m_sizeStream( makeConstantHandler( Vector2D( 0 , 0 ) ) ) \r
- {\r
- }\r
- \r
- Component2D( const Rectangle< int >& region )\r
- : \r
- m_positionStream\r
- (\r
- makeConstantHandler\r
- ( \r
- Vector2D(region.beginX , region.beginY)\r
- )\r
- ) ,\r
- m_sizeStream\r
- (\r
- makeConstantHandler\r
- (\r
- Vector2D(region.getWidth() , region.getHeight())\r
- )\r
- ) \r
- {}\r
-\r
- };\r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/utilities.hpp"
+
+namespace mof
+{
+
+ class Component2D
+ {
+ public:
+ virtual ~Component2D( ){}
+
+ /** コンポーネントの左上の位置を指定する
+ * @note このメソッドで指定するハンドラとgetPosition()で
+ * 得られるハンドラは同一であると扱える
+ * @retval このウィジェットの左上の位置を得るためのハンドラ
+ */
+ /*virtual void setPositionStream( const Vector2DStream& stream )
+ {
+ m_positionStream = stream;
+ }*/
+
+ /** コンポーネントの左上の位置を得る
+ * @note このメソッドで得られるハンドラとsetPosition()で
+ * 指定したハンドラは同一であると扱える
+ * @retval このウィジェットの左上の位置を得るためのハンドラ
+ */
+ virtual const Vector2DStream& getPositionStream( ) const
+ {
+ return m_positionStream;
+ }
+
+ /** コンポーネントの左上の位置を得る
+ * @note このメソッドで得られるハンドラとsetPosition()で
+ * 指定したハンドラは同一であると扱える
+ * @retval このウィジェットの左上の位置を得るためのハンドラ
+ */
+ virtual Vector2DStream& getPositionStream( )
+ {
+ return m_positionStream;
+ }
+
+
+ /** コンポーネントの左上の位置を指定する
+ * @note このメソッドで指定するハンドラとgetPosition()で
+ * 得られるハンドラは同一であると扱える
+ * @retval このウィジェットの左上の位置を得るためのハンドラ
+ */
+ /*virtual void setSizeStream( const Vector2DStream& stream )
+ {
+ m_sizeStream = stream;
+ }*/
+
+ /** コンポーネントの大きさを得る
+ * @note このメソッドで得られるハンドラとsetSize()で
+ * 指定したハンドラは同一であると扱える
+ * @retval このウィジェットの大きさを得るためのハンドラ
+ */
+ virtual const Vector2DStream& getSizeStream( ) const
+ {
+ return m_sizeStream;
+ }
+
+ /** コンポーネントの大きさを得る
+ * @note このメソッドで得られるハンドラとsetSize()で
+ * 指定したハンドラは同一であると扱える
+ * @retval このウィジェットの大きさを得るためのハンドラ
+ */
+ virtual Vector2DStream& getSizeStream( )
+ {
+ return m_sizeStream;
+ }
+
+
+ protected:
+ Vector2DStream m_positionStream;
+ Vector2DStream m_sizeStream;
+
+ Component2D( )
+ :
+ m_positionStream( makeConstantHandler( Vector2D( 0 , 0 ) ) ) ,
+ m_sizeStream( makeConstantHandler( Vector2D( 0 , 0 ) ) )
+ {
+ }
+
+ Component2D( const Rectangle< int >& region )
+ :
+ m_positionStream
+ (
+ makeConstantHandler
+ (
+ Vector2D(region.beginX , region.beginY)
+ )
+ ) ,
+ m_sizeStream
+ (
+ makeConstantHandler
+ (
+ Vector2D(region.getWidth() , region.getHeight())
+ )
+ )
+ {}
+
+ };
+} // namespace mof
-#include "mof/Component3D.hpp"\r
-#include "mof/Constant.hpp"\r
-#include "mof/Matrix3D.hpp"\r
-\r
-void mof::Component3D::setWorldMatrix(const mof::Matrix3D& matrix){\r
- setWorldMatrix(mof::makeConstantHandler(matrix));\r
-}\r
+#include "mof/Component3D.hpp"
+#include "mof/Constant.hpp"
+#include "mof/Matrix3D.hpp"
+
+void mof::Component3D::setWorldMatrix(const mof::Matrix3D& matrix){
+ setWorldMatrix(mof::makeConstantHandler(matrix));
+}
-\r
-//#include "mof/Matrix3D.hpp"\r
-\r
-#include "mof/Vector3D.hpp"\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-namespace mof{\r
-class Matrix3D;\r
-\r
-class Component3D {\r
- \r
-public:\r
- ~Component3D(){}\r
-\r
- virtual void setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler) = 0;\r
- virtual void setWorldMatrix(const mof::Matrix3D& matrix);\r
- //TODO \83R\83\8a\83W\83\87\83\93\r
-};\r
-\r
-}\r
-\r
-#endif\r
+
+//#include "mof/Matrix3D.hpp"
+
+#include "mof/Vector3D.hpp"
+#include "mof/stream/Manipulator.hpp"
+
+namespace mof{
+class Matrix3D;
+
+class Component3D {
+
+public:
+ ~Component3D(){}
+
+ virtual void setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler) = 0;
+ virtual void setWorldMatrix(const mof::Matrix3D& matrix);
+ //TODO \83R\83\8a\83W\83\87\83\93
+};
+
+}
+
+#endif
-#include "mof/ConsoleIO.hpp"\r
-\r
+#include "mof/ConsoleIO.hpp"
+
ConsoleOut* ConsoleOut::obj = NULL;
\ No newline at end of file
-\r
-#ifndef CONSOLE_H\r
-#define CONSOLE_H\r
-\r
-#include <iostream>\r
-#include <windows.h>\r
-#include <tchar.h>\r
-\r
-//--------------------------------------------\r
-// class ConsoleIO\r
-//\r
-// \83R\83\93\83\\81[\83\8b\82ð\8cÄ\82Ñ\8fo\82µ\81A\93ü\8fo\97Í\82ð\8ds\82¤\81B\r
-// C++\82Ì\93ü\8fo\97Í\83X\83g\83\8a\81[\83\80\83N\83\89\83X\81Astd::basic_stream\r
-// \82ð\8cp\8f³\82·\82é\81B\r
-//--------------------------------------------\r
-template <class CharT , class Tr = std::char_traits<CharT> >\r
-class ConsoleIO : public std::basic_streambuf<CharT , Tr>{\r
-\r
-protected:\r
- std::streampos seekoff( \r
- std::streamoff off, \r
- std::ios::seek_dir dir, \r
- int nMode = std::ios::in | std::ios::out ){\r
- return EOF;\r
- }\r
- \r
- std::streampos seekpos( std::streampos , int ){\r
- return EOF;\r
- }\r
-\r
- int_type overflow( int_type nCh = EOF ){\r
- DWORD size;\r
- WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),(WCHAR*)&nCh,1,&size,NULL);\r
- return 0;\r
- }\r
-\r
- int_type underflow(void){\r
- return EOF;\r
- }\r
-\r
-\r
-public:\r
- ConsoleIO(){\r
- setbuf(0,0);\r
- AllocConsole();\r
- }\r
- \r
- ~ConsoleIO(){\r
- FreeConsole();\r
- }\r
-\r
-};\r
-\r
-\r
-\r
-//--------------------------------------------\r
-// class ConsoleOut\r
-//\r
-// \83R\83\93\83\\81[\83\8b\8fo\97Í\82É\82Í\81A\82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82ð\8dì\82é\r
-//--------------------------------------------\r
-class ConsoleOut : public std::basic_iostream<TCHAR> {\r
- static ConsoleOut* obj;\r
- \r
- ConsoleOut(void) \r
- : std::basic_iostream<TCHAR>(new ConsoleIO<TCHAR>() ){\r
- }\r
-\r
-public:\r
- static ConsoleOut* getInstance(){\r
- if(obj == NULL)obj = new ConsoleOut();\r
- return obj;\r
- }\r
-\r
-\r
-};\r
-\r
-#define DEBUG_PRINT(x) (*ConsoleOut::getInstance() << x << std::endl)\r
-//#define DEBUG_PRINT(x)\r
-\r
-#endif \r
+
+#ifndef CONSOLE_H
+#define CONSOLE_H
+
+#include <iostream>
+#include <windows.h>
+#include <tchar.h>
+
+//--------------------------------------------
+// class ConsoleIO
+//
+// \83R\83\93\83\\81[\83\8b\82ð\8cÄ\82Ñ\8fo\82µ\81A\93ü\8fo\97Í\82ð\8ds\82¤\81B
+// C++\82Ì\93ü\8fo\97Í\83X\83g\83\8a\81[\83\80\83N\83\89\83X\81Astd::basic_stream
+// \82ð\8cp\8f³\82·\82é\81B
+//--------------------------------------------
+template <class CharT , class Tr = std::char_traits<CharT> >
+class ConsoleIO : public std::basic_streambuf<CharT , Tr>{
+
+protected:
+ std::streampos seekoff(
+ std::streamoff off,
+ std::ios::seek_dir dir,
+ int nMode = std::ios::in | std::ios::out ){
+ return EOF;
+ }
+
+ std::streampos seekpos( std::streampos , int ){
+ return EOF;
+ }
+
+ int_type overflow( int_type nCh = EOF ){
+ DWORD size;
+ WriteConsole(GetStdHandle(STD_OUTPUT_HANDLE),(WCHAR*)&nCh,1,&size,NULL);
+ return 0;
+ }
+
+ int_type underflow(void){
+ return EOF;
+ }
+
+
+public:
+ ConsoleIO(){
+ setbuf(0,0);
+ AllocConsole();
+ }
+
+ ~ConsoleIO(){
+ FreeConsole();
+ }
+
+};
+
+
+
+//--------------------------------------------
+// class ConsoleOut
+//
+// \83R\83\93\83\\81[\83\8b\8fo\97Í\82É\82Í\81A\82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82ð\8dì\82é
+//--------------------------------------------
+class ConsoleOut : public std::basic_iostream<TCHAR> {
+ static ConsoleOut* obj;
+
+ ConsoleOut(void)
+ : std::basic_iostream<TCHAR>(new ConsoleIO<TCHAR>() ){
+ }
+
+public:
+ static ConsoleOut* getInstance(){
+ if(obj == NULL)obj = new ConsoleOut();
+ return obj;
+ }
+
+
+};
+
+#define DEBUG_PRINT(x) (*ConsoleOut::getInstance() << x << std::endl)
+//#define DEBUG_PRINT(x)
+
+#endif
-#include "mof/Container2D.h"\r
-#include "mof/ConsoleIO.h"\r
-\r
-\r
-\r
-mof::Container2D::Container2D(int nColumns)\r
-: mof::Component2D() , m_margin(0) , m_paddingX(0) , m_paddingY(0)\r
-{\r
- m_nColumns = nColumns;\r
-}\r
-\r
-\r
-mof::Container2D::~Container2D(){\r
-\r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- delete m_children.at(i);\r
- }\r
-}\r
-\r
-bool mof::Container2D::update(){\r
-\r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- m_children.at(i)->update();\r
- }\r
-\r
-\r
- //setPosition(getAnimationSet()->getPosition(getPosition()));\r
- setPosition(getAnimationSet()->getPosition());\r
- getAnimationSet()->update();\r
- return true;\r
-}\r
-\r
-\r
-bool mof::Container2D::draw(){\r
- \r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- m_children.at(i)->draw();\r
- }\r
- return true;\r
-}\r
-\r
-\r
-/*\r
-bool mof::Container2D::draw(mof::Matrix3D& transform){\r
- transform = m_worldTransform * transform;\r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- m_children.at(i)->draw(transform);\r
- }\r
- return true;\r
-}*/\r
-\r
-\r
-void mof::Container2D::add(mof::Component2D* component){\r
- m_children.push_back(component);\r
-}\r
-\r
-bool mof::Container2D::remove(mof::Component2D* component){\r
- for(std::vector<mof::Component2D*>::iterator itr = m_children.begin() ; itr !=m_children.end() ; ++itr){\r
- if((*itr) == component){\r
- delete component;\r
- return true;\r
- }\r
- }\r
- return false;\r
-}\r
-\r
-int mof::Container2D::indexOf(mof::Component2D* component){\r
- for(int i = 0 ; i < m_children.size() ; ++i){\r
- if(m_children.at(i) == component)return i;\r
- }\r
- return -1;\r
-}\r
-\r
-void mof::Container2D::set(int index , mof::Component2D* component){\r
- delete m_children.at(index);\r
- m_children.at(index) = component;\r
-}\r
-\r
-mof::Component2D* mof::Container2D::get(int index){\r
- return m_children.at(index);\r
-}\r
-\r
-mof::Vector2D mof::Container2D::getPositionOf(int index){\r
- return get(index)->getPosition();/* * m_worldTransform;*/\r
- //return get(index)->getPosition();\r
-}\r
-\r
-void mof::Container2D::setPosition(Vector2D& _position){\r
- mof::Vector2D position = _position;\r
- m_position = position;\r
- position.x += m_margin;\r
- position.y += m_margin;\r
- \r
- int* maxWidthArray = new int[m_nColumns];\r
- \r
- //\97ñ\96\88\82É\8dÅ\91å\95\9d\82ð\8b\81\82ß\82é\r
- for(int i = 0 ; i < m_nColumns ; i++){\r
- maxWidthArray[i] = 0 ;\r
- for(int j = i ; j < m_children.size() ; j += m_nColumns){\r
- int width = get(j)->getWidth();\r
- if(maxWidthArray[i] < width)maxWidthArray[i] = width;\r
- }\r
- }\r
-\r
- for(int i = 0 ; i < m_children.size() ; i++){\r
- get(i)->setPosition(position);\r
- if(i % m_nColumns == m_nColumns -1){\r
- position.y += get(i)->getHeight() + m_paddingY;\r
- position.x = m_position.x + m_margin;\r
- }\r
- else position.x += maxWidthArray[i % m_nColumns] + m_paddingX;\r
- }\r
- \r
- delete[] maxWidthArray;\r
-}\r
-\r
-mof::Vector2D mof::Container2D::getPosition(){\r
- return m_position;\r
-}\r
- \r
-void mof::Container2D::setVisible(bool visible){\r
-\r
-\r
-}\r
-\r
-int mof::Container2D::getWidth(){\r
- int* maxWidthArray = new int[m_nColumns];\r
- //\97ñ\96\88\82É\8dÅ\91å\95\9d\82ð\8b\81\82ß\82é\r
- for(int i = 0 ; i < m_nColumns ; i++){\r
- maxWidthArray[i] = 0 ;\r
- for(int j = i ; j < m_children.size() ; j += m_nColumns){\r
- int width = get(j)->getWidth();\r
- if(maxWidthArray[i] < width)maxWidthArray[i] = width;\r
- }\r
- }\r
- int sumWidth = 0;\r
- for(int i = 0 ; i < m_nColumns ; i++)sumWidth += maxWidthArray[i];\r
- delete[] maxWidthArray;\r
- return sumWidth + (m_nColumns-1)* m_paddingX + getMargin()*2;\r
-}\r
-\r
-int mof::Container2D::getHeight(){\r
- int sumHeight = 0;\r
- for(int i = 0 ; i < m_children.size() ; i++){\r
- if(i % m_nColumns == 0)sumHeight += m_children.at(i)->getHeight() + m_paddingY;\r
- }\r
- return sumHeight + getMargin() *2;\r
-}\r
- \r
-\r
-mof::RectangleModel mof::Container2D::getBounds(){\r
- return mof::RectangleModel(getPosition().x , getPosition().y , getWidth() , getHeight());\r
-}\r
-\r
-void mof::Container2D::setLayout(){\r
- mof::Vector2D position = getPosition();\r
- position.x += m_margin;\r
- position.y += m_margin;\r
- //DEBUG_PRINT(position.x << _T(",") << position.y);\r
- setPosition(getPosition());\r
-}\r
+#include "mof/Container2D.h"
+#include "mof/ConsoleIO.h"
+
+
+
+mof::Container2D::Container2D(int nColumns)
+: mof::Component2D() , m_margin(0) , m_paddingX(0) , m_paddingY(0)
+{
+ m_nColumns = nColumns;
+}
+
+
+mof::Container2D::~Container2D(){
+
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ delete m_children.at(i);
+ }
+}
+
+bool mof::Container2D::update(){
+
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ m_children.at(i)->update();
+ }
+
+
+ //setPosition(getAnimationSet()->getPosition(getPosition()));
+ setPosition(getAnimationSet()->getPosition());
+ getAnimationSet()->update();
+ return true;
+}
+
+
+bool mof::Container2D::draw(){
+
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ m_children.at(i)->draw();
+ }
+ return true;
+}
+
+
+/*
+bool mof::Container2D::draw(mof::Matrix3D& transform){
+ transform = m_worldTransform * transform;
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ m_children.at(i)->draw(transform);
+ }
+ return true;
+}*/
+
+
+void mof::Container2D::add(mof::Component2D* component){
+ m_children.push_back(component);
+}
+
+bool mof::Container2D::remove(mof::Component2D* component){
+ for(std::vector<mof::Component2D*>::iterator itr = m_children.begin() ; itr !=m_children.end() ; ++itr){
+ if((*itr) == component){
+ delete component;
+ return true;
+ }
+ }
+ return false;
+}
+
+int mof::Container2D::indexOf(mof::Component2D* component){
+ for(int i = 0 ; i < m_children.size() ; ++i){
+ if(m_children.at(i) == component)return i;
+ }
+ return -1;
+}
+
+void mof::Container2D::set(int index , mof::Component2D* component){
+ delete m_children.at(index);
+ m_children.at(index) = component;
+}
+
+mof::Component2D* mof::Container2D::get(int index){
+ return m_children.at(index);
+}
+
+mof::Vector2D mof::Container2D::getPositionOf(int index){
+ return get(index)->getPosition();/* * m_worldTransform;*/
+ //return get(index)->getPosition();
+}
+
+void mof::Container2D::setPosition(Vector2D& _position){
+ mof::Vector2D position = _position;
+ m_position = position;
+ position.x += m_margin;
+ position.y += m_margin;
+
+ int* maxWidthArray = new int[m_nColumns];
+
+ //\97ñ\96\88\82É\8dÅ\91å\95\9d\82ð\8b\81\82ß\82é
+ for(int i = 0 ; i < m_nColumns ; i++){
+ maxWidthArray[i] = 0 ;
+ for(int j = i ; j < m_children.size() ; j += m_nColumns){
+ int width = get(j)->getWidth();
+ if(maxWidthArray[i] < width)maxWidthArray[i] = width;
+ }
+ }
+
+ for(int i = 0 ; i < m_children.size() ; i++){
+ get(i)->setPosition(position);
+ if(i % m_nColumns == m_nColumns -1){
+ position.y += get(i)->getHeight() + m_paddingY;
+ position.x = m_position.x + m_margin;
+ }
+ else position.x += maxWidthArray[i % m_nColumns] + m_paddingX;
+ }
+
+ delete[] maxWidthArray;
+}
+
+mof::Vector2D mof::Container2D::getPosition(){
+ return m_position;
+}
+
+void mof::Container2D::setVisible(bool visible){
+
+
+}
+
+int mof::Container2D::getWidth(){
+ int* maxWidthArray = new int[m_nColumns];
+ //\97ñ\96\88\82É\8dÅ\91å\95\9d\82ð\8b\81\82ß\82é
+ for(int i = 0 ; i < m_nColumns ; i++){
+ maxWidthArray[i] = 0 ;
+ for(int j = i ; j < m_children.size() ; j += m_nColumns){
+ int width = get(j)->getWidth();
+ if(maxWidthArray[i] < width)maxWidthArray[i] = width;
+ }
+ }
+ int sumWidth = 0;
+ for(int i = 0 ; i < m_nColumns ; i++)sumWidth += maxWidthArray[i];
+ delete[] maxWidthArray;
+ return sumWidth + (m_nColumns-1)* m_paddingX + getMargin()*2;
+}
+
+int mof::Container2D::getHeight(){
+ int sumHeight = 0;
+ for(int i = 0 ; i < m_children.size() ; i++){
+ if(i % m_nColumns == 0)sumHeight += m_children.at(i)->getHeight() + m_paddingY;
+ }
+ return sumHeight + getMargin() *2;
+}
+
+
+mof::RectangleModel mof::Container2D::getBounds(){
+ return mof::RectangleModel(getPosition().x , getPosition().y , getWidth() , getHeight());
+}
+
+void mof::Container2D::setLayout(){
+ mof::Vector2D position = getPosition();
+ position.x += m_margin;
+ position.y += m_margin;
+ //DEBUG_PRINT(position.x << _T(",") << position.y);
+ setPosition(getPosition());
+}
\ No newline at end of file
-#pragma once\r
-#include "mof/Component2D.h"\r
-#include <vector>\r
-\r
-namespace mof{\r
- \r
- class Container2D : public Component2D{\r
- std::vector<mof::Component2D*> m_children;\r
- mof::Vector2D m_position;\r
- int m_margin;\r
- int m_paddingX;\r
- int m_paddingY;\r
- int m_nColumns;\r
- public:\r
- Container2D(int nColumns = 1);\r
- ~Container2D();\r
-\r
- virtual bool update();\r
- virtual bool draw();\r
- \r
- void add(mof::Component2D* component);\r
- bool remove(mof::Component2D* component);\r
- mof::Component2D* get(int index);\r
- void set(int index , mof::Component2D* component);\r
- int indexOf(mof::Component2D* component);\r
- int size(){return m_children.size();}\r
- \r
- mof::Vector2D getPositionOf(int index);\r
- \r
- virtual void setPosition(Vector2D& position);\r
- void setMargin(int margin){m_margin = margin;}\r
- void setColumn(int nColumns){m_nColumns = nColumns;}\r
- void setPaddingX(int paddingX){m_paddingX = paddingX;}\r
- void setPaddingY(int paddingY){m_paddingY = paddingY;}\r
- int getMargin(){return m_margin;}\r
- virtual mof::Vector2D getPosition();\r
- virtual int getWidth();\r
- virtual int getHeight();\r
- \r
- virtual void setVisible(bool visible);\r
- virtual RectangleModel getBounds();\r
- virtual void setLayout();\r
- \r
- };\r
+#pragma once
+#include "mof/Component2D.h"
+#include <vector>
+
+namespace mof{
+
+ class Container2D : public Component2D{
+ std::vector<mof::Component2D*> m_children;
+ mof::Vector2D m_position;
+ int m_margin;
+ int m_paddingX;
+ int m_paddingY;
+ int m_nColumns;
+ public:
+ Container2D(int nColumns = 1);
+ ~Container2D();
+
+ virtual bool update();
+ virtual bool draw();
+
+ void add(mof::Component2D* component);
+ bool remove(mof::Component2D* component);
+ mof::Component2D* get(int index);
+ void set(int index , mof::Component2D* component);
+ int indexOf(mof::Component2D* component);
+ int size(){return m_children.size();}
+
+ mof::Vector2D getPositionOf(int index);
+
+ virtual void setPosition(Vector2D& position);
+ void setMargin(int margin){m_margin = margin;}
+ void setColumn(int nColumns){m_nColumns = nColumns;}
+ void setPaddingX(int paddingX){m_paddingX = paddingX;}
+ void setPaddingY(int paddingY){m_paddingY = paddingY;}
+ int getMargin(){return m_margin;}
+ virtual mof::Vector2D getPosition();
+ virtual int getWidth();
+ virtual int getHeight();
+
+ virtual void setVisible(bool visible);
+ virtual RectangleModel getBounds();
+ virtual void setLayout();
+
+ };
};
\ No newline at end of file
-#include "mof/Container3D.h"\r
-\r
-\r
-\r
-mof::Container3D::Container3D()\r
-: mof::Component3D() \r
-{\r
-}\r
-\r
-\r
-mof::Container3D::~Container3D(){\r
-\r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- delete m_children.at(i);\r
- }\r
-}\r
-\r
-bool mof::Container3D::draw(){\r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- if(m_children.at(i) == NULL)continue;\r
- m_children.at(i)->draw(m_worldTransform);\r
- }\r
- return true;\r
-}\r
-\r
-\r
-bool mof::Container3D::draw(mof::Matrix3D& transform){\r
- transform = m_worldTransform * transform;\r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- if(m_children.at(i) == NULL)continue;\r
- m_children.at(i)->draw(transform);\r
- }\r
- return true;\r
-} \r
-\r
-bool mof::Container3D::update(){\r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- if(m_children.at(i) == NULL)continue;\r
- m_children.at(i)->update();\r
- }\r
- return mof::Component3D::update();\r
-}\r
-\r
-\r
-void mof::Container3D::add(mof::Component3D* component){\r
- for(int i = 0 ; i < m_children.size() ; i ++){\r
- if(m_children.at(i) == NULL){\r
- m_children.at(i) = component;\r
- return;\r
- }\r
- }\r
- m_children.push_back(component);\r
-}\r
-\r
-mof::Component3D* mof::Container3D::get(int index){\r
- return m_children.at(index);\r
-}\r
-\r
-mof::Vector3D mof::Container3D::getPositionOf(int index){\r
- return get(index)->getPosition() * m_worldTransform;\r
- //return get(index)->getPosition();\r
+#include "mof/Container3D.h"
+
+
+
+mof::Container3D::Container3D()
+: mof::Component3D()
+{
+}
+
+
+mof::Container3D::~Container3D(){
+
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ delete m_children.at(i);
+ }
+}
+
+bool mof::Container3D::draw(){
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ if(m_children.at(i) == NULL)continue;
+ m_children.at(i)->draw(m_worldTransform);
+ }
+ return true;
+}
+
+
+bool mof::Container3D::draw(mof::Matrix3D& transform){
+ transform = m_worldTransform * transform;
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ if(m_children.at(i) == NULL)continue;
+ m_children.at(i)->draw(transform);
+ }
+ return true;
+}
+
+bool mof::Container3D::update(){
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ if(m_children.at(i) == NULL)continue;
+ m_children.at(i)->update();
+ }
+ return mof::Component3D::update();
+}
+
+
+void mof::Container3D::add(mof::Component3D* component){
+ for(int i = 0 ; i < m_children.size() ; i ++){
+ if(m_children.at(i) == NULL){
+ m_children.at(i) = component;
+ return;
+ }
+ }
+ m_children.push_back(component);
+}
+
+mof::Component3D* mof::Container3D::get(int index){
+ return m_children.at(index);
+}
+
+mof::Vector3D mof::Container3D::getPositionOf(int index){
+ return get(index)->getPosition() * m_worldTransform;
+ //return get(index)->getPosition();
}
\ No newline at end of file
-#pragma once\r
-#include "mof/Component3D.h"\r
-#include <vector>\r
-\r
-namespace mof{\r
- \r
- class Container3D : public Component3D{\r
- protected:\r
- std::vector<mof::Component3D*> m_children;\r
- public:\r
- Container3D();\r
- ~Container3D();\r
-\r
- \r
- virtual bool draw();\r
- virtual bool draw(mof::Matrix3D& transform);\r
- virtual bool update();\r
- \r
- void add(mof::Component3D* component);\r
- mof::Component3D* get(int index);\r
- \r
- mof::Vector3D getPositionOf(int index);\r
- \r
- //void deleteAll();\r
- \r
- };\r
+#pragma once
+#include "mof/Component3D.h"
+#include <vector>
+
+namespace mof{
+
+ class Container3D : public Component3D{
+ protected:
+ std::vector<mof::Component3D*> m_children;
+ public:
+ Container3D();
+ ~Container3D();
+
+
+ virtual bool draw();
+ virtual bool draw(mof::Matrix3D& transform);
+ virtual bool update();
+
+ void add(mof::Component3D* component);
+ mof::Component3D* get(int index);
+
+ mof::Vector3D getPositionOf(int index);
+
+ //void deleteAll();
+
+ };
};
\ No newline at end of file
-#include "DataRow.h"\r
-\r
-mof::DataRow::DataRow( const DataResource& data , const TCHAR* const pRowName)\r
-: m_data(data){\r
- m_rowIndex = m_data->getRowIndex(pRowName);\r
-}\r
-\r
-mof::DataRow::DataRow( const DataResource& data , int index)\r
-: m_data(data) , m_rowIndex(index){\r
- \r
-}\r
-\r
+#include "DataRow.h"
+
+mof::DataRow::DataRow( const DataResource& data , const TCHAR* const pRowName)
+: m_data(data){
+ m_rowIndex = m_data->getRowIndex(pRowName);
+}
+
+mof::DataRow::DataRow( const DataResource& data , int index)
+: m_data(data) , m_rowIndex(index){
+
+}
+
-#pragma once\r
-#include "mof/DataTable.h"\r
-\r
-namespace mof{\r
- class DataRow\r
- {\r
- int m_rowIndex;\r
- DataResource m_data;\r
- public:\r
- DataRow(){;}\r
- DataRow( const DataResource& data , const TCHAR * const pRowName);\r
- DataRow( const DataResource& data , int index);\r
-\r
- inline mof::tstring& getData( const TCHAR * const pColumnName);\r
- inline mof::tstring& getData( int columnIndex);\r
-\r
- inline int getIntegerData( const TCHAR * const pColumnName);\r
- inline int getIntegerData( int columnIndex);\r
- };\r
-\r
-\r
-}\r
-\r
-\r
-mof::tstring& mof::DataRow::getData( const TCHAR * const pColumnName){\r
- return m_data->getData(m_rowIndex , pColumnName);\r
-}\r
-\r
-\r
-\r
-mof::tstring& mof::DataRow::getData( int columnIndex){\r
- return m_data->getData(m_rowIndex , columnIndex);\r
-}\r
-\r
-\r
-\r
-int mof::DataRow::getIntegerData( const TCHAR * const pColumnName){\r
- return m_data->getIntegerData(m_rowIndex , pColumnName);\r
-}\r
-\r
-\r
-\r
-int mof::DataRow::getIntegerData( int columnIndex){\r
- return m_data->getIntegerData(m_rowIndex , columnIndex);\r
-}\r
-\r
-\r
+#pragma once
+#include "mof/DataTable.h"
+
+namespace mof{
+ class DataRow
+ {
+ int m_rowIndex;
+ DataResource m_data;
+ public:
+ DataRow(){;}
+ DataRow( const DataResource& data , const TCHAR * const pRowName);
+ DataRow( const DataResource& data , int index);
+
+ inline mof::tstring& getData( const TCHAR * const pColumnName);
+ inline mof::tstring& getData( int columnIndex);
+
+ inline int getIntegerData( const TCHAR * const pColumnName);
+ inline int getIntegerData( int columnIndex);
+ };
+
+
+}
+
+
+mof::tstring& mof::DataRow::getData( const TCHAR * const pColumnName){
+ return m_data->getData(m_rowIndex , pColumnName);
+}
+
+
+
+mof::tstring& mof::DataRow::getData( int columnIndex){
+ return m_data->getData(m_rowIndex , columnIndex);
+}
+
+
+
+int mof::DataRow::getIntegerData( const TCHAR * const pColumnName){
+ return m_data->getIntegerData(m_rowIndex , pColumnName);
+}
+
+
+
+int mof::DataRow::getIntegerData( int columnIndex){
+ return m_data->getIntegerData(m_rowIndex , columnIndex);
+}
+
+
-#include "mof/ConsoleIO.h"\r
-#include "mof/DataTable.h"\r
-#include "mof/CSVFile.h"\r
-#include <boost/lexical_cast.hpp>\r
-#include <assert.h>\r
-#include <stdexcept>\r
-\r
-mof::DataTable::DataTable(tstring& name )\r
- : mof::Resource(name){\r
-}\r
-\r
-mof::DataTable::DataTable(const TCHAR * const name)\r
- : mof::Resource(mof::tstring(name)){\r
-}\r
-\r
- \r
-void mof::DataTable::load(){\r
- if(isAvailable())return;\r
- //CVS\83t\83@\83C\83\8b\82©\82ç\83f\81[\83^\82ð\83\8d\81[\83h\r
- mof::CSVFile csvFile(getName().c_str());\r
- csvFile.setIgnoreNL(false);\r
-\r
- //column\8fî\95ñ\82Ì\83\8d\81[\83h\r
- for(int i = 0 ; csvFile.hasNextValue() ; i++){\r
- m_columnMap.insert(std::pair<mof::tstring , int>( mof::tstring(csvFile.getNextValue()) , i));\r
- }\r
- \r
- while(csvFile.nextLine()){\r
- m_dataList.push_back(std::vector<mof::tstring>());\r
- while(csvFile.hasNextValue()){\r
- m_dataList.back().push_back(mof::tstring(csvFile.getNextValue()));\r
- }\r
- \r
- }\r
- setAvailable(true);\r
- \r
-}\r
-\r
-void mof::DataTable::unload(){\r
- if(!isAvailable())return;\r
- m_dataList.clear();\r
- m_columnMap.clear();\r
- setAvailable(false);\r
- }\r
-\r
-\r
-int mof::DataTable::getRowIndex(const TCHAR * const pRowName){\r
- if(!isAvailable())load();\r
- for(int i = 0 ; i < m_dataList.size() ; ++i){\r
- if(!m_dataList.at(i).empty() && m_dataList.at(i).at(0) == pRowName)return i;\r
- }\r
- return -1;\r
-}\r
-\r
-\r
-int mof::DataTable::getColumnIndex(const TCHAR * const pColumnName){\r
- if(!isAvailable())load();\r
- mof::tstring tmp(pColumnName);\r
- std::map<mof::tstring , int>::iterator itr = m_columnMap.find(tmp);\r
- return itr != m_columnMap.end() ? itr->second : -1;\r
-}\r
-\r
-\r
-mof::tstring& mof::DataTable::getData(const TCHAR * const pRowName , const TCHAR * const pColumnName){\r
- if(!isAvailable())load();\r
- int columnIndex = getColumnIndex(pColumnName);\r
- int rowIndex = getRowIndex(pRowName);\r
- return m_dataList.at(rowIndex).at(columnIndex);\r
- \r
-}\r
-\r
-\r
-mof::tstring& mof::DataTable::getData(int rowIndex , const TCHAR *const pColumnName){\r
- if(!isAvailable())load();\r
- int columnIndex = getColumnIndex(pColumnName);\r
- return m_dataList.at(rowIndex).at(columnIndex);\r
-}\r
-\r
-\r
-mof::tstring& mof::DataTable::getData(int rowIndex , int columnIndex){\r
- if(!isAvailable())load();\r
- return m_dataList.at(rowIndex).at(columnIndex);\r
-}\r
-\r
-int mof::DataTable::getIntegerData(const TCHAR *const pRowName ,const TCHAR * const pColumnName){\r
- if(!isAvailable())load();\r
- return boost::lexical_cast<int>(getData(pRowName , pColumnName));\r
-}\r
-\r
-int mof::DataTable::getIntegerData(int rowIndex , const TCHAR *const pColumnName){\r
- if(!isAvailable())load();\r
- return boost::lexical_cast<int>(getData(rowIndex , pColumnName));\r
-}\r
-\r
-int mof::DataTable::getIntegerData(int rowIndex , int columnIndex){\r
- if(!isAvailable())load();\r
- return boost::lexical_cast<int>(getData(rowIndex , columnIndex));\r
-}\r
-\r
-\r
-int mof::DataTable::getNumberOfRows(){\r
- if(!isAvailable())load();\r
- return m_dataList.size();\r
+#include "mof/ConsoleIO.h"
+#include "mof/DataTable.h"
+#include "mof/CSVFile.h"
+#include <boost/lexical_cast.hpp>
+#include <assert.h>
+#include <stdexcept>
+
+mof::DataTable::DataTable(tstring& name )
+ : mof::Resource(name){
+}
+
+mof::DataTable::DataTable(const TCHAR * const name)
+ : mof::Resource(mof::tstring(name)){
+}
+
+
+void mof::DataTable::load(){
+ if(isAvailable())return;
+ //CVS\83t\83@\83C\83\8b\82©\82ç\83f\81[\83^\82ð\83\8d\81[\83h
+ mof::CSVFile csvFile(getName().c_str());
+ csvFile.setIgnoreNL(false);
+
+ //column\8fî\95ñ\82Ì\83\8d\81[\83h
+ for(int i = 0 ; csvFile.hasNextValue() ; i++){
+ m_columnMap.insert(std::pair<mof::tstring , int>( mof::tstring(csvFile.getNextValue()) , i));
+ }
+
+ while(csvFile.nextLine()){
+ m_dataList.push_back(std::vector<mof::tstring>());
+ while(csvFile.hasNextValue()){
+ m_dataList.back().push_back(mof::tstring(csvFile.getNextValue()));
+ }
+
+ }
+ setAvailable(true);
+
+}
+
+void mof::DataTable::unload(){
+ if(!isAvailable())return;
+ m_dataList.clear();
+ m_columnMap.clear();
+ setAvailable(false);
+ }
+
+
+int mof::DataTable::getRowIndex(const TCHAR * const pRowName){
+ if(!isAvailable())load();
+ for(int i = 0 ; i < m_dataList.size() ; ++i){
+ if(!m_dataList.at(i).empty() && m_dataList.at(i).at(0) == pRowName)return i;
+ }
+ return -1;
+}
+
+
+int mof::DataTable::getColumnIndex(const TCHAR * const pColumnName){
+ if(!isAvailable())load();
+ mof::tstring tmp(pColumnName);
+ std::map<mof::tstring , int>::iterator itr = m_columnMap.find(tmp);
+ return itr != m_columnMap.end() ? itr->second : -1;
+}
+
+
+mof::tstring& mof::DataTable::getData(const TCHAR * const pRowName , const TCHAR * const pColumnName){
+ if(!isAvailable())load();
+ int columnIndex = getColumnIndex(pColumnName);
+ int rowIndex = getRowIndex(pRowName);
+ return m_dataList.at(rowIndex).at(columnIndex);
+
+}
+
+
+mof::tstring& mof::DataTable::getData(int rowIndex , const TCHAR *const pColumnName){
+ if(!isAvailable())load();
+ int columnIndex = getColumnIndex(pColumnName);
+ return m_dataList.at(rowIndex).at(columnIndex);
+}
+
+
+mof::tstring& mof::DataTable::getData(int rowIndex , int columnIndex){
+ if(!isAvailable())load();
+ return m_dataList.at(rowIndex).at(columnIndex);
+}
+
+int mof::DataTable::getIntegerData(const TCHAR *const pRowName ,const TCHAR * const pColumnName){
+ if(!isAvailable())load();
+ return boost::lexical_cast<int>(getData(pRowName , pColumnName));
+}
+
+int mof::DataTable::getIntegerData(int rowIndex , const TCHAR *const pColumnName){
+ if(!isAvailable())load();
+ return boost::lexical_cast<int>(getData(rowIndex , pColumnName));
+}
+
+int mof::DataTable::getIntegerData(int rowIndex , int columnIndex){
+ if(!isAvailable())load();
+ return boost::lexical_cast<int>(getData(rowIndex , columnIndex));
+}
+
+
+int mof::DataTable::getNumberOfRows(){
+ if(!isAvailable())load();
+ return m_dataList.size();
}
\ No newline at end of file
-#pragma once\r
-#include "mof/Resource.h"\r
-#include "mof/tstring.h"\r
-#include <vector>\r
-#include <map>\r
-#include "mof/ResourceManager.h"\r
-\r
-\r
-namespace mof{\r
-\r
- \r
- class DataTable : public Resource\r
- {\r
- std::map<mof::tstring , int> m_columnMap;\r
- std::vector<std::vector<mof::tstring>> m_dataList;\r
-\r
- public:\r
- DataTable(tstring& name );\r
- DataTable(const TCHAR * const name);\r
- \r
- virtual void load();\r
- virtual void unload();\r
-\r
- int getRowIndex(const TCHAR * const pRowName);\r
- int getColumnIndex(const TCHAR * const pRowName);\r
- mof::tstring& getData(const TCHAR * const pRowName , const TCHAR * const pColumnName);\r
- mof::tstring& getData(int rowIndex , const TCHAR * const pColumnName);\r
- mof::tstring& getData(int rowIndex , int columnIndex);\r
-\r
- int getIntegerData(const TCHAR * const pRowName , const TCHAR * const pColumnName);\r
- int getIntegerData(int rowIndex , const TCHAR * const pColumnName);\r
- int getIntegerData(int rowIndex , int columnIndex);\r
- \r
- int getNumberOfRows();\r
- };\r
-\r
-\r
-\r
- typedef mof::ResourceManager<DataTable> DataResourceManager;\r
- typedef boost::shared_ptr<DataTable> DataResource;\r
-};\r
+#pragma once
+#include "mof/Resource.h"
+#include "mof/tstring.h"
+#include <vector>
+#include <map>
+#include "mof/ResourceManager.h"
+
+
+namespace mof{
+
+
+ class DataTable : public Resource
+ {
+ std::map<mof::tstring , int> m_columnMap;
+ std::vector<std::vector<mof::tstring>> m_dataList;
+
+ public:
+ DataTable(tstring& name );
+ DataTable(const TCHAR * const name);
+
+ virtual void load();
+ virtual void unload();
+
+ int getRowIndex(const TCHAR * const pRowName);
+ int getColumnIndex(const TCHAR * const pRowName);
+ mof::tstring& getData(const TCHAR * const pRowName , const TCHAR * const pColumnName);
+ mof::tstring& getData(int rowIndex , const TCHAR * const pColumnName);
+ mof::tstring& getData(int rowIndex , int columnIndex);
+
+ int getIntegerData(const TCHAR * const pRowName , const TCHAR * const pColumnName);
+ int getIntegerData(int rowIndex , const TCHAR * const pColumnName);
+ int getIntegerData(int rowIndex , int columnIndex);
+
+ int getNumberOfRows();
+ };
+
+
+
+ typedef mof::ResourceManager<DataTable> DataResourceManager;
+ typedef boost::shared_ptr<DataTable> DataResource;
+};
-#include <boost/shared_ptr.hpp>\r
-#include <boost/weak_ptr.hpp>\r
-#include "mof/EventScheduler.hpp"\r
-\r
-namespace mof{\r
- \r
- template <class T>\r
- class Deleter{\r
- boost::shared_ptr<T> m_p;\r
- public:\r
- Deleter(T* p) : m_p(p) {}\r
- Deleter( typename boost::shared_ptr<T>& p) : m_p(p) {}\r
-\r
- void operator ()(){\r
- m_p = boost::shared_ptr<T>();\r
- }\r
-\r
- boost::weak_ptr<T> getWeak(){\r
- return m_p;\r
- }\r
- };\r
-\r
-};\r
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include "mof/EventScheduler.hpp"
+
+namespace mof{
+
+ template <class T>
+ class Deleter{
+ boost::shared_ptr<T> m_p;
+ public:
+ Deleter(T* p) : m_p(p) {}
+ Deleter( typename boost::shared_ptr<T>& p) : m_p(p) {}
+
+ void operator ()(){
+ m_p = boost::shared_ptr<T>();
+ }
+
+ boost::weak_ptr<T> getWeak(){
+ return m_p;
+ }
+ };
+
+};
-#include "mof/private/DirectInput.hpp"\r
-#include "mof/private/DeviceInputReceiver.hpp"\r
-#include "mof/InputDevice.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/InputEventCondition.hpp"\r
-\r
-\r
-mof::DeviceInputReceiver::DeviceInputReceiver()\r
-: mof::InputReceiver(){\r
- m_pKeyStates = new bool[mof::DeviceInputReceiver::END];\r
- for(int i = 0 ; i < mof::DeviceInputReceiver::END ; i++)m_pKeyStates[i] = false;\r
-}\r
-\r
-mof::DeviceInputReceiver::~DeviceInputReceiver(){\r
- delete[] m_pKeyStates;\r
- \r
-}\r
-\r
-bool mof::DeviceInputReceiver::testKeyState(mof::InputReceiver::Key key){\r
-\r
- return m_pKeyStates[key];\r
- \r
-}\r
-\r
-void mof::DeviceInputReceiver::update(){\r
- mof::InputDevice::update();\r
-}\r
-\r
-\r
-void mof::DeviceInputReceiver::notifyInputEvent(mof::InputEvent& inputEvent){\r
- mof::DeviceInputReceiver::Key key;\r
-\r
- \r
- switch(inputEvent.dwOfs){\r
- case DIK_UP :\r
- key = mof::DeviceInputReceiver::UP;\r
- break;\r
- case DIK_DOWN :\r
- key = mof::DeviceInputReceiver::DOWN;\r
- break;\r
- case DIK_LEFT :\r
- key = mof::DeviceInputReceiver::LEFT;\r
- break;\r
- case DIK_RIGHT :\r
- key = mof::DeviceInputReceiver::RIGHT;\r
- break;\r
- case DIK_A :\r
- key = mof::DeviceInputReceiver::A;\r
- break;\r
- case DIK_B :\r
- key = mof::DeviceInputReceiver::B;\r
- break;\r
- case DIK_C :\r
- key = mof::DeviceInputReceiver::C;\r
- break;\r
- case DIK_D :\r
- key = mof::DeviceInputReceiver::D;\r
- break;\r
- case DIK_E :\r
- key = mof::DeviceInputReceiver::E;\r
- break;\r
- case DIK_F :\r
- key = mof::DeviceInputReceiver::F;\r
- break;\r
- case DIK_G :\r
- key = mof::DeviceInputReceiver::G;\r
- break;\r
- case DIK_H :\r
- key = mof::DeviceInputReceiver::H;\r
- break;\r
- case DIK_I :\r
- key = mof::DeviceInputReceiver::I;\r
- break;\r
- case DIK_J :\r
- key = mof::DeviceInputReceiver::J;\r
- break;\r
- case DIK_K :\r
- key = mof::DeviceInputReceiver::K;\r
- break;\r
- case DIK_L :\r
- key = mof::DeviceInputReceiver::L;\r
- break;\r
- case DIK_M :\r
- key = mof::DeviceInputReceiver::M;\r
- break;\r
- case DIK_N :\r
- key = mof::DeviceInputReceiver::N;\r
- break;\r
- case DIK_O :\r
- key = mof::DeviceInputReceiver::O;\r
- break;\r
- case DIK_P :\r
- key = mof::DeviceInputReceiver::P;\r
- break;\r
- case DIK_Q :\r
- key = mof::DeviceInputReceiver::Q;\r
- break;\r
- case DIK_R :\r
- key = mof::DeviceInputReceiver::R;\r
- break;\r
- case DIK_S :\r
- key = mof::DeviceInputReceiver::S;\r
- break;\r
- case DIK_T :\r
- key = mof::DeviceInputReceiver::T;\r
- break;\r
- case DIK_U :\r
- key = mof::DeviceInputReceiver::U;\r
- break;\r
- case DIK_V :\r
- key = mof::DeviceInputReceiver::V;\r
- break;\r
- case DIK_W :\r
- key = mof::DeviceInputReceiver::W;\r
- break;\r
- case DIK_X :\r
- key = mof::DeviceInputReceiver::X;\r
- break;\r
- case DIK_Y :\r
- key = mof::DeviceInputReceiver::Y;\r
- break;\r
- case DIK_Z :\r
- key = mof::DeviceInputReceiver::Z;\r
- break;\r
- case DIK_ESCAPE :\r
- key = mof::DeviceInputReceiver::ESCAPE;\r
- break;\r
- default : \r
- return;\r
- }\r
- m_pKeyStates[key] = (inputEvent.dwData & 0x80) != 0;\r
- \r
-}\r
+#include "mof/private/DirectInput.hpp"
+#include "mof/private/DeviceInputReceiver.hpp"
+#include "mof/InputDevice.hpp"
+#include "mof/ConsoleIO.hpp"
+#include "mof/InputEventCondition.hpp"
+
+
+mof::DeviceInputReceiver::DeviceInputReceiver()
+: mof::InputReceiver(){
+ m_pKeyStates = new bool[mof::DeviceInputReceiver::END];
+ for(int i = 0 ; i < mof::DeviceInputReceiver::END ; i++)m_pKeyStates[i] = false;
+}
+
+mof::DeviceInputReceiver::~DeviceInputReceiver(){
+ delete[] m_pKeyStates;
+
+}
+
+bool mof::DeviceInputReceiver::testKeyState(mof::InputReceiver::Key key){
+
+ return m_pKeyStates[key];
+
+}
+
+void mof::DeviceInputReceiver::update(){
+ mof::InputDevice::update();
+}
+
+
+void mof::DeviceInputReceiver::notifyInputEvent(mof::InputEvent& inputEvent){
+ mof::DeviceInputReceiver::Key key;
+
+
+ switch(inputEvent.dwOfs){
+ case DIK_UP :
+ key = mof::DeviceInputReceiver::UP;
+ break;
+ case DIK_DOWN :
+ key = mof::DeviceInputReceiver::DOWN;
+ break;
+ case DIK_LEFT :
+ key = mof::DeviceInputReceiver::LEFT;
+ break;
+ case DIK_RIGHT :
+ key = mof::DeviceInputReceiver::RIGHT;
+ break;
+ case DIK_A :
+ key = mof::DeviceInputReceiver::A;
+ break;
+ case DIK_B :
+ key = mof::DeviceInputReceiver::B;
+ break;
+ case DIK_C :
+ key = mof::DeviceInputReceiver::C;
+ break;
+ case DIK_D :
+ key = mof::DeviceInputReceiver::D;
+ break;
+ case DIK_E :
+ key = mof::DeviceInputReceiver::E;
+ break;
+ case DIK_F :
+ key = mof::DeviceInputReceiver::F;
+ break;
+ case DIK_G :
+ key = mof::DeviceInputReceiver::G;
+ break;
+ case DIK_H :
+ key = mof::DeviceInputReceiver::H;
+ break;
+ case DIK_I :
+ key = mof::DeviceInputReceiver::I;
+ break;
+ case DIK_J :
+ key = mof::DeviceInputReceiver::J;
+ break;
+ case DIK_K :
+ key = mof::DeviceInputReceiver::K;
+ break;
+ case DIK_L :
+ key = mof::DeviceInputReceiver::L;
+ break;
+ case DIK_M :
+ key = mof::DeviceInputReceiver::M;
+ break;
+ case DIK_N :
+ key = mof::DeviceInputReceiver::N;
+ break;
+ case DIK_O :
+ key = mof::DeviceInputReceiver::O;
+ break;
+ case DIK_P :
+ key = mof::DeviceInputReceiver::P;
+ break;
+ case DIK_Q :
+ key = mof::DeviceInputReceiver::Q;
+ break;
+ case DIK_R :
+ key = mof::DeviceInputReceiver::R;
+ break;
+ case DIK_S :
+ key = mof::DeviceInputReceiver::S;
+ break;
+ case DIK_T :
+ key = mof::DeviceInputReceiver::T;
+ break;
+ case DIK_U :
+ key = mof::DeviceInputReceiver::U;
+ break;
+ case DIK_V :
+ key = mof::DeviceInputReceiver::V;
+ break;
+ case DIK_W :
+ key = mof::DeviceInputReceiver::W;
+ break;
+ case DIK_X :
+ key = mof::DeviceInputReceiver::X;
+ break;
+ case DIK_Y :
+ key = mof::DeviceInputReceiver::Y;
+ break;
+ case DIK_Z :
+ key = mof::DeviceInputReceiver::Z;
+ break;
+ case DIK_ESCAPE :
+ key = mof::DeviceInputReceiver::ESCAPE;
+ break;
+ default :
+ return;
+ }
+ m_pKeyStates[key] = (inputEvent.dwData & 0x80) != 0;
+
+}
-#include "mof/DirectionalLight.h"\r
-#include <d3dx9.h>\r
-#include "GraphicsDevice.h"\r
-\r
-\r
-mof::DirectionalLight::DirectionalLight(mof::Color diffuse , mof::Color ambient , mof::Vector3D& direction)\r
-: mof::Light()\r
-{\r
- setDiffuseColor(diffuse);\r
- setAmbientColor(ambient);\r
- setDirection(direction);\r
-\r
-}\r
-\r
-\r
-void mof::DirectionalLight::update(){\r
- //mof::Animation* pAnimation = getAnimation();\r
- //if(pAnimation == NULL)return;\r
- //pAnimation->update();\r
- //mof::Color color = pAnimation->get();\r
- //set(pAnimation->getColor());\r
-}\r
-\r
-void mof::DirectionalLight::reflect(){\r
- GRAPHICS_DEVICE pDevice = mof::GraphicsDevice::getInstance()->getGraphicsDevice();\r
- D3DLIGHT9 light;\r
- ZeroMemory(&light , sizeof(light));\r
- light.Type = D3DLIGHT_DIRECTIONAL;\r
- light.Diffuse.a = (float)mof::getAlpha(m_diffuse) / 255.0f;\r
- light.Diffuse.r = (float)mof::getRed(m_diffuse) / 255.0f;\r
- light.Diffuse.g = (float)mof::getGreen(m_diffuse) / 255.0f;\r
- light.Diffuse.b = (float)mof::getBlue(m_diffuse) / 255.0f;\r
-\r
- light.Ambient.a = (float)mof::getAlpha(m_ambient) / 255.0f;\r
- light.Ambient.r = (float)mof::getRed(m_ambient) / 255.0f;\r
- light.Ambient.g = (float)mof::getGreen(m_ambient) / 255.0f;\r
- light.Ambient.b = (float)mof::getBlue(m_ambient) / 255.0f;\r
-\r
- light.Direction = D3DXVECTOR3(m_direction.x , m_direction.y , m_direction.z);\r
- \r
- \r
- pDevice->SetLight(0 , &light);\r
- pDevice->LightEnable(0 , TRUE);\r
-}\r
+#include "mof/DirectionalLight.h"
+#include <d3dx9.h>
+#include "GraphicsDevice.h"
+
+
+mof::DirectionalLight::DirectionalLight(mof::Color diffuse , mof::Color ambient , mof::Vector3D& direction)
+: mof::Light()
+{
+ setDiffuseColor(diffuse);
+ setAmbientColor(ambient);
+ setDirection(direction);
+
+}
+
+
+void mof::DirectionalLight::update(){
+ //mof::Animation* pAnimation = getAnimation();
+ //if(pAnimation == NULL)return;
+ //pAnimation->update();
+ //mof::Color color = pAnimation->get();
+ //set(pAnimation->getColor());
+}
+
+void mof::DirectionalLight::reflect(){
+ GRAPHICS_DEVICE pDevice = mof::GraphicsDevice::getInstance()->getGraphicsDevice();
+ D3DLIGHT9 light;
+ ZeroMemory(&light , sizeof(light));
+ light.Type = D3DLIGHT_DIRECTIONAL;
+ light.Diffuse.a = (float)mof::getAlpha(m_diffuse) / 255.0f;
+ light.Diffuse.r = (float)mof::getRed(m_diffuse) / 255.0f;
+ light.Diffuse.g = (float)mof::getGreen(m_diffuse) / 255.0f;
+ light.Diffuse.b = (float)mof::getBlue(m_diffuse) / 255.0f;
+
+ light.Ambient.a = (float)mof::getAlpha(m_ambient) / 255.0f;
+ light.Ambient.r = (float)mof::getRed(m_ambient) / 255.0f;
+ light.Ambient.g = (float)mof::getGreen(m_ambient) / 255.0f;
+ light.Ambient.b = (float)mof::getBlue(m_ambient) / 255.0f;
+
+ light.Direction = D3DXVECTOR3(m_direction.x , m_direction.y , m_direction.z);
+
+
+ pDevice->SetLight(0 , &light);
+ pDevice->LightEnable(0 , TRUE);
+}
-#pragma once\r
-#include "mof/Light.h"\r
-#include "mof/Color.h"\r
-\r
-namespace mof{\r
-\r
- class DirectionalLight : public Light{\r
- mof::Color m_diffuse;\r
- mof::Color m_ambient;\r
- mof::Vector3D m_direction;\r
- public:\r
- DirectionalLight(mof::Color diffuse , mof::Color ambient , mof::Vector3D& direction);\r
- void setDiffuseColor(mof::Color diffuse){m_diffuse = diffuse;}\r
- void setAmbientColor(mof::Color ambient){m_ambient = ambient;}\r
- void setDirection(mof::Vector3D& direction){m_direction = direction;}\r
-\r
- virtual void update();\r
- virtual void reflect();\r
-\r
- };\r
-\r
+#pragma once
+#include "mof/Light.h"
+#include "mof/Color.h"
+
+namespace mof{
+
+ class DirectionalLight : public Light{
+ mof::Color m_diffuse;
+ mof::Color m_ambient;
+ mof::Vector3D m_direction;
+ public:
+ DirectionalLight(mof::Color diffuse , mof::Color ambient , mof::Vector3D& direction);
+ void setDiffuseColor(mof::Color diffuse){m_diffuse = diffuse;}
+ void setAmbientColor(mof::Color ambient){m_ambient = ambient;}
+ void setDirection(mof::Vector3D& direction){m_direction = direction;}
+
+ virtual void update();
+ virtual void reflect();
+
+ };
+
};
\ No newline at end of file
-#pragma once\r
-\r
-namespace mof\r
-{\r
- class Drawable\r
- {\r
- public:\r
- virtual ~Drawable(){}\r
- virtual void draw() const = 0;\r
- };\r
-}\r
+#pragma once
+
+namespace mof
+{
+ class Drawable
+ {
+ public:
+ virtual ~Drawable(){}
+ virtual void draw() const = 0;
+ };
+}
-#pragma once\r
-\r
-namespace mof{\r
-\r
- class EventCondition{\r
- public:\r
- virtual ~EventCondition(){}\r
- virtual bool test() = 0;\r
- virtual void update() = 0;\r
- virtual bool isDisposable() = 0;\r
- };\r
-\r
-}\r
-\r
+#pragma once
+
+namespace mof{
+
+ class EventCondition{
+ public:
+ virtual ~EventCondition(){}
+ virtual bool test() = 0;
+ virtual void update() = 0;
+ virtual bool isDisposable() = 0;
+ };
+
+}
+
-#include "mof/EventScheduler.hpp"\r
-#include "mof/EventCondition.hpp"\r
-#include <list>\r
-#include <utility>\r
-#include "mof/utilities.hpp"\r
-\r
-\r
-class TimeEventCondition : public mof::EventCondition{\r
- mof::FrameNumber limit;\r
- mof::FrameNumber count;\r
-\r
-public:\r
- TimeEventCondition(mof::FrameNumber limit)\r
- : limit(limit) , count(0)\r
- {\r
- }\r
-\r
- virtual ~TimeEventCondition(){}\r
-\r
- virtual bool test(){\r
- return count == limit;\r
- }\r
-\r
- virtual bool isDisposable(){\r
- return count > limit;\r
- }\r
-\r
- virtual void update(){\r
- if(limit >= count)count++;\r
- }\r
-};\r
-\r
-struct mof::EventScheduler::Impl{\r
- typedef std::pair<mof::EventCondition* , boost::function0<void>> Schedule; \r
- typedef std::list<std::pair<mof::EventCondition* , boost::function0<void>>> EventList; \r
- EventList eventList;\r
-\r
- Impl(){\r
- }\r
-\r
- ~Impl(){\r
- foreach( Impl::Schedule &value , eventList ){\r
- delete value.first;\r
- }\r
- }\r
-\r
-};\r
-\r
-mof::EventScheduler::EventScheduler()\r
-: m_pImpl(new Impl())\r
-{\r
-}\r
-\r
-mof::EventScheduler::~EventScheduler(){\r
- \r
-}\r
-\r
-void mof::EventScheduler::addEvent( mof::EventCondition* pCondition , const boost::function0<void> &action){\r
- m_pImpl->eventList.push_back(std::pair<mof::EventCondition* , boost::function0<void>>(pCondition , action));\r
-}\r
-\r
-void mof::EventScheduler::addEvent(mof::FrameNumber frame, const boost::function0<void> &action){\r
- addEvent(new TimeEventCondition(frame) , action);\r
-}\r
-\r
-void mof::EventScheduler::update(){\r
- for( Impl::EventList::iterator itr = m_pImpl->eventList.begin() ;\r
- itr != m_pImpl->eventList.end() ; \r
- ){\r
- itr->first->update();\r
- if(itr->first->test()){\r
- itr->second();\r
- }\r
- if(itr->first->isDisposable()){\r
- delete itr->first;\r
- itr = m_pImpl->eventList.erase(itr);\r
- }\r
- else ++itr;\r
- }\r
-}\r
-\r
-\r
-\r
+#include "mof/EventScheduler.hpp"
+#include "mof/EventCondition.hpp"
+#include <list>
+#include <utility>
+#include "mof/utilities.hpp"
+
+
+class TimeEventCondition : public mof::EventCondition{
+ mof::FrameNumber limit;
+ mof::FrameNumber count;
+
+public:
+ TimeEventCondition(mof::FrameNumber limit)
+ : limit(limit) , count(0)
+ {
+ }
+
+ virtual ~TimeEventCondition(){}
+
+ virtual bool test(){
+ return count == limit;
+ }
+
+ virtual bool isDisposable(){
+ return count > limit;
+ }
+
+ virtual void update(){
+ if(limit >= count)count++;
+ }
+};
+
+struct mof::EventScheduler::Impl{
+ typedef std::pair<mof::EventCondition* , boost::function0<void>> Schedule;
+ typedef std::list<std::pair<mof::EventCondition* , boost::function0<void>>> EventList;
+ EventList eventList;
+
+ Impl(){
+ }
+
+ ~Impl(){
+ foreach( Impl::Schedule &value , eventList ){
+ delete value.first;
+ }
+ }
+
+};
+
+mof::EventScheduler::EventScheduler()
+: m_pImpl(new Impl())
+{
+}
+
+mof::EventScheduler::~EventScheduler(){
+
+}
+
+void mof::EventScheduler::addEvent( mof::EventCondition* pCondition , const boost::function0<void> &action){
+ m_pImpl->eventList.push_back(std::pair<mof::EventCondition* , boost::function0<void>>(pCondition , action));
+}
+
+void mof::EventScheduler::addEvent(mof::FrameNumber frame, const boost::function0<void> &action){
+ addEvent(new TimeEventCondition(frame) , action);
+}
+
+void mof::EventScheduler::update(){
+ for( Impl::EventList::iterator itr = m_pImpl->eventList.begin() ;
+ itr != m_pImpl->eventList.end() ;
+ ){
+ itr->first->update();
+ if(itr->first->test()){
+ itr->second();
+ }
+ if(itr->first->isDisposable()){
+ delete itr->first;
+ itr = m_pImpl->eventList.erase(itr);
+ }
+ else ++itr;
+ }
+}
+
+
+
-#ifndef MOF_EVENT_SCHEDULER_HPP\r
-#define MOF_EVENT_SCHEDULER_HPP\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/function/function0.hpp>\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-namespace mof{\r
-\r
-class EventCondition;\r
-\r
-class EventScheduler{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
-public:\r
- typedef boost::function0<void> Action;\r
- EventScheduler();\r
- ~EventScheduler();\r
-\r
- void addEvent(mof::EventCondition* pCondition , const Action& action);\r
- void addEvent(mof::FrameNumber interval , const Action& action);\r
- void update();\r
-};\r
-\r
-}\r
-\r
-\r
-\r
-\r
-#endif\r
+#ifndef MOF_EVENT_SCHEDULER_HPP
+#define MOF_EVENT_SCHEDULER_HPP
+#include <boost/scoped_ptr.hpp>
+#include <boost/function/function0.hpp>
+#include "mof/stream/Manipulator.hpp"
+
+namespace mof{
+
+class EventCondition;
+
+class EventScheduler{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+public:
+ typedef boost::function0<void> Action;
+ EventScheduler();
+ ~EventScheduler();
+
+ void addEvent(mof::EventCondition* pCondition , const Action& action);
+ void addEvent(mof::FrameNumber interval , const Action& action);
+ void update();
+};
+
+}
+
+
+
+
+#endif
-#pragma once\r
-#include <boost/function/function0.hpp>\r
-\r
-namespace mof\r
-{\r
- //TODO タイプリストとかで、そのままのインタフェースでより汎用的にする\r
- //非const参照を渡したい場合は?(constructorにそれはありえない)\r
-\r
-\r
-//{{{ FactoryMethod\r
- template < class T > \r
- class FactoryMethod\r
- {\r
- public: \r
- FactoryMethod( const boost::function<T* (void)>& factory)\r
- : m_factory(factory){}\r
-\r
- T* operator() () const{ return m_factory(); }\r
- \r
- template<class T>\r
- operator FactoryMethod<T>( ) const\r
- {\r
- return FactoryMethod<T>(m_factory); \r
- }\r
-\r
-\r
-\r
- private: \r
- boost::function<T* (void)> m_factory;\r
- };\r
-\r
- \r
-//}}}\r
-//{{{ Constructor0\r
- template < class T > \r
- class Constructor0\r
- {\r
- public: \r
- T* operator() ( ) const {return new T();}\r
- };\r
-//}}}\r
-//{{{ Constructor1\r
- template <class T , class P1> \r
- class Constructor1 : protected Constructor0<T>\r
- {\r
- protected:\r
- P1 p1;\r
- public: \r
- Constructor1(const P1& p1_)\r
- : p1(p1_)\r
- {}\r
-\r
- T* operator() ( ) const {return new T(p1);}\r
- };\r
-//}}}\r
-//{{{ Constructor2\r
- template <class T , class P1 , class P2> \r
- class Constructor2 : protected Constructor1<T , P1>\r
- {\r
- protected:\r
- P2 p2;\r
- public: \r
- Constructor2(const P1& p1_ , const P2& p2_)\r
- : Constructor1(p1_) , p2(p2_)\r
- {}\r
-\r
- T* operator() ( ) const {return new T(p1 , p2);}\r
- };\r
-//}}}\r
-//{{{ Constructor3\r
- template <class T , class P1 , class P2 , class P3> \r
- class Constructor3 : protected Constructor2<T , P1 , P2>\r
- {\r
- protected:\r
- P3 p3;\r
- public: \r
- Constructor3(const P1& p1_ , const P2& p2_ , const P3& p3_)\r
- : Constructor2(p1_ , p2_) , p3(p3_)\r
- {}\r
-\r
- T* operator() ( ) const {return new T(p1 , p2 , p3);}\r
- };\r
-//}}}\r
-//{{{ Constructor4\r
- template <class T , class P1 , class P2 , class P3 , class P4> \r
- class Constructor4 : protected Constructor3<T , P1 , P2 , P3>\r
- {\r
- protected:\r
- P4 p4;\r
- public: \r
- Constructor4(const P1& p1_ , const P2& p2_ , const P3& p3_ , const P4& p4_)\r
- : Constructor2(p1_ , p2_ , p3_) , p4(p4_)\r
- {}\r
-\r
- T* operator() ( ) const {return new T(p1 , p2 , p3 , p4);}\r
- };\r
-//}}}\r
- \r
-//{{{ makeFactoryMethod\r
- template<class T>\r
- FactoryMethod<T>\r
- makeFactoryMethod()\r
- {\r
- return FactoryMethod<T>( Constructor0<T>() );\r
- }\r
- \r
- template<class T , class P1>\r
- FactoryMethod<T>\r
- makeFactoryMethod(const P1& p1)\r
- {\r
- return FactoryMethod<T>( Constructor1<T , P1>(p1) );\r
- }\r
- \r
- template<class T , class P1 , class P2>\r
- FactoryMethod<T>\r
- makeFactoryMethod(const P1& p1 , const P2& p2)\r
- {\r
- return FactoryMethod<T>( Constructor2<T , P1 , P2>(p1 , p2) );\r
- }\r
- \r
- template<class T , class P1 , class P2 , class P3>\r
- FactoryMethod<T>\r
- makeFactoryMethod(const P1& p1 , const P2& p2 , const P3& p3)\r
- {\r
- return FactoryMethod<T>( Constructor3<T , P1 , P2 , P3>(p1 , p2 , p3) );\r
- }\r
- \r
- template<class T , class P1 , class P2 , class P3 , class P4>\r
- FactoryMethod<T>\r
- makeFactoryMethod(const P1& p1 , const P2& p2 , const P3& p3 , const P4& p4)\r
- {\r
- return FactoryMethod<T>( Constructor4<T , P1 , P2 , P3 , P4>(p1 , p2 , p3 , p4) );\r
- }\r
-//}}}\r
-\r
-\r
-}\r
+#pragma once
+#include <boost/function/function0.hpp>
+
+namespace mof
+{
+ //TODO タイプリストとかで、そのままのインタフェースでより汎用的にする
+ //非const参照を渡したい場合は?(constructorにそれはありえない)
+
+
+//{{{ FactoryMethod
+ template < class T >
+ class FactoryMethod
+ {
+ public:
+ FactoryMethod( const boost::function<T* (void)>& factory)
+ : m_factory(factory){}
+
+ T* operator() () const{ return m_factory(); }
+
+ template<class T>
+ operator FactoryMethod<T>( ) const
+ {
+ return FactoryMethod<T>(m_factory);
+ }
+
+
+
+ private:
+ boost::function<T* (void)> m_factory;
+ };
+
+
+//}}}
+//{{{ Constructor0
+ template < class T >
+ class Constructor0
+ {
+ public:
+ T* operator() ( ) const {return new T();}
+ };
+//}}}
+//{{{ Constructor1
+ template <class T , class P1>
+ class Constructor1 : protected Constructor0<T>
+ {
+ protected:
+ P1 p1;
+ public:
+ Constructor1(const P1& p1_)
+ : p1(p1_)
+ {}
+
+ T* operator() ( ) const {return new T(p1);}
+ };
+//}}}
+//{{{ Constructor2
+ template <class T , class P1 , class P2>
+ class Constructor2 : protected Constructor1<T , P1>
+ {
+ protected:
+ P2 p2;
+ public:
+ Constructor2(const P1& p1_ , const P2& p2_)
+ : Constructor1(p1_) , p2(p2_)
+ {}
+
+ T* operator() ( ) const {return new T(p1 , p2);}
+ };
+//}}}
+//{{{ Constructor3
+ template <class T , class P1 , class P2 , class P3>
+ class Constructor3 : protected Constructor2<T , P1 , P2>
+ {
+ protected:
+ P3 p3;
+ public:
+ Constructor3(const P1& p1_ , const P2& p2_ , const P3& p3_)
+ : Constructor2(p1_ , p2_) , p3(p3_)
+ {}
+
+ T* operator() ( ) const {return new T(p1 , p2 , p3);}
+ };
+//}}}
+//{{{ Constructor4
+ template <class T , class P1 , class P2 , class P3 , class P4>
+ class Constructor4 : protected Constructor3<T , P1 , P2 , P3>
+ {
+ protected:
+ P4 p4;
+ public:
+ Constructor4(const P1& p1_ , const P2& p2_ , const P3& p3_ , const P4& p4_)
+ : Constructor2(p1_ , p2_ , p3_) , p4(p4_)
+ {}
+
+ T* operator() ( ) const {return new T(p1 , p2 , p3 , p4);}
+ };
+//}}}
+
+//{{{ makeFactoryMethod
+ template<class T>
+ FactoryMethod<T>
+ makeFactoryMethod()
+ {
+ return FactoryMethod<T>( Constructor0<T>() );
+ }
+
+ template<class T , class P1>
+ FactoryMethod<T>
+ makeFactoryMethod(const P1& p1)
+ {
+ return FactoryMethod<T>( Constructor1<T , P1>(p1) );
+ }
+
+ template<class T , class P1 , class P2>
+ FactoryMethod<T>
+ makeFactoryMethod(const P1& p1 , const P2& p2)
+ {
+ return FactoryMethod<T>( Constructor2<T , P1 , P2>(p1 , p2) );
+ }
+
+ template<class T , class P1 , class P2 , class P3>
+ FactoryMethod<T>
+ makeFactoryMethod(const P1& p1 , const P2& p2 , const P3& p3)
+ {
+ return FactoryMethod<T>( Constructor3<T , P1 , P2 , P3>(p1 , p2 , p3) );
+ }
+
+ template<class T , class P1 , class P2 , class P3 , class P4>
+ FactoryMethod<T>
+ makeFactoryMethod(const P1& p1 , const P2& p2 , const P3& p3 , const P4& p4)
+ {
+ return FactoryMethod<T>( Constructor4<T , P1 , P2 , P3 , P4>(p1 , p2 , p3 , p4) );
+ }
+//}}}
+
+
+}
-#include "mof/FilePath.hpp"\r
-#include <boost/regex.hpp>\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-\r
-mof::FilePath::FilePath(const mof::tstring& path){\r
- m_path = path;\r
-}\r
-\r
-\r
-mof::tstring mof::FilePath::getFormat(){\r
- try {\r
- boost::regex regex("(.*)\\.(.*)");//name . format\r
- boost::smatch match;\r
- //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢\r
- if(!boost::regex_search(m_path , match , regex)){\r
- DEBUG_PRINT(_T("FormatError --- ") << m_path);\r
- return mof::tstring();\r
- }\r
- return match.str(2); \r
- }\r
- catch (std::exception &e) {\r
- throw e;\r
- }\r
- return mof::tstring();\r
-}\r
- \r
-\r
-mof::tstring& mof::FilePath::getPath(){\r
- return m_path;\r
-}\r
-\r
-mof::tstring mof::FilePath::dir(){\r
- try {\r
- boost::regex regex("(.*)/[^/]*\\.(.*)");//name . format\r
- boost::smatch match;\r
- //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢\r
- if(!boost::regex_search(m_path , match , regex)){\r
- DEBUG_PRINT(_T("FormatError --- ") << m_path);\r
- return mof::tstring();\r
- }\r
- return match.str(1); \r
- }\r
- catch (std::exception &e) {\r
- throw e;\r
- }\r
- return mof::tstring();\r
-\r
-}\r
- \r
-mof::tstring mof::FilePath::basename(){\r
- try {\r
- boost::regex regex("(.*)/([^/]*)");//name . format\r
- boost::smatch match;\r
- //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢\r
- if(!boost::regex_search(m_path , match , regex)){\r
- DEBUG_PRINT(_T("FormatError --- ") << m_path);\r
- return mof::tstring();\r
- }\r
- return match.str(2); \r
- }\r
- catch (std::exception &e) {\r
- throw e;\r
- }\r
- return mof::tstring();\r
-\r
-}\r
-\r
+#include "mof/FilePath.hpp"
+#include <boost/regex.hpp>
+#include "mof/ConsoleIO.hpp"
+
+
+mof::FilePath::FilePath(const mof::tstring& path){
+ m_path = path;
+}
+
+
+mof::tstring mof::FilePath::getFormat(){
+ try {
+ boost::regex regex("(.*)\\.(.*)");//name . format
+ boost::smatch match;
+ //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢
+ if(!boost::regex_search(m_path , match , regex)){
+ DEBUG_PRINT(_T("FormatError --- ") << m_path);
+ return mof::tstring();
+ }
+ return match.str(2);
+ }
+ catch (std::exception &e) {
+ throw e;
+ }
+ return mof::tstring();
+}
+
+
+mof::tstring& mof::FilePath::getPath(){
+ return m_path;
+}
+
+mof::tstring mof::FilePath::dir(){
+ try {
+ boost::regex regex("(.*)/[^/]*\\.(.*)");//name . format
+ boost::smatch match;
+ //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢
+ if(!boost::regex_search(m_path , match , regex)){
+ DEBUG_PRINT(_T("FormatError --- ") << m_path);
+ return mof::tstring();
+ }
+ return match.str(1);
+ }
+ catch (std::exception &e) {
+ throw e;
+ }
+ return mof::tstring();
+
+}
+
+mof::tstring mof::FilePath::basename(){
+ try {
+ boost::regex regex("(.*)/([^/]*)");//name . format
+ boost::smatch match;
+ //\8a¿\8e\9a\82É\82Í\91Î\89\9e\82µ\82Ä\82¢\82È\82¢
+ if(!boost::regex_search(m_path , match , regex)){
+ DEBUG_PRINT(_T("FormatError --- ") << m_path);
+ return mof::tstring();
+ }
+ return match.str(2);
+ }
+ catch (std::exception &e) {
+ throw e;
+ }
+ return mof::tstring();
+
+}
+
-#ifndef MOF_FILE_PATH_HPP\r
-#define MOF_FILE_PATH_HPP\r
-\r
-#include "mof/tstring.hpp"\r
-\r
-namespace mof{\r
-\r
-class FilePath{\r
- mof::tstring m_path;\r
-\r
-public:\r
- FilePath(const mof::tstring& path);\r
-\r
- mof::tstring getFormat();\r
- mof::tstring& getPath();\r
- mof::tstring dir();\r
- mof::tstring basename();\r
-};\r
-\r
-}\r
-\r
-#endif\r
+#ifndef MOF_FILE_PATH_HPP
+#define MOF_FILE_PATH_HPP
+
+#include "mof/tstring.hpp"
+
+namespace mof{
+
+class FilePath{
+ mof::tstring m_path;
+
+public:
+ FilePath(const mof::tstring& path);
+
+ mof::tstring getFormat();
+ mof::tstring& getPath();
+ mof::tstring dir();
+ mof::tstring basename();
+};
+
+}
+
+#endif
-\r
-#include "mof/FileTextureBuilder.h"\r
-#include <d3dx9.h>\r
-#include <dxerr9.h>\r
-#include "GraphicsDevice.h"\r
-#include "mof/ConsoleIO.h"\r
-\r
-mof::FileTextureBuilder::FileTextureBuilder(mof::tstring& path)\r
-{\r
- m_path = path;\r
-}\r
-\r
-mof::FileTextureBuilder::~FileTextureBuilder(void)\r
-{\r
-}\r
-\r
-\r
-mof::TextureRecord mof::FileTextureBuilder::create(){\r
- LPDIRECT3DTEXTURE9 texture;\r
- mof::GRAPHICS_DEVICE pDevice = mof::GraphicsDevice::getInstance()->getGraphicsDevice();\r
- HRESULT hr = D3DXCreateTextureFromFileEx(pDevice , m_path.c_str() , \r
- 0 , 0 , 1 , 0/*RENDER*/ , D3DFMT_UNKNOWN , D3DPOOL_MANAGED ,\r
- D3DX_DEFAULT , D3DX_DEFAULT , mof::createColor(0 , 0 , 0) , NULL , NULL , &texture);\r
-\r
- if(FAILED(hr)){\r
- *ConsoleOut::getInstance() << "CreateTexture --- " << DXGetErrorDescription9(hr) << std::endl;\r
- TextureRecord record;\r
- record.pTexture = NULL;\r
- return record;\r
- }\r
-\r
- TextureRecord record;\r
- record.pTexture = texture;\r
- record.validRect = mof::RectangleModel(0 , 0 , 0 , 0);//\91S\94Í\88Í\r
- return record;\r
-\r
+
+#include "mof/FileTextureBuilder.h"
+#include <d3dx9.h>
+#include <dxerr9.h>
+#include "GraphicsDevice.h"
+#include "mof/ConsoleIO.h"
+
+mof::FileTextureBuilder::FileTextureBuilder(mof::tstring& path)
+{
+ m_path = path;
+}
+
+mof::FileTextureBuilder::~FileTextureBuilder(void)
+{
+}
+
+
+mof::TextureRecord mof::FileTextureBuilder::create(){
+ LPDIRECT3DTEXTURE9 texture;
+ mof::GRAPHICS_DEVICE pDevice = mof::GraphicsDevice::getInstance()->getGraphicsDevice();
+ HRESULT hr = D3DXCreateTextureFromFileEx(pDevice , m_path.c_str() ,
+ 0 , 0 , 1 , 0/*RENDER*/ , D3DFMT_UNKNOWN , D3DPOOL_MANAGED ,
+ D3DX_DEFAULT , D3DX_DEFAULT , mof::createColor(0 , 0 , 0) , NULL , NULL , &texture);
+
+ if(FAILED(hr)){
+ *ConsoleOut::getInstance() << "CreateTexture --- " << DXGetErrorDescription9(hr) << std::endl;
+ TextureRecord record;
+ record.pTexture = NULL;
+ return record;
+ }
+
+ TextureRecord record;
+ record.pTexture = texture;
+ record.validRect = mof::RectangleModel(0 , 0 , 0 , 0);//\91S\94Í\88Í
+ return record;
+
}
\ No newline at end of file
-#pragma once\r
-\r
-\r
-namespace mof\r
-{\r
- \r
- \r
- //TODO \83R\83\93\83e\83i\82É\91ã\93ü\82Å\82«\82È\82¢\82æ\82¤\82É\82·\82é\r
- class Finalizer \r
- {\r
- mutable void (*m_finalize)( );\r
- \r
- public:\r
- Finalizer( )\r
- : m_finalize(NULL)\r
- {\r
- // do nothing\r
- }\r
- \r
- Finalizer( void (*finalize_)() )\r
- : m_finalize(finalize_)\r
- {\r
- // do nothing\r
- }\r
- \r
- Finalizer( const Finalizer& obj){\r
- if( this == &obj)return;\r
- m_finalize = obj.m_finalize;\r
- obj.m_finalize = NULL;\r
- }\r
- \r
- ~Finalizer( )\r
- {\r
- if( m_finalize )m_finalize();\r
- }\r
- \r
- void cancel( )\r
- {\r
- m_finalize = NULL;\r
- }\r
- \r
- Finalizer& operator = ( const Finalizer& obj )\r
- {\r
- if( this == &obj)return *this;\r
- if( m_finalize )m_finalize();\r
- m_finalize = obj.m_finalize;\r
- obj.m_finalize = NULL;\r
- return *this;\r
- }\r
- \r
- \r
- };\r
+#pragma once
+
+
+namespace mof
+{
+
+
+ //TODO \83R\83\93\83e\83i\82É\91ã\93ü\82Å\82«\82È\82¢\82æ\82¤\82É\82·\82é
+ class Finalizer
+ {
+ mutable void (*m_finalize)( );
+
+ public:
+ Finalizer( )
+ : m_finalize(NULL)
+ {
+ // do nothing
+ }
+
+ Finalizer( void (*finalize_)() )
+ : m_finalize(finalize_)
+ {
+ // do nothing
+ }
+
+ Finalizer( const Finalizer& obj){
+ if( this == &obj)return;
+ m_finalize = obj.m_finalize;
+ obj.m_finalize = NULL;
+ }
+
+ ~Finalizer( )
+ {
+ if( m_finalize )m_finalize();
+ }
+
+ void cancel( )
+ {
+ m_finalize = NULL;
+ }
+
+ Finalizer& operator = ( const Finalizer& obj )
+ {
+ if( this == &obj)return *this;
+ if( m_finalize )m_finalize();
+ m_finalize = obj.m_finalize;
+ obj.m_finalize = NULL;
+ return *this;
+ }
+
+
+ };
}
\ No newline at end of file
-#include "mof/Font.hpp"\r
-#include <list>\r
-#include <windows.h>\r
-#include "mof/ConsoleIO.hpp"\r
-#include <vector>\r
-#include "mof/utilities.hpp"\r
-\r
-const TCHAR* mof::Font::MS_GOTHIC = _T("\82l\82r \83S\83V\83b\83N");\r
-const TCHAR* mof::Font::MS_P_GOTHIC = _T("\82l\82r \82o\83S\83V\83b\83N");\r
-\r
-\r
-namespace\r
-{\r
- struct FontManager \r
- {\r
- std::vector<mof::tstring> additionalFontResources;\r
- \r
- ~FontManager()\r
- {\r
- foreach( mof::tstring& filename , additionalFontResources )\r
- {\r
- RemoveFontResource( filename.c_str() );\r
- }\r
- }\r
- } g_fontManager;\r
-}\r
-\r
-struct GlyphData{\r
- int iOfs_x , iOfs_y , iBmp_w , iBmp_h , level , width;\r
- BYTE* pBmpBuffer;\r
- bool valid;\r
-\r
- GlyphData(GLYPHMETRICS& GM , TEXTMETRIC& TM , int _level , int bufSize){\r
- iOfs_x = GM.gmptGlyphOrigin.x;\r
- iOfs_y = TM.tmAscent - GM.gmptGlyphOrigin.y;\r
- iBmp_w = GM.gmBlackBoxX + (4-(GM.gmBlackBoxX%4))%4;\r
- iBmp_h = GM.gmBlackBoxY;\r
- level = _level;\r
- width = GM.gmCellIncX;\r
- pBmpBuffer = new BYTE[bufSize];\r
- valid = true;\r
- }\r
-\r
- ~GlyphData(){\r
- delete[] pBmpBuffer;\r
- }\r
-};\r
-\r
-struct mof::Font::Impl{\r
- HFONT hFont;\r
- size_t fontSize;\r
-\r
- Impl(size_t fontSize_)\r
- : hFont(NULL) ,fontSize(fontSize_)\r
- {\r
- }\r
-\r
- ~Impl(){\r
- DeleteObject(hFont);\r
- }\r
-\r
-};\r
-\r
-mof::Font::Font(const TCHAR* fontName , size_t size)\r
-: m_pImpl(new Impl(size))\r
-{\r
- LOGFONT lf = {m_pImpl->fontSize , 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, OUT_TT_ONLY_PRECIS,\r
- CLIP_DEFAULT_PRECIS , PROOF_QUALITY, FIXED_PITCH | FF_MODERN , "" };\r
- strcpy_s(lf.lfFaceName , fontName );\r
-\r
- if(!(m_pImpl->hFont = CreateFontIndirect(&lf))){\r
- throw std::runtime_error("Failed --- CreateFontIndirect");\r
- }\r
-\r
- \r
-\r
-}\r
-\r
-mof::Font::~Font(){\r
- \r
-}\r
-\r
- \r
-\r
-mof::PixelMap* mof::Font::createText(const mof::tstring& text) const{\r
-\r
- // \83f\83o\83C\83X\83R\83\93\83e\83L\83X\83g\8eæ\93¾\r
- // \83f\83o\83C\83X\82É\83t\83H\83\93\83g\82ð\8e\9d\82½\82¹\82È\82¢\82ÆGetGlyphOutline\8aÖ\90\94\82Í\83G\83\89\81[\82Æ\82È\82é\r
- HDC hdc = GetDC(NULL);\r
- HFONT oldFont = static_cast<HFONT>(SelectObject(hdc , m_pImpl->hFont));\r
- TEXTMETRIC TM;\r
- GetTextMetrics( hdc, &TM );\r
-\r
- int sumWidth = 0;\r
- int maxHeight = 0;\r
- typedef std::list<GlyphData*>::iterator GDITR;\r
- std::list<GlyphData*> glyphDataList;\r
- for(int i = 0 ; text.c_str()[i] ; ){\r
-\r
-\r
- // \95¶\8e\9a\83R\81[\83h\8eæ\93¾\r
- UINT code = 0;\r
- #if _UNICODE\r
- // unicode\82Ì\8fê\8d\87\81A\95¶\8e\9a\83R\81[\83h\82Í\92P\8f\83\82É\83\8f\83C\83h\95¶\8e\9a\82ÌUINT\95Ï\8a·\82Å\82·\r
- code = (UINT)str[i++];\r
- #else\r
- // \83}\83\8b\83`\83o\83C\83g\95¶\8e\9a\82Ì\8fê\8d\87\81A\r
- // 1\83o\83C\83g\95¶\8e\9a\82Ì\83R\81[\83h\82Í1\83o\83C\83g\96Ú\82ÌUINT\95Ï\8a·\81A\r
- // 2\83o\83C\83g\95¶\8e\9a\82Ì\83R\81[\83h\82Í[\90æ\93±\83R\81[\83h]*256 + [\95¶\8e\9a\83R\81[\83h]\82Å\82·\r
- if(IsDBCSLeadByte(text[i])){\r
- code = (text[i] << 8) | (text[i+1] & 0xff); // \95¶\8e\9a\r
- code &= 0x0000ffff;\r
- i += 2;\r
- }\r
- else{\r
- code = text[i++];\r
- }\r
- #endif\r
-\r
- unsigned int spaceCode = (_T(" ")[0]);\r
- unsigned int wSpaceCode = (_T("\81@")[0] << 8) | (_T("\81@")[1] & 0xff);\r
- wSpaceCode &= 0x0000ffff;\r
-\r
-\r
- // \83t\83H\83\93\83g\83r\83b\83g\83}\83b\83v\8eæ\93¾\r
- GLYPHMETRICS GM;\r
- CONST MAT2 Mat = {{0,1},{0,0},{0,0},{0,1}};\r
- DWORD size = GetGlyphOutline(hdc, code , GGO_GRAY8_BITMAP, &GM, 0, NULL, &Mat);\r
- GlyphData* pGD = new GlyphData(GM , TM , 65 , size);\r
- GetGlyphOutline(hdc, code, GGO_GRAY8_BITMAP, &GM, size, pGD->pBmpBuffer , &Mat);\r
-\r
- if(code == spaceCode || code == wSpaceCode){\r
- //\8bó\94\92\82Í\89½\8cÌ\82©\82¤\82Ü\82\8f\91\82«\8d\9e\82ß\82È\82¢\82±\82Æ\82Ö\82Ì\91Î\8f\88\r
- pGD->valid = false;\r
- }\r
- glyphDataList.push_back(pGD);\r
- sumWidth += pGD->width;//\91S\91Ì\82Ì\95\9d\r
- maxHeight = max(maxHeight , TM.tmHeight);\r
- }\r
- \r
- // \83f\83o\83C\83X\83R\83\93\83e\83L\83X\83g\82Æ\83t\83H\83\93\83g\83n\83\93\83h\83\8b\82Ì\8aJ\95ú\r
- SelectObject(hdc, oldFont);\r
- ReleaseDC(NULL, hdc);\r
-\r
- typedef mof::PixelMap::size_type size_type;\r
- boost::array<size_type , 2> sizes = {{ sumWidth , maxHeight }};\r
- mof::PixelMap* pPixelMap = new mof::PixelMap(sizes);\r
-\r
- // \83t\83H\83\93\83g\8fî\95ñ\82Ì\8f\91\82«\8d\9e\82Ý\r
- // iOfs_x, iOfs_y : \8f\91\82«\8fo\82µ\88Ê\92u(\8d¶\8fã)\r
- // iBmp_w, iBmp_h : \83t\83H\83\93\83g\83r\83b\83g\83}\83b\83v\82Ì\95\9d\8d\82\r
- // Level : \83¿\92l\82Ì\92i\8aK (GGO_GRAY4_BITMAP\82È\82Ì\82Å17\92i\8aK)\r
-\r
- DWORD Alpha, Color;\r
- int hoseiX = 0;\r
- for(int y = 0 ; y < maxHeight ; y++){\r
- for(int x = 0 ; x < sumWidth ; x++){\r
- (*pPixelMap)[x][y] = 0;\r
- }\r
- }\r
- for(GDITR itr = glyphDataList.begin() ; itr != glyphDataList.end() ; ++itr){\r
- for(int y = (*itr)->iOfs_y ; y < (*itr)->iOfs_y + (*itr)->iBmp_h ; y++){\r
- if(!(*itr)->valid)break;//\8bó\94\92\95¶\8e\9a\82È\82ç\8f\91\82«\8d\9e\82Ý\82ð\96³\8e\8b\82·\82é\r
- for(int x = (*itr)->iOfs_x + hoseiX ; x < (*itr)->iOfs_x + (*itr)->iBmp_w + hoseiX && x < sumWidth ; x++){\r
- Alpha = (255 * (*itr)->pBmpBuffer[x - ((*itr)->iOfs_x + hoseiX) + (*itr)->iBmp_w * ( y - (*itr)->iOfs_y ) ] ) / ((*itr)->level-1);\r
- Color = 0x00ffffff | (Alpha<<24);\r
- \r
- (*pPixelMap)[x][y] = Color;\r
- \r
- }\r
- }\r
- hoseiX += (*itr)->width;\r
- delete *itr;\r
- }\r
-\r
- return pPixelMap;\r
-}\r
-\r
-\r
-bool mof::Font::addFontResource(const mof::tstring& filename ){\r
- g_fontManager.additionalFontResources.push_back(filename);\r
- return AddFontResource( filename.c_str() ) ? true : false ;\r
-}\r
+#include "mof/Font.hpp"
+#include <list>
+#include <windows.h>
+#include "mof/ConsoleIO.hpp"
+#include <vector>
+#include "mof/utilities.hpp"
+
+const TCHAR* mof::Font::MS_GOTHIC = _T("\82l\82r \83S\83V\83b\83N");
+const TCHAR* mof::Font::MS_P_GOTHIC = _T("\82l\82r \82o\83S\83V\83b\83N");
+
+
+namespace
+{
+ struct FontManager
+ {
+ std::vector<mof::tstring> additionalFontResources;
+
+ ~FontManager()
+ {
+ foreach( mof::tstring& filename , additionalFontResources )
+ {
+ RemoveFontResource( filename.c_str() );
+ }
+ }
+ } g_fontManager;
+}
+
+struct GlyphData{
+ int iOfs_x , iOfs_y , iBmp_w , iBmp_h , level , width;
+ BYTE* pBmpBuffer;
+ bool valid;
+
+ GlyphData(GLYPHMETRICS& GM , TEXTMETRIC& TM , int _level , int bufSize){
+ iOfs_x = GM.gmptGlyphOrigin.x;
+ iOfs_y = TM.tmAscent - GM.gmptGlyphOrigin.y;
+ iBmp_w = GM.gmBlackBoxX + (4-(GM.gmBlackBoxX%4))%4;
+ iBmp_h = GM.gmBlackBoxY;
+ level = _level;
+ width = GM.gmCellIncX;
+ pBmpBuffer = new BYTE[bufSize];
+ valid = true;
+ }
+
+ ~GlyphData(){
+ delete[] pBmpBuffer;
+ }
+};
+
+struct mof::Font::Impl{
+ HFONT hFont;
+ size_t fontSize;
+
+ Impl(size_t fontSize_)
+ : hFont(NULL) ,fontSize(fontSize_)
+ {
+ }
+
+ ~Impl(){
+ DeleteObject(hFont);
+ }
+
+};
+
+mof::Font::Font(const TCHAR* fontName , size_t size)
+: m_pImpl(new Impl(size))
+{
+ LOGFONT lf = {m_pImpl->fontSize , 0, 0, 0, 0, 0, 0, 0, SHIFTJIS_CHARSET, OUT_TT_ONLY_PRECIS,
+ CLIP_DEFAULT_PRECIS , PROOF_QUALITY, FIXED_PITCH | FF_MODERN , "" };
+ strcpy_s(lf.lfFaceName , fontName );
+
+ if(!(m_pImpl->hFont = CreateFontIndirect(&lf))){
+ throw std::runtime_error("Failed --- CreateFontIndirect");
+ }
+
+
+
+}
+
+mof::Font::~Font(){
+
+}
+
+
+
+mof::PixelMap* mof::Font::createText(const mof::tstring& text) const{
+
+ // \83f\83o\83C\83X\83R\83\93\83e\83L\83X\83g\8eæ\93¾
+ // \83f\83o\83C\83X\82É\83t\83H\83\93\83g\82ð\8e\9d\82½\82¹\82È\82¢\82ÆGetGlyphOutline\8aÖ\90\94\82Í\83G\83\89\81[\82Æ\82È\82é
+ HDC hdc = GetDC(NULL);
+ HFONT oldFont = static_cast<HFONT>(SelectObject(hdc , m_pImpl->hFont));
+ TEXTMETRIC TM;
+ GetTextMetrics( hdc, &TM );
+
+ int sumWidth = 0;
+ int maxHeight = 0;
+ typedef std::list<GlyphData*>::iterator GDITR;
+ std::list<GlyphData*> glyphDataList;
+ for(int i = 0 ; text.c_str()[i] ; ){
+
+
+ // \95¶\8e\9a\83R\81[\83h\8eæ\93¾
+ UINT code = 0;
+ #if _UNICODE
+ // unicode\82Ì\8fê\8d\87\81A\95¶\8e\9a\83R\81[\83h\82Í\92P\8f\83\82É\83\8f\83C\83h\95¶\8e\9a\82ÌUINT\95Ï\8a·\82Å\82·
+ code = (UINT)str[i++];
+ #else
+ // \83}\83\8b\83`\83o\83C\83g\95¶\8e\9a\82Ì\8fê\8d\87\81A
+ // 1\83o\83C\83g\95¶\8e\9a\82Ì\83R\81[\83h\82Í1\83o\83C\83g\96Ú\82ÌUINT\95Ï\8a·\81A
+ // 2\83o\83C\83g\95¶\8e\9a\82Ì\83R\81[\83h\82Í[\90æ\93±\83R\81[\83h]*256 + [\95¶\8e\9a\83R\81[\83h]\82Å\82·
+ if(IsDBCSLeadByte(text[i])){
+ code = (text[i] << 8) | (text[i+1] & 0xff); // \95¶\8e\9a
+ code &= 0x0000ffff;
+ i += 2;
+ }
+ else{
+ code = text[i++];
+ }
+ #endif
+
+ unsigned int spaceCode = (_T(" ")[0]);
+ unsigned int wSpaceCode = (_T("\81@")[0] << 8) | (_T("\81@")[1] & 0xff);
+ wSpaceCode &= 0x0000ffff;
+
+
+ // \83t\83H\83\93\83g\83r\83b\83g\83}\83b\83v\8eæ\93¾
+ GLYPHMETRICS GM;
+ CONST MAT2 Mat = {{0,1},{0,0},{0,0},{0,1}};
+ DWORD size = GetGlyphOutline(hdc, code , GGO_GRAY8_BITMAP, &GM, 0, NULL, &Mat);
+ GlyphData* pGD = new GlyphData(GM , TM , 65 , size);
+ GetGlyphOutline(hdc, code, GGO_GRAY8_BITMAP, &GM, size, pGD->pBmpBuffer , &Mat);
+
+ if(code == spaceCode || code == wSpaceCode){
+ //\8bó\94\92\82Í\89½\8cÌ\82©\82¤\82Ü\82\8f\91\82«\8d\9e\82ß\82È\82¢\82±\82Æ\82Ö\82Ì\91Î\8f\88
+ pGD->valid = false;
+ }
+ glyphDataList.push_back(pGD);
+ sumWidth += pGD->width;//\91S\91Ì\82Ì\95\9d
+ maxHeight = max(maxHeight , TM.tmHeight);
+ }
+
+ // \83f\83o\83C\83X\83R\83\93\83e\83L\83X\83g\82Æ\83t\83H\83\93\83g\83n\83\93\83h\83\8b\82Ì\8aJ\95ú
+ SelectObject(hdc, oldFont);
+ ReleaseDC(NULL, hdc);
+
+ typedef mof::PixelMap::size_type size_type;
+ boost::array<size_type , 2> sizes = {{ sumWidth , maxHeight }};
+ mof::PixelMap* pPixelMap = new mof::PixelMap(sizes);
+
+ // \83t\83H\83\93\83g\8fî\95ñ\82Ì\8f\91\82«\8d\9e\82Ý
+ // iOfs_x, iOfs_y : \8f\91\82«\8fo\82µ\88Ê\92u(\8d¶\8fã)
+ // iBmp_w, iBmp_h : \83t\83H\83\93\83g\83r\83b\83g\83}\83b\83v\82Ì\95\9d\8d\82
+ // Level : \83¿\92l\82Ì\92i\8aK (GGO_GRAY4_BITMAP\82È\82Ì\82Å17\92i\8aK)
+
+ DWORD Alpha, Color;
+ int hoseiX = 0;
+ for(int y = 0 ; y < maxHeight ; y++){
+ for(int x = 0 ; x < sumWidth ; x++){
+ (*pPixelMap)[x][y] = 0;
+ }
+ }
+ for(GDITR itr = glyphDataList.begin() ; itr != glyphDataList.end() ; ++itr){
+ for(int y = (*itr)->iOfs_y ; y < (*itr)->iOfs_y + (*itr)->iBmp_h ; y++){
+ if(!(*itr)->valid)break;//\8bó\94\92\95¶\8e\9a\82È\82ç\8f\91\82«\8d\9e\82Ý\82ð\96³\8e\8b\82·\82é
+ for(int x = (*itr)->iOfs_x + hoseiX ; x < (*itr)->iOfs_x + (*itr)->iBmp_w + hoseiX && x < sumWidth ; x++){
+ Alpha = (255 * (*itr)->pBmpBuffer[x - ((*itr)->iOfs_x + hoseiX) + (*itr)->iBmp_w * ( y - (*itr)->iOfs_y ) ] ) / ((*itr)->level-1);
+ Color = 0x00ffffff | (Alpha<<24);
+
+ (*pPixelMap)[x][y] = Color;
+
+ }
+ }
+ hoseiX += (*itr)->width;
+ delete *itr;
+ }
+
+ return pPixelMap;
+}
+
+
+bool mof::Font::addFontResource(const mof::tstring& filename ){
+ g_fontManager.additionalFontResources.push_back(filename);
+ return AddFontResource( filename.c_str() ) ? true : false ;
+}
-#ifndef MOF_FONT_HPP\r
-#define MOF_FONT_HPP\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/tstring.hpp"\r
-#include "mof/PixelMap.hpp"\r
-\r
-namespace mof{\r
-\r
-class Font{\r
- struct Impl;\r
- boost::shared_ptr<Impl> m_pImpl;\r
-\r
-public:\r
- Font(const TCHAR* fontName , size_t size);\r
- ~Font();\r
-\r
- mof::PixelMap* createText(const mof::tstring& text) const;\r
-\r
- static const TCHAR* MS_GOTHIC;\r
- static const TCHAR* MS_P_GOTHIC;\r
- \r
- static bool addFontResource(const mof::tstring& filename );\r
-};\r
-\r
-}\r
-\r
-\r
-\r
-#endif\r
+#ifndef MOF_FONT_HPP
+#define MOF_FONT_HPP
+#include <boost/shared_ptr.hpp>
+#include "mof/tstring.hpp"
+#include "mof/PixelMap.hpp"
+
+namespace mof{
+
+class Font{
+ struct Impl;
+ boost::shared_ptr<Impl> m_pImpl;
+
+public:
+ Font(const TCHAR* fontName , size_t size);
+ ~Font();
+
+ mof::PixelMap* createText(const mof::tstring& text) const;
+
+ static const TCHAR* MS_GOTHIC;
+ static const TCHAR* MS_P_GOTHIC;
+
+ static bool addFontResource(const mof::tstring& filename );
+};
+
+}
+
+
+
+#endif
-#ifndef MOF_GRAPHICS3D_HPP\r
-#define MOF_GRAPHICS3D_HPP\r
-#include "mof/Component3D.hpp"\r
-#include "mof/SceneGraph.hpp"\r
-#include "mof/Texture.hpp"\r
-\r
-namespace mof{\r
-\r
-\r
-class Graphics3D : public Component3D , public SceneGraph {\r
-public :\r
- virtual ~Graphics3D(){}\r
- //virtual const mof::GraphicsUnit& getUnit() = 0;\r
- virtual void setTexture( \r
- unsigned int num , const boost::shared_ptr<mof::Texture>& pTexture) = 0;\r
-\r
-};\r
-\r
-}\r
-\r
-#endif\r
+#ifndef MOF_GRAPHICS3D_HPP
+#define MOF_GRAPHICS3D_HPP
+#include "mof/Component3D.hpp"
+#include "mof/SceneGraph.hpp"
+#include "mof/Texture.hpp"
+
+namespace mof{
+
+
+class Graphics3D : public Component3D , public SceneGraph {
+public :
+ virtual ~Graphics3D(){}
+ //virtual const mof::GraphicsUnit& getUnit() = 0;
+ virtual void setTexture(
+ unsigned int num , const boost::shared_ptr<mof::Texture>& pTexture) = 0;
+
+};
+
+}
+
+#endif
-\r
-\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include <list>\r
-#include <stdexcept>\r
-#include "mof/private/VertexFVF.hpp"\r
-#include "mof/Material.hpp"\r
-#include "mof/private/TextureImpl.hpp"\r
-#include "mof/Window.hpp"\r
-\r
-namespace \r
-{\r
- \r
- HWND m_hWnd = NULL;\r
- int m_width;\r
- int m_height;\r
- LPDIRECT3DDEVICE9 m_pDevice = NULL;\r
- LPDIRECT3D9 m_pD3D = NULL;\r
- D3DPRESENT_PARAMETERS* m_pParam = NULL;\r
- IDirect3DStateBlock9* m_pNormalBlendingBlock = NULL;\r
- IDirect3DStateBlock9* m_pAddBlendingBlock = NULL;\r
- IDirect3DStateBlock9* m_pAlphaBlendingBlock = NULL;\r
- int m_currentStateBlock;\r
- mof::Matrix3D m_worldTransform;\r
- mof::Matrix3D m_viewTransform;\r
- mof::Matrix3D m_projectionTransform;\r
- bool m_flagActive;\r
- bool m_flagDeviceLost;\r
-}\r
-\r
-\r
-inline bool isOK(HRESULT hr){\r
- return hr == S_OK;\r
-}\r
-\r
-\r
-namespace mof\r
-{\r
- template void GraphicsDevice::drawVertexArray( const VertexXYZRHWCUV& , const VertexXYZRHWCUV& , PRIMITIVE_TYPE );\r
- template void GraphicsDevice::drawVertexArray( const VertexXYZRHWC& , const VertexXYZRHWC& , PRIMITIVE_TYPE);\r
- template void GraphicsDevice::drawVertexArray( const VertexXYZCUV& , const VertexXYZCUV& , PRIMITIVE_TYPE);\r
- template void GraphicsDevice::drawVertexArray( const VertexXYZNUV& , const VertexXYZNUV& , PRIMITIVE_TYPE);\r
- template void GraphicsDevice::drawVertexArray( const VertexXYZC& , const VertexXYZC& , PRIMITIVE_TYPE);\r
-\r
-\r
-\r
- //TODO \8aÖ\90\94\95ª\8a\84\r
- void GraphicsDevice::initialize( const mof::Window& window , int width , int height , bool fullscreen )\r
- {\r
- \r
- HRESULT hr;\r
- m_hWnd = window.getHandler();\r
- m_width = width;\r
- m_height = height;\r
-\r
- if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )\r
- {\r
- throw std::runtime_error( "Failed --- Direct3DCreate9" );\r
- }\r
-\r
- m_pParam = new D3DPRESENT_PARAMETERS;\r
- ZeroMemory( m_pParam, sizeof(D3DPRESENT_PARAMETERS) );\r
- m_pParam->Windowed = (fullscreen)? FALSE : TRUE; //TRUE=Window,FALSE=FULLSCREEN\r
- m_pParam->BackBufferCount = 1;\r
- m_pParam->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;\r
-\r
- if( fullscreen )\r
- {\r
- //\83t\83\8b\83X\83N\83\8a\81[\83\93\8e\9e\82Í\83o\83b\83N\83o\83b\83t\83@\82Ì\95\9d\81A\8d\82\82³\82ð\8dÄ\8ew\92è\r
- m_pParam->BackBufferWidth = width; //\95\9d\r
- m_pParam->BackBufferHeight = height; //\8d\82\82³\r
- m_pParam->BackBufferFormat = D3DFMT_X8R8G8B8; //16bit\r
- //m_pParam->BackBufferFormat = D3DFMT_R5G6B5; //16bit\r
- m_pParam->FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;\r
- }\r
- else\r
- {\r
- m_pParam->BackBufferFormat = D3DFMT_UNKNOWN; //\8c»\8dÝ\82Ì\89æ\96Ê\83\82\81[\83h\82ð\97\98\97p\r
- }\r
- m_pParam->SwapEffect = D3DSWAPEFFECT_DISCARD;\r
- // Z \83o\83b\83t\83@\82Ì\8e©\93®\8dì\90¬\r
- m_pParam->EnableAutoDepthStencil = 1;\r
- m_pParam->AutoDepthStencilFormat = D3DFMT_D16;\r
- \r
-\r
- \r
-\r
- //HAL(pure vp)\r
- if\r
- ( \r
- FAILED\r
- ( \r
- hr = \r
- m_pD3D->CreateDevice\r
- (\r
- 0 , D3DDEVTYPE_HAL , m_hWnd ,\r
- D3DCREATE_HARDWARE_VERTEXPROCESSING , m_pParam , &m_pDevice\r
- )\r
- )\r
- )\r
- {\r
- //HAL(soft vp)\r
- if\r
- (\r
- FAILED\r
- ( \r
- hr =\r
- m_pD3D->CreateDevice\r
- (\r
- 0 , D3DDEVTYPE_HAL , m_hWnd ,\r
- D3DCREATE_SOFTWARE_VERTEXPROCESSING , m_pParam , &(m_pDevice) \r
- )\r
- )\r
- )\r
- {\r
- //REF\r
- if\r
- ( \r
- FAILED(\r
- hr = \r
- m_pD3D->CreateDevice\r
- (\r
- 0 , D3DDEVTYPE_REF , m_hWnd ,\r
- D3DCREATE_HARDWARE_VERTEXPROCESSING , m_pParam , &m_pDevice\r
- )\r
- )\r
- )\r
- {\r
- delete m_pParam;\r
- m_pD3D->Release();\r
- throw std::runtime_error(std::string("Failed --- CreateDevice"));\r
- }\r
- } // if\r
- } // if\r
- \r
- setViewport( mof::Rectangle<int>(0 , 0 , width , height) );\r
- \r
- //\r
- m_pDevice->SetSamplerState(0 , D3DSAMP_MAGFILTER , D3DTEXF_LINEAR ); //D3DTEXF_POINT \r
- m_pDevice->SetSamplerState(0 , D3DSAMP_MINFILTER , D3DTEXF_LINEAR ); //D3DTEXF_POINT \r
- \r
- \r
- m_pDevice->BeginStateBlock( );\r
- m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE , TRUE );\r
- m_pDevice->SetRenderState( D3DRS_SRCBLEND,D3DBLEND_SRCALPHA );\r
- m_pDevice->SetRenderState( D3DRS_DESTBLEND,D3DBLEND_ONE );\r
- m_pDevice->SetTextureStageState( 0 , D3DTSS_ALPHAOP,D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83¿\92l\82ð\8fæ\8eZ\82µ\82Ä\83¿\92l\82ð\8eæ\93¾\82µ\82Ü\82·\81B\r
- m_pDevice->SetTextureStageState( 0 , D3DTSS_ALPHAARG1,D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83¿\92l\r
- m_pDevice->SetTextureStageState( 0 , D3DTSS_ALPHAARG2,D3DTA_TEXTURE ); //\92¸\93_\82Ì\83¿\r
- m_pDevice->SetTextureStageState( 0 , D3DTSS_COLOROP,D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83J\83\89\81[\82Ì\92l\82ð\8fæ\8eZ\82µ\82Ü\82·\81B\r
- m_pDevice->SetTextureStageState( 0 , D3DTSS_COLORARG1,D3DTA_TEXTURE ); //\83e\83N\83X\83`\83\83\82Ì\83J\83\89\81[\r
- m_pDevice->SetTextureStageState( 0 , D3DTSS_COLORARG2,D3DTA_DIFFUSE ); //\92¸\93_\82Ì\83J\83\89\81[*/\r
- m_pDevice->EndStateBlock( &m_pAddBlendingBlock );\r
-\r
- m_pDevice->BeginStateBlock( );\r
- m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE , TRUE );\r
- m_pDevice->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );\r
- m_pDevice->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );\r
- m_pDevice->SetTextureStageState( 0 ,D3DTSS_ALPHAOP , D3DTOP_SELECTARG2 ); //ARG1\82ÆARG2\82Ì\83¿\92l\82ð\8fæ\8eZ\82µ\82Ä\83¿\92l\82ð\8eæ\93¾\82µ\82Ü\82·\81B\r
- m_pDevice->SetTextureStageState( 0 ,D3DTSS_ALPHAARG1 , D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83¿\92l\r
- m_pDevice->SetTextureStageState( 0 ,D3DTSS_ALPHAARG2 , D3DTA_TEXTURE ); //\92¸\93_\82Ì\83¿\92l\r
- m_pDevice->SetTextureStageState( 0 ,D3DTSS_COLOROP , D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83J\83\89\81[\82Ì\92l\82ð\8fæ\8eZ\82µ\82Ü\82·\81B\r
- m_pDevice->SetTextureStageState( 0 ,D3DTSS_COLORARG1 , D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83J\83\89\81[\r
- m_pDevice->SetTextureStageState( 0 ,D3DTSS_COLORARG2 , D3DTA_TEXTURE ); //\92¸\93_\82Ì\83J\83\89\81[*/\r
- m_pDevice->EndStateBlock( &m_pNormalBlendingBlock );\r
-\r
- m_pDevice->BeginStateBlock( );\r
- m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE , TRUE );\r
- m_pDevice->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );\r
- m_pDevice->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );\r
- m_pDevice->SetTextureStageState( 0,D3DTSS_ALPHAOP , D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83¿\92l\82ð\8fæ\8eZ\82µ\82Ä\83¿\92l\82ð\8eæ\93¾\82µ\82Ü\82·\81B\r
- m_pDevice->SetTextureStageState( 0,D3DTSS_ALPHAARG1 , D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83¿\92l\r
- m_pDevice->SetTextureStageState( 0,D3DTSS_ALPHAARG2 , D3DTA_TEXTURE ); //\92¸\93_\82Ì\83¿\92l\r
- m_pDevice->SetTextureStageState( 0,D3DTSS_COLOROP , D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83J\83\89\81[\82Ì\92l\82ð\8fæ\8eZ\82µ\82Ü\82·\81B\r
- m_pDevice->SetTextureStageState( 0,D3DTSS_COLORARG1 , D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83J\83\89\81[\r
- m_pDevice->SetTextureStageState( 0,D3DTSS_COLORARG2 , D3DTA_TEXTURE ); //\92¸\93_\82Ì\83J\83\89\81[*/\r
- m_pDevice->EndStateBlock( &m_pAlphaBlendingBlock );\r
- \r
- setProjectionTransform(0.1f , 100);\r
- } // function initialize\r
-\r
-\r
-\r
- void GraphicsDevice::finalize( )\r
- {\r
- m_pAddBlendingBlock->Release();\r
- m_pNormalBlendingBlock->Release();\r
- m_pAlphaBlendingBlock->Release();\r
- if(m_pDevice != NULL)m_pDevice->Release();\r
- if(m_pD3D != NULL)m_pD3D->Release();\r
- delete m_pParam;\r
- }\r
-\r
-\r
-\r
-\r
- void GraphicsDevice::beginScene( )\r
- {\r
- \r
-\r
- if(true == m_flagDeviceLost)\r
- { \r
- Sleep(100); // 0.1\95b\91Ò\82Â\r
- if(/*m_flagActive == true &&*/ m_pDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET )\r
- {\r
- //---\83f\83o\83C\83X\95\9c\8bA\82ð\8e\8e\82Ý\82é\r
- \r
- if( FAILED( m_pDevice->Reset( m_pParam) ) )return;\r
- \r
- //\83f\83o\83C\83X\82Ì\95\9c\8bA\82É\90¬\8c÷\r
- m_flagDeviceLost = false;\r
- //---\83X\83e\81[\83g\82ð\95\9c\8bA\r
- DEBUG_PRINT( "DeviceRecovered!" );\r
- }\r
- else return;\r
- }\r
- \r
- \r
-\r
- if( !isOK( m_pDevice->BeginScene( ) ) )\r
- {\r
- throw std::runtime_error("Failed --- BeginScene");\r
- }\r
-\r
-\r
- } // function beginScene\r
- \r
-\r
-\r
-\r
- void GraphicsDevice::endScene( )\r
- {\r
- \r
- if( !isOK( m_pDevice->EndScene() ) )\r
- {\r
- throw std::runtime_error("Failed --- EndScene");\r
- }\r
-\r
- //\83o\83b\83N\83o\83b\83t\83@\82©\82ç\83v\83\89\83C\83}\83\8a\83o\83b\83t\83@\82Ö\93]\91\97\r
- HRESULT hr = m_pDevice->Present( NULL, NULL, NULL, NULL );\r
- \r
- if( hr == D3DERR_DEVICELOST && false == m_flagDeviceLost )\r
- {\r
- DEBUG_PRINT( "DeviceLost!" );\r
- m_flagDeviceLost = true;\r
- //\83\8a\83\\81[\83X\82Ì\89ð\95ú\8f\88\97\9d\r
-\r
- }\r
-\r
- \r
- if( !isOK( hr ) )throw std::runtime_error("Present");\r
- \r
-\r
- } // function endScene\r
-\r
-\r
-\r
-\r
- void GraphicsDevice::setWorldTransform( const mof::Matrix3D& matrix )\r
- {\r
- m_worldTransform = matrix;\r
- D3DXMATRIX mat;\r
- for(int i = 0 ; i < 4 ; ++i ){\r
- for(int j = 0 ; j < 4 ; ++j){\r
- mat(i , j) = matrix.at(i , j);\r
- }\r
- }\r
- m_pDevice->SetTransform( D3DTS_WORLD, &mat );\r
- }\r
-\r
-\r
-\r
- void GraphicsDevice::setProjectionTransform( real min , real max )\r
- {\r
- D3DXMATRIX matProj;\r
- D3DXMatrixPerspectiveFovLH\r
- ( \r
- &matProj, D3DX_PI / 4.0f, \r
- static_cast<float>(getViewportWidth()) / static_cast<float>(getViewportHeight()) , min, max\r
- );\r
-\r
- mof::Matrix3D::Array arry;\r
- for(int i = 0 ; i < 4 ; ++i ){\r
- for(int j = 0 ; j < 4 ; ++j){\r
- arry.elements[i][j] = matProj( i , j );\r
- }\r
- }\r
- m_projectionTransform = mof::Matrix3D( arry );\r
- m_pDevice->SetTransform( D3DTS_PROJECTION , &matProj );\r
-\r
- } \r
-\r
-\r
-\r
- void GraphicsDevice::setViewTransform( const mof::Matrix3D& matrix )\r
- {\r
- m_viewTransform = matrix;\r
- D3DXMATRIX mat;\r
- for(int i = 0 ; i < 4 ; ++i ){\r
- for(int j = 0 ; j < 4 ; ++j){\r
- mat(i , j) = matrix.at(i , j);\r
- }\r
- }\r
- m_pDevice->SetTransform( D3DTS_VIEW , &mat );\r
- }\r
-\r
-\r
-\r
-\r
- const mof::Matrix3D& GraphicsDevice::getWorldTransform( ) \r
- {\r
- return m_worldTransform;\r
- }\r
-\r
-\r
- \r
- const mof::Matrix3D& GraphicsDevice::getProjectionTransform() \r
- {\r
- return m_projectionTransform;\r
- }\r
- \r
-\r
-\r
- const mof::Matrix3D& GraphicsDevice::getViewTransform()\r
- {\r
- return m_viewTransform;\r
- }\r
-\r
- \r
-\r
- void GraphicsDevice::setZBuffer( bool available )\r
- {\r
- if( available )m_pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );\r
- else m_pDevice->SetRenderState( D3DRS_ZENABLE , D3DZB_FALSE ); \r
- }\r
-\r
-\r
-\r
- void GraphicsDevice::lightEnable( bool available )\r
- {\r
- m_pDevice->SetRenderState( D3DRS_LIGHTING , available );\r
- }\r
-\r
-\r
-\r
- void GraphicsDevice::clearZBuffer()\r
- {\r
- m_pDevice->Clear( 0 , NULL , D3DCLEAR_ZBUFFER , 0 , 1.0f, 0 );\r
- }\r
-\r
-\r
-\r
- void GraphicsDevice::clearRenderTarget( mof::Color color )\r
- {\r
- m_pDevice->Clear( 0 , 0 , D3DCLEAR_TARGET , color , 0 , 0 );\r
- }\r
-\r
-\r
-\r
- void GraphicsDevice::setAlphaBlendingMode( const int flag )\r
- {\r
- if(flag == m_currentStateBlock )return;\r
-\r
- if( flag == mof::GraphicsDevice::BLENDING_MODE_ADD ){\r
- m_pAddBlendingBlock->Apply();\r
- }\r
- else if(flag == mof::GraphicsDevice::BLENDING_MODE_BASIC)\r
- {\r
- m_pNormalBlendingBlock->Apply();\r
- }\r
- else if( flag == mof::GraphicsDevice::BLENDING_MODE_ALPHA )\r
- {\r
- m_pAlphaBlendingBlock->Apply();\r
- }\r
-\r
- m_currentStateBlock = flag;\r
- }\r
-\r
-\r
-\r
- Vector2D GraphicsDevice::to2DPosition( const mof::Vector3D& position )\r
- {\r
- mof::Matrix3D matrix = m_worldTransform;\r
- matrix = m_viewTransform * m_projectionTransform;\r
- int hWidth = getViewportWidth() / 2;\r
- int hHeight = getViewportHeight() / 2;\r
- mof::Vector3D tmpPosition = position * matrix;\r
- \r
- return mof::Vector2D\r
- (\r
- static_cast<int>(tmpPosition.x * hWidth + hWidth ) , \r
- static_cast<int>(-tmpPosition.y * hHeight + hHeight)\r
- );\r
- }\r
-\r
-\r
- void GraphicsDevice::setViewport( const mof::Rectangle<int>& area )\r
- {\r
- D3DVIEWPORT9 vp;\r
- vp.X = area.beginX;\r
- vp.Y = area.beginY;\r
- vp.Width = area.getWidth( );\r
- vp.Height = area.getHeight( );\r
- vp.MinZ = 0.0f;\r
- vp.MaxZ = 1.0f;\r
- if( FAILED( m_pDevice->SetViewport( &vp ) ) )\r
- {\r
- throw std::runtime_error( "Failed --- SetViewport" );\r
- }\r
- }\r
-\r
- int GraphicsDevice::getViewportWidth( ) \r
- {\r
- D3DVIEWPORT9 vp;\r
- if( FAILED(m_pDevice->GetViewport( &vp ) ) )\r
- {\r
- throw std::runtime_error("Failed --- getViewportWidth");\r
- }\r
- return vp.Width;\r
- }\r
-\r
-\r
- int GraphicsDevice::getViewportHeight() {\r
- D3DVIEWPORT9 vp;\r
- if( FAILED( m_pDevice->GetViewport( &vp ) ) )\r
- {\r
- throw std::runtime_error("Failed --- getViewportHeight");\r
- }\r
- return vp.Height;\r
- }\r
-\r
-\r
-\r
-\r
- template <class T>\r
- void GraphicsDevice::drawVertexArray( const T& front , const T& last , mof::PRIMITIVE_TYPE type )\r
- {\r
- HRESULT hr = E_FAIL;\r
- if(&last < &front)return;\r
- int length = &last - &front + 1; //\92¸\93_\90\94\r
-\r
- m_pDevice->SetFVF( mof::getFVF<T>() );\r
-\r
- if(type == mof::PRIMITIVE_TYPE_TRIANGLESTRIP)\r
- {\r
- hr = m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP , length > 3 ? length - 2 : 1 , (const void*)&front , sizeof(T) );\r
- }\r
- else if( type == PRIMITIVE_TYPE_TRIANGLELIST )\r
- {\r
- hr = m_pDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST , length / 3 , (const void*)&front , sizeof(T) );\r
- }\r
- else if( type == mof::PRIMITIVE_TYPE_LINELIST )\r
- {\r
- hr = m_pDevice->DrawPrimitiveUP(D3DPT_LINELIST , length / 2 , (const void*)&front , sizeof(T) );\r
- }\r
- \r
- if( FAILED( hr ) )\r
- {\r
- throw std::runtime_error("Failed -- DrawPrimitiveUP");\r
- }\r
-\r
- } // function drawVertexArray\r
-\r
-\r
-\r
- void GraphicsDevice::setMaterial(const mof::Material& material){\r
- D3DMATERIAL9 mat;\r
-\r
- memcpy(static_cast<void*>(&mat) , static_cast<const void*>(&material) , sizeof(D3DMATERIAL9));\r
-\r
- if( FAILED( m_pDevice->SetMaterial( &mat ) ) )\r
- {\r
- throw std::runtime_error("Faild --- SetMaterial");\r
- }\r
- }\r
-\r
-\r
- void GraphicsDevice::setTexture( const mof::Texture* pTexture )\r
- {\r
- if( pTexture == NULL )m_pDevice->SetTexture( 0 , NULL );\r
- else m_pDevice->SetTexture( 0 , pTexture->m_pImpl->pTexture );\r
- }\r
-\r
-\r
- mof::Rectangle<int> GraphicsDevice::getClientRegion() \r
- {\r
- \r
-\r
- RECT rect;\r
- GetWindowRect(m_hWnd , &rect);\r
- POINT point;\r
- point.x = rect.left;\r
- point.y = rect.top;\r
- ScreenToClient(m_hWnd , &point);\r
- int beginX = rect.left - point.x;\r
- int beginY = rect.top - point.y;\r
- return mof::Rectangle<int>(beginX , beginY , beginX + m_width , beginY + m_height);\r
- }\r
- \r
- LPDIRECT3DDEVICE9 GraphicsDevice::getRawDevice( )\r
- {\r
- return m_pDevice;\r
- }\r
- \r
-} // namespace GraphicsDevice\r
+
+
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include "mof/ConsoleIO.hpp"
+#include <list>
+#include <stdexcept>
+#include "mof/private/VertexFVF.hpp"
+#include "mof/Material.hpp"
+#include "mof/private/TextureImpl.hpp"
+#include "mof/Window.hpp"
+
+namespace
+{
+
+ HWND m_hWnd = NULL;
+ int m_width;
+ int m_height;
+ LPDIRECT3DDEVICE9 m_pDevice = NULL;
+ LPDIRECT3D9 m_pD3D = NULL;
+ D3DPRESENT_PARAMETERS* m_pParam = NULL;
+ IDirect3DStateBlock9* m_pNormalBlendingBlock = NULL;
+ IDirect3DStateBlock9* m_pAddBlendingBlock = NULL;
+ IDirect3DStateBlock9* m_pAlphaBlendingBlock = NULL;
+ int m_currentStateBlock;
+ mof::Matrix3D m_worldTransform;
+ mof::Matrix3D m_viewTransform;
+ mof::Matrix3D m_projectionTransform;
+ bool m_flagActive;
+ bool m_flagDeviceLost;
+}
+
+
+inline bool isOK(HRESULT hr){
+ return hr == S_OK;
+}
+
+
+namespace mof
+{
+ template void GraphicsDevice::drawVertexArray( const VertexXYZRHWCUV& , const VertexXYZRHWCUV& , PRIMITIVE_TYPE );
+ template void GraphicsDevice::drawVertexArray( const VertexXYZRHWC& , const VertexXYZRHWC& , PRIMITIVE_TYPE);
+ template void GraphicsDevice::drawVertexArray( const VertexXYZCUV& , const VertexXYZCUV& , PRIMITIVE_TYPE);
+ template void GraphicsDevice::drawVertexArray( const VertexXYZNUV& , const VertexXYZNUV& , PRIMITIVE_TYPE);
+ template void GraphicsDevice::drawVertexArray( const VertexXYZC& , const VertexXYZC& , PRIMITIVE_TYPE);
+
+
+
+ //TODO \8aÖ\90\94\95ª\8a\84
+ void GraphicsDevice::initialize( const mof::Window& window , int width , int height , bool fullscreen )
+ {
+
+ HRESULT hr;
+ m_hWnd = window.getHandler();
+ m_width = width;
+ m_height = height;
+
+ if( NULL == ( m_pD3D = Direct3DCreate9( D3D_SDK_VERSION ) ) )
+ {
+ throw std::runtime_error( "Failed --- Direct3DCreate9" );
+ }
+
+ m_pParam = new D3DPRESENT_PARAMETERS;
+ ZeroMemory( m_pParam, sizeof(D3DPRESENT_PARAMETERS) );
+ m_pParam->Windowed = (fullscreen)? FALSE : TRUE; //TRUE=Window,FALSE=FULLSCREEN
+ m_pParam->BackBufferCount = 1;
+ m_pParam->PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
+
+ if( fullscreen )
+ {
+ //\83t\83\8b\83X\83N\83\8a\81[\83\93\8e\9e\82Í\83o\83b\83N\83o\83b\83t\83@\82Ì\95\9d\81A\8d\82\82³\82ð\8dÄ\8ew\92è
+ m_pParam->BackBufferWidth = width; //\95\9d
+ m_pParam->BackBufferHeight = height; //\8d\82\82³
+ m_pParam->BackBufferFormat = D3DFMT_X8R8G8B8; //16bit
+ //m_pParam->BackBufferFormat = D3DFMT_R5G6B5; //16bit
+ m_pParam->FullScreen_RefreshRateInHz = D3DPRESENT_RATE_DEFAULT;
+ }
+ else
+ {
+ m_pParam->BackBufferFormat = D3DFMT_UNKNOWN; //\8c»\8dÝ\82Ì\89æ\96Ê\83\82\81[\83h\82ð\97\98\97p
+ }
+ m_pParam->SwapEffect = D3DSWAPEFFECT_DISCARD;
+ // Z \83o\83b\83t\83@\82Ì\8e©\93®\8dì\90¬
+ m_pParam->EnableAutoDepthStencil = 1;
+ m_pParam->AutoDepthStencilFormat = D3DFMT_D16;
+
+
+
+
+ //HAL(pure vp)
+ if
+ (
+ FAILED
+ (
+ hr =
+ m_pD3D->CreateDevice
+ (
+ 0 , D3DDEVTYPE_HAL , m_hWnd ,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING , m_pParam , &m_pDevice
+ )
+ )
+ )
+ {
+ //HAL(soft vp)
+ if
+ (
+ FAILED
+ (
+ hr =
+ m_pD3D->CreateDevice
+ (
+ 0 , D3DDEVTYPE_HAL , m_hWnd ,
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING , m_pParam , &(m_pDevice)
+ )
+ )
+ )
+ {
+ //REF
+ if
+ (
+ FAILED(
+ hr =
+ m_pD3D->CreateDevice
+ (
+ 0 , D3DDEVTYPE_REF , m_hWnd ,
+ D3DCREATE_HARDWARE_VERTEXPROCESSING , m_pParam , &m_pDevice
+ )
+ )
+ )
+ {
+ delete m_pParam;
+ m_pD3D->Release();
+ throw std::runtime_error(std::string("Failed --- CreateDevice"));
+ }
+ } // if
+ } // if
+
+ setViewport( mof::Rectangle<int>(0 , 0 , width , height) );
+
+ //
+ m_pDevice->SetSamplerState(0 , D3DSAMP_MAGFILTER , D3DTEXF_LINEAR ); //D3DTEXF_POINT
+ m_pDevice->SetSamplerState(0 , D3DSAMP_MINFILTER , D3DTEXF_LINEAR ); //D3DTEXF_POINT
+
+
+ m_pDevice->BeginStateBlock( );
+ m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE , TRUE );
+ m_pDevice->SetRenderState( D3DRS_SRCBLEND,D3DBLEND_SRCALPHA );
+ m_pDevice->SetRenderState( D3DRS_DESTBLEND,D3DBLEND_ONE );
+ m_pDevice->SetTextureStageState( 0 , D3DTSS_ALPHAOP,D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83¿\92l\82ð\8fæ\8eZ\82µ\82Ä\83¿\92l\82ð\8eæ\93¾\82µ\82Ü\82·\81B
+ m_pDevice->SetTextureStageState( 0 , D3DTSS_ALPHAARG1,D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83¿\92l
+ m_pDevice->SetTextureStageState( 0 , D3DTSS_ALPHAARG2,D3DTA_TEXTURE ); //\92¸\93_\82Ì\83¿
+ m_pDevice->SetTextureStageState( 0 , D3DTSS_COLOROP,D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83J\83\89\81[\82Ì\92l\82ð\8fæ\8eZ\82µ\82Ü\82·\81B
+ m_pDevice->SetTextureStageState( 0 , D3DTSS_COLORARG1,D3DTA_TEXTURE ); //\83e\83N\83X\83`\83\83\82Ì\83J\83\89\81[
+ m_pDevice->SetTextureStageState( 0 , D3DTSS_COLORARG2,D3DTA_DIFFUSE ); //\92¸\93_\82Ì\83J\83\89\81[*/
+ m_pDevice->EndStateBlock( &m_pAddBlendingBlock );
+
+ m_pDevice->BeginStateBlock( );
+ m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE , TRUE );
+ m_pDevice->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );
+ m_pDevice->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );
+ m_pDevice->SetTextureStageState( 0 ,D3DTSS_ALPHAOP , D3DTOP_SELECTARG2 ); //ARG1\82ÆARG2\82Ì\83¿\92l\82ð\8fæ\8eZ\82µ\82Ä\83¿\92l\82ð\8eæ\93¾\82µ\82Ü\82·\81B
+ m_pDevice->SetTextureStageState( 0 ,D3DTSS_ALPHAARG1 , D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83¿\92l
+ m_pDevice->SetTextureStageState( 0 ,D3DTSS_ALPHAARG2 , D3DTA_TEXTURE ); //\92¸\93_\82Ì\83¿\92l
+ m_pDevice->SetTextureStageState( 0 ,D3DTSS_COLOROP , D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83J\83\89\81[\82Ì\92l\82ð\8fæ\8eZ\82µ\82Ü\82·\81B
+ m_pDevice->SetTextureStageState( 0 ,D3DTSS_COLORARG1 , D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83J\83\89\81[
+ m_pDevice->SetTextureStageState( 0 ,D3DTSS_COLORARG2 , D3DTA_TEXTURE ); //\92¸\93_\82Ì\83J\83\89\81[*/
+ m_pDevice->EndStateBlock( &m_pNormalBlendingBlock );
+
+ m_pDevice->BeginStateBlock( );
+ m_pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE , TRUE );
+ m_pDevice->SetRenderState( D3DRS_SRCBLEND , D3DBLEND_SRCALPHA );
+ m_pDevice->SetRenderState( D3DRS_DESTBLEND , D3DBLEND_INVSRCALPHA );
+ m_pDevice->SetTextureStageState( 0,D3DTSS_ALPHAOP , D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83¿\92l\82ð\8fæ\8eZ\82µ\82Ä\83¿\92l\82ð\8eæ\93¾\82µ\82Ü\82·\81B
+ m_pDevice->SetTextureStageState( 0,D3DTSS_ALPHAARG1 , D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83¿\92l
+ m_pDevice->SetTextureStageState( 0,D3DTSS_ALPHAARG2 , D3DTA_TEXTURE ); //\92¸\93_\82Ì\83¿\92l
+ m_pDevice->SetTextureStageState( 0,D3DTSS_COLOROP , D3DTOP_MODULATE ); //ARG1\82ÆARG2\82Ì\83J\83\89\81[\82Ì\92l\82ð\8fæ\8eZ\82µ\82Ü\82·\81B
+ m_pDevice->SetTextureStageState( 0,D3DTSS_COLORARG1 , D3DTA_DIFFUSE ); //\83e\83N\83X\83`\83\83\82Ì\83J\83\89\81[
+ m_pDevice->SetTextureStageState( 0,D3DTSS_COLORARG2 , D3DTA_TEXTURE ); //\92¸\93_\82Ì\83J\83\89\81[*/
+ m_pDevice->EndStateBlock( &m_pAlphaBlendingBlock );
+
+ setProjectionTransform(0.1f , 100);
+ } // function initialize
+
+
+
+ void GraphicsDevice::finalize( )
+ {
+ m_pAddBlendingBlock->Release();
+ m_pNormalBlendingBlock->Release();
+ m_pAlphaBlendingBlock->Release();
+ if(m_pDevice != NULL)m_pDevice->Release();
+ if(m_pD3D != NULL)m_pD3D->Release();
+ delete m_pParam;
+ }
+
+
+
+
+ void GraphicsDevice::beginScene( )
+ {
+
+
+ if(true == m_flagDeviceLost)
+ {
+ Sleep(100); // 0.1\95b\91Ò\82Â
+ if(/*m_flagActive == true &&*/ m_pDevice->TestCooperativeLevel() == D3DERR_DEVICENOTRESET )
+ {
+ //---\83f\83o\83C\83X\95\9c\8bA\82ð\8e\8e\82Ý\82é
+
+ if( FAILED( m_pDevice->Reset( m_pParam) ) )return;
+
+ //\83f\83o\83C\83X\82Ì\95\9c\8bA\82É\90¬\8c÷
+ m_flagDeviceLost = false;
+ //---\83X\83e\81[\83g\82ð\95\9c\8bA
+ DEBUG_PRINT( "DeviceRecovered!" );
+ }
+ else return;
+ }
+
+
+
+ if( !isOK( m_pDevice->BeginScene( ) ) )
+ {
+ throw std::runtime_error("Failed --- BeginScene");
+ }
+
+
+ } // function beginScene
+
+
+
+
+ void GraphicsDevice::endScene( )
+ {
+
+ if( !isOK( m_pDevice->EndScene() ) )
+ {
+ throw std::runtime_error("Failed --- EndScene");
+ }
+
+ //\83o\83b\83N\83o\83b\83t\83@\82©\82ç\83v\83\89\83C\83}\83\8a\83o\83b\83t\83@\82Ö\93]\91\97
+ HRESULT hr = m_pDevice->Present( NULL, NULL, NULL, NULL );
+
+ if( hr == D3DERR_DEVICELOST && false == m_flagDeviceLost )
+ {
+ DEBUG_PRINT( "DeviceLost!" );
+ m_flagDeviceLost = true;
+ //\83\8a\83\\81[\83X\82Ì\89ð\95ú\8f\88\97\9d
+
+ }
+
+
+ if( !isOK( hr ) )throw std::runtime_error("Present");
+
+
+ } // function endScene
+
+
+
+
+ void GraphicsDevice::setWorldTransform( const mof::Matrix3D& matrix )
+ {
+ m_worldTransform = matrix;
+ D3DXMATRIX mat;
+ for(int i = 0 ; i < 4 ; ++i ){
+ for(int j = 0 ; j < 4 ; ++j){
+ mat(i , j) = matrix.at(i , j);
+ }
+ }
+ m_pDevice->SetTransform( D3DTS_WORLD, &mat );
+ }
+
+
+
+ void GraphicsDevice::setProjectionTransform( real min , real max )
+ {
+ D3DXMATRIX matProj;
+ D3DXMatrixPerspectiveFovLH
+ (
+ &matProj, D3DX_PI / 4.0f,
+ static_cast<float>(getViewportWidth()) / static_cast<float>(getViewportHeight()) , min, max
+ );
+
+ mof::Matrix3D::Array arry;
+ for(int i = 0 ; i < 4 ; ++i ){
+ for(int j = 0 ; j < 4 ; ++j){
+ arry.elements[i][j] = matProj( i , j );
+ }
+ }
+ m_projectionTransform = mof::Matrix3D( arry );
+ m_pDevice->SetTransform( D3DTS_PROJECTION , &matProj );
+
+ }
+
+
+
+ void GraphicsDevice::setViewTransform( const mof::Matrix3D& matrix )
+ {
+ m_viewTransform = matrix;
+ D3DXMATRIX mat;
+ for(int i = 0 ; i < 4 ; ++i ){
+ for(int j = 0 ; j < 4 ; ++j){
+ mat(i , j) = matrix.at(i , j);
+ }
+ }
+ m_pDevice->SetTransform( D3DTS_VIEW , &mat );
+ }
+
+
+
+
+ const mof::Matrix3D& GraphicsDevice::getWorldTransform( )
+ {
+ return m_worldTransform;
+ }
+
+
+
+ const mof::Matrix3D& GraphicsDevice::getProjectionTransform()
+ {
+ return m_projectionTransform;
+ }
+
+
+
+ const mof::Matrix3D& GraphicsDevice::getViewTransform()
+ {
+ return m_viewTransform;
+ }
+
+
+
+ void GraphicsDevice::setZBuffer( bool available )
+ {
+ if( available )m_pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_TRUE );
+ else m_pDevice->SetRenderState( D3DRS_ZENABLE , D3DZB_FALSE );
+ }
+
+
+
+ void GraphicsDevice::lightEnable( bool available )
+ {
+ m_pDevice->SetRenderState( D3DRS_LIGHTING , available );
+ }
+
+
+
+ void GraphicsDevice::clearZBuffer()
+ {
+ m_pDevice->Clear( 0 , NULL , D3DCLEAR_ZBUFFER , 0 , 1.0f, 0 );
+ }
+
+
+
+ void GraphicsDevice::clearRenderTarget( mof::Color color )
+ {
+ m_pDevice->Clear( 0 , 0 , D3DCLEAR_TARGET , color , 0 , 0 );
+ }
+
+
+
+ void GraphicsDevice::setAlphaBlendingMode( const int flag )
+ {
+ if(flag == m_currentStateBlock )return;
+
+ if( flag == mof::GraphicsDevice::BLENDING_MODE_ADD ){
+ m_pAddBlendingBlock->Apply();
+ }
+ else if(flag == mof::GraphicsDevice::BLENDING_MODE_BASIC)
+ {
+ m_pNormalBlendingBlock->Apply();
+ }
+ else if( flag == mof::GraphicsDevice::BLENDING_MODE_ALPHA )
+ {
+ m_pAlphaBlendingBlock->Apply();
+ }
+
+ m_currentStateBlock = flag;
+ }
+
+
+
+ Vector2D GraphicsDevice::to2DPosition( const mof::Vector3D& position )
+ {
+ mof::Matrix3D matrix = m_worldTransform;
+ matrix = m_viewTransform * m_projectionTransform;
+ int hWidth = getViewportWidth() / 2;
+ int hHeight = getViewportHeight() / 2;
+ mof::Vector3D tmpPosition = position * matrix;
+
+ return mof::Vector2D
+ (
+ static_cast<int>(tmpPosition.x * hWidth + hWidth ) ,
+ static_cast<int>(-tmpPosition.y * hHeight + hHeight)
+ );
+ }
+
+
+ void GraphicsDevice::setViewport( const mof::Rectangle<int>& area )
+ {
+ D3DVIEWPORT9 vp;
+ vp.X = area.beginX;
+ vp.Y = area.beginY;
+ vp.Width = area.getWidth( );
+ vp.Height = area.getHeight( );
+ vp.MinZ = 0.0f;
+ vp.MaxZ = 1.0f;
+ if( FAILED( m_pDevice->SetViewport( &vp ) ) )
+ {
+ throw std::runtime_error( "Failed --- SetViewport" );
+ }
+ }
+
+ int GraphicsDevice::getViewportWidth( )
+ {
+ D3DVIEWPORT9 vp;
+ if( FAILED(m_pDevice->GetViewport( &vp ) ) )
+ {
+ throw std::runtime_error("Failed --- getViewportWidth");
+ }
+ return vp.Width;
+ }
+
+
+ int GraphicsDevice::getViewportHeight() {
+ D3DVIEWPORT9 vp;
+ if( FAILED( m_pDevice->GetViewport( &vp ) ) )
+ {
+ throw std::runtime_error("Failed --- getViewportHeight");
+ }
+ return vp.Height;
+ }
+
+
+
+
+ template <class T>
+ void GraphicsDevice::drawVertexArray( const T& front , const T& last , mof::PRIMITIVE_TYPE type )
+ {
+ HRESULT hr = E_FAIL;
+ if(&last < &front)return;
+ int length = &last - &front + 1; //\92¸\93_\90\94
+
+ m_pDevice->SetFVF( mof::getFVF<T>() );
+
+ if(type == mof::PRIMITIVE_TYPE_TRIANGLESTRIP)
+ {
+ hr = m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLESTRIP , length > 3 ? length - 2 : 1 , (const void*)&front , sizeof(T) );
+ }
+ else if( type == PRIMITIVE_TYPE_TRIANGLELIST )
+ {
+ hr = m_pDevice->DrawPrimitiveUP( D3DPT_TRIANGLELIST , length / 3 , (const void*)&front , sizeof(T) );
+ }
+ else if( type == mof::PRIMITIVE_TYPE_LINELIST )
+ {
+ hr = m_pDevice->DrawPrimitiveUP(D3DPT_LINELIST , length / 2 , (const void*)&front , sizeof(T) );
+ }
+
+ if( FAILED( hr ) )
+ {
+ throw std::runtime_error("Failed -- DrawPrimitiveUP");
+ }
+
+ } // function drawVertexArray
+
+
+
+ void GraphicsDevice::setMaterial(const mof::Material& material){
+ D3DMATERIAL9 mat;
+
+ memcpy(static_cast<void*>(&mat) , static_cast<const void*>(&material) , sizeof(D3DMATERIAL9));
+
+ if( FAILED( m_pDevice->SetMaterial( &mat ) ) )
+ {
+ throw std::runtime_error("Faild --- SetMaterial");
+ }
+ }
+
+
+ void GraphicsDevice::setTexture( const mof::Texture* pTexture )
+ {
+ if( pTexture == NULL )m_pDevice->SetTexture( 0 , NULL );
+ else m_pDevice->SetTexture( 0 , pTexture->m_pImpl->pTexture );
+ }
+
+
+ mof::Rectangle<int> GraphicsDevice::getClientRegion()
+ {
+
+
+ RECT rect;
+ GetWindowRect(m_hWnd , &rect);
+ POINT point;
+ point.x = rect.left;
+ point.y = rect.top;
+ ScreenToClient(m_hWnd , &point);
+ int beginX = rect.left - point.x;
+ int beginY = rect.top - point.y;
+ return mof::Rectangle<int>(beginX , beginY , beginX + m_width , beginY + m_height);
+ }
+
+ LPDIRECT3DDEVICE9 GraphicsDevice::getRawDevice( )
+ {
+ return m_pDevice;
+ }
+
+} // namespace GraphicsDevice
-#pragma once\r
-#include "mof/real.hpp"\r
-#include "mof/Color.hpp"\r
-#include "mof/Matrix3D.hpp"\r
-#include "mof/VertexTypes.hpp"\r
-#include <boost/utility.hpp>\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/Rectangle.hpp"\r
-\r
-\r
-\r
-namespace mof{\r
- struct Material;\r
- class Texture;\r
-\r
- namespace GraphicsDevice \r
- {\r
-\r
- // public \r
- \r
- enum BlendingMode\r
- {\r
- BLENDING_MODE_ADD ,\r
- BLENDING_MODE_BASIC ,\r
- BLENDING_MODE_ALPHA\r
- };\r
- \r
- void setWorldTransform( const mof::Matrix3D& matrix );\r
- void setProjectionTransform( real min , real max );\r
- void setViewTransform( const mof::Matrix3D& matrix );\r
- const mof::Matrix3D& getWorldTransform( );\r
- const mof::Matrix3D& getProjectionTransform( );\r
- const mof::Matrix3D& getViewTransform( );\r
- void setZBuffer( bool flag );\r
- void lightEnable( bool enable );\r
- void clearZBuffer( );\r
- void clearRenderTarget( mof::Color color );\r
- void setAlphaBlendingMode( const int flag );\r
- mof::Vector2D to2DPosition( const mof::Vector3D& position );\r
- void setViewport( const mof::Rectangle<int>& area );\r
- int getViewportWidth( );\r
- int getViewportHeight( );\r
-\r
- template <class T> void drawVertexArray\r
- (\r
- const T& front , const T& last , \r
- mof::PRIMITIVE_TYPE type = PRIMITIVE_TYPE_TRIANGLELIST \r
- ); \r
- void setMaterial( const mof::Material& material );\r
- void setTexture( const mof::Texture* pTexture );\r
- mof::Rectangle<int> getClientRegion( );\r
- \r
- } // namespace GraphicsDevice\r
-\r
-\r
-} // namespace mof\r
+#pragma once
+#include "mof/real.hpp"
+#include "mof/Color.hpp"
+#include "mof/Matrix3D.hpp"
+#include "mof/VertexTypes.hpp"
+#include <boost/utility.hpp>
+#include <boost/scoped_ptr.hpp>
+#include "mof/Rectangle.hpp"
+
+
+
+namespace mof{
+ struct Material;
+ class Texture;
+
+ namespace GraphicsDevice
+ {
+
+ // public
+
+ enum BlendingMode
+ {
+ BLENDING_MODE_ADD ,
+ BLENDING_MODE_BASIC ,
+ BLENDING_MODE_ALPHA
+ };
+
+ void setWorldTransform( const mof::Matrix3D& matrix );
+ void setProjectionTransform( real min , real max );
+ void setViewTransform( const mof::Matrix3D& matrix );
+ const mof::Matrix3D& getWorldTransform( );
+ const mof::Matrix3D& getProjectionTransform( );
+ const mof::Matrix3D& getViewTransform( );
+ void setZBuffer( bool flag );
+ void lightEnable( bool enable );
+ void clearZBuffer( );
+ void clearRenderTarget( mof::Color color );
+ void setAlphaBlendingMode( const int flag );
+ mof::Vector2D to2DPosition( const mof::Vector3D& position );
+ void setViewport( const mof::Rectangle<int>& area );
+ int getViewportWidth( );
+ int getViewportHeight( );
+
+ template <class T> void drawVertexArray
+ (
+ const T& front , const T& last ,
+ mof::PRIMITIVE_TYPE type = PRIMITIVE_TYPE_TRIANGLELIST
+ );
+ void setMaterial( const mof::Material& material );
+ void setTexture( const mof::Texture* pTexture );
+ mof::Rectangle<int> getClientRegion( );
+
+ } // namespace GraphicsDevice
+
+
+} // namespace mof
-\r
-#include "mof/GraphicsObject.h"\r
-#include <iostream>\r
-\r
-mof::GraphicsObject::GraphicsObject(void)\r
-: m_pAnimations( new mof::CascadeAnimation())\r
-{\r
- \r
-}\r
-\r
-mof::GraphicsObject::~GraphicsObject(void)\r
-{\r
-\r
-}\r
-\r
+
+#include "mof/GraphicsObject.h"
+#include <iostream>
+
+mof::GraphicsObject::GraphicsObject(void)
+: m_pAnimations( new mof::CascadeAnimation())
+{
+
+}
+
+mof::GraphicsObject::~GraphicsObject(void)
+{
+
+}
+
-#include "mof/GraphicsSchedule.h"\r
-#include "mof/ConsoleIO.h"\r
-\r
-\r
-\r
-\r
-\r
-mof::GraphicsSchedule::GraphicsSchedule(){\r
- m_key = 0;\r
-\r
-}\r
-\r
-mof::GraphicsSchedule::~GraphicsSchedule(){\r
- \r
-}\r
-\r
-void mof::GraphicsSchedule::update(){\r
- \r
- std::pair<MapItr , MapItr> range = m_map.equal_range(m_key);\r
- for(MapItr itr = range.first ; itr != range.second ; ++itr){\r
- if((*itr).second.pAnimation.get() != NULL){\r
- (*itr).second.pObject->setAnimation(0 , (*itr).second.pAnimation);\r
- (*itr).second.pAnimation->start();\r
- }\r
- }\r
- \r
- m_key++;\r
-}\r
-\r
-void mof::GraphicsSchedule::add(int index , mof::GraphicsModelPtr& pObject , mof::AnimationResource& pAnimation){\r
- if(pObject.get() == NULL)return;\r
- if(pAnimation.get() != NULL)pAnimation->stop();\r
- mof::GraphicsSchedule::Element element = {pObject , pAnimation };\r
- m_modelList.push_back(pObject);\r
- m_map.insert(std::multimap<mof::AnimationKey , mof::GraphicsSchedule::Element>::value_type(index , element));\r
-}\r
- \r
-std::list<mof::GraphicsModelPtr>& mof::GraphicsSchedule::appendModelList( std::list<mof::GraphicsModelPtr>& modelList){\r
- modelList.insert(modelList.end() , m_modelList.begin() , m_modelList.end());\r
- return modelList;\r
-}\r
- \r
-\r
-\r
- \r
-bool mof::GraphicsSchedule::isFinalized(){\r
- if(m_map.size() == 0)return true;\r
- for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){\r
- if(!itr->second.pAnimation->isFinalized() )return false;\r
- }\r
- return true;\r
-}\r
-\r
- \r
-bool mof::GraphicsSchedule::isPlaying(){\r
- for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){\r
- if(itr->second.pAnimation->isPlaying() || itr->second.pAnimation->isFinalized())return true;\r
- }\r
- return false;\r
-}\r
-\r
-\r
-void mof::GraphicsSchedule::clear(){\r
- m_key = 0;\r
- m_map.clear();\r
+#include "mof/GraphicsSchedule.h"
+#include "mof/ConsoleIO.h"
+
+
+
+
+
+mof::GraphicsSchedule::GraphicsSchedule(){
+ m_key = 0;
+
+}
+
+mof::GraphicsSchedule::~GraphicsSchedule(){
+
+}
+
+void mof::GraphicsSchedule::update(){
+
+ std::pair<MapItr , MapItr> range = m_map.equal_range(m_key);
+ for(MapItr itr = range.first ; itr != range.second ; ++itr){
+ if((*itr).second.pAnimation.get() != NULL){
+ (*itr).second.pObject->setAnimation(0 , (*itr).second.pAnimation);
+ (*itr).second.pAnimation->start();
+ }
+ }
+
+ m_key++;
+}
+
+void mof::GraphicsSchedule::add(int index , mof::GraphicsModelPtr& pObject , mof::AnimationResource& pAnimation){
+ if(pObject.get() == NULL)return;
+ if(pAnimation.get() != NULL)pAnimation->stop();
+ mof::GraphicsSchedule::Element element = {pObject , pAnimation };
+ m_modelList.push_back(pObject);
+ m_map.insert(std::multimap<mof::AnimationKey , mof::GraphicsSchedule::Element>::value_type(index , element));
+}
+
+std::list<mof::GraphicsModelPtr>& mof::GraphicsSchedule::appendModelList( std::list<mof::GraphicsModelPtr>& modelList){
+ modelList.insert(modelList.end() , m_modelList.begin() , m_modelList.end());
+ return modelList;
+}
+
+
+
+
+bool mof::GraphicsSchedule::isFinalized(){
+ if(m_map.size() == 0)return true;
+ for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){
+ if(!itr->second.pAnimation->isFinalized() )return false;
+ }
+ return true;
+}
+
+
+bool mof::GraphicsSchedule::isPlaying(){
+ for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){
+ if(itr->second.pAnimation->isPlaying() || itr->second.pAnimation->isFinalized())return true;
+ }
+ return false;
+}
+
+
+void mof::GraphicsSchedule::clear(){
+ m_key = 0;
+ m_map.clear();
}
\ No newline at end of file
-#pragma once\r
-#include "mof/GraphicsObject.h"\r
-#include <map>\r
-#include <list>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof{\r
-\r
- typedef boost::shared_ptr<mof::GraphicsObject> GraphicsModelPtr;\r
-\r
- class GraphicsSchedule{\r
- \r
- struct Element{\r
- mof::GraphicsModelPtr pObject;\r
- mof::AnimationResource pAnimation;\r
- };\r
- typedef std::multimap<int , mof::GraphicsSchedule::Element>::iterator MapItr;\r
-\r
- std::multimap<int , Element> m_map;\r
- std::list<mof::GraphicsModelPtr> m_modelList;\r
- int m_key;\r
- public:\r
- GraphicsSchedule();\r
- ~GraphicsSchedule();\r
-\r
- void update();\r
- void add(int index , mof::GraphicsModelPtr& pObject , mof::AnimationResource& pAnimation);\r
- bool isFinalized();\r
- bool isPlaying();\r
- void clear();\r
- bool isEmpty(){return m_map.empty();}\r
-\r
- std::list<mof::GraphicsModelPtr>& appendModelList( std::list<mof::GraphicsModelPtr>& modelList);\r
-\r
- };\r
-\r
+#pragma once
+#include "mof/GraphicsObject.h"
+#include <map>
+#include <list>
+#include <boost/shared_ptr.hpp>
+
+namespace mof{
+
+ typedef boost::shared_ptr<mof::GraphicsObject> GraphicsModelPtr;
+
+ class GraphicsSchedule{
+
+ struct Element{
+ mof::GraphicsModelPtr pObject;
+ mof::AnimationResource pAnimation;
+ };
+ typedef std::multimap<int , mof::GraphicsSchedule::Element>::iterator MapItr;
+
+ std::multimap<int , Element> m_map;
+ std::list<mof::GraphicsModelPtr> m_modelList;
+ int m_key;
+ public:
+ GraphicsSchedule();
+ ~GraphicsSchedule();
+
+ void update();
+ void add(int index , mof::GraphicsModelPtr& pObject , mof::AnimationResource& pAnimation);
+ bool isFinalized();
+ bool isPlaying();
+ void clear();
+ bool isEmpty(){return m_map.empty();}
+
+ std::list<mof::GraphicsModelPtr>& appendModelList( std::list<mof::GraphicsModelPtr>& modelList);
+
+ };
+
};
\ No newline at end of file
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/Material.hpp"\r
-#include "mof/Texture.hpp"\r
-#include "mof/VertexBuffer.hpp"\r
-#include "mof/VertexTypes.hpp"\r
-\r
-namespace mof{\r
-\r
- struct GraphicsUnit\r
- {\r
- boost::shared_ptr<mof::Material> pMaterial;\r
- boost::shared_ptr<mof::Texture> pTexture;\r
- boost::shared_ptr<mof::VertexBuffer<mof::VertexXYZNUV> > pModel;\r
- };\r
-\r
-}\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+#include "mof/Material.hpp"
+#include "mof/Texture.hpp"
+#include "mof/VertexBuffer.hpp"
+#include "mof/VertexTypes.hpp"
+
+namespace mof{
+
+ struct GraphicsUnit
+ {
+ boost::shared_ptr<mof::Material> pMaterial;
+ boost::shared_ptr<mof::Texture> pTexture;
+ boost::shared_ptr<mof::VertexBuffer<mof::VertexXYZNUV> > pModel;
+ };
+
+}
-#include "mof/private/DirectInput.hpp"\r
-#include <vector>\r
-#include "mof/InputReceiver.hpp"\r
-#include "mof/InputDevice.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/private/DeviceInputReceiver.hpp"\r
-#include "boost/shared_ptr.hpp"\r
-\r
-namespace {\r
- LPDIRECTINPUT8 pInput;\r
- LPDIRECTINPUTDEVICE8A pDevice;\r
- boost::shared_ptr<mof::InputReceiver> pInputReceiver;//\8aO\95\94\82É\93n\82·\82½\82ß\r
- mof::DeviceInputReceiver* pDeviceInputReceiver;//\8fã\8bL\82Æ\93¯\82¶\83C\83\93\83X\83^\83\93\83X\r
-}\r
-\r
-//--- \83v\83\8d\83g\83^\83C\83v\90é\8c¾\r
-BOOL CALLBACK enumJoyCallback(const DIDEVICEINSTANCE* pInstance , VOID* pContext);\r
-\r
-/**\r
- * mof::InputDevice::initialize\r
- *\r
- */\r
-void mof::InputDevice::initialize( ){\r
- HINSTANCE hInst = GetModuleHandle(NULL);\r
- HRESULT hr;\r
- hr = DirectInput8Create(hInst , DIRECTINPUT_VERSION ,IID_IDirectInput8 , (void**)&pInput , NULL);\r
- if(FAILED(hr)){\r
- switch(hr){\r
- case DIERR_BETADIRECTINPUTVERSION :\r
- DEBUG_PRINT("DIERR_BETADIRECTINPUTVERSION");\r
- break;\r
- case DIERR_INVALIDPARAM :\r
- DEBUG_PRINT("DIERR_INVALIDPARAM");\r
- break;\r
- case DIERR_OLDDIRECTINPUTVERSION : \r
- DEBUG_PRINT("DIERR_OLDDIRECTINPUTVERSION");\r
- break;\r
- case DIERR_OUTOFMEMORY :\r
- DEBUG_PRINT("DIERR_OUTOFMEMORY");\r
- break;\r
- }\r
- throw std::runtime_error("Failed --- create direct input");\r
- }\r
- \r
- LPCDIDATAFORMAT dataFmt = &c_dfDIJoystick;//\83W\83\87\83C\83X\83e\83B\83b\83N\82ª\8eæ\93¾\82Å\82«\82½\82Æ\89¼\92è\r
- //---\83f\83o\83C\83X\82Ì\90Ý\92è\r
- //\83Q\81[\83\80\83p\83b\83h\83f\83o\83C\83X\82ð\92T\82·\r
- hr = pInput->EnumDevices(DI8DEVCLASS_GAMECTRL , enumJoyCallback , NULL , DIEDFL_ATTACHEDONLY);\r
- if(FAILED(hr) || pDevice == NULL){\r
- //\83Q\81[\83\80\83p\83b\83h\82ª\82È\82¯\82ê\82Î\83L\81[\83{\81[\83h\r
- hr = pInput->CreateDevice(GUID_SysKeyboard , &pDevice , NULL);\r
- if(FAILED(hr)){\r
- pInput->Release();\r
- pInput = NULL;\r
- throw std::runtime_error("Failed --- create device");\r
- }\r
- dataFmt = &c_dfDIKeyboard;//\83L\81[\83{\81[\83h\82ð\83f\83o\83C\83X\82Æ\82µ\82Ä\8eæ\93¾\r
- DEBUG_PRINT("Select --- keyboard as input device");\r
- }\r
- else DEBUG_PRINT("Select --- joystick as input device");\r
- \r
- hr = pDevice->SetDataFormat(dataFmt);\r
- if(FAILED(hr)){\r
- pDevice->Release();\r
- pDevice = NULL;\r
- pInput->Release();\r
- pInput = NULL;\r
- throw std::runtime_error("Failed --- set data format");\r
- }\r
-\r
-\r
- DIPROPDWORD diprop;\r
- diprop.diph.dwSize = sizeof(diprop);\r
- diprop.diph.dwHeaderSize = sizeof(diprop.diph);\r
- diprop.diph.dwObj = 0;\r
- diprop.diph.dwHow = DIPH_DEVICE;\r
- diprop.dwData = 1000;\r
- pDevice->SetProperty(DIPROP_BUFFERSIZE , &diprop.diph);\r
- setActivation(true);\r
- \r
- pDeviceInputReceiver = new mof::DeviceInputReceiver();\r
- pInputReceiver = boost::shared_ptr<mof::InputReceiver>(pDeviceInputReceiver);\r
-}\r
-\r
-\r
-\r
-/**\r
- * mof::InputDevice::finalize\r
- *\r
- */\r
-void mof::InputDevice::finalize(void)\r
-{\r
- mof::InputDevice::setActivation(false);\r
- if(pDevice != NULL)pDevice->Release();\r
- if(pInput != NULL)pInput->Release();\r
-}\r
-\r
-\r
-void mof::InputDevice::setActivation(bool active){\r
- if(pDevice == NULL)return;\r
-\r
- if(active == false)pDevice->Unacquire();\r
- else pDevice->Acquire();\r
-}\r
-\r
-\r
-\r
-BOOL CALLBACK enumJoyCallback(const DIDEVICEINSTANCE* pInstance , VOID* /*pContext*/ ){\r
- HRESULT hr;\r
- \r
- hr = pInput->CreateDevice(pInstance->guidInstance , &(pDevice) , NULL);\r
- if(FAILED(hr))return DIENUM_CONTINUE;\r
-\r
- DIDEVICEINSTANCE deviceInstance;\r
- deviceInstance.dwSize = sizeof(DIDEVCAPS);\r
- hr = pDevice->GetCapabilities((LPDIDEVCAPS)&deviceInstance);\r
- if(FAILED(hr)){\r
- pDevice->Release();\r
- pDevice = NULL;\r
- return DIENUM_CONTINUE;\r
- }\r
-\r
- *ConsoleOut::getInstance() << "Found InputDevice --- " << deviceInstance.tszInstanceName \r
- << ":" << deviceInstance.tszProductName << std::endl;\r
- return DIENUM_STOP;//\89½\82Å\82à\82¢\82¢\82©\82ç\8dÌ\97p\r
-}\r
-\r
- \r
-void mof::InputDevice::update(){\r
- \r
- HRESULT hr;\r
- while(true){\r
- DIDEVICEOBJECTDATA od;\r
- DWORD dwItems = 1;\r
- hr = pDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA) , &od , &dwItems , 0);\r
- if(hr == DIERR_INPUTLOST)pDevice->Acquire();\r
- else if(FAILED(hr) || dwItems == 0)return;\r
- \r
- InputEvent iEvent(od.dwOfs , od.dwData);\r
- //inputSignal(iEvent);\r
- pDeviceInputReceiver->notifyInputEvent(iEvent);\r
-\r
- /*for(int i = 0 ; i < listenerList.size() ; ++i){\r
- int tmpSize = listenerList.size();\r
- listenerList.at(i)->notifyInputEvent(iEvent);\r
- if(tmpSize != listenerList.size())i--;//NotifyInputEvent\82ÅRemove\82³\82ê\82½\82©\82ð\83`\83F\83b\83N\r
- }*/\r
- \r
- }\r
-\r
-\r
-}\r
-\r
-\r
-\r
-boost::shared_ptr<mof::InputReceiver> mof::InputDevice::getInputReceiver(){\r
- return pInputReceiver;\r
-}\r
-\r
-\r
-/*\r
-namespace mof{\r
-\r
- class DeviceInputReceiver;\r
-\r
- class InputDevice\r
- {\r
- \r
-\r
- std::vector<DeviceInputReceiver*> listenerList;\r
- \r
- void addReceiver(DeviceInputReceiver* pReceiver);\r
- public:\r
- InputDevice(void);\r
- ~InputDevice(void);\r
- \r
-\r
- bool initialize( HINSTANCE hInst);\r
- static BOOL CALLBACK enumJoyCallback(const DIDEVICEINSTANCE* pInstance , VOID* pContext);\r
-\r
- void activate(bool);\r
- void updateInputData();\r
- InputReceiver* getInputReceiver();\r
- void removeReceiver(DeviceInputReceiver* pReceiver);\r
- //void clearListenerList();\r
-\r
-\r
- };\r
-\r
-};\r
-\r
-typedef std::vector<mof::DeviceInputReceiver*>::iterator LISTENERITR;\r
-\r
-mof::InputDevice::InputDevice(void)\r
-{\r
- m_pInput = NULL;\r
- m_pDevice = NULL;\r
-}\r
-\r
-mof::InputDevice::~InputDevice(void)\r
-{\r
- activate(false);\r
- if(m_pDevice != NULL)m_pDevice->Release();\r
- if(m_pInput != NULL)m_pInput->Release();\r
-}\r
-\r
-\r
-bool mof::InputDevice::initialize( HINSTANCE hInst){\r
- HRESULT hr;\r
- hr = DirectInput8Create(hInst , DIRECTINPUT_VERSION ,IID_IDirectInput8 , (void**)&m_pInput , NULL);\r
- if(FAILED(hr))return false;\r
- \r
- LPCDIDATAFORMAT dataFmt = &c_dfDIJoystick;//\83W\83\87\83C\83X\83e\83B\83b\83N\82ª\8eæ\93¾\82Å\82«\82½\82Æ\89¼\92è\r
- //---\83f\83o\83C\83X\82Ì\90Ý\92è\r
- //\83Q\81[\83\80\83p\83b\83h\83f\83o\83C\83X\82ð\92T\82·\r
- hr = m_pInput->EnumDevices(DI8DEVCLASS_GAMECTRL , enumJoyCallback , NULL , DIEDFL_ATTACHEDONLY);\r
- if(FAILED(hr) || m_pDevice == NULL){\r
- //\83Q\81[\83\80\83p\83b\83h\82ª\82È\82¯\82ê\82Î\83L\81[\83{\81[\83h\r
- hr = m_pInput->CreateDevice(GUID_SysKeyboard , &m_pDevice , NULL);\r
- if(FAILED(hr)){\r
- m_pInput->Release();\r
- m_pInput = NULL;\r
- return false;\r
- }\r
- else dataFmt = &c_dfDIKeyboard;//\83L\81[\83{\81[\83h\82ð\83f\83o\83C\83X\82Æ\82µ\82Ä\8eæ\93¾\r
- }\r
-\r
- \r
- hr = m_pDevice->SetDataFormat(dataFmt);\r
- if(FAILED(hr)){\r
- *ConsoleOut::getInstance() << "SetDataFormat --- ERROR" << std::endl;\r
- m_pDevice->Release();\r
- m_pDevice = NULL;\r
- m_pInput->Release();\r
- m_pInput = NULL;\r
- return false;\r
- }\r
-\r
- //m_pDevice->SetCooperativeLevel( hWnd , DISCL_FOREGROUND);\r
-\r
- DIPROPDWORD diprop;\r
- diprop.diph.dwSize = sizeof(diprop);\r
- diprop.diph.dwHeaderSize = sizeof(diprop.diph);\r
- diprop.diph.dwObj = 0;\r
- diprop.diph.dwHow = DIPH_DEVICE;\r
- diprop.dwData = 1000;\r
- m_pDevice->SetProperty(DIPROP_BUFFERSIZE , &diprop.diph);\r
- activate(true);\r
- return true;\r
-}\r
- \r
-\r
-void mof::InputDevice::activate(bool active){\r
- if(m_pDevice == NULL)return;\r
-\r
- if(active == false)m_pDevice->Unacquire();\r
- else m_pDevice->Acquire();\r
-}\r
-\r
-void mof::InputDevice::updateInputData(){\r
- \r
- HRESULT hr;\r
- while(true){\r
- DIDEVICEOBJECTDATA od;\r
- DWORD dwItems = 1;\r
- hr = m_pDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA) , &od , &dwItems , 0);\r
- if(hr == DIERR_INPUTLOST)m_pDevice->Acquire();\r
- else if(FAILED(hr) || dwItems == 0)return;\r
- \r
- InputEvent iEvent(od.dwOfs , od.dwData);\r
- //inputSignal(iEvent);\r
- \r
- for(int i = 0 ; i < listenerList.size() ; ++i){\r
- int tmpSize = listenerList.size();\r
- listenerList.at(i)->notifyInputEvent(iEvent);\r
- if(tmpSize != listenerList.size())i--;//NotifyInputEvent\82ÅRemove\82³\82ê\82½\82©\82ð\83`\83F\83b\83N\r
- }\r
- \r
- }\r
-\r
-\r
-}\r
-\r
-\r
-\r
-mof::InputReceiver* mof::InputDevice::getInputReceiver(){\r
- mof::DeviceInputReceiver* pReceiver = new mof::DeviceInputReceiver();\r
- addReceiver(pReceiver);\r
- return pReceiver;\r
-\r
-}\r
-\r
-\r
-void mof::InputDevice::addReceiver(mof::DeviceInputReceiver* pReceiver){\r
- for(LISTENERITR itr = listenerList.begin() ; itr != listenerList.end() ; ++itr){\r
- if((*itr) == pReceiver)return;//\8aù\82É\93o\98^\8dÏ\82Ý\r
- }\r
- listenerList.push_back(pReceiver);\r
-}\r
-\r
-void mof::InputDevice::removeReceiver(mof::DeviceInputReceiver* pReceiver){\r
- for(LISTENERITR itr = listenerList.begin() ; itr != listenerList.end() ; ++itr){\r
- if((*itr) == pReceiver){\r
- listenerList.erase(itr);\r
- return;\r
- }\r
- }\r
- \r
-}\r
-*/\r
+#include "mof/private/DirectInput.hpp"
+#include <vector>
+#include "mof/InputReceiver.hpp"
+#include "mof/InputDevice.hpp"
+#include "mof/ConsoleIO.hpp"
+#include "mof/private/DeviceInputReceiver.hpp"
+#include "boost/shared_ptr.hpp"
+
+namespace {
+ LPDIRECTINPUT8 pInput;
+ LPDIRECTINPUTDEVICE8A pDevice;
+ boost::shared_ptr<mof::InputReceiver> pInputReceiver;//\8aO\95\94\82É\93n\82·\82½\82ß
+ mof::DeviceInputReceiver* pDeviceInputReceiver;//\8fã\8bL\82Æ\93¯\82¶\83C\83\93\83X\83^\83\93\83X
+}
+
+//--- \83v\83\8d\83g\83^\83C\83v\90é\8c¾
+BOOL CALLBACK enumJoyCallback(const DIDEVICEINSTANCE* pInstance , VOID* pContext);
+
+/**
+ * mof::InputDevice::initialize
+ *
+ */
+void mof::InputDevice::initialize( ){
+ HINSTANCE hInst = GetModuleHandle(NULL);
+ HRESULT hr;
+ hr = DirectInput8Create(hInst , DIRECTINPUT_VERSION ,IID_IDirectInput8 , (void**)&pInput , NULL);
+ if(FAILED(hr)){
+ switch(hr){
+ case DIERR_BETADIRECTINPUTVERSION :
+ DEBUG_PRINT("DIERR_BETADIRECTINPUTVERSION");
+ break;
+ case DIERR_INVALIDPARAM :
+ DEBUG_PRINT("DIERR_INVALIDPARAM");
+ break;
+ case DIERR_OLDDIRECTINPUTVERSION :
+ DEBUG_PRINT("DIERR_OLDDIRECTINPUTVERSION");
+ break;
+ case DIERR_OUTOFMEMORY :
+ DEBUG_PRINT("DIERR_OUTOFMEMORY");
+ break;
+ }
+ throw std::runtime_error("Failed --- create direct input");
+ }
+
+ LPCDIDATAFORMAT dataFmt = &c_dfDIJoystick;//\83W\83\87\83C\83X\83e\83B\83b\83N\82ª\8eæ\93¾\82Å\82«\82½\82Æ\89¼\92è
+ //---\83f\83o\83C\83X\82Ì\90Ý\92è
+ //\83Q\81[\83\80\83p\83b\83h\83f\83o\83C\83X\82ð\92T\82·
+ hr = pInput->EnumDevices(DI8DEVCLASS_GAMECTRL , enumJoyCallback , NULL , DIEDFL_ATTACHEDONLY);
+ if(FAILED(hr) || pDevice == NULL){
+ //\83Q\81[\83\80\83p\83b\83h\82ª\82È\82¯\82ê\82Î\83L\81[\83{\81[\83h
+ hr = pInput->CreateDevice(GUID_SysKeyboard , &pDevice , NULL);
+ if(FAILED(hr)){
+ pInput->Release();
+ pInput = NULL;
+ throw std::runtime_error("Failed --- create device");
+ }
+ dataFmt = &c_dfDIKeyboard;//\83L\81[\83{\81[\83h\82ð\83f\83o\83C\83X\82Æ\82µ\82Ä\8eæ\93¾
+ DEBUG_PRINT("Select --- keyboard as input device");
+ }
+ else DEBUG_PRINT("Select --- joystick as input device");
+
+ hr = pDevice->SetDataFormat(dataFmt);
+ if(FAILED(hr)){
+ pDevice->Release();
+ pDevice = NULL;
+ pInput->Release();
+ pInput = NULL;
+ throw std::runtime_error("Failed --- set data format");
+ }
+
+
+ DIPROPDWORD diprop;
+ diprop.diph.dwSize = sizeof(diprop);
+ diprop.diph.dwHeaderSize = sizeof(diprop.diph);
+ diprop.diph.dwObj = 0;
+ diprop.diph.dwHow = DIPH_DEVICE;
+ diprop.dwData = 1000;
+ pDevice->SetProperty(DIPROP_BUFFERSIZE , &diprop.diph);
+ setActivation(true);
+
+ pDeviceInputReceiver = new mof::DeviceInputReceiver();
+ pInputReceiver = boost::shared_ptr<mof::InputReceiver>(pDeviceInputReceiver);
+}
+
+
+
+/**
+ * mof::InputDevice::finalize
+ *
+ */
+void mof::InputDevice::finalize(void)
+{
+ mof::InputDevice::setActivation(false);
+ if(pDevice != NULL)pDevice->Release();
+ if(pInput != NULL)pInput->Release();
+}
+
+
+void mof::InputDevice::setActivation(bool active){
+ if(pDevice == NULL)return;
+
+ if(active == false)pDevice->Unacquire();
+ else pDevice->Acquire();
+}
+
+
+
+BOOL CALLBACK enumJoyCallback(const DIDEVICEINSTANCE* pInstance , VOID* /*pContext*/ ){
+ HRESULT hr;
+
+ hr = pInput->CreateDevice(pInstance->guidInstance , &(pDevice) , NULL);
+ if(FAILED(hr))return DIENUM_CONTINUE;
+
+ DIDEVICEINSTANCE deviceInstance;
+ deviceInstance.dwSize = sizeof(DIDEVCAPS);
+ hr = pDevice->GetCapabilities((LPDIDEVCAPS)&deviceInstance);
+ if(FAILED(hr)){
+ pDevice->Release();
+ pDevice = NULL;
+ return DIENUM_CONTINUE;
+ }
+
+ *ConsoleOut::getInstance() << "Found InputDevice --- " << deviceInstance.tszInstanceName
+ << ":" << deviceInstance.tszProductName << std::endl;
+ return DIENUM_STOP;//\89½\82Å\82à\82¢\82¢\82©\82ç\8dÌ\97p
+}
+
+
+void mof::InputDevice::update(){
+
+ HRESULT hr;
+ while(true){
+ DIDEVICEOBJECTDATA od;
+ DWORD dwItems = 1;
+ hr = pDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA) , &od , &dwItems , 0);
+ if(hr == DIERR_INPUTLOST)pDevice->Acquire();
+ else if(FAILED(hr) || dwItems == 0)return;
+
+ InputEvent iEvent(od.dwOfs , od.dwData);
+ //inputSignal(iEvent);
+ pDeviceInputReceiver->notifyInputEvent(iEvent);
+
+ /*for(int i = 0 ; i < listenerList.size() ; ++i){
+ int tmpSize = listenerList.size();
+ listenerList.at(i)->notifyInputEvent(iEvent);
+ if(tmpSize != listenerList.size())i--;//NotifyInputEvent\82ÅRemove\82³\82ê\82½\82©\82ð\83`\83F\83b\83N
+ }*/
+
+ }
+
+
+}
+
+
+
+boost::shared_ptr<mof::InputReceiver> mof::InputDevice::getInputReceiver(){
+ return pInputReceiver;
+}
+
+
+/*
+namespace mof{
+
+ class DeviceInputReceiver;
+
+ class InputDevice
+ {
+
+
+ std::vector<DeviceInputReceiver*> listenerList;
+
+ void addReceiver(DeviceInputReceiver* pReceiver);
+ public:
+ InputDevice(void);
+ ~InputDevice(void);
+
+
+ bool initialize( HINSTANCE hInst);
+ static BOOL CALLBACK enumJoyCallback(const DIDEVICEINSTANCE* pInstance , VOID* pContext);
+
+ void activate(bool);
+ void updateInputData();
+ InputReceiver* getInputReceiver();
+ void removeReceiver(DeviceInputReceiver* pReceiver);
+ //void clearListenerList();
+
+
+ };
+
+};
+
+typedef std::vector<mof::DeviceInputReceiver*>::iterator LISTENERITR;
+
+mof::InputDevice::InputDevice(void)
+{
+ m_pInput = NULL;
+ m_pDevice = NULL;
+}
+
+mof::InputDevice::~InputDevice(void)
+{
+ activate(false);
+ if(m_pDevice != NULL)m_pDevice->Release();
+ if(m_pInput != NULL)m_pInput->Release();
+}
+
+
+bool mof::InputDevice::initialize( HINSTANCE hInst){
+ HRESULT hr;
+ hr = DirectInput8Create(hInst , DIRECTINPUT_VERSION ,IID_IDirectInput8 , (void**)&m_pInput , NULL);
+ if(FAILED(hr))return false;
+
+ LPCDIDATAFORMAT dataFmt = &c_dfDIJoystick;//\83W\83\87\83C\83X\83e\83B\83b\83N\82ª\8eæ\93¾\82Å\82«\82½\82Æ\89¼\92è
+ //---\83f\83o\83C\83X\82Ì\90Ý\92è
+ //\83Q\81[\83\80\83p\83b\83h\83f\83o\83C\83X\82ð\92T\82·
+ hr = m_pInput->EnumDevices(DI8DEVCLASS_GAMECTRL , enumJoyCallback , NULL , DIEDFL_ATTACHEDONLY);
+ if(FAILED(hr) || m_pDevice == NULL){
+ //\83Q\81[\83\80\83p\83b\83h\82ª\82È\82¯\82ê\82Î\83L\81[\83{\81[\83h
+ hr = m_pInput->CreateDevice(GUID_SysKeyboard , &m_pDevice , NULL);
+ if(FAILED(hr)){
+ m_pInput->Release();
+ m_pInput = NULL;
+ return false;
+ }
+ else dataFmt = &c_dfDIKeyboard;//\83L\81[\83{\81[\83h\82ð\83f\83o\83C\83X\82Æ\82µ\82Ä\8eæ\93¾
+ }
+
+
+ hr = m_pDevice->SetDataFormat(dataFmt);
+ if(FAILED(hr)){
+ *ConsoleOut::getInstance() << "SetDataFormat --- ERROR" << std::endl;
+ m_pDevice->Release();
+ m_pDevice = NULL;
+ m_pInput->Release();
+ m_pInput = NULL;
+ return false;
+ }
+
+ //m_pDevice->SetCooperativeLevel( hWnd , DISCL_FOREGROUND);
+
+ DIPROPDWORD diprop;
+ diprop.diph.dwSize = sizeof(diprop);
+ diprop.diph.dwHeaderSize = sizeof(diprop.diph);
+ diprop.diph.dwObj = 0;
+ diprop.diph.dwHow = DIPH_DEVICE;
+ diprop.dwData = 1000;
+ m_pDevice->SetProperty(DIPROP_BUFFERSIZE , &diprop.diph);
+ activate(true);
+ return true;
+}
+
+
+void mof::InputDevice::activate(bool active){
+ if(m_pDevice == NULL)return;
+
+ if(active == false)m_pDevice->Unacquire();
+ else m_pDevice->Acquire();
+}
+
+void mof::InputDevice::updateInputData(){
+
+ HRESULT hr;
+ while(true){
+ DIDEVICEOBJECTDATA od;
+ DWORD dwItems = 1;
+ hr = m_pDevice->GetDeviceData(sizeof(DIDEVICEOBJECTDATA) , &od , &dwItems , 0);
+ if(hr == DIERR_INPUTLOST)m_pDevice->Acquire();
+ else if(FAILED(hr) || dwItems == 0)return;
+
+ InputEvent iEvent(od.dwOfs , od.dwData);
+ //inputSignal(iEvent);
+
+ for(int i = 0 ; i < listenerList.size() ; ++i){
+ int tmpSize = listenerList.size();
+ listenerList.at(i)->notifyInputEvent(iEvent);
+ if(tmpSize != listenerList.size())i--;//NotifyInputEvent\82ÅRemove\82³\82ê\82½\82©\82ð\83`\83F\83b\83N
+ }
+
+ }
+
+
+}
+
+
+
+mof::InputReceiver* mof::InputDevice::getInputReceiver(){
+ mof::DeviceInputReceiver* pReceiver = new mof::DeviceInputReceiver();
+ addReceiver(pReceiver);
+ return pReceiver;
+
+}
+
+
+void mof::InputDevice::addReceiver(mof::DeviceInputReceiver* pReceiver){
+ for(LISTENERITR itr = listenerList.begin() ; itr != listenerList.end() ; ++itr){
+ if((*itr) == pReceiver)return;//\8aù\82É\93o\98^\8dÏ\82Ý
+ }
+ listenerList.push_back(pReceiver);
+}
+
+void mof::InputDevice::removeReceiver(mof::DeviceInputReceiver* pReceiver){
+ for(LISTENERITR itr = listenerList.begin() ; itr != listenerList.end() ; ++itr){
+ if((*itr) == pReceiver){
+ listenerList.erase(itr);
+ return;
+ }
+ }
+
+}
+*/
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-#include <windows.h>\r
-\r
-//TODO private\82Í\95Ê\83t\83@\83C\83\8b\82É\r
-namespace mof {\r
- class InputReceiver;\r
-\r
- namespace InputDevice{\r
-\r
- // --- private\r
- void initialize();\r
- void finalize();\r
- void setActivation(bool active);\r
- void update();\r
-\r
- // -- public\r
- boost::shared_ptr<mof::InputReceiver> getInputReceiver();\r
- \r
-\r
- \r
- }\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+#include <windows.h>
+
+//TODO private\82Í\95Ê\83t\83@\83C\83\8b\82É
+namespace mof {
+ class InputReceiver;
+
+ namespace InputDevice{
+
+ // --- private
+ void initialize();
+ void finalize();
+ void setActivation(bool active);
+ void update();
+
+ // -- public
+ boost::shared_ptr<mof::InputReceiver> getInputReceiver();
+
+
+
+ }
}
\ No newline at end of file
-#include "mof/InputEventCondition.hpp"\r
-\r
-mof::InputEventCondition::InputEventCondition(\r
- mof::InputReceiver::Key key, \r
- const boost::shared_ptr<mof::InputReceiver> &pInputReceiver)\r
- : m_key(key) , m_pInputReceiver(pInputReceiver)\r
-{\r
- update();\r
-}\r
-\r
-mof::InputEventCondition::~InputEventCondition(){\r
-}\r
-\r
-bool mof::InputEventCondition::test(){\r
- return m_state;\r
-}\r
-\r
-void mof::InputEventCondition::update(){\r
- m_state = m_pInputReceiver->testKeyState(m_key);\r
-}\r
-\r
-bool mof::InputEventCondition::isDisposable(){\r
- return false;\r
-}\r
+#include "mof/InputEventCondition.hpp"
+
+mof::InputEventCondition::InputEventCondition(
+ mof::InputReceiver::Key key,
+ const boost::shared_ptr<mof::InputReceiver> &pInputReceiver)
+ : m_key(key) , m_pInputReceiver(pInputReceiver)
+{
+ update();
+}
+
+mof::InputEventCondition::~InputEventCondition(){
+}
+
+bool mof::InputEventCondition::test(){
+ return m_state;
+}
+
+void mof::InputEventCondition::update(){
+ m_state = m_pInputReceiver->testKeyState(m_key);
+}
+
+bool mof::InputEventCondition::isDisposable(){
+ return false;
+}
-#pragma once\r
-#include "mof/EventCondition.hpp"\r
-#include "mof/InputReceiver.hpp"\r
-#include "boost/shared_ptr.hpp"\r
-\r
-namespace mof{\r
-\r
-\r
- class InputEventCondition : public EventCondition{\r
- mof::InputReceiver::Key m_key;\r
- boost::shared_ptr<mof::InputReceiver> m_pInputReceiver;\r
- bool m_state;\r
- public:\r
- InputEventCondition(\r
- mof::InputReceiver::Key key , \r
- const boost::shared_ptr<mof::InputReceiver>& pInputReceiver\r
- );\r
-\r
- virtual ~InputEventCondition();\r
- virtual bool test();\r
- virtual void update();\r
- virtual bool isDisposable();\r
- };\r
-\r
-\r
-}\r
-\r
+#pragma once
+#include "mof/EventCondition.hpp"
+#include "mof/InputReceiver.hpp"
+#include "boost/shared_ptr.hpp"
+
+namespace mof{
+
+
+ class InputEventCondition : public EventCondition{
+ mof::InputReceiver::Key m_key;
+ boost::shared_ptr<mof::InputReceiver> m_pInputReceiver;
+ bool m_state;
+ public:
+ InputEventCondition(
+ mof::InputReceiver::Key key ,
+ const boost::shared_ptr<mof::InputReceiver>& pInputReceiver
+ );
+
+ virtual ~InputEventCondition();
+ virtual bool test();
+ virtual void update();
+ virtual bool isDisposable();
+ };
+
+
+}
+
-#pragma once\r
-\r
-\r
-namespace mof{\r
- \r
- class InputReceiver{\r
- public:\r
- typedef enum{\r
- UP = 0 , DOWN , LEFT , RIGHT ,\r
- A , B , C , D , E , F , G , H , I ,\r
- J , K , L , M , N , O , P , Q , R ,\r
- S , T , U , V , W , X , Y , Z ,\r
- ESCAPE ,\r
- END //\8dÅ\8cã\82Í\95K\82¸\82±\82ê\82Å\8fI\82í\82é\82æ\82¤\82É\r
- } Key;\r
-\r
- \r
- virtual ~InputReceiver(){}\r
- virtual bool testKeyState(Key key) = 0;\r
-\r
- /**\r
- * \95s\93Á\92è\91½\90\94\82Ì\83I\83u\83W\83F\83N\83g\82ª\82±\82Ì\83\81\83\\83b\83h\82ð\8cÄ\82Ñ\8fo\82·\82Æ\81A\r
- * \88Ó\90}\82µ\82½\93ü\97Í\8f\88\97\9d\82ª\82Å\82«\82È\82¢\89Â\94\\90«\82ª\82 \82è\82Ü\82·\81B\r
- */\r
- virtual void update() = 0;\r
- \r
- };\r
-};\r
+#pragma once
+
+
+namespace mof{
+
+ class InputReceiver{
+ public:
+ typedef enum{
+ UP = 0 , DOWN , LEFT , RIGHT ,
+ A , B , C , D , E , F , G , H , I ,
+ J , K , L , M , N , O , P , Q , R ,
+ S , T , U , V , W , X , Y , Z ,
+ ESCAPE ,
+ END //\8dÅ\8cã\82Í\95K\82¸\82±\82ê\82Å\8fI\82í\82é\82æ\82¤\82É
+ } Key;
+
+
+ virtual ~InputReceiver(){}
+ virtual bool testKeyState(Key key) = 0;
+
+ /**
+ * \95s\93Á\92è\91½\90\94\82Ì\83I\83u\83W\83F\83N\83g\82ª\82±\82Ì\83\81\83\\83b\83h\82ð\8cÄ\82Ñ\8fo\82·\82Æ\81A
+ * \88Ó\90}\82µ\82½\93ü\97Í\8f\88\97\9d\82ª\82Å\82«\82È\82¢\89Â\94\\90«\82ª\82 \82è\82Ü\82·\81B
+ */
+ virtual void update() = 0;
+
+ };
+};
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-//#include "mof/MessageWidget.hpp"\r
-#include "mof/tstring.hpp"\r
- \r
-namespace mof\r
-{\r
- class MessageWidget;\r
-\r
- class InstructionSet\r
- {\r
- public:\r
- /** \r
- * @brief \83\81\83b\83Z\81[\83W\83E\83B\83\93\83h\83E\82ð\90¶\90¬\82·\82é\82½\82ß\82Ì\83R\81[\83\8b\83o\83b\83N\r
- * @return \90¶\90¬\82µ\82½\83\81\83b\83Z\81[\83W\83E\83B\83\93\83h\83E\r
- */\r
- virtual boost::shared_ptr< MessageWidget > createMessageWidget( ) = 0;\r
- \r
- /** \r
- * @brief \83\81\83b\83Z\81[\83W\83E\83B\83\93\83h\83E\82É\83y\81[\83W\82ð\92Ç\89Á\82·\82é\82½\82ß\82Ì\83R\81[\83\8b\83o\83b\83N\r
- * @param[in] \83\81\83b\83Z\81[\83W\82Ì\83^\83C\83g\83\8b\r
- * @param[in] \83\81\83b\83Z\81[\83W\93à\97e\r
- * @return \90¶\90¬\82µ\82½\83\81\83b\83Z\81[\83W\83E\83B\83\93\83h\83E\r
- */\r
- virtual int addMessageWidgetPage\r
- ( \r
- boost::shared_ptr<MessageWidget>& message ,\r
- const tstring& title ,\r
- const tstring& text \r
- ) = 0;\r
- \r
-\r
-\r
- /** \r
- * @brief \83N\83\89\83C\83A\83\93\83g\91¤\82Å\88ø\82«\91±\82«\83\8a\83\\81[\83X\82ð\97\98\97p\82·\82é\82½\82ß\82Ì\83R\81[\83\8b\83o\83b\83N\r
- * @note \88ø\90\94\82Å\93n\82³\82ê\82½\83\8a\83\\81[\83X\82ª\82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82É\82æ\82è\8d¡\8cã\8eQ\8fÆ\82³\82ê\82é\82±\82Æ\82Í\82È\82¢\r
- * @param[in] \95s\97v\82Æ\82È\82Á\82½\83\8a\83\\81[\83X\r
- */\r
- virtual void inactive( boost::shared_ptr<MessageWidget>& message ) = 0;\r
- \r
- virtual ~InstructionSet(){}\r
-\r
- };\r
-\r
-}\r
-\r
-\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+//#include "mof/MessageWidget.hpp"
+#include "mof/tstring.hpp"
+
+namespace mof
+{
+ class MessageWidget;
+
+ class InstructionSet
+ {
+ public:
+ /**
+ * @brief \83\81\83b\83Z\81[\83W\83E\83B\83\93\83h\83E\82ð\90¶\90¬\82·\82é\82½\82ß\82Ì\83R\81[\83\8b\83o\83b\83N
+ * @return \90¶\90¬\82µ\82½\83\81\83b\83Z\81[\83W\83E\83B\83\93\83h\83E
+ */
+ virtual boost::shared_ptr< MessageWidget > createMessageWidget( ) = 0;
+
+ /**
+ * @brief \83\81\83b\83Z\81[\83W\83E\83B\83\93\83h\83E\82É\83y\81[\83W\82ð\92Ç\89Á\82·\82é\82½\82ß\82Ì\83R\81[\83\8b\83o\83b\83N
+ * @param[in] \83\81\83b\83Z\81[\83W\82Ì\83^\83C\83g\83\8b
+ * @param[in] \83\81\83b\83Z\81[\83W\93à\97e
+ * @return \90¶\90¬\82µ\82½\83\81\83b\83Z\81[\83W\83E\83B\83\93\83h\83E
+ */
+ virtual int addMessageWidgetPage
+ (
+ boost::shared_ptr<MessageWidget>& message ,
+ const tstring& title ,
+ const tstring& text
+ ) = 0;
+
+
+
+ /**
+ * @brief \83N\83\89\83C\83A\83\93\83g\91¤\82Å\88ø\82«\91±\82«\83\8a\83\\81[\83X\82ð\97\98\97p\82·\82é\82½\82ß\82Ì\83R\81[\83\8b\83o\83b\83N
+ * @note \88ø\90\94\82Å\93n\82³\82ê\82½\83\8a\83\\81[\83X\82ª\82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82É\82æ\82è\8d¡\8cã\8eQ\8fÆ\82³\82ê\82é\82±\82Æ\82Í\82È\82¢
+ * @param[in] \95s\97v\82Æ\82È\82Á\82½\83\8a\83\\81[\83X
+ */
+ virtual void inactive( boost::shared_ptr<MessageWidget>& message ) = 0;
+
+ virtual ~InstructionSet(){}
+
+ };
+
+}
+
+
- #pragma once\r
- #include "mof/Vector2D.hpp"\r
- #include "mof/stream/Manipulator.hpp"\r
- #include <map>\r
- #include <algorithm>\r
- \r
- namespace mof{\r
- \r
- template <typename T>\r
- T stepInterpolate(const std::map<mof::FrameNumber , T>& map , mof::FrameNumber current ){\r
- if(map.empty())throw std::invalid_argument("the map is empty");\r
- for(\r
- typename std::map<mof::FrameNumber , T>::const_reverse_iterator itr = map.rbegin() ;\r
- itr != map.rend() ; \r
- ++itr\r
- ){\r
- if(itr->first <= current)return itr->second;\r
- }\r
- return map.begin()->second;//default\r
- }\r
- \r
- template<class T> inline\r
- T calcLinerInterpolationValue( float blending , const T& prevObj , const T& nextObj){\r
- return (1 - blending) * prevObj + blending * nextObj;\r
- } \r
- \r
- //\8cë\8d·\92á\8c¸\82Ì\82½\82ß\82Ì\93Á\8eê\89»\r
- /*template<> inline\r
- Vector2D calcLinerInterpolationValue( float blending , const Vector2D& prev , const Vector2D& next )\r
- {\r
- return mof::Vector2D\r
- (\r
- prev.x != next.x ? (1 - blending) * prev.x + blending * next.x : prev.x , \r
- prev.y != next.y ? (1 - blending) * prev.y + blending * next.y : prev.y \r
- );\r
- }*/ \r
-\r
- template <typename T>\r
- T linerInterpolate(const std::map<mof::FrameNumber , T>& map , mof::FrameNumber current ){\r
- if(map.empty())throw std::invalid_argument("the map is empty");\r
- typename std::map<mof::FrameNumber , T>::const_iterator n = map.find(current);\r
- if(n != map.end())return n->second;// just key frame\r
- \r
- //\92¼\91O\81A\92¼\8cã\82Ì\83L\81[\82ð\8c\9f\8dõ\r
- mof::FrameNumber prevKeyFrame = current;\r
- bool foundPrev = false;\r
- T prevObj;\r
- mof::FrameNumber nextKeyFrame = current;\r
- bool foundNext = false;\r
- T nextObj;\r
- \r
- for(\r
- typename std::map<mof::FrameNumber , T>::const_iterator itr = map.begin() ;\r
- itr != map.end() ;\r
- ++itr\r
- ){\r
- if(itr->first < current && (!foundPrev || itr->first > prevKeyFrame)){\r
- foundPrev = true;\r
- prevKeyFrame = itr->first;\r
- prevObj = itr->second;\r
- }\r
- else if(itr->first > current && (!foundNext || itr->first < nextKeyFrame)){\r
- foundNext = true;\r
- nextKeyFrame = itr->first;\r
- nextObj = itr->second;\r
- }\r
- \r
- }\r
- \r
- assert(foundPrev || foundNext);\r
- if(!foundPrev && foundNext)return nextObj;//\92¼\91O\82Ì\83L\81[\82Í\8c©\82Â\82©\82ç\82È\82©\82Á\82½\r
- else if(foundPrev && !foundNext)return prevObj;//\92¼\8cã\82Ì\83L\81[\82Í\8c©\82Â\82©\82ç\82È\82©\82Á\82½\r
- float blending = static_cast<float>(current - prevKeyFrame) / static_cast<float>(nextKeyFrame - prevKeyFrame);\r
- return calcLinerInterpolationValue<T>(blending , prevObj , nextObj);\r
- }\r
- \r
- } //namespace mof\r
- \r
- \r
+ #pragma once
+ #include "mof/Vector2D.hpp"
+ #include "mof/stream/Manipulator.hpp"
+ #include <map>
+ #include <algorithm>
+
+ namespace mof{
+
+ template <typename T>
+ T stepInterpolate(const std::map<mof::FrameNumber , T>& map , mof::FrameNumber current ){
+ if(map.empty())throw std::invalid_argument("the map is empty");
+ for(
+ typename std::map<mof::FrameNumber , T>::const_reverse_iterator itr = map.rbegin() ;
+ itr != map.rend() ;
+ ++itr
+ ){
+ if(itr->first <= current)return itr->second;
+ }
+ return map.begin()->second;//default
+ }
+
+ template<class T> inline
+ T calcLinerInterpolationValue( float blending , const T& prevObj , const T& nextObj){
+ return (1 - blending) * prevObj + blending * nextObj;
+ }
+
+ //\8cë\8d·\92á\8c¸\82Ì\82½\82ß\82Ì\93Á\8eê\89»
+ /*template<> inline
+ Vector2D calcLinerInterpolationValue( float blending , const Vector2D& prev , const Vector2D& next )
+ {
+ return mof::Vector2D
+ (
+ prev.x != next.x ? (1 - blending) * prev.x + blending * next.x : prev.x ,
+ prev.y != next.y ? (1 - blending) * prev.y + blending * next.y : prev.y
+ );
+ }*/
+
+ template <typename T>
+ T linerInterpolate(const std::map<mof::FrameNumber , T>& map , mof::FrameNumber current ){
+ if(map.empty())throw std::invalid_argument("the map is empty");
+ typename std::map<mof::FrameNumber , T>::const_iterator n = map.find(current);
+ if(n != map.end())return n->second;// just key frame
+
+ //\92¼\91O\81A\92¼\8cã\82Ì\83L\81[\82ð\8c\9f\8dõ
+ mof::FrameNumber prevKeyFrame = current;
+ bool foundPrev = false;
+ T prevObj;
+ mof::FrameNumber nextKeyFrame = current;
+ bool foundNext = false;
+ T nextObj;
+
+ for(
+ typename std::map<mof::FrameNumber , T>::const_iterator itr = map.begin() ;
+ itr != map.end() ;
+ ++itr
+ ){
+ if(itr->first < current && (!foundPrev || itr->first > prevKeyFrame)){
+ foundPrev = true;
+ prevKeyFrame = itr->first;
+ prevObj = itr->second;
+ }
+ else if(itr->first > current && (!foundNext || itr->first < nextKeyFrame)){
+ foundNext = true;
+ nextKeyFrame = itr->first;
+ nextObj = itr->second;
+ }
+
+ }
+
+ assert(foundPrev || foundNext);
+ if(!foundPrev && foundNext)return nextObj;//\92¼\91O\82Ì\83L\81[\82Í\8c©\82Â\82©\82ç\82È\82©\82Á\82½
+ else if(foundPrev && !foundNext)return prevObj;//\92¼\8cã\82Ì\83L\81[\82Í\8c©\82Â\82©\82ç\82È\82©\82Á\82½
+ float blending = static_cast<float>(current - prevKeyFrame) / static_cast<float>(nextKeyFrame - prevKeyFrame);
+ return calcLinerInterpolationValue<T>(blending , prevObj , nextObj);
+ }
+
+ } //namespace mof
+
+
-#include "mof/Interpreter.hpp"\r
-#include "mof/private/Interpreter.hpp"\r
-#include "mof/private/regist.hpp"\r
-#include "mof/EventScheduler.hpp"\r
-#include "mof/OnceEventCondition.hpp"\r
-#include "mof/InputReceiver.hpp"\r
-#include "mof/MessageWidget.hpp"\r
-#include "mof/LuaScript.hpp"\r
-#include "mof/KeyPressedEventCondition.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/utilities.hpp"\r
-#include <boost/bind.hpp>\r
- \r
-typedef boost::shared_ptr< mof::MessageWidget > MessageWidgetHandler;\r
-\r
-//{{{ \83\82\83W\83\85\81[\83\8b\95Ï\90\94\r
-namespace\r
-{\r
- \r
- std::vector<MessageWidgetHandler> m_messages;\r
- mof::EventScheduler m_scheduler;\r
- mof::LuaScript* m_pLua;\r
- boost::shared_ptr<mof::InputReceiver> m_pInput;\r
- mof::InstructionSet* m_pInstructionSet;\r
- mof::Interpreter::State m_state;\r
-} // namepsace \r
-//}}}\r
-namespace mof\r
-{\r
-//{{{ _setState\r
- void _setState( Interpreter::State state )\r
- {\r
- m_state = state;\r
- /*switch( m_state )\r
- {\r
- case mof::Interpreter::WAITING : \r
- throw std::runtime_error("waiting on taskFinished");//\82±\82±\82É\97\88\82é\82±\82Æ\82Í\82 \82è\82¦\82È\82¢\r
- break;\r
- case mof::Interpreter::RUNNING :\r
- m_state = mof::Interpreter::WAITING;\r
- break;\r
- case mof::Interpreter::BUSY :\r
- m_state = mof::Interpreter::RUNNING;\r
- mof::Interpreter::doNextCommand();\r
- break;\r
- case mof::Interpreter::FREE :\r
- throw std::runtime_error("waiting on taskFinished");//\82±\82±\82É\97\88\82é\82±\82Æ\82Í\82 \82è\82¦\82È\82¢\r
- break;\r
- }*/\r
- }\r
-//}}} \r
-//{{{ _createMessageWidget \r
- int Interpreter::_createMessageWidget()\r
- {\r
- m_messages.push_back( m_pInstructionSet->createMessageWidget( ) );\r
- return m_messages.size() -1;\r
- }\r
-//}}}\r
-//{{{ _addMessageWidgetPage \r
- int Interpreter::_addMessageWidgetPage\r
- ( \r
- int id ,\r
- const mof::tstring& title ,\r
- const mof::tstring& text \r
- )\r
- {\r
- int frame = m_pInstructionSet->addMessageWidgetPage( m_messages.at(id) , title , text ) ;\r
- m_messages.at(id)->nextPage();\r
- return frame;\r
- }\r
-//}}}\r
-//{{{ _hideMessageWidget\r
- int Interpreter::_hideMessageWidget( int id ){\r
- m_messages.at( id )->close();\r
- return 10;\r
- }\r
-//}}}\r
-//{{{ _waitKey\r
- void Interpreter::_waitKey( const mof::tstring& keystring ){\r
- mof::InputReceiver::Key key;\r
- if( keystring == "z" || keystring == "Z")key = mof::InputReceiver::Z;\r
- else return;\r
-\r
- m_scheduler.addEvent\r
- (\r
- new mof::OnceEventCondition( new mof::KeyPressedEventCondition( key , m_pInput ) ) , \r
- boost::bind( &mof::_setState , mof::Interpreter::WAITING )\r
- );\r
- _setState( mof::Interpreter::RUNNING );\r
- }\r
-//}}}\r
-//{{{ _waitFrame\r
- void Interpreter::_waitFrame( int frame ){\r
- m_scheduler.addEvent\r
- (\r
- frame , \r
- boost::bind( &mof::_setState , mof::Interpreter::WAITING )\r
- );\r
- _setState( mof::Interpreter::RUNNING );\r
- }\r
-//}}}\r
-//{{{ initialize \r
- void Interpreter::initialize\r
- ( \r
- const boost::shared_ptr<mof::InputReceiver>& pInput ,\r
- InstructionSet& implementation \r
- )\r
- {\r
- m_pLua = NULL;\r
- m_pInput = pInput;\r
- m_pInstructionSet = &implementation;\r
- m_state = WAITING;\r
- \r
- }\r
-//}}} \r
-//{{{ finalize\r
- void Interpreter::finalize() \r
- {\r
- mof::safe_delete( m_pLua );\r
- } \r
-//}}} \r
-//{{{ getState\r
- Interpreter::State Interpreter::getState( ) \r
- {\r
- return m_state;\r
- }\r
-//}}}\r
-//{{{ doNextCommand\r
- void Interpreter::doNextCommand( )\r
- {\r
- switch( m_state )\r
- {\r
- case WAITING : \r
- m_pLua->nextCommand();\r
- break;\r
- case RUNNING :\r
- m_state = BUSY;\r
- break;\r
- case BUSY :\r
- break;\r
- case FREE :\r
- break;\r
- }\r
- }\r
-//}}} \r
-//{{{ open \r
- void Interpreter::open( const tstring& filename )\r
- {\r
- if( !m_pLua )m_pLua = new LuaScript(filename);\r
- //---\8aÖ\90\94\82Ì\8a\84\82è\93\96\82Ä\r
- mof::regist::registMessage( m_pLua->getLuaState() );\r
- mof::regist::registWait( m_pLua->getLuaState() );\r
- }\r
-//}}}\r
-//{{{ update\r
- void Interpreter::update()\r
- {\r
- \r
- m_scheduler.update();\r
-\r
- foreach( MessageWidgetHandler& handler , m_messages )\r
- {\r
- if( handler.get() )handler->update();\r
- }\r
- }\r
-//}}} \r
-} //namespace mof\r
+#include "mof/Interpreter.hpp"
+#include "mof/private/Interpreter.hpp"
+#include "mof/private/regist.hpp"
+#include "mof/EventScheduler.hpp"
+#include "mof/OnceEventCondition.hpp"
+#include "mof/InputReceiver.hpp"
+#include "mof/MessageWidget.hpp"
+#include "mof/LuaScript.hpp"
+#include "mof/KeyPressedEventCondition.hpp"
+#include "mof/ConsoleIO.hpp"
+#include "mof/utilities.hpp"
+#include <boost/bind.hpp>
+
+typedef boost::shared_ptr< mof::MessageWidget > MessageWidgetHandler;
+
+//{{{ \83\82\83W\83\85\81[\83\8b\95Ï\90\94
+namespace
+{
+
+ std::vector<MessageWidgetHandler> m_messages;
+ mof::EventScheduler m_scheduler;
+ mof::LuaScript* m_pLua;
+ boost::shared_ptr<mof::InputReceiver> m_pInput;
+ mof::InstructionSet* m_pInstructionSet;
+ mof::Interpreter::State m_state;
+} // namepsace
+//}}}
+namespace mof
+{
+//{{{ _setState
+ void _setState( Interpreter::State state )
+ {
+ m_state = state;
+ /*switch( m_state )
+ {
+ case mof::Interpreter::WAITING :
+ throw std::runtime_error("waiting on taskFinished");//\82±\82±\82É\97\88\82é\82±\82Æ\82Í\82 \82è\82¦\82È\82¢
+ break;
+ case mof::Interpreter::RUNNING :
+ m_state = mof::Interpreter::WAITING;
+ break;
+ case mof::Interpreter::BUSY :
+ m_state = mof::Interpreter::RUNNING;
+ mof::Interpreter::doNextCommand();
+ break;
+ case mof::Interpreter::FREE :
+ throw std::runtime_error("waiting on taskFinished");//\82±\82±\82É\97\88\82é\82±\82Æ\82Í\82 \82è\82¦\82È\82¢
+ break;
+ }*/
+ }
+//}}}
+//{{{ _createMessageWidget
+ int Interpreter::_createMessageWidget()
+ {
+ m_messages.push_back( m_pInstructionSet->createMessageWidget( ) );
+ return m_messages.size() -1;
+ }
+//}}}
+//{{{ _addMessageWidgetPage
+ int Interpreter::_addMessageWidgetPage
+ (
+ int id ,
+ const mof::tstring& title ,
+ const mof::tstring& text
+ )
+ {
+ int frame = m_pInstructionSet->addMessageWidgetPage( m_messages.at(id) , title , text ) ;
+ m_messages.at(id)->nextPage();
+ return frame;
+ }
+//}}}
+//{{{ _hideMessageWidget
+ int Interpreter::_hideMessageWidget( int id ){
+ m_messages.at( id )->close();
+ return 10;
+ }
+//}}}
+//{{{ _waitKey
+ void Interpreter::_waitKey( const mof::tstring& keystring ){
+ mof::InputReceiver::Key key;
+ if( keystring == "z" || keystring == "Z")key = mof::InputReceiver::Z;
+ else return;
+
+ m_scheduler.addEvent
+ (
+ new mof::OnceEventCondition( new mof::KeyPressedEventCondition( key , m_pInput ) ) ,
+ boost::bind( &mof::_setState , mof::Interpreter::WAITING )
+ );
+ _setState( mof::Interpreter::RUNNING );
+ }
+//}}}
+//{{{ _waitFrame
+ void Interpreter::_waitFrame( int frame ){
+ m_scheduler.addEvent
+ (
+ frame ,
+ boost::bind( &mof::_setState , mof::Interpreter::WAITING )
+ );
+ _setState( mof::Interpreter::RUNNING );
+ }
+//}}}
+//{{{ initialize
+ void Interpreter::initialize
+ (
+ const boost::shared_ptr<mof::InputReceiver>& pInput ,
+ InstructionSet& implementation
+ )
+ {
+ m_pLua = NULL;
+ m_pInput = pInput;
+ m_pInstructionSet = &implementation;
+ m_state = WAITING;
+
+ }
+//}}}
+//{{{ finalize
+ void Interpreter::finalize()
+ {
+ mof::safe_delete( m_pLua );
+ }
+//}}}
+//{{{ getState
+ Interpreter::State Interpreter::getState( )
+ {
+ return m_state;
+ }
+//}}}
+//{{{ doNextCommand
+ void Interpreter::doNextCommand( )
+ {
+ switch( m_state )
+ {
+ case WAITING :
+ m_pLua->nextCommand();
+ break;
+ case RUNNING :
+ m_state = BUSY;
+ break;
+ case BUSY :
+ break;
+ case FREE :
+ break;
+ }
+ }
+//}}}
+//{{{ open
+ void Interpreter::open( const tstring& filename )
+ {
+ if( !m_pLua )m_pLua = new LuaScript(filename);
+ //---\8aÖ\90\94\82Ì\8a\84\82è\93\96\82Ä
+ mof::regist::registMessage( m_pLua->getLuaState() );
+ mof::regist::registWait( m_pLua->getLuaState() );
+ }
+//}}}
+//{{{ update
+ void Interpreter::update()
+ {
+
+ m_scheduler.update();
+
+ foreach( MessageWidgetHandler& handler , m_messages )
+ {
+ if( handler.get() )handler->update();
+ }
+ }
+//}}}
+} //namespace mof
-#pragma once\r
-#include "mof/InstructionSet.hpp"\r
-\r
-namespace mof\r
-{\r
- class InputReceiver;\r
- \r
- namespace Interpreter\r
- {\r
- enum State\r
- {\r
- WAITING , /** doNextCommand\82Å\8e\9f\82Ì\83R\83}\83\93\83h\82ð\89ð\90Í\82·\82é */\r
- BUSY , /** \83R\83}\83\93\83h\82ð\8f\88\97\9d\92\86(doNextCommand\82Í\8cÄ\82Î\82ê\82Ä\82¢\82é) */\r
- RUNNING , /** \83R\83}\83\93\83h\82ð\8f\88\97\9d\92\86(doNextCommand\82Í\8cÄ\82Î\82ê\82Ä\82¢\82È\82¢) */\r
- FREE /** \83X\83N\83\8a\83v\83g\82ð\8dÅ\8cã\82Ü\82Å\8f\88\97\9d\82µ\82½ */\r
- };\r
- \r
- /**\r
- * @note \88ø\90\94\82Å\93n\82µ\82½\93ü\97Í\83\8c\83V\81[\83o\82É\82æ\82Á\82Ä\81A\83R\83}\83\93\83h\82Ì\8f\88\97\9d\82ª\8ds\82í\82ê\82é\r
- * @param[in] \83R\83}\83\93\83h\8f\88\97\9d\97p\83C\83\93\83v\83b\83g\83\8c\83V\81[\83o\r
- * @param[in] \96½\97ß\82Ì\8eÀ\91\95\r
- */\r
- void initialize\r
- ( \r
- const boost::shared_ptr<InputReceiver> & pInput ,\r
- InstructionSet& implementation\r
- );\r
-\r
- void finalize( );\r
- \r
- \r
- /**\r
- * @brief \82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82É\82æ\82è\89ð\90Í\82³\82ê\82é\83X\83N\83\8a\83v\83g\82ð\92Ç\89Á\82·\82é\r
- * @param[in] \83X\83N\83\8a\83v\83g\83t\83@\83C\83\8b\96¼\r
- */\r
- void open( const tstring& filename );\r
- \r
- /**\r
- * @brief \8c»\8dÝ\82Ì\83C\83\93\83^\83v\83\8a\83^\82Ì\8fó\91Ô\82ð\93¾\82é\r
- * @return \8c»\8dÝ\82Ì\8fó\91Ô\r
- */\r
- State getState();\r
- \r
- /**\r
- * @brief \83R\83}\83\93\83h\82Ì\8f\88\97\9d\82ð\8ds\82¤\r
- * @note create\8cn\83\81\83\\83b\83h\82Å\90¶\90¬\82³\82ê\82½\83\8a\83\\81[\83X\82Ì\8dX\90V\83\81\83\\83b\83h\82ª\8cÄ\82Î\82ê\82é\81B\r
- * @note \82½\82¾\82µ\81Ainactive\8cn\83\81\83\\83b\83h\82Å\93n\82³\82ê\82½\83\8a\83\\81[\83X\82É\82Â\82¢\82Ä\82Í\82±\82Ì\8cÀ\82è\82Å\82È\82¢\81B\r
- */\r
- void update();\r
- \r
- /**\r
- * @brief \83C\83\93\83^\83v\83\8a\83^\82É\8e\9f\82Ì\83R\83}\83\93\83h\82Ì\8eÀ\8ds\82ð\91£\82·\r
- * @note \83C\83\93\83^\83v\83\8a\83^\82ªWAITING\8fó\91Ô\82Ì\8fê\8d\87\81A\92¼\82¿\82É\8e\9f\82Ì\83R\83}\83\93\83h\82ª\89ð\90Í\82³\82ê\82é\81BRUNNING\81ABUSY\8fó\91Ô\r
- * @note \82Ì\8fê\8d\87\82Íupdate\8cÄ\82Ñ\8fo\82µ\82É\82æ\82è\83C\83\93\83^\83v\83\8a\83^\82ª\8c»\8dÝ\82Ì\83R\83}\83\93\83h\82Ì\8f\88\97\9d\82ð\8a®\97¹\82µ\82½\8cã\82Å\8e\9f\82Ì\r
- * @note \89ð\90Í\82ª\8aJ\8en\82³\82ê\82é\81B\r
- */\r
- void doNextCommand();\r
- \r
- \r
- };\r
-\r
-}\r
-\r
+#pragma once
+#include "mof/InstructionSet.hpp"
+
+namespace mof
+{
+ class InputReceiver;
+
+ namespace Interpreter
+ {
+ enum State
+ {
+ WAITING , /** doNextCommand\82Å\8e\9f\82Ì\83R\83}\83\93\83h\82ð\89ð\90Í\82·\82é */
+ BUSY , /** \83R\83}\83\93\83h\82ð\8f\88\97\9d\92\86(doNextCommand\82Í\8cÄ\82Î\82ê\82Ä\82¢\82é) */
+ RUNNING , /** \83R\83}\83\93\83h\82ð\8f\88\97\9d\92\86(doNextCommand\82Í\8cÄ\82Î\82ê\82Ä\82¢\82È\82¢) */
+ FREE /** \83X\83N\83\8a\83v\83g\82ð\8dÅ\8cã\82Ü\82Å\8f\88\97\9d\82µ\82½ */
+ };
+
+ /**
+ * @note \88ø\90\94\82Å\93n\82µ\82½\93ü\97Í\83\8c\83V\81[\83o\82É\82æ\82Á\82Ä\81A\83R\83}\83\93\83h\82Ì\8f\88\97\9d\82ª\8ds\82í\82ê\82é
+ * @param[in] \83R\83}\83\93\83h\8f\88\97\9d\97p\83C\83\93\83v\83b\83g\83\8c\83V\81[\83o
+ * @param[in] \96½\97ß\82Ì\8eÀ\91\95
+ */
+ void initialize
+ (
+ const boost::shared_ptr<InputReceiver> & pInput ,
+ InstructionSet& implementation
+ );
+
+ void finalize( );
+
+
+ /**
+ * @brief \82±\82Ì\83N\83\89\83X\82Ì\83I\83u\83W\83F\83N\83g\82É\82æ\82è\89ð\90Í\82³\82ê\82é\83X\83N\83\8a\83v\83g\82ð\92Ç\89Á\82·\82é
+ * @param[in] \83X\83N\83\8a\83v\83g\83t\83@\83C\83\8b\96¼
+ */
+ void open( const tstring& filename );
+
+ /**
+ * @brief \8c»\8dÝ\82Ì\83C\83\93\83^\83v\83\8a\83^\82Ì\8fó\91Ô\82ð\93¾\82é
+ * @return \8c»\8dÝ\82Ì\8fó\91Ô
+ */
+ State getState();
+
+ /**
+ * @brief \83R\83}\83\93\83h\82Ì\8f\88\97\9d\82ð\8ds\82¤
+ * @note create\8cn\83\81\83\\83b\83h\82Å\90¶\90¬\82³\82ê\82½\83\8a\83\\81[\83X\82Ì\8dX\90V\83\81\83\\83b\83h\82ª\8cÄ\82Î\82ê\82é\81B
+ * @note \82½\82¾\82µ\81Ainactive\8cn\83\81\83\\83b\83h\82Å\93n\82³\82ê\82½\83\8a\83\\81[\83X\82É\82Â\82¢\82Ä\82Í\82±\82Ì\8cÀ\82è\82Å\82È\82¢\81B
+ */
+ void update();
+
+ /**
+ * @brief \83C\83\93\83^\83v\83\8a\83^\82É\8e\9f\82Ì\83R\83}\83\93\83h\82Ì\8eÀ\8ds\82ð\91£\82·
+ * @note \83C\83\93\83^\83v\83\8a\83^\82ªWAITING\8fó\91Ô\82Ì\8fê\8d\87\81A\92¼\82¿\82É\8e\9f\82Ì\83R\83}\83\93\83h\82ª\89ð\90Í\82³\82ê\82é\81BRUNNING\81ABUSY\8fó\91Ô
+ * @note \82Ì\8fê\8d\87\82Íupdate\8cÄ\82Ñ\8fo\82µ\82É\82æ\82è\83C\83\93\83^\83v\83\8a\83^\82ª\8c»\8dÝ\82Ì\83R\83}\83\93\83h\82Ì\8f\88\97\9d\82ð\8a®\97¹\82µ\82½\8cã\82Å\8e\9f\82Ì
+ * @note \89ð\90Í\82ª\8aJ\8en\82³\82ê\82é\81B
+ */
+ void doNextCommand();
+
+
+ };
+
+}
+
-#include "mof/KeyPressedEventCondition.hpp"\r
-\r
-mof::KeyPressedEventCondition::KeyPressedEventCondition\r
-(\r
- mof::InputReceiver::Key key, \r
- const boost::shared_ptr<mof::InputReceiver> &pInputReceiver \r
-)\r
-: m_key(key) , m_pInputReceiver(pInputReceiver) , m_currentState(false) \r
-{\r
- update();\r
-}\r
-\r
-mof::KeyPressedEventCondition::~KeyPressedEventCondition(){\r
-}\r
-\r
-bool mof::KeyPressedEventCondition::test(){\r
- return m_oldState == false && m_currentState == true ;\r
-}\r
-\r
-void mof::KeyPressedEventCondition::update(){\r
- m_oldState = m_currentState;\r
- m_currentState = m_pInputReceiver->testKeyState(m_key);\r
-}\r
-\r
-bool mof::KeyPressedEventCondition::isDisposable(){\r
- return false;\r
-}\r
-\r
-\r
+#include "mof/KeyPressedEventCondition.hpp"
+
+mof::KeyPressedEventCondition::KeyPressedEventCondition
+(
+ mof::InputReceiver::Key key,
+ const boost::shared_ptr<mof::InputReceiver> &pInputReceiver
+)
+: m_key(key) , m_pInputReceiver(pInputReceiver) , m_currentState(false)
+{
+ update();
+}
+
+mof::KeyPressedEventCondition::~KeyPressedEventCondition(){
+}
+
+bool mof::KeyPressedEventCondition::test(){
+ return m_oldState == false && m_currentState == true ;
+}
+
+void mof::KeyPressedEventCondition::update(){
+ m_oldState = m_currentState;
+ m_currentState = m_pInputReceiver->testKeyState(m_key);
+}
+
+bool mof::KeyPressedEventCondition::isDisposable(){
+ return false;
+}
+
+
-#pragma once\r
-#include "mof/EventCondition.hpp"\r
-#include "mof/InputReceiver.hpp"\r
-#include "boost/shared_ptr.hpp"\r
-\r
-namespace mof{\r
-\r
-\r
- class KeyPressedEventCondition : public EventCondition{\r
- mof::InputReceiver::Key m_key;\r
- boost::shared_ptr<mof::InputReceiver> m_pInputReceiver;\r
- bool m_oldState;\r
- bool m_currentState;\r
- public:\r
- KeyPressedEventCondition\r
- (\r
- mof::InputReceiver::Key key , \r
- const boost::shared_ptr<mof::InputReceiver>& pInputReceiver \r
- );\r
-\r
- virtual ~KeyPressedEventCondition();\r
- virtual bool test();\r
- virtual void update();\r
- virtual bool isDisposable();\r
- };\r
-\r
-\r
-}\r
-\r
+#pragma once
+#include "mof/EventCondition.hpp"
+#include "mof/InputReceiver.hpp"
+#include "boost/shared_ptr.hpp"
+
+namespace mof{
+
+
+ class KeyPressedEventCondition : public EventCondition{
+ mof::InputReceiver::Key m_key;
+ boost::shared_ptr<mof::InputReceiver> m_pInputReceiver;
+ bool m_oldState;
+ bool m_currentState;
+ public:
+ KeyPressedEventCondition
+ (
+ mof::InputReceiver::Key key ,
+ const boost::shared_ptr<mof::InputReceiver>& pInputReceiver
+ );
+
+ virtual ~KeyPressedEventCondition();
+ virtual bool test();
+ virtual void update();
+ virtual bool isDisposable();
+ };
+
+
+}
+
-#include "mof/Light.hpp"\r
-#include "mof/Constant.hpp"\r
-\r
-mof::Light::Light()\r
-: m_diffuseColor(mof::makeConstantHandler(mof::Color4f(1 , 1 , 1))) , m_frame(0){\r
- \r
-}\r
-\r
-\r
-mof::Light::~Light(){\r
-}\r
-\r
-void mof::Light::setDiffuseColor(mof::Color4f color){\r
- mof::Animation<mof::Color4f>::Handler f = mof::makeConstantHandler(color);\r
- setDiffuseColor(f);\r
-}\r
-\r
-void mof::Light::setDiffuseColor(const mof::Animation<mof::Color4f>::Handler& f){\r
- m_diffuseColor = f;\r
- m_frame = 0;\r
-}\r
-\r
+#include "mof/Light.hpp"
+#include "mof/Constant.hpp"
+
+mof::Light::Light()
+: m_diffuseColor(mof::makeConstantHandler(mof::Color4f(1 , 1 , 1))) , m_frame(0){
+
+}
+
+
+mof::Light::~Light(){
+}
+
+void mof::Light::setDiffuseColor(mof::Color4f color){
+ mof::Animation<mof::Color4f>::Handler f = mof::makeConstantHandler(color);
+ setDiffuseColor(f);
+}
+
+void mof::Light::setDiffuseColor(const mof::Animation<mof::Color4f>::Handler& f){
+ m_diffuseColor = f;
+ m_frame = 0;
+}
+
-#ifndef MOF_ANIMATION\r
-#define MOF_ANIMATION\r
-#include <boost/utility.hpp>\r
-#include "mof/Color.hpp"\r
-\r
-namespace mof{\r
-\r
-class Light : public boost::noncopyable{\r
- \r
-protected:\r
- mof::Manipulator<mof::Color4f>::Handler m_diffuseColor;\r
- FrameNumber m_frame;\r
-public:\r
- Light();\r
- virtual ~Light();\r
- void setDiffuseColor(mof::Color4f color);\r
- void setDiffuseColor(const Manipulator<mof::Color4f>::Handler& f);\r
-\r
- virtual void setEnable(bool enable) = 0;\r
-\r
-};\r
-\r
-};\r
-\r
-#endif\r
+#ifndef MOF_ANIMATION
+#define MOF_ANIMATION
+#include <boost/utility.hpp>
+#include "mof/Color.hpp"
+
+namespace mof{
+
+class Light : public boost::noncopyable{
+
+protected:
+ mof::Manipulator<mof::Color4f>::Handler m_diffuseColor;
+ FrameNumber m_frame;
+public:
+ Light();
+ virtual ~Light();
+ void setDiffuseColor(mof::Color4f color);
+ void setDiffuseColor(const Manipulator<mof::Color4f>::Handler& f);
+
+ virtual void setEnable(bool enable) = 0;
+
+};
+
+};
+
+#endif
-#include "Line3D.h"\r
-\r
-mof::Line3D::Line3D(float beginX , float beginY , float beginZ , float endX , float endY , float endZ)\r
-{\r
- m_begin = mof::Vector3D(beginX , beginY , beginZ);\r
- m_end = mof::Vector3D(endX , endY , endZ);\r
-}\r
-\r
-\r
-mof::Line3D::Line3D(mof::Vector3D& begin , mof::Vector3D& end){\r
- m_begin = begin;\r
- m_end = end;\r
-}\r
-\r
-mof::Line3D::~Line3D(void)\r
-{\r
-}\r
-\r
- \r
-\r
+#include "Line3D.h"
+
+mof::Line3D::Line3D(float beginX , float beginY , float beginZ , float endX , float endY , float endZ)
+{
+ m_begin = mof::Vector3D(beginX , beginY , beginZ);
+ m_end = mof::Vector3D(endX , endY , endZ);
+}
+
+
+mof::Line3D::Line3D(mof::Vector3D& begin , mof::Vector3D& end){
+ m_begin = begin;
+ m_end = end;
+}
+
+mof::Line3D::~Line3D(void)
+{
+}
+
+
+
-#pragma once\r
-#include "mof/Vector3D.h"\r
-\r
-namespace mof{\r
- class Line3D\r
- {\r
-\r
- mof::Vector3D m_begin;\r
- mof::Vector3D m_end;\r
- public:\r
- Line3D(float beginX , float beginY , float beginZ , float endX , float endY , float endZ);\r
- Line3D(mof::Vector3D& begin , mof::Vector3D& end);\r
- ~Line3D(void);\r
-\r
- mof::Vector3D& getBegin(){return m_begin;}\r
- mof::Vector3D& getEnd(){return m_end;}\r
-\r
- \r
- };\r
-\r
-\r
+#pragma once
+#include "mof/Vector3D.h"
+
+namespace mof{
+ class Line3D
+ {
+
+ mof::Vector3D m_begin;
+ mof::Vector3D m_end;
+ public:
+ Line3D(float beginX , float beginY , float beginZ , float endX , float endY , float endZ);
+ Line3D(mof::Vector3D& begin , mof::Vector3D& end);
+ ~Line3D(void);
+
+ mof::Vector3D& getBegin(){return m_begin;}
+ mof::Vector3D& getEnd(){return m_end;}
+
+
+ };
+
+
};
\ No newline at end of file
-#include "mof/LoggedInputReceiver.hpp"\r
-#include "mof/InputDevice.hpp"\r
-\r
-mof::LoggedInputReceiver::LoggedInputReceiver(TCHAR* filename )\r
-: mof::InputReceiver() , m_log(filename){\r
-}\r
-\r
-mof::LoggedInputReceiver::~LoggedInputReceiver(){\r
- \r
-}\r
-\r
-bool mof::LoggedInputReceiver::testKeyState(mof::InputReceiver::Key){\r
- bool result = false;\r
- m_log >> result;\r
- return result;\r
- \r
-}\r
-\r
-void mof::LoggedInputReceiver::update(){\r
-}\r
-\r
+#include "mof/LoggedInputReceiver.hpp"
+#include "mof/InputDevice.hpp"
+
+mof::LoggedInputReceiver::LoggedInputReceiver(TCHAR* filename )
+: mof::InputReceiver() , m_log(filename){
+}
+
+mof::LoggedInputReceiver::~LoggedInputReceiver(){
+
+}
+
+bool mof::LoggedInputReceiver::testKeyState(mof::InputReceiver::Key){
+ bool result = false;
+ m_log >> result;
+ return result;
+
+}
+
+void mof::LoggedInputReceiver::update(){
+}
+
-#pragma once\r
-#include "mof/InputReceiver.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <fstream>\r
-\r
-\r
-\r
-namespace mof{\r
- \r
-\r
- class LoggedInputReceiver : public InputReceiver\r
- {\r
- std::ifstream m_log;\r
- \r
- public:\r
- \r
- LoggedInputReceiver(TCHAR* filename );\r
- virtual ~LoggedInputReceiver();\r
- virtual bool testKeyState(mof::InputReceiver::Key key);\r
- virtual void update();\r
- \r
- };\r
-\r
-};\r
+#pragma once
+#include "mof/InputReceiver.hpp"
+#include "mof/tstring.hpp"
+#include <fstream>
+
+
+
+namespace mof{
+
+
+ class LoggedInputReceiver : public InputReceiver
+ {
+ std::ifstream m_log;
+
+ public:
+
+ LoggedInputReceiver(TCHAR* filename );
+ virtual ~LoggedInputReceiver();
+ virtual bool testKeyState(mof::InputReceiver::Key key);
+ virtual void update();
+
+ };
+
+};
-#include "mof/LoggingInputReceiver.hpp"\r
-#include "mof/InputDevice.hpp"\r
-#include <fstream>\r
-\r
-\r
-mof::LoggingInputReceiver::LoggingInputReceiver(TCHAR* filename )\r
-: m_filename(filename){\r
-}\r
-\r
-mof::LoggingInputReceiver::~LoggingInputReceiver(){\r
- output();\r
-}\r
-\r
-bool mof::LoggingInputReceiver::testKeyState(mof::InputReceiver::Key key){\r
- bool result = mof::InputDevice::getInputReceiver()->testKeyState(key);\r
- m_log.push_back(result);\r
- return result;\r
- \r
-}\r
-\r
-void mof::LoggingInputReceiver::update(){\r
- mof::InputDevice::getInputReceiver()->update();\r
-}\r
-\r
-\r
-\r
-void mof::LoggingInputReceiver::output(){\r
- std::ofstream ofs( m_filename.c_str() );\r
- for(std::list<bool>::iterator itr = m_log.begin() ; itr != m_log.end() ; ++itr){\r
- ofs << *itr << std::endl;\r
- }\r
-\r
+#include "mof/LoggingInputReceiver.hpp"
+#include "mof/InputDevice.hpp"
+#include <fstream>
+
+
+mof::LoggingInputReceiver::LoggingInputReceiver(TCHAR* filename )
+: m_filename(filename){
+}
+
+mof::LoggingInputReceiver::~LoggingInputReceiver(){
+ output();
+}
+
+bool mof::LoggingInputReceiver::testKeyState(mof::InputReceiver::Key key){
+ bool result = mof::InputDevice::getInputReceiver()->testKeyState(key);
+ m_log.push_back(result);
+ return result;
+
+}
+
+void mof::LoggingInputReceiver::update(){
+ mof::InputDevice::getInputReceiver()->update();
+}
+
+
+
+void mof::LoggingInputReceiver::output(){
+ std::ofstream ofs( m_filename.c_str() );
+ for(std::list<bool>::iterator itr = m_log.begin() ; itr != m_log.end() ; ++itr){
+ ofs << *itr << std::endl;
+ }
+
}
\ No newline at end of file
-#pragma once\r
-#include "mof/InputReceiver.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <list>\r
-\r
-namespace mof{\r
- \r
-\r
- class LoggingInputReceiver : public InputReceiver\r
- {\r
- std::list<bool> m_log;\r
- mof::tstring m_filename;\r
- public:\r
- \r
- LoggingInputReceiver(TCHAR* filename );\r
- virtual ~LoggingInputReceiver();\r
- virtual bool testKeyState(Key key);\r
- virtual void update();\r
- void output();\r
- };\r
-\r
-};\r
+#pragma once
+#include "mof/InputReceiver.hpp"
+#include "mof/tstring.hpp"
+#include <list>
+
+namespace mof{
+
+
+ class LoggingInputReceiver : public InputReceiver
+ {
+ std::list<bool> m_log;
+ mof::tstring m_filename;
+ public:
+
+ LoggingInputReceiver(TCHAR* filename );
+ virtual ~LoggingInputReceiver();
+ virtual bool testKeyState(Key key);
+ virtual void update();
+ void output();
+ };
+
+};
-#include "mof/LuaScript.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include <lua.hpp>\r
-#include "luabind/luabind.hpp"\r
-#include "mof/utilities.hpp"\r
-\r
-\r
-struct mof::LuaScript::Impl{\r
- lua_State *l;\r
- lua_State *co;\r
-\r
-\r
-\r
- Impl()\r
- : l(NULL) \r
- {\r
- }\r
-\r
- ~Impl(){\r
- if(l)lua_close(l);\r
- }\r
- \r
- \r
-\r
-};\r
-\r
-\r
-\r
-mof::LuaScript::LuaScript(const mof::tstring& filename )\r
-: m_pImpl(new Impl()){\r
- m_pImpl->l = lua_open();\r
- luaL_openlibs(m_pImpl->l);\r
- luabind::open(m_pImpl->l);\r
-\r
- \r
- \r
- \r
- \r
- int error = luaL_dofile(m_pImpl->l , filename.c_str());\r
- //error = luaL_dofile(m_pImpl->l , "script/test2.lua");\r
- if(error){\r
- DEBUG_PRINT(_T("ERROR-") << lua_tostring(m_pImpl->l , -1));\r
- throw std::runtime_error("Failed --- start lua script");\r
- }\r
- m_pImpl->co = lua_newthread(m_pImpl->l);\r
- if(!m_pImpl->co){\r
- DEBUG_PRINT(_T("ERROR-Failed lua_newthread") );\r
- throw std::runtime_error("Failed --- start lua script");\r
- }\r
- lua_getglobal(m_pImpl->co , "main");\r
- \r
-}\r
-\r
-mof::LuaScript::~LuaScript(){\r
-\r
-}\r
-\r
-\r
-void mof::LuaScript::nextCommand(){\r
- lua_resume(m_pImpl->co , 0);\r
- \r
-\r
-}\r
-\r
-lua_State* mof::LuaScript::getLuaState() const{\r
- return m_pImpl->l;\r
-}\r
+#include "mof/LuaScript.hpp"
+#include "mof/ConsoleIO.hpp"
+#include <lua.hpp>
+#include "luabind/luabind.hpp"
+#include "mof/utilities.hpp"
+
+
+struct mof::LuaScript::Impl{
+ lua_State *l;
+ lua_State *co;
+
+
+
+ Impl()
+ : l(NULL)
+ {
+ }
+
+ ~Impl(){
+ if(l)lua_close(l);
+ }
+
+
+
+};
+
+
+
+mof::LuaScript::LuaScript(const mof::tstring& filename )
+: m_pImpl(new Impl()){
+ m_pImpl->l = lua_open();
+ luaL_openlibs(m_pImpl->l);
+ luabind::open(m_pImpl->l);
+
+
+
+
+
+ int error = luaL_dofile(m_pImpl->l , filename.c_str());
+ //error = luaL_dofile(m_pImpl->l , "script/test2.lua");
+ if(error){
+ DEBUG_PRINT(_T("ERROR-") << lua_tostring(m_pImpl->l , -1));
+ throw std::runtime_error("Failed --- start lua script");
+ }
+ m_pImpl->co = lua_newthread(m_pImpl->l);
+ if(!m_pImpl->co){
+ DEBUG_PRINT(_T("ERROR-Failed lua_newthread") );
+ throw std::runtime_error("Failed --- start lua script");
+ }
+ lua_getglobal(m_pImpl->co , "main");
+
+}
+
+mof::LuaScript::~LuaScript(){
+
+}
+
+
+void mof::LuaScript::nextCommand(){
+ lua_resume(m_pImpl->co , 0);
+
+
+}
+
+lua_State* mof::LuaScript::getLuaState() const{
+ return m_pImpl->l;
+}
-#ifndef _LUASCRIPT_HPP\r
-#define _LUASCRIPT_HPP\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/tstring.hpp"\r
-#include <lua.hpp>\r
-\r
-namespace mof{\r
- class MessageWidget;\r
- \r
-\r
- class LuaScript{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- public :\r
- LuaScript(const mof::tstring& filename );\r
- ~LuaScript();\r
-\r
- void nextCommand();\r
- lua_State * getLuaState() const;\r
- };\r
-\r
-}\r
-\r
-\r
-#endif\r
+#ifndef _LUASCRIPT_HPP
+#define _LUASCRIPT_HPP
+#include <boost/scoped_ptr.hpp>
+#include "mof/tstring.hpp"
+#include <lua.hpp>
+
+namespace mof{
+ class MessageWidget;
+
+
+ class LuaScript{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ public :
+ LuaScript(const mof::tstring& filename );
+ ~LuaScript();
+
+ void nextCommand();
+ lua_State * getLuaState() const;
+ };
+
+}
+
+
+#endif
-#ifndef MOF_MATERIAL_HPP\r
-#define MOF_MATERIAL_HPP\r
-#include "Color.hpp"\r
-\r
-namespace mof{\r
-\r
-struct Material{\r
- mof::Color4f diffuseColor;\r
- mof::Color4f ambientColor;\r
- mof::Color4f specularColor;\r
- float power;\r
- mof::Color4f emissiveColor;\r
-\r
- Material()\r
- : ambientColor(0 , 0 , 0) , \r
- diffuseColor(0 , 0 , 0) ,\r
- specularColor(0 , 0 , 0),\r
- power(0),\r
- emissiveColor(0 , 0 , 0)\r
- {\r
- \r
- }\r
-\r
- Material(\r
- mof::Color4f ambient_ ,\r
- mof::Color4f diffuse_ ,\r
- mof::Color4f specular_ ,\r
- real power_ ,\r
- mof::Color4f emissive_\r
- )\r
- : ambientColor(ambient_) , \r
- diffuseColor(diffuse_) ,\r
- specularColor(specular_),\r
- power(power_),\r
- emissiveColor(emissive_)\r
- {\r
- \r
- }\r
-\r
-\r
-};\r
-\r
-}\r
-\r
-#endif\r
+#ifndef MOF_MATERIAL_HPP
+#define MOF_MATERIAL_HPP
+#include "Color.hpp"
+
+namespace mof{
+
+struct Material{
+ mof::Color4f diffuseColor;
+ mof::Color4f ambientColor;
+ mof::Color4f specularColor;
+ float power;
+ mof::Color4f emissiveColor;
+
+ Material()
+ : ambientColor(0 , 0 , 0) ,
+ diffuseColor(0 , 0 , 0) ,
+ specularColor(0 , 0 , 0),
+ power(0),
+ emissiveColor(0 , 0 , 0)
+ {
+
+ }
+
+ Material(
+ mof::Color4f ambient_ ,
+ mof::Color4f diffuse_ ,
+ mof::Color4f specular_ ,
+ real power_ ,
+ mof::Color4f emissive_
+ )
+ : ambientColor(ambient_) ,
+ diffuseColor(diffuse_) ,
+ specularColor(specular_),
+ power(power_),
+ emissiveColor(emissive_)
+ {
+
+ }
+
+
+};
+
+}
+
+#endif
-#include "mof/MaterialBuilder.hpp"\r
-#include "mof/Material.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include "mof/Constant.hpp"\r
-\r
-struct mof::MaterialBuilder::Impl{\r
-\r
- Impl(\r
- const mof::Animation<mof::Color4f>::Handler& ambient_ ,\r
- const mof::Animation<mof::Color4f>::Handler& diffuse_ ,\r
- const mof::Animation<mof::Color4f>::Handler& specular_ ,\r
- const mof::Animation<float>::Handler& specularPower_ ,\r
- const mof::Animation<mof::Color4f>::Handler& emissive_)\r
- : diffuse(diffuse_) , ambient(ambient_) , specular(specular_) ,\r
- specularPower(specularPower_) , emissive(emissive_) , pMaterial(NULL) , frame(0) {\r
- }\r
-\r
- ~Impl(){\r
- delete pMaterial;\r
- }\r
-\r
- mof::Material* pMaterial;\r
- FrameNumber frame;\r
- mof::Animation<mof::Color4f>::Handler diffuse;\r
- mof::Animation<mof::Color4f>::Handler ambient;\r
- mof::Animation<mof::Color4f>::Handler specular;\r
- mof::Animation<float>::Handler specularPower;\r
- mof::Animation<mof::Color4f>::Handler emissive;\r
-\r
- \r
-};\r
-\r
-\r
-\r
- \r
-mof::MaterialBuilder::MaterialBuilder( )\r
-: m_pImpl(new Impl( \r
- mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,\r
- mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,\r
- mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,\r
- mof::makeConstantHandler(0.0f) , \r
- mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) \r
- ) )\r
-{\r
- m_pImpl->pMaterial = new Material;\r
-}\r
-\r
-\r
-mof::MaterialBuilder::MaterialBuilder( mof::Color4f ambient )\r
-: m_pImpl(new Impl( \r
- mof::makeConstantHandler(ambient) ,\r
- mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,\r
- mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,\r
- mof::makeConstantHandler(0.0f) , \r
- mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ))\r
-{\r
- m_pImpl->pMaterial = new Material;\r
- construct();\r
-}\r
-\r
-\r
-mof::MaterialBuilder::MaterialBuilder( mof::Color4f ambient , mof::Color4f diffuse , \r
- mof::Color4f specular , float power , mof::Color4f emissive )\r
-: m_pImpl(new Impl(\r
- mof::makeConstantHandler(ambient) ,\r
- mof::makeConstantHandler(diffuse) ,\r
- mof::makeConstantHandler(specular) ,\r
- mof::makeConstantHandler(power) , \r
- mof::makeConstantHandler(emissive) ))\r
-{\r
- m_pImpl->pMaterial = new Material;\r
- construct();\r
-}\r
-\r
-mof::MaterialBuilder::MaterialBuilder(\r
- const mof::Animation<mof::Color4f>::Handler& ambient_ , \r
- const mof::Animation<mof::Color4f>::Handler& diffuse_ ,\r
- const mof::Animation<mof::Color4f>::Handler& specular_ ,\r
- const mof::Animation<float>::Handler& power_ ,\r
- const mof::Animation<mof::Color4f>::Handler& emissive_ )\r
-: m_pImpl(new Impl( ambient_ , diffuse_ , specular_ , power_ , emissive_ ))\r
-{\r
- m_pImpl->pMaterial = new Material;\r
- construct();\r
-}\r
-\r
-mof::MaterialBuilder::~MaterialBuilder(){\r
-}\r
-\r
-void mof::MaterialBuilder::setFrameNumber(mof::FrameNumber frame){\r
- m_pImpl->frame = frame;\r
-}\r
-\r
-void mof::MaterialBuilder::nextFrame(){\r
- setFrameNumber(m_pImpl->frame + 1 );\r
-}\r
-\r
-void mof::MaterialBuilder::prevFrame(){\r
- if(m_pImpl->frame > 0)setFrameNumber(m_pImpl->frame - 1);\r
-}\r
-\r
-\r
-\r
-mof::Color4f mof::MaterialBuilder::getDiffuseColor() const{\r
- return m_pImpl->diffuse->getValue(m_pImpl->frame);\r
-}\r
-\r
-mof::Color4f mof::MaterialBuilder::getAmbientColor() const{\r
- return m_pImpl->ambient->getValue(m_pImpl->frame);\r
-}\r
-\r
-mof::Color4f mof::MaterialBuilder::getSpecularColor() const{\r
- return m_pImpl->specular->getValue(m_pImpl->frame);\r
-}\r
-\r
-mof::Color4f mof::MaterialBuilder::getEmissiveColor() const{\r
- return m_pImpl->emissive->getValue(m_pImpl->frame);\r
-}\r
-\r
-float mof::MaterialBuilder::getSpecularPower() const{\r
- return m_pImpl->specularPower->getValue(m_pImpl->frame);\r
-}\r
-\r
-\r
-const mof::Material& mof::MaterialBuilder::construct() const{\r
- \r
- m_pImpl->pMaterial->diffuseColor = m_pImpl->diffuse->getValue(m_pImpl->frame);\r
- m_pImpl->pMaterial->ambientColor = m_pImpl->ambient->getValue(m_pImpl->frame);\r
- m_pImpl->pMaterial->specularColor = m_pImpl->specular->getValue(m_pImpl->frame);\r
- m_pImpl->pMaterial->power = m_pImpl->specularPower->getValue(m_pImpl->frame);\r
- m_pImpl->pMaterial->emissiveColor = m_pImpl->emissive->getValue(m_pImpl->frame);\r
-\r
- return *(m_pImpl->pMaterial);\r
-}\r
+#include "mof/MaterialBuilder.hpp"
+#include "mof/Material.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include "mof/Constant.hpp"
+
+struct mof::MaterialBuilder::Impl{
+
+ Impl(
+ const mof::Animation<mof::Color4f>::Handler& ambient_ ,
+ const mof::Animation<mof::Color4f>::Handler& diffuse_ ,
+ const mof::Animation<mof::Color4f>::Handler& specular_ ,
+ const mof::Animation<float>::Handler& specularPower_ ,
+ const mof::Animation<mof::Color4f>::Handler& emissive_)
+ : diffuse(diffuse_) , ambient(ambient_) , specular(specular_) ,
+ specularPower(specularPower_) , emissive(emissive_) , pMaterial(NULL) , frame(0) {
+ }
+
+ ~Impl(){
+ delete pMaterial;
+ }
+
+ mof::Material* pMaterial;
+ FrameNumber frame;
+ mof::Animation<mof::Color4f>::Handler diffuse;
+ mof::Animation<mof::Color4f>::Handler ambient;
+ mof::Animation<mof::Color4f>::Handler specular;
+ mof::Animation<float>::Handler specularPower;
+ mof::Animation<mof::Color4f>::Handler emissive;
+
+
+};
+
+
+
+
+mof::MaterialBuilder::MaterialBuilder( )
+: m_pImpl(new Impl(
+ mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,
+ mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,
+ mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,
+ mof::makeConstantHandler(0.0f) ,
+ mof::makeConstantHandler(mof::Color4f(0 , 0 , 0))
+ ) )
+{
+ m_pImpl->pMaterial = new Material;
+}
+
+
+mof::MaterialBuilder::MaterialBuilder( mof::Color4f ambient )
+: m_pImpl(new Impl(
+ mof::makeConstantHandler(ambient) ,
+ mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,
+ mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ,
+ mof::makeConstantHandler(0.0f) ,
+ mof::makeConstantHandler(mof::Color4f(0 , 0 , 0)) ))
+{
+ m_pImpl->pMaterial = new Material;
+ construct();
+}
+
+
+mof::MaterialBuilder::MaterialBuilder( mof::Color4f ambient , mof::Color4f diffuse ,
+ mof::Color4f specular , float power , mof::Color4f emissive )
+: m_pImpl(new Impl(
+ mof::makeConstantHandler(ambient) ,
+ mof::makeConstantHandler(diffuse) ,
+ mof::makeConstantHandler(specular) ,
+ mof::makeConstantHandler(power) ,
+ mof::makeConstantHandler(emissive) ))
+{
+ m_pImpl->pMaterial = new Material;
+ construct();
+}
+
+mof::MaterialBuilder::MaterialBuilder(
+ const mof::Animation<mof::Color4f>::Handler& ambient_ ,
+ const mof::Animation<mof::Color4f>::Handler& diffuse_ ,
+ const mof::Animation<mof::Color4f>::Handler& specular_ ,
+ const mof::Animation<float>::Handler& power_ ,
+ const mof::Animation<mof::Color4f>::Handler& emissive_ )
+: m_pImpl(new Impl( ambient_ , diffuse_ , specular_ , power_ , emissive_ ))
+{
+ m_pImpl->pMaterial = new Material;
+ construct();
+}
+
+mof::MaterialBuilder::~MaterialBuilder(){
+}
+
+void mof::MaterialBuilder::setFrameNumber(mof::FrameNumber frame){
+ m_pImpl->frame = frame;
+}
+
+void mof::MaterialBuilder::nextFrame(){
+ setFrameNumber(m_pImpl->frame + 1 );
+}
+
+void mof::MaterialBuilder::prevFrame(){
+ if(m_pImpl->frame > 0)setFrameNumber(m_pImpl->frame - 1);
+}
+
+
+
+mof::Color4f mof::MaterialBuilder::getDiffuseColor() const{
+ return m_pImpl->diffuse->getValue(m_pImpl->frame);
+}
+
+mof::Color4f mof::MaterialBuilder::getAmbientColor() const{
+ return m_pImpl->ambient->getValue(m_pImpl->frame);
+}
+
+mof::Color4f mof::MaterialBuilder::getSpecularColor() const{
+ return m_pImpl->specular->getValue(m_pImpl->frame);
+}
+
+mof::Color4f mof::MaterialBuilder::getEmissiveColor() const{
+ return m_pImpl->emissive->getValue(m_pImpl->frame);
+}
+
+float mof::MaterialBuilder::getSpecularPower() const{
+ return m_pImpl->specularPower->getValue(m_pImpl->frame);
+}
+
+
+const mof::Material& mof::MaterialBuilder::construct() const{
+
+ m_pImpl->pMaterial->diffuseColor = m_pImpl->diffuse->getValue(m_pImpl->frame);
+ m_pImpl->pMaterial->ambientColor = m_pImpl->ambient->getValue(m_pImpl->frame);
+ m_pImpl->pMaterial->specularColor = m_pImpl->specular->getValue(m_pImpl->frame);
+ m_pImpl->pMaterial->power = m_pImpl->specularPower->getValue(m_pImpl->frame);
+ m_pImpl->pMaterial->emissiveColor = m_pImpl->emissive->getValue(m_pImpl->frame);
+
+ return *(m_pImpl->pMaterial);
+}
-#ifndef MOF_MATERIAL_BUILDER_HPP\r
-#define MOF_MATERIAL_BUILDER_HPP\r
-\r
-#include "mof/Color.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/utility.hpp>\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-//struct _D3DMATERIAL9;\r
-//typedef _D3DMATERIAL9 D3DMATERIAL9;\r
-namespace mof{\r
-\r
-\r
-struct Material;\r
-\r
-class MaterialBuilder : boost::noncopyable{\r
-\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
-public:\r
- MaterialBuilder();\r
- MaterialBuilder( mof::Color4f ambient );\r
- MaterialBuilder( mof::Color4f ambient , mof::Color4f diffuse , mof::Color4f specular , float power , mof::Color4f emissive );\r
- MaterialBuilder\r
- (\r
- const mof::Animation<mof::Color4f>::Handler& ambient , \r
- const mof::Animation<mof::Color4f>::Handler& diffuse ,\r
- const mof::Animation<mof::Color4f>::Handler& specular ,\r
- const mof::Animation<float>::Handler& power ,\r
- const mof::Animation<mof::Color4f>::Handler& emissive \r
- );\r
- ~MaterialBuilder();\r
-\r
- void setFrameNumber(mof::FrameNumber frame);\r
- void nextFrame();\r
- void prevFrame();\r
-\r
- mof::Color4f getDiffuseColor() const;\r
- mof::Color4f getAmbientColor() const;\r
- mof::Color4f getSpecularColor() const;\r
- float getSpecularPower() const;\r
- mof::Color4f getEmissiveColor() const;\r
-\r
- const mof::Material& construct() const;\r
-};\r
-\r
-}\r
-\r
-#endif \r
+#ifndef MOF_MATERIAL_BUILDER_HPP
+#define MOF_MATERIAL_BUILDER_HPP
+
+#include "mof/Color.hpp"
+#include <boost/scoped_ptr.hpp>
+#include <boost/utility.hpp>
+#include "mof/stream/Manipulator.hpp"
+
+//struct _D3DMATERIAL9;
+//typedef _D3DMATERIAL9 D3DMATERIAL9;
+namespace mof{
+
+
+struct Material;
+
+class MaterialBuilder : boost::noncopyable{
+
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+public:
+ MaterialBuilder();
+ MaterialBuilder( mof::Color4f ambient );
+ MaterialBuilder( mof::Color4f ambient , mof::Color4f diffuse , mof::Color4f specular , float power , mof::Color4f emissive );
+ MaterialBuilder
+ (
+ const mof::Animation<mof::Color4f>::Handler& ambient ,
+ const mof::Animation<mof::Color4f>::Handler& diffuse ,
+ const mof::Animation<mof::Color4f>::Handler& specular ,
+ const mof::Animation<float>::Handler& power ,
+ const mof::Animation<mof::Color4f>::Handler& emissive
+ );
+ ~MaterialBuilder();
+
+ void setFrameNumber(mof::FrameNumber frame);
+ void nextFrame();
+ void prevFrame();
+
+ mof::Color4f getDiffuseColor() const;
+ mof::Color4f getAmbientColor() const;
+ mof::Color4f getSpecularColor() const;
+ float getSpecularPower() const;
+ mof::Color4f getEmissiveColor() const;
+
+ const mof::Material& construct() const;
+};
+
+}
+
+#endif
-#include <d3dx9.h>\r
-#include <string.h>\r
-#include "mof/Matrix2D.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-const int DIMENSION = 2;\r
-\r
-\r
-mof::Matrix2D::Matrix2D()\r
-: m_pImpl(new Array)\r
-{\r
- for(int i = 0 ; i <= DIMENSION ; ++i){\r
- for(int j = 0 ; j <= DIMENSION ; ++j){\r
- if(i == j)m_pImpl->elements[i][j] = 1;\r
- else m_pImpl->elements[i][j] = 0;\r
- }\r
- }\r
-}\r
-\r
-mof::Matrix2D::Matrix2D(const Matrix2D& obj )\r
-: m_pImpl(new Array)\r
-{\r
- *m_pImpl = *obj.m_pImpl;\r
-}\r
-\r
-mof::Matrix2D::Matrix2D(const mof::Matrix2D::Array & arr)\r
-: m_pImpl(new Array)\r
-{\r
- *m_pImpl = arr;\r
-}\r
-\r
-\r
-mof::Matrix2D::~Matrix2D(){\r
-}\r
-\r
-\r
-mof::real mof::Matrix2D::at(int row , int column) const{\r
- return m_pImpl->elements[row][column];\r
-}\r
-\r
-mof::Matrix2D::Array mof::Matrix2D::getArray() const{\r
- return *m_pImpl;\r
-}\r
-\r
-\r
-mof::Matrix2D mof::Matrix2D::createIdentity(){\r
- return mof::Matrix2D();\r
-}\r
-\r
-\r
-mof::Matrix2D mof::Matrix2D::createTransposed(mof::Matrix2D& matrix){\r
- Matrix2D transposed;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- transposed.m_pImpl->elements[j][i] = matrix.m_pImpl->elements[i][j];\r
- }\r
- }\r
- return transposed;\r
-}\r
-\r
-\r
-\r
-mof::Matrix2D mof::Matrix2D::createRotation(const mof::Vector2D& position){\r
- Matrix2D matrix;\r
- matrix.m_pImpl->elements[DIMENSION][0] = position.x;\r
- matrix.m_pImpl->elements[DIMENSION][1] = position.y;\r
- return matrix;\r
-}\r
-\r
-\r
-mof::Matrix2D mof::Matrix2D::createTranslation(const mof::Vector2D& position){\r
- Matrix2D matrix;\r
- matrix.m_pImpl->elements[DIMENSION][0] = position.x;\r
- matrix.m_pImpl->elements[DIMENSION][1] = position.y;\r
- return matrix;\r
-}\r
-\r
-mof::Matrix2D mof::Matrix2D::createScaling(const mof::Vector2D& scaling){\r
- Matrix2D matrix;\r
- matrix.m_pImpl->elements[0][0] = scaling.x;\r
- matrix.m_pImpl->elements[1][1] = scaling.y;\r
- return matrix;\r
-}\r
-\r
-\r
-mof::Vector2D mof::Matrix2D::getTranslation(const mof::Matrix2D& matrix){\r
- return mof::Vector2D(\r
- matrix.m_pImpl->elements[DIMENSION][0] ,\r
- matrix.m_pImpl->elements[DIMENSION][1]\r
- );\r
-}\r
-\r
-mof::Vector2D mof::Matrix2D::getDiagonal() const{\r
- return mof::Vector2D(\r
- m_pImpl->elements[0][0] ,\r
- m_pImpl->elements[1][1]\r
- );\r
-}\r
-\r
- \r
-mof::Matrix2D mof::Matrix2D::operator *(const mof::Matrix2D& matrix) const{\r
- mof::Matrix2D multiplied;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- mof::real sum = 0;\r
- for(int k = 0 ; k <= DIMENSION ; k++){\r
- sum += m_pImpl->elements[i][k] * matrix.m_pImpl->elements[k][j];\r
- }\r
- multiplied.m_pImpl->elements[i][j] = sum;\r
- }\r
- }\r
- return multiplied;\r
-}\r
-\r
-\r
-mof::Matrix2D mof::Matrix2D::operator +(const mof::Matrix2D& matrix) const{\r
- mof::Matrix2D result;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- result.m_pImpl->elements[i][j] = \r
- m_pImpl->elements[i][j] + matrix.m_pImpl->elements[i][j];\r
- }\r
- }\r
- return result;\r
-}\r
-\r
-\r
-mof::Matrix2D mof::Matrix2D::operator -(const mof::Matrix2D& matrix) const{\r
- mof::Matrix2D result;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- result.m_pImpl->elements[i][j] = \r
- m_pImpl->elements[i][j] - matrix.m_pImpl->elements[i][j];\r
- }\r
- }\r
- return result;\r
-}\r
-\r
-\r
-mof::Matrix2D mof::operator *(const mof::Matrix2D& matrix , mof::real f){\r
- mof::Matrix2D result;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- result.m_pImpl->elements[i][j] = \r
- matrix.m_pImpl->elements[i][j] * f;\r
- }\r
- }\r
- return result;\r
-}\r
- \r
-mof::Matrix2D mof::operator *(mof::real f , mof::Matrix2D const& matrix){\r
- return matrix * f;\r
-}\r
-\r
-\r
-mof::Vector2D mof::operator *(const mof::Vector2D& vec , const mof::Matrix2D& matrix) {\r
- mof::real input[3] = {vec.x , vec.y , 1};\r
- mof::real output[3];\r
- for(int i = 0 ; i < DIMENSION ; i++){\r
- mof::real sum = 0;\r
- for(int k = 0 ; k <= DIMENSION ; k++){\r
- sum += input[k] * matrix.at(k , i);\r
- }\r
- output[i] = sum;\r
- \r
- }\r
- return mof::Vector2D(output[0] , output[1]);\r
-}\r
-\r
-\r
-mof::Rectangle<int> mof::Matrix2D::toBoundingBox(){\r
- mof::Vector2D begin = mof::Vector2D(0 , 0) * (*this);\r
- mof::Vector2D end = mof::Vector2D(1 , 1) * (*this);\r
- return mof::Rectangle<int>( (int)begin.x , (int)begin.y , (int)end.x , (int)end.y );\r
-}\r
+#include <d3dx9.h>
+#include <string.h>
+#include "mof/Matrix2D.hpp"
+#include "mof/ConsoleIO.hpp"
+
+const int DIMENSION = 2;
+
+
+mof::Matrix2D::Matrix2D()
+: m_pImpl(new Array)
+{
+ for(int i = 0 ; i <= DIMENSION ; ++i){
+ for(int j = 0 ; j <= DIMENSION ; ++j){
+ if(i == j)m_pImpl->elements[i][j] = 1;
+ else m_pImpl->elements[i][j] = 0;
+ }
+ }
+}
+
+mof::Matrix2D::Matrix2D(const Matrix2D& obj )
+: m_pImpl(new Array)
+{
+ *m_pImpl = *obj.m_pImpl;
+}
+
+mof::Matrix2D::Matrix2D(const mof::Matrix2D::Array & arr)
+: m_pImpl(new Array)
+{
+ *m_pImpl = arr;
+}
+
+
+mof::Matrix2D::~Matrix2D(){
+}
+
+
+mof::real mof::Matrix2D::at(int row , int column) const{
+ return m_pImpl->elements[row][column];
+}
+
+mof::Matrix2D::Array mof::Matrix2D::getArray() const{
+ return *m_pImpl;
+}
+
+
+mof::Matrix2D mof::Matrix2D::createIdentity(){
+ return mof::Matrix2D();
+}
+
+
+mof::Matrix2D mof::Matrix2D::createTransposed(mof::Matrix2D& matrix){
+ Matrix2D transposed;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ transposed.m_pImpl->elements[j][i] = matrix.m_pImpl->elements[i][j];
+ }
+ }
+ return transposed;
+}
+
+
+
+mof::Matrix2D mof::Matrix2D::createRotation(const mof::Vector2D& position){
+ Matrix2D matrix;
+ matrix.m_pImpl->elements[DIMENSION][0] = position.x;
+ matrix.m_pImpl->elements[DIMENSION][1] = position.y;
+ return matrix;
+}
+
+
+mof::Matrix2D mof::Matrix2D::createTranslation(const mof::Vector2D& position){
+ Matrix2D matrix;
+ matrix.m_pImpl->elements[DIMENSION][0] = position.x;
+ matrix.m_pImpl->elements[DIMENSION][1] = position.y;
+ return matrix;
+}
+
+mof::Matrix2D mof::Matrix2D::createScaling(const mof::Vector2D& scaling){
+ Matrix2D matrix;
+ matrix.m_pImpl->elements[0][0] = scaling.x;
+ matrix.m_pImpl->elements[1][1] = scaling.y;
+ return matrix;
+}
+
+
+mof::Vector2D mof::Matrix2D::getTranslation(const mof::Matrix2D& matrix){
+ return mof::Vector2D(
+ matrix.m_pImpl->elements[DIMENSION][0] ,
+ matrix.m_pImpl->elements[DIMENSION][1]
+ );
+}
+
+mof::Vector2D mof::Matrix2D::getDiagonal() const{
+ return mof::Vector2D(
+ m_pImpl->elements[0][0] ,
+ m_pImpl->elements[1][1]
+ );
+}
+
+
+mof::Matrix2D mof::Matrix2D::operator *(const mof::Matrix2D& matrix) const{
+ mof::Matrix2D multiplied;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ mof::real sum = 0;
+ for(int k = 0 ; k <= DIMENSION ; k++){
+ sum += m_pImpl->elements[i][k] * matrix.m_pImpl->elements[k][j];
+ }
+ multiplied.m_pImpl->elements[i][j] = sum;
+ }
+ }
+ return multiplied;
+}
+
+
+mof::Matrix2D mof::Matrix2D::operator +(const mof::Matrix2D& matrix) const{
+ mof::Matrix2D result;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ result.m_pImpl->elements[i][j] =
+ m_pImpl->elements[i][j] + matrix.m_pImpl->elements[i][j];
+ }
+ }
+ return result;
+}
+
+
+mof::Matrix2D mof::Matrix2D::operator -(const mof::Matrix2D& matrix) const{
+ mof::Matrix2D result;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ result.m_pImpl->elements[i][j] =
+ m_pImpl->elements[i][j] - matrix.m_pImpl->elements[i][j];
+ }
+ }
+ return result;
+}
+
+
+mof::Matrix2D mof::operator *(const mof::Matrix2D& matrix , mof::real f){
+ mof::Matrix2D result;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ result.m_pImpl->elements[i][j] =
+ matrix.m_pImpl->elements[i][j] * f;
+ }
+ }
+ return result;
+}
+
+mof::Matrix2D mof::operator *(mof::real f , mof::Matrix2D const& matrix){
+ return matrix * f;
+}
+
+
+mof::Vector2D mof::operator *(const mof::Vector2D& vec , const mof::Matrix2D& matrix) {
+ mof::real input[3] = {vec.x , vec.y , 1};
+ mof::real output[3];
+ for(int i = 0 ; i < DIMENSION ; i++){
+ mof::real sum = 0;
+ for(int k = 0 ; k <= DIMENSION ; k++){
+ sum += input[k] * matrix.at(k , i);
+ }
+ output[i] = sum;
+
+ }
+ return mof::Vector2D(output[0] , output[1]);
+}
+
+
+mof::Rectangle<int> mof::Matrix2D::toBoundingBox(){
+ mof::Vector2D begin = mof::Vector2D(0 , 0) * (*this);
+ mof::Vector2D end = mof::Vector2D(1 , 1) * (*this);
+ return mof::Rectangle<int>( (int)begin.x , (int)begin.y , (int)end.x , (int)end.y );
+}
-#ifndef MATRIX2D_HPP\r
-#define MATRIX2D_HPP\r
-#include <mof/real.hpp>\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include <boost/shared_ptr.hpp>\r
-\r
-\r
-namespace mof{\r
- class Matrix2D{\r
- public:\r
- struct Array{\r
- real elements[3][3];\r
- };\r
- private:\r
- boost::shared_ptr<Array> m_pImpl;\r
- public:\r
- \r
- Matrix2D();\r
- Matrix2D(const Matrix2D& );\r
- explicit Matrix2D(const mof::Matrix2D::Array &);\r
- ~Matrix2D();\r
- real at(int row , int column) const;\r
- Array getArray() const;\r
-\r
- static Matrix2D createIdentity();\r
- static Matrix2D createTransposed(Matrix2D& matrix);\r
- static Matrix2D createRotation(const mof::Vector2D& angle);\r
- static Matrix2D createTranslation(const mof::Vector2D& position);\r
- static Matrix2D createScaling(const mof::Vector2D& scale);\r
- static Vector2D getTranslation(const mof::Matrix2D& matrix);\r
- Vector2D getDiagonal() const;\r
-\r
-\r
- Matrix2D operator *(const mof::Matrix2D& matrix ) const;\r
- Matrix2D operator +(const mof::Matrix2D& matrix ) const;\r
- Matrix2D operator -(const mof::Matrix2D& matrix ) const;\r
-\r
- friend Vector2D operator *(const mof::Vector2D& vec , const mof::Matrix2D& matrix);\r
- friend Matrix2D operator *(const mof::Matrix2D& matrix , real f);\r
- friend Matrix2D operator *(real f , const mof::Matrix2D & matrix);\r
-\r
- mof::Rectangle<int> toBoundingBox();\r
- \r
- \r
- };\r
-} // namespace mof\r
-\r
-\r
-#endif\r
+#ifndef MATRIX2D_HPP
+#define MATRIX2D_HPP
+#include <mof/real.hpp>
+#include "mof/Vector2D.hpp"
+#include "mof/Rectangle.hpp"
+#include <boost/shared_ptr.hpp>
+
+
+namespace mof{
+ class Matrix2D{
+ public:
+ struct Array{
+ real elements[3][3];
+ };
+ private:
+ boost::shared_ptr<Array> m_pImpl;
+ public:
+
+ Matrix2D();
+ Matrix2D(const Matrix2D& );
+ explicit Matrix2D(const mof::Matrix2D::Array &);
+ ~Matrix2D();
+ real at(int row , int column) const;
+ Array getArray() const;
+
+ static Matrix2D createIdentity();
+ static Matrix2D createTransposed(Matrix2D& matrix);
+ static Matrix2D createRotation(const mof::Vector2D& angle);
+ static Matrix2D createTranslation(const mof::Vector2D& position);
+ static Matrix2D createScaling(const mof::Vector2D& scale);
+ static Vector2D getTranslation(const mof::Matrix2D& matrix);
+ Vector2D getDiagonal() const;
+
+
+ Matrix2D operator *(const mof::Matrix2D& matrix ) const;
+ Matrix2D operator +(const mof::Matrix2D& matrix ) const;
+ Matrix2D operator -(const mof::Matrix2D& matrix ) const;
+
+ friend Vector2D operator *(const mof::Vector2D& vec , const mof::Matrix2D& matrix);
+ friend Matrix2D operator *(const mof::Matrix2D& matrix , real f);
+ friend Matrix2D operator *(real f , const mof::Matrix2D & matrix);
+
+ mof::Rectangle<int> toBoundingBox();
+
+
+ };
+} // namespace mof
+
+
+#endif
-#include <string.h>\r
-#include <iostream>\r
-#include "mof/Matrix3D.hpp"\r
-#include "mof/utilities.hpp"\r
-#include <d3dx9.h>\r
-\r
-const int DIMENSION = 3;\r
-\r
-\r
-mof::Matrix3D::Matrix3D()\r
-: m_pImpl(new Array)\r
-{\r
- for(int i = 0 ; i <= DIMENSION ; ++i){\r
- for(int j = 0 ; j <= DIMENSION ; ++j){\r
- if(i == j)m_pImpl->elements[i][j] = 1;\r
- else m_pImpl->elements[i][j] = 0;\r
- }\r
- }\r
-}\r
-\r
-mof::Matrix3D::Matrix3D(const mof::Matrix3D::Array & arr)\r
-: m_pImpl(new Array)\r
-{\r
- *m_pImpl = arr;\r
-}\r
-\r
-\r
-mof::Matrix3D::~Matrix3D(){\r
-}\r
-\r
-\r
-mof::real mof::Matrix3D::at(int row , int column) const{\r
- return m_pImpl->elements[row][column];\r
-}\r
-\r
-mof::Matrix3D::Array mof::Matrix3D::getArray() const{\r
- return *m_pImpl;\r
-}\r
-\r
-\r
-mof::Matrix3D mof::Matrix3D::createIdentity(){\r
- return mof::Matrix3D();\r
-}\r
-\r
-\r
-mof::Matrix3D mof::Matrix3D::createTransposed(const mof::Matrix3D& matrix){\r
- Matrix3D transposed;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- transposed.m_pImpl->elements[j][i] = matrix.m_pImpl->elements[i][j];\r
- }\r
- }\r
- return transposed;\r
-}\r
-\r
-\r
-mof::Matrix3D mof::Matrix3D::createRotation(const mof::Vector3D& radians){\r
- mof::real cosx = cosf(radians.x);\r
- mof::real sinx = sinf(radians.x);\r
- mof::real cosy = cosf(radians.y);\r
- mof::real siny = sinf(radians.y);\r
- mof::real cosz = cosf(radians.z);\r
- mof::real sinz = sinf(radians.z);\r
- mof::Matrix3D::Array x = \r
- {{\r
- { 1.f , 0.f , 0.f , 0.f } ,\r
- { 0.f , cosx , sinx , 0.f } ,\r
- { 0.f , -sinx , cosx , 0.f } ,\r
- { 0.f , 0.f , 0.f , 1.f } \r
- }};\r
- mof::Matrix3D::Array y = \r
- {{\r
- { cosy , 0.f , -siny , 0.f } ,\r
- { 0.f , 1.f , 0.f , 0.f } ,\r
- { siny , 0.f , cosy , 0.f } ,\r
- { 0.f , 0.f , 0.f , 1.f }\r
- }};\r
- mof::Matrix3D::Array z = \r
- {{\r
- { cosz , sinz , 0.f , 0.f } ,\r
- { -sinz , cosz , 0.f , 0.f } ,\r
- { 0.f , 0.f , 1.f , 0.f } ,\r
- { 0.f , 0.f , 0.f , 1.f } \r
- }};\r
- return mof::Matrix3D(x) * mof::Matrix3D(y) * mof::Matrix3D(z); //TODO \90Ï\82ð\83n\81[\83h\83R\81[\83f\83B\83\93\83O\r
-}\r
-\r
-\r
-mof::Matrix3D mof::Matrix3D::createTranslation(const mof::Vector3D& position){\r
- Matrix3D matrix;\r
- matrix.m_pImpl->elements[DIMENSION][0] = position.x;\r
- matrix.m_pImpl->elements[DIMENSION][1] = position.y;\r
- matrix.m_pImpl->elements[DIMENSION][2] = position.z;\r
- return matrix;\r
-}\r
-\r
-mof::Matrix3D mof::Matrix3D::createScaling(const mof::Vector3D& scaling){\r
- Matrix3D matrix;\r
- matrix.m_pImpl->elements[0][0] = scaling.x;\r
- matrix.m_pImpl->elements[1][1] = scaling.y;\r
- matrix.m_pImpl->elements[2][2] = scaling.z;\r
- return matrix;\r
-}\r
-\r
-\r
-\r
-mof::Matrix3D mof::Matrix3D::createLookAtLH\r
-(\r
- const mof::Vector3D& eye ,\r
- const mof::Vector3D& lookAt ,\r
- const mof::Vector3D& up\r
-)\r
-{\r
- D3DXVECTOR3 vEye(eye.x , eye.y , eye.z);\r
- D3DXVECTOR3 vLookAt(lookAt.x , lookAt.y , lookAt.z);\r
- D3DXVECTOR3 vUp(up.x , up.y , up.z);\r
- D3DXMATRIX m;\r
- mof::Matrix3D::Array array;\r
- D3DXMatrixLookAtLH( &m , &vEye , &vLookAt , &vUp );\r
- for( int i = 0 ; i < DIMENSION ; i++ )\r
- {\r
- for( int j = 0 ; j < DIMENSION ; j++ )\r
- {\r
- array.elements[i][j] = m.m[i][j];\r
- }\r
- }\r
- return mof::Matrix3D( array );\r
-}\r
-\r
-mof::Vector3D mof::Matrix3D::getTranslation(const mof::Matrix3D& matrix){\r
- return mof::Vector3D(\r
- matrix.m_pImpl->elements[DIMENSION][0] ,\r
- matrix.m_pImpl->elements[DIMENSION][1] ,\r
- matrix.m_pImpl->elements[DIMENSION][2]\r
- );\r
-}\r
- \r
-mof::Vector3D mof::Matrix3D::getDiagonal() const{\r
- return mof::Vector3D(\r
- m_pImpl->elements[0][0] ,\r
- m_pImpl->elements[1][1] ,\r
- m_pImpl->elements[2][2]\r
- );\r
-}\r
- \r
-\r
-\r
-mof::Matrix3D mof::Matrix3D::operator *(const mof::Matrix3D& matrix) const{\r
- mof::Matrix3D multiplied;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- mof::real sum = 0;\r
- for(int k = 0 ; k <= DIMENSION ; k++){\r
- sum += m_pImpl->elements[i][k] * matrix.m_pImpl->elements[k][j];\r
- }\r
- multiplied.m_pImpl->elements[i][j] = sum;\r
- }\r
- }\r
- return multiplied;\r
-}\r
-\r
-\r
-mof::Matrix3D mof::Matrix3D::operator +(const mof::Matrix3D& matrix) const{\r
- mof::Matrix3D result;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- result.m_pImpl->elements[i][j] = \r
- m_pImpl->elements[i][j] + matrix.m_pImpl->elements[i][j];\r
- }\r
- }\r
- return result;\r
-}\r
-\r
-\r
-mof::Matrix3D mof::Matrix3D::operator -(const mof::Matrix3D& matrix) const{\r
- mof::Matrix3D result;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- result.m_pImpl->elements[i][j] = \r
- m_pImpl->elements[i][j] - matrix.m_pImpl->elements[i][j];\r
- }\r
- }\r
- return result;\r
-}\r
-\r
-\r
-mof::Matrix3D mof::operator *(const mof::Matrix3D& matrix , mof::real f){\r
- mof::Matrix3D result;\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- result.m_pImpl->elements[i][j] = \r
- matrix.m_pImpl->elements[i][j] * f;\r
- }\r
- }\r
- return result;\r
-}\r
- \r
-mof::Matrix3D mof::operator *(mof::real f , mof::Matrix3D const& matrix){\r
- return matrix * f;\r
-}\r
-\r
-\r
-mof::Vector3D mof::operator *(const mof::Vector3D& vec , const mof::Matrix3D& matrix) {\r
- mof::real input[4] = {vec.x , vec.y , vec.z , 1};\r
- mof::real output[4];\r
- for(int i = 0 ; i < DIMENSION ; i++){\r
- mof::real sum = 0;\r
- for(int k = 0 ; k <= DIMENSION ; k++){\r
- sum += input[k] * matrix.at(k , i);\r
- }\r
- output[i] = sum;\r
- \r
- }\r
- return mof::Vector3D(output[0] , output[1] , output[2]);\r
-}\r
-\r
-\r
-std::ostream& mof::operator <<(std::ostream& os , const mof::Matrix3D& mat){\r
- for(int i = 0 ; i <= DIMENSION ; i++){\r
- for(int j = 0 ; j <= DIMENSION ; j++){\r
- if(j != 0)os << " , ";\r
- os << mat.m_pImpl->elements[i][j];\r
- }\r
- os << '\n';\r
- }\r
- return os;\r
-}\r
+#include <string.h>
+#include <iostream>
+#include "mof/Matrix3D.hpp"
+#include "mof/utilities.hpp"
+#include <d3dx9.h>
+
+const int DIMENSION = 3;
+
+
+mof::Matrix3D::Matrix3D()
+: m_pImpl(new Array)
+{
+ for(int i = 0 ; i <= DIMENSION ; ++i){
+ for(int j = 0 ; j <= DIMENSION ; ++j){
+ if(i == j)m_pImpl->elements[i][j] = 1;
+ else m_pImpl->elements[i][j] = 0;
+ }
+ }
+}
+
+mof::Matrix3D::Matrix3D(const mof::Matrix3D::Array & arr)
+: m_pImpl(new Array)
+{
+ *m_pImpl = arr;
+}
+
+
+mof::Matrix3D::~Matrix3D(){
+}
+
+
+mof::real mof::Matrix3D::at(int row , int column) const{
+ return m_pImpl->elements[row][column];
+}
+
+mof::Matrix3D::Array mof::Matrix3D::getArray() const{
+ return *m_pImpl;
+}
+
+
+mof::Matrix3D mof::Matrix3D::createIdentity(){
+ return mof::Matrix3D();
+}
+
+
+mof::Matrix3D mof::Matrix3D::createTransposed(const mof::Matrix3D& matrix){
+ Matrix3D transposed;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ transposed.m_pImpl->elements[j][i] = matrix.m_pImpl->elements[i][j];
+ }
+ }
+ return transposed;
+}
+
+
+mof::Matrix3D mof::Matrix3D::createRotation(const mof::Vector3D& radians){
+ mof::real cosx = cosf(radians.x);
+ mof::real sinx = sinf(radians.x);
+ mof::real cosy = cosf(radians.y);
+ mof::real siny = sinf(radians.y);
+ mof::real cosz = cosf(radians.z);
+ mof::real sinz = sinf(radians.z);
+ mof::Matrix3D::Array x =
+ {{
+ { 1.f , 0.f , 0.f , 0.f } ,
+ { 0.f , cosx , sinx , 0.f } ,
+ { 0.f , -sinx , cosx , 0.f } ,
+ { 0.f , 0.f , 0.f , 1.f }
+ }};
+ mof::Matrix3D::Array y =
+ {{
+ { cosy , 0.f , -siny , 0.f } ,
+ { 0.f , 1.f , 0.f , 0.f } ,
+ { siny , 0.f , cosy , 0.f } ,
+ { 0.f , 0.f , 0.f , 1.f }
+ }};
+ mof::Matrix3D::Array z =
+ {{
+ { cosz , sinz , 0.f , 0.f } ,
+ { -sinz , cosz , 0.f , 0.f } ,
+ { 0.f , 0.f , 1.f , 0.f } ,
+ { 0.f , 0.f , 0.f , 1.f }
+ }};
+ return mof::Matrix3D(x) * mof::Matrix3D(y) * mof::Matrix3D(z); //TODO \90Ï\82ð\83n\81[\83h\83R\81[\83f\83B\83\93\83O
+}
+
+
+mof::Matrix3D mof::Matrix3D::createTranslation(const mof::Vector3D& position){
+ Matrix3D matrix;
+ matrix.m_pImpl->elements[DIMENSION][0] = position.x;
+ matrix.m_pImpl->elements[DIMENSION][1] = position.y;
+ matrix.m_pImpl->elements[DIMENSION][2] = position.z;
+ return matrix;
+}
+
+mof::Matrix3D mof::Matrix3D::createScaling(const mof::Vector3D& scaling){
+ Matrix3D matrix;
+ matrix.m_pImpl->elements[0][0] = scaling.x;
+ matrix.m_pImpl->elements[1][1] = scaling.y;
+ matrix.m_pImpl->elements[2][2] = scaling.z;
+ return matrix;
+}
+
+
+
+mof::Matrix3D mof::Matrix3D::createLookAtLH
+(
+ const mof::Vector3D& eye ,
+ const mof::Vector3D& lookAt ,
+ const mof::Vector3D& up
+)
+{
+ D3DXVECTOR3 vEye(eye.x , eye.y , eye.z);
+ D3DXVECTOR3 vLookAt(lookAt.x , lookAt.y , lookAt.z);
+ D3DXVECTOR3 vUp(up.x , up.y , up.z);
+ D3DXMATRIX m;
+ mof::Matrix3D::Array array;
+ D3DXMatrixLookAtLH( &m , &vEye , &vLookAt , &vUp );
+ for( int i = 0 ; i < DIMENSION ; i++ )
+ {
+ for( int j = 0 ; j < DIMENSION ; j++ )
+ {
+ array.elements[i][j] = m.m[i][j];
+ }
+ }
+ return mof::Matrix3D( array );
+}
+
+mof::Vector3D mof::Matrix3D::getTranslation(const mof::Matrix3D& matrix){
+ return mof::Vector3D(
+ matrix.m_pImpl->elements[DIMENSION][0] ,
+ matrix.m_pImpl->elements[DIMENSION][1] ,
+ matrix.m_pImpl->elements[DIMENSION][2]
+ );
+}
+
+mof::Vector3D mof::Matrix3D::getDiagonal() const{
+ return mof::Vector3D(
+ m_pImpl->elements[0][0] ,
+ m_pImpl->elements[1][1] ,
+ m_pImpl->elements[2][2]
+ );
+}
+
+
+
+mof::Matrix3D mof::Matrix3D::operator *(const mof::Matrix3D& matrix) const{
+ mof::Matrix3D multiplied;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ mof::real sum = 0;
+ for(int k = 0 ; k <= DIMENSION ; k++){
+ sum += m_pImpl->elements[i][k] * matrix.m_pImpl->elements[k][j];
+ }
+ multiplied.m_pImpl->elements[i][j] = sum;
+ }
+ }
+ return multiplied;
+}
+
+
+mof::Matrix3D mof::Matrix3D::operator +(const mof::Matrix3D& matrix) const{
+ mof::Matrix3D result;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ result.m_pImpl->elements[i][j] =
+ m_pImpl->elements[i][j] + matrix.m_pImpl->elements[i][j];
+ }
+ }
+ return result;
+}
+
+
+mof::Matrix3D mof::Matrix3D::operator -(const mof::Matrix3D& matrix) const{
+ mof::Matrix3D result;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ result.m_pImpl->elements[i][j] =
+ m_pImpl->elements[i][j] - matrix.m_pImpl->elements[i][j];
+ }
+ }
+ return result;
+}
+
+
+mof::Matrix3D mof::operator *(const mof::Matrix3D& matrix , mof::real f){
+ mof::Matrix3D result;
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ result.m_pImpl->elements[i][j] =
+ matrix.m_pImpl->elements[i][j] * f;
+ }
+ }
+ return result;
+}
+
+mof::Matrix3D mof::operator *(mof::real f , mof::Matrix3D const& matrix){
+ return matrix * f;
+}
+
+
+mof::Vector3D mof::operator *(const mof::Vector3D& vec , const mof::Matrix3D& matrix) {
+ mof::real input[4] = {vec.x , vec.y , vec.z , 1};
+ mof::real output[4];
+ for(int i = 0 ; i < DIMENSION ; i++){
+ mof::real sum = 0;
+ for(int k = 0 ; k <= DIMENSION ; k++){
+ sum += input[k] * matrix.at(k , i);
+ }
+ output[i] = sum;
+
+ }
+ return mof::Vector3D(output[0] , output[1] , output[2]);
+}
+
+
+std::ostream& mof::operator <<(std::ostream& os , const mof::Matrix3D& mat){
+ for(int i = 0 ; i <= DIMENSION ; i++){
+ for(int j = 0 ; j <= DIMENSION ; j++){
+ if(j != 0)os << " , ";
+ os << mat.m_pImpl->elements[i][j];
+ }
+ os << '\n';
+ }
+ return os;
+}
-#pragma once\r
-#include "mof/Vector3D.hpp"\r
-#include <mof/real.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-\r
-namespace mof{\r
-\r
- class Matrix3D\r
- {\r
- public:\r
- struct Array\r
- {\r
- real elements[4][4];\r
- };\r
- private:\r
- boost::shared_ptr<Array> m_pImpl;\r
- public:\r
- \r
- Matrix3D();\r
- explicit Matrix3D(const Array &);\r
- ~Matrix3D();\r
- real at(int row , int column) const;\r
- Array getArray() const;\r
-\r
- static Matrix3D createIdentity();\r
- static Matrix3D createTransposed(const Matrix3D& matrix);\r
- static Matrix3D createRotation(const mof::Vector3D& angle);\r
- static Matrix3D createTranslation(const mof::Vector3D& position);\r
- static Matrix3D createScaling(const mof::Vector3D& scale);\r
- static Matrix3D createLookAtLH( const Vector3D& eye , const Vector3D& lookAt , const Vector3D& up );\r
- static Vector3D getTranslation(const mof::Matrix3D& matrix);\r
- Vector3D getDiagonal() const;\r
-\r
-\r
- Matrix3D operator *(const mof::Matrix3D& matrix ) const;\r
- Matrix3D operator +(const mof::Matrix3D& matrix ) const;\r
- Matrix3D operator -(const mof::Matrix3D& matrix ) const;\r
-\r
- friend Vector3D operator *(const mof::Vector3D& vec , const mof::Matrix3D& matrix);\r
- friend Matrix3D operator *(const mof::Matrix3D& matrix , real f);\r
- friend Matrix3D operator *(real f , const mof::Matrix3D & matrix);\r
- friend std::ostream& operator <<(std::ostream& os , const mof::Matrix3D& mat);\r
- }; // class Matrix3D\r
- \r
- std::ostream& operator <<(std::ostream& os , const mof::Matrix3D& mat);\r
-\r
-} // namespace mof\r
-\r
+#pragma once
+#include "mof/Vector3D.hpp"
+#include <mof/real.hpp>
+#include <boost/shared_ptr.hpp>
+
+
+namespace mof{
+
+ class Matrix3D
+ {
+ public:
+ struct Array
+ {
+ real elements[4][4];
+ };
+ private:
+ boost::shared_ptr<Array> m_pImpl;
+ public:
+
+ Matrix3D();
+ explicit Matrix3D(const Array &);
+ ~Matrix3D();
+ real at(int row , int column) const;
+ Array getArray() const;
+
+ static Matrix3D createIdentity();
+ static Matrix3D createTransposed(const Matrix3D& matrix);
+ static Matrix3D createRotation(const mof::Vector3D& angle);
+ static Matrix3D createTranslation(const mof::Vector3D& position);
+ static Matrix3D createScaling(const mof::Vector3D& scale);
+ static Matrix3D createLookAtLH( const Vector3D& eye , const Vector3D& lookAt , const Vector3D& up );
+ static Vector3D getTranslation(const mof::Matrix3D& matrix);
+ Vector3D getDiagonal() const;
+
+
+ Matrix3D operator *(const mof::Matrix3D& matrix ) const;
+ Matrix3D operator +(const mof::Matrix3D& matrix ) const;
+ Matrix3D operator -(const mof::Matrix3D& matrix ) const;
+
+ friend Vector3D operator *(const mof::Vector3D& vec , const mof::Matrix3D& matrix);
+ friend Matrix3D operator *(const mof::Matrix3D& matrix , real f);
+ friend Matrix3D operator *(real f , const mof::Matrix3D & matrix);
+ friend std::ostream& operator <<(std::ostream& os , const mof::Matrix3D& mat);
+ }; // class Matrix3D
+
+ std::ostream& operator <<(std::ostream& os , const mof::Matrix3D& mat);
+
+} // namespace mof
+
-#include "mof/private/Mesh.hpp"\r
-#include "mof/GraphicsDevice.hpp"\r
-#include "mof/private/MeshDisposer.hpp"\r
-#include "mof/Constant.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-struct mof::Mesh::Impl{\r
- \r
- boost::shared_ptr<mof::MeshDisposer> pMeshDisposer;\r
- unsigned long nMaterials;\r
- boost::shared_ptr<Material>* materials; \r
- boost::shared_ptr<Texture>* textures;\r
- mof::Animation<mof::Matrix3D>::Handler worldMatrix;\r
- \r
-\r
- Impl(\r
- boost::shared_ptr<mof::MeshDisposer> pMeshDisposer_ ,\r
- unsigned long nMaterials_ \r
- ) : \r
- pMeshDisposer(pMeshDisposer_) , \r
- nMaterials(nMaterials_) , materials(NULL) , textures(NULL) ,\r
- worldMatrix(mof::makeConstantHandler(mof::Matrix3D::createIdentity()))\r
- {}\r
-\r
- ~Impl(){\r
- delete[] materials;\r
- delete[] textures;\r
- }\r
-}; \r
-\r
-mof::Mesh::Mesh(\r
- boost::shared_ptr<mof::MeshDisposer> pMeshDisposer ,\r
- unsigned long nMaterials ,\r
- const boost::shared_ptr<Material>* materials , \r
- const boost::shared_ptr<Texture>* textures \r
- ) : m_pImpl(new Impl(pMeshDisposer , nMaterials )){\r
-\r
- m_pImpl->materials = new boost::shared_ptr<mof::Material>[nMaterials];\r
- m_pImpl->textures = new boost::shared_ptr<mof::Texture>[nMaterials]; \r
-\r
- for(unsigned long i = 0 ; i < nMaterials ; i++ ){\r
- m_pImpl->materials[i] = materials[i];\r
- m_pImpl->textures[i] = textures[i];\r
- }\r
-}\r
-\r
-mof::Mesh::~Mesh(){\r
-}\r
- \r
-\r
-\r
-void mof::Mesh::setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler){\r
- m_pImpl->worldMatrix = handler;\r
-}\r
-\r
-\r
-\r
-\r
-\r
-void mof::Mesh::setTexture( \r
- unsigned int num ,\r
- const boost::shared_ptr<mof::Texture>& pTexture){\r
-\r
- if(num < m_pImpl->nMaterials)m_pImpl->textures[num] = pTexture; \r
-\r
-}\r
-\r
-\r
-bool mof::Mesh::isVisible() const{\r
- return true;\r
-}\r
-\r
-\r
-void mof::Mesh::update(){\r
- nextFrame();\r
-}\r
-\r
-void mof::Mesh::draw() const{\r
- \r
-\r
- for( DWORD i = 0; i < m_pImpl->nMaterials ; i++ )\r
- {\r
- mof::GraphicsDevice::setMaterial(*m_pImpl->materials[i].get()); \r
- mof::GraphicsDevice::setTexture(m_pImpl->textures[i].get());\r
- mof::GraphicsDevice::setWorldTransform(m_pImpl->worldMatrix->getValue(m_frame));\r
-\r
- HRESULT hr = m_pImpl->pMeshDisposer->pMesh->DrawSubset( i );\r
- if(FAILED(hr))throw std::runtime_error("Failed --- DrawSubset");\r
- }\r
-}\r
-\r
+#include "mof/private/Mesh.hpp"
+#include "mof/GraphicsDevice.hpp"
+#include "mof/private/MeshDisposer.hpp"
+#include "mof/Constant.hpp"
+#include "mof/ConsoleIO.hpp"
+
+struct mof::Mesh::Impl{
+
+ boost::shared_ptr<mof::MeshDisposer> pMeshDisposer;
+ unsigned long nMaterials;
+ boost::shared_ptr<Material>* materials;
+ boost::shared_ptr<Texture>* textures;
+ mof::Animation<mof::Matrix3D>::Handler worldMatrix;
+
+
+ Impl(
+ boost::shared_ptr<mof::MeshDisposer> pMeshDisposer_ ,
+ unsigned long nMaterials_
+ ) :
+ pMeshDisposer(pMeshDisposer_) ,
+ nMaterials(nMaterials_) , materials(NULL) , textures(NULL) ,
+ worldMatrix(mof::makeConstantHandler(mof::Matrix3D::createIdentity()))
+ {}
+
+ ~Impl(){
+ delete[] materials;
+ delete[] textures;
+ }
+};
+
+mof::Mesh::Mesh(
+ boost::shared_ptr<mof::MeshDisposer> pMeshDisposer ,
+ unsigned long nMaterials ,
+ const boost::shared_ptr<Material>* materials ,
+ const boost::shared_ptr<Texture>* textures
+ ) : m_pImpl(new Impl(pMeshDisposer , nMaterials )){
+
+ m_pImpl->materials = new boost::shared_ptr<mof::Material>[nMaterials];
+ m_pImpl->textures = new boost::shared_ptr<mof::Texture>[nMaterials];
+
+ for(unsigned long i = 0 ; i < nMaterials ; i++ ){
+ m_pImpl->materials[i] = materials[i];
+ m_pImpl->textures[i] = textures[i];
+ }
+}
+
+mof::Mesh::~Mesh(){
+}
+
+
+
+void mof::Mesh::setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler){
+ m_pImpl->worldMatrix = handler;
+}
+
+
+
+
+
+void mof::Mesh::setTexture(
+ unsigned int num ,
+ const boost::shared_ptr<mof::Texture>& pTexture){
+
+ if(num < m_pImpl->nMaterials)m_pImpl->textures[num] = pTexture;
+
+}
+
+
+bool mof::Mesh::isVisible() const{
+ return true;
+}
+
+
+void mof::Mesh::update(){
+ nextFrame();
+}
+
+void mof::Mesh::draw() const{
+
+
+ for( DWORD i = 0; i < m_pImpl->nMaterials ; i++ )
+ {
+ mof::GraphicsDevice::setMaterial(*m_pImpl->materials[i].get());
+ mof::GraphicsDevice::setTexture(m_pImpl->textures[i].get());
+ mof::GraphicsDevice::setWorldTransform(m_pImpl->worldMatrix->getValue(m_frame));
+
+ HRESULT hr = m_pImpl->pMeshDisposer->pMesh->DrawSubset( i );
+ if(FAILED(hr))throw std::runtime_error("Failed --- DrawSubset");
+ }
+}
+
-#include "MeshBuilder.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include <stdexcept>\r
-#include "mof/private/MeshDisposer.hpp"\r
-#include <boost/shared_ptr.hpp>\r
-#include <stdlib.h>\r
-#include "mof/FilePath.hpp"\r
-#include "mof/private/VertexFVF.hpp"\r
-#include "mof/Material.hpp"\r
-#include "mof/Texture.hpp"\r
-#include "mof/private/Mesh.hpp"\r
-\r
-struct mof::MeshBuilder::Impl{\r
- boost::shared_ptr<mof::MeshDisposer> pMeshDisposer;\r
- unsigned long nMaterials;\r
- boost::shared_ptr<Material>* materials;\r
- boost::shared_ptr<Texture>* textures;\r
-\r
-\r
- Impl()\r
- : pMeshDisposer() , nMaterials(0) ,\r
- materials(NULL) , textures(NULL){\r
- }\r
-\r
- ~Impl(){\r
- delete[] materials;\r
- delete[] textures;\r
- }\r
-\r
-};\r
-\r
-mof::MeshBuilder::MeshBuilder(const mof::tstring& path )\r
-: m_pImpl(new Impl())\r
-{\r
-\r
- LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();\r
- HRESULT hr;\r
- LPD3DXBUFFER pD3DXMtrlBuffer; //\83}\83e\83\8a\83A\83\8b\97p\83o\83b\83t\83@\r
- m_pImpl->pMeshDisposer = boost::shared_ptr<mof::MeshDisposer>( new mof::MeshDisposer() );\r
-\r
- //\83t\83@\83C\83\8b\83\8d\81[\83h\r
- hr = D3DXLoadMeshFromX(path.c_str() , D3DXMESH_MANAGED, pDevice,\r
- &(m_pImpl->pMeshDisposer->pAdjacency) ,\r
- &pD3DXMtrlBuffer , NULL, \r
- &(m_pImpl->nMaterials) , \r
- &(m_pImpl->pMeshDisposer->pMesh) );\r
- if(hr != D3D_OK)throw std::invalid_argument("Failed --- D3DXLoadMeshFromX");\r
-\r
- //\8ae\8eí\83C\83\93\83X\83^\83\93\83X\8eæ\93¾\r
- D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer();\r
- try{\r
- m_pImpl->materials = new boost::shared_ptr<mof::Material>[m_pImpl->nMaterials];\r
- m_pImpl->textures = new boost::shared_ptr<mof::Texture>[m_pImpl->nMaterials];\r
- \r
- \r
- for( DWORD i = 0; i< m_pImpl->nMaterials; i++ )\r
- {\r
- //\83}\83e\83\8a\83A\83\8b\82Ì\83R\83s\81[\r
- D3DMATERIAL9 mat = d3dxMaterials[i].MatD3D;\r
- mat.Ambient = mat.Diffuse;\r
- mof::Material tmp;\r
- memcpy(\r
- static_cast<void*>(&tmp) , \r
- static_cast<const void*>(&mat) ,\r
- sizeof(D3DMATERIAL9)\r
- );\r
- \r
- boost::shared_ptr<mof::Material> p(new mof::Material(tmp));\r
- m_pImpl->materials[i] = p;\r
-\r
- //\83e\83N\83X\83`\83\83\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý\r
- if( d3dxMaterials[i].pTextureFilename != NULL && \r
- lstrlen(d3dxMaterials[i].pTextureFilename) > 0 )\r
- {\r
- mof::otstringstream os;\r
- mof::FilePath path(path);\r
- os << path.dir().c_str() << _T("/") << d3dxMaterials[i].pTextureFilename;\r
- m_pImpl->textures[i] = boost::shared_ptr<mof::Texture>(new mof::Texture( os.str()));\r
- }\r
- }\r
-\r
- }\r
- catch( std::exception& e){\r
- pD3DXMtrlBuffer->Release(); //\83o\83b\83t\83@\89ð\95ú\r
- throw e;\r
- }\r
- pD3DXMtrlBuffer->Release(); //\83o\83b\83t\83@\89ð\95ú\r
-\r
- LPD3DXMESH pMesh = NULL;\r
- if(m_pImpl->pMeshDisposer->pMesh->GetFVF() != mof::getFVF<VertexXYZNUV>())\r
- {\r
- //\83\81\83b\83V\83\85\82É\96@\90ü\82ª\82È\82¢\8fê\8d\87\8f\91\82«\8d\9e\82Þ\r
- m_pImpl->pMeshDisposer->pMesh->CloneMeshFVF(\r
- m_pImpl->pMeshDisposer->pMesh->GetOptions() ,\r
- mof::getFVF<VertexXYZNUV>() ,\r
- pDevice , &pMesh );\r
- \r
- LPD3DXMESH tmp = m_pImpl->pMeshDisposer->pMesh;\r
- m_pImpl->pMeshDisposer->pMesh = pMesh;\r
- tmp->Release();\r
- }\r
-\r
-}\r
- \r
-mof::MeshBuilder::~MeshBuilder(){}\r
-\r
-mof::Graphics3D* mof::MeshBuilder::construct() const{\r
- return new mof::Mesh(\r
- m_pImpl->pMeshDisposer ,\r
- m_pImpl->nMaterials , \r
- m_pImpl->materials ,\r
- m_pImpl->textures \r
- );\r
-}\r
+#include "MeshBuilder.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include "mof/ConsoleIO.hpp"
+#include <stdexcept>
+#include "mof/private/MeshDisposer.hpp"
+#include <boost/shared_ptr.hpp>
+#include <stdlib.h>
+#include "mof/FilePath.hpp"
+#include "mof/private/VertexFVF.hpp"
+#include "mof/Material.hpp"
+#include "mof/Texture.hpp"
+#include "mof/private/Mesh.hpp"
+
+struct mof::MeshBuilder::Impl{
+ boost::shared_ptr<mof::MeshDisposer> pMeshDisposer;
+ unsigned long nMaterials;
+ boost::shared_ptr<Material>* materials;
+ boost::shared_ptr<Texture>* textures;
+
+
+ Impl()
+ : pMeshDisposer() , nMaterials(0) ,
+ materials(NULL) , textures(NULL){
+ }
+
+ ~Impl(){
+ delete[] materials;
+ delete[] textures;
+ }
+
+};
+
+mof::MeshBuilder::MeshBuilder(const mof::tstring& path )
+: m_pImpl(new Impl())
+{
+
+ LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();
+ HRESULT hr;
+ LPD3DXBUFFER pD3DXMtrlBuffer; //\83}\83e\83\8a\83A\83\8b\97p\83o\83b\83t\83@
+ m_pImpl->pMeshDisposer = boost::shared_ptr<mof::MeshDisposer>( new mof::MeshDisposer() );
+
+ //\83t\83@\83C\83\8b\83\8d\81[\83h
+ hr = D3DXLoadMeshFromX(path.c_str() , D3DXMESH_MANAGED, pDevice,
+ &(m_pImpl->pMeshDisposer->pAdjacency) ,
+ &pD3DXMtrlBuffer , NULL,
+ &(m_pImpl->nMaterials) ,
+ &(m_pImpl->pMeshDisposer->pMesh) );
+ if(hr != D3D_OK)throw std::invalid_argument("Failed --- D3DXLoadMeshFromX");
+
+ //\8ae\8eí\83C\83\93\83X\83^\83\93\83X\8eæ\93¾
+ D3DXMATERIAL* d3dxMaterials = (D3DXMATERIAL*)pD3DXMtrlBuffer->GetBufferPointer();
+ try{
+ m_pImpl->materials = new boost::shared_ptr<mof::Material>[m_pImpl->nMaterials];
+ m_pImpl->textures = new boost::shared_ptr<mof::Texture>[m_pImpl->nMaterials];
+
+
+ for( DWORD i = 0; i< m_pImpl->nMaterials; i++ )
+ {
+ //\83}\83e\83\8a\83A\83\8b\82Ì\83R\83s\81[
+ D3DMATERIAL9 mat = d3dxMaterials[i].MatD3D;
+ mat.Ambient = mat.Diffuse;
+ mof::Material tmp;
+ memcpy(
+ static_cast<void*>(&tmp) ,
+ static_cast<const void*>(&mat) ,
+ sizeof(D3DMATERIAL9)
+ );
+
+ boost::shared_ptr<mof::Material> p(new mof::Material(tmp));
+ m_pImpl->materials[i] = p;
+
+ //\83e\83N\83X\83`\83\83\83t\83@\83C\83\8b\82Ì\93Ç\82Ý\8d\9e\82Ý
+ if( d3dxMaterials[i].pTextureFilename != NULL &&
+ lstrlen(d3dxMaterials[i].pTextureFilename) > 0 )
+ {
+ mof::otstringstream os;
+ mof::FilePath path(path);
+ os << path.dir().c_str() << _T("/") << d3dxMaterials[i].pTextureFilename;
+ m_pImpl->textures[i] = boost::shared_ptr<mof::Texture>(new mof::Texture( os.str()));
+ }
+ }
+
+ }
+ catch( std::exception& e){
+ pD3DXMtrlBuffer->Release(); //\83o\83b\83t\83@\89ð\95ú
+ throw e;
+ }
+ pD3DXMtrlBuffer->Release(); //\83o\83b\83t\83@\89ð\95ú
+
+ LPD3DXMESH pMesh = NULL;
+ if(m_pImpl->pMeshDisposer->pMesh->GetFVF() != mof::getFVF<VertexXYZNUV>())
+ {
+ //\83\81\83b\83V\83\85\82É\96@\90ü\82ª\82È\82¢\8fê\8d\87\8f\91\82«\8d\9e\82Þ
+ m_pImpl->pMeshDisposer->pMesh->CloneMeshFVF(
+ m_pImpl->pMeshDisposer->pMesh->GetOptions() ,
+ mof::getFVF<VertexXYZNUV>() ,
+ pDevice , &pMesh );
+
+ LPD3DXMESH tmp = m_pImpl->pMeshDisposer->pMesh;
+ m_pImpl->pMeshDisposer->pMesh = pMesh;
+ tmp->Release();
+ }
+
+}
+
+mof::MeshBuilder::~MeshBuilder(){}
+
+mof::Graphics3D* mof::MeshBuilder::construct() const{
+ return new mof::Mesh(
+ m_pImpl->pMeshDisposer ,
+ m_pImpl->nMaterials ,
+ m_pImpl->materials ,
+ m_pImpl->textures
+ );
+}
-#ifndef MOF_MESH_BUILDER_HPP\r
-#define MOF_MESH_BUILDER_HPP\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/utility.hpp>\r
-#include "mof/tstring.hpp"\r
-\r
-\r
-namespace mof{\r
- class Graphics3D;\r
- \r
- class MeshBuilder : boost::noncopyable\r
- {\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- public:\r
- \r
- MeshBuilder( const mof::tstring& path );\r
- ~MeshBuilder();\r
-\r
- mof::Graphics3D* construct() const;\r
- };\r
-}\r
-\r
-#endif\r
+#ifndef MOF_MESH_BUILDER_HPP
+#define MOF_MESH_BUILDER_HPP
+#include <boost/scoped_ptr.hpp>
+#include <boost/utility.hpp>
+#include "mof/tstring.hpp"
+
+
+namespace mof{
+ class Graphics3D;
+
+ class MeshBuilder : boost::noncopyable
+ {
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ public:
+
+ MeshBuilder( const mof::tstring& path );
+ ~MeshBuilder();
+
+ mof::Graphics3D* construct() const;
+ };
+}
+
+#endif
-#pragma once\r
-\r
-#include "mof/ResourceManager.h"\r
-#include "mof/Mesh.h"\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof{\r
- \r
- typedef boost::shared_ptr<mof::Mesh> MeshResource;\r
- typedef mof::ResourceManager<mof::Mesh> MeshManager;\r
- \r
+#pragma once
+
+#include "mof/ResourceManager.h"
+#include "mof/Mesh.h"
+#include <boost/shared_ptr.hpp>
+
+namespace mof{
+
+ typedef boost::shared_ptr<mof::Mesh> MeshResource;
+ typedef mof::ResourceManager<mof::Mesh> MeshManager;
+
};
\ No newline at end of file
-#include "mof/OnceEventCondition.hpp"\r
-#include "mof/utilities.hpp"\r
-\r
-namespace mof\r
-{\r
- OnceEventCondition::OnceEventCondition( EventCondition* pBody )\r
- : m_disposable( false ) , m_pBody( pBody )\r
- {\r
- }\r
-\r
- OnceEventCondition::~OnceEventCondition( )\r
- {\r
- mof::safe_delete( m_pBody );\r
- }\r
-\r
- bool OnceEventCondition::test( )\r
- {\r
- bool result = m_pBody->test();\r
- if( !m_disposable && result )m_disposable = true;\r
- return result;\r
- }\r
-\r
- void OnceEventCondition::update( )\r
- {\r
- m_pBody->update();\r
- }\r
-\r
- bool OnceEventCondition::isDisposable( )\r
- {\r
- return m_disposable;\r
- }\r
-\r
-\r
-\r
-}\r
-\r
+#include "mof/OnceEventCondition.hpp"
+#include "mof/utilities.hpp"
+
+namespace mof
+{
+ OnceEventCondition::OnceEventCondition( EventCondition* pBody )
+ : m_disposable( false ) , m_pBody( pBody )
+ {
+ }
+
+ OnceEventCondition::~OnceEventCondition( )
+ {
+ mof::safe_delete( m_pBody );
+ }
+
+ bool OnceEventCondition::test( )
+ {
+ bool result = m_pBody->test();
+ if( !m_disposable && result )m_disposable = true;
+ return result;
+ }
+
+ void OnceEventCondition::update( )
+ {
+ m_pBody->update();
+ }
+
+ bool OnceEventCondition::isDisposable( )
+ {
+ return m_disposable;
+ }
+
+
+
+}
+
-#pragma once\r
-#include "mof/EventCondition.hpp"\r
-\r
-namespace mof\r
-{\r
-\r
- class OnceEventCondition : public EventCondition\r
- {\r
- bool m_disposable;\r
- EventCondition* m_pBody;\r
- public:\r
- OnceEventCondition( EventCondition* pBody );\r
- virtual ~OnceEventCondition();\r
- virtual bool test();\r
- virtual void update();\r
- virtual bool isDisposable();\r
- };\r
-\r
-}\r
-\r
+#pragma once
+#include "mof/EventCondition.hpp"
+
+namespace mof
+{
+
+ class OnceEventCondition : public EventCondition
+ {
+ bool m_disposable;
+ EventCondition* m_pBody;
+ public:
+ OnceEventCondition( EventCondition* pBody );
+ virtual ~OnceEventCondition();
+ virtual bool test();
+ virtual void update();
+ virtual bool isDisposable();
+ };
+
+}
+
-#ifndef MOF_PIXEL_MAP_HPP\r
-#define MOF_PIXEL_MAP_HPP\r
-\r
-#include "mof/Color.hpp"\r
-#include <boost/multi_array.hpp>\r
-\r
-namespace mof{\r
- typedef boost::multi_array<mof::Color , 2> PixelMap;\r
-}\r
-\r
-#endif \r
+#ifndef MOF_PIXEL_MAP_HPP
+#define MOF_PIXEL_MAP_HPP
+
+#include "mof/Color.hpp"
+#include <boost/multi_array.hpp>
+
+namespace mof{
+ typedef boost::multi_array<mof::Color , 2> PixelMap;
+}
+
+#endif
-#include "mof/private/PixelMapTextureBuilder.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include <list>\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/Font.hpp"\r
-\r
-\r
-mof::PixelMapTextureBuilder::PixelMapTextureBuilder( const boost::shared_ptr<mof::PixelMap>& pixelMap)\r
-: m_pPixelMap(pixelMap)\r
-{\r
-}\r
-\r
-mof::PixelMapTextureBuilder::~PixelMapTextureBuilder(void)\r
-{\r
- \r
-}\r
-\r
-\r
-LPDIRECT3DTEXTURE9 mof::PixelMapTextureBuilder::create(){\r
- HRESULT hr;\r
- LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();\r
-\r
- unsigned int tWidth = 2;\r
- while(tWidth < m_pPixelMap->shape()[0])tWidth *= 2;\r
- unsigned int tHeight = 2;\r
- while(tHeight < m_pPixelMap->shape()[1])tHeight *= 2;\r
- \r
- \r
- // \83e\83N\83X\83`\83\83\8dì\90¬\r
- LPDIRECT3DTEXTURE9 texture;\r
- if\r
- (\r
- FAILED\r
- (\r
- hr = D3DXCreateTexture\r
- (\r
- pDevice , tWidth , tHeight ,\r
- 1 , D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8, \r
- D3DPOOL_DEFAULT, &texture\r
- )\r
- )\r
- )\r
- {\r
- throw std::runtime_error("Failed --- D3DXCreateTexture");\r
- }\r
-\r
- \r
-\r
- // \83e\83N\83X\83`\83\83\82É\83t\83H\83\93\83g\83r\83b\83g\83}\83b\83v\8f\91\82«\8d\9e\82Ý\r
- D3DLOCKED_RECT LockedRect;\r
- if(FAILED(hr = texture->LockRect(0, &LockedRect, NULL, D3DLOCK_DISCARD))){\r
- throw std::runtime_error("Failed --- LockRect");\r
- }\r
-\r
- // \83t\83H\83\93\83g\8fî\95ñ\82Ì\8f\91\82«\8d\9e\82Ý\r
- \r
- FillMemory(LockedRect.pBits , LockedRect.Pitch * tHeight , 0);\r
- for(unsigned int y = 0 ; y < m_pPixelMap->shape()[1] ; y++){\r
- for(unsigned int x = 0 ; x < m_pPixelMap->shape()[0] ; x++){\r
- memcpy((BYTE*)LockedRect.pBits + LockedRect.Pitch * y + 4 * x , &((*m_pPixelMap)[x][y]) , sizeof(DWORD));\r
- }\r
- }\r
-\r
- \r
- texture->UnlockRect(0);\r
- return texture;\r
-\r
-\r
-}\r
-\r
+#include "mof/private/PixelMapTextureBuilder.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include <list>
+#include "mof/ConsoleIO.hpp"
+#include "mof/Font.hpp"
+
+
+mof::PixelMapTextureBuilder::PixelMapTextureBuilder( const boost::shared_ptr<mof::PixelMap>& pixelMap)
+: m_pPixelMap(pixelMap)
+{
+}
+
+mof::PixelMapTextureBuilder::~PixelMapTextureBuilder(void)
+{
+
+}
+
+
+LPDIRECT3DTEXTURE9 mof::PixelMapTextureBuilder::create(){
+ HRESULT hr;
+ LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();
+
+ unsigned int tWidth = 2;
+ while(tWidth < m_pPixelMap->shape()[0])tWidth *= 2;
+ unsigned int tHeight = 2;
+ while(tHeight < m_pPixelMap->shape()[1])tHeight *= 2;
+
+
+ // \83e\83N\83X\83`\83\83\8dì\90¬
+ LPDIRECT3DTEXTURE9 texture;
+ if
+ (
+ FAILED
+ (
+ hr = D3DXCreateTexture
+ (
+ pDevice , tWidth , tHeight ,
+ 1 , D3DUSAGE_DYNAMIC, D3DFMT_A8R8G8B8,
+ D3DPOOL_DEFAULT, &texture
+ )
+ )
+ )
+ {
+ throw std::runtime_error("Failed --- D3DXCreateTexture");
+ }
+
+
+
+ // \83e\83N\83X\83`\83\83\82É\83t\83H\83\93\83g\83r\83b\83g\83}\83b\83v\8f\91\82«\8d\9e\82Ý
+ D3DLOCKED_RECT LockedRect;
+ if(FAILED(hr = texture->LockRect(0, &LockedRect, NULL, D3DLOCK_DISCARD))){
+ throw std::runtime_error("Failed --- LockRect");
+ }
+
+ // \83t\83H\83\93\83g\8fî\95ñ\82Ì\8f\91\82«\8d\9e\82Ý
+
+ FillMemory(LockedRect.pBits , LockedRect.Pitch * tHeight , 0);
+ for(unsigned int y = 0 ; y < m_pPixelMap->shape()[1] ; y++){
+ for(unsigned int x = 0 ; x < m_pPixelMap->shape()[0] ; x++){
+ memcpy((BYTE*)LockedRect.pBits + LockedRect.Pitch * y + 4 * x , &((*m_pPixelMap)[x][y]) , sizeof(DWORD));
+ }
+ }
+
+
+ texture->UnlockRect(0);
+ return texture;
+
+
+}
+
-#include "mof/PlainWidgetView.hpp"\r
-#include "mof/GraphicsDevice.hpp"\r
-#include "mof/Sprite.hpp"\r
-#include "mof/mofAnimations.hpp"\r
-#include "mof/Font.hpp"\r
-\r
-\r
-struct mof::PlainWidgetView::Impl{\r
- mof::Animation<mof::Matrix2D>::Handler transform;\r
- mof::Animation<bool>::Handler visible;\r
- mof::FrameNumber frame;\r
- mof::Rectangle<int> bounds;\r
- mof::Sprite* pCaption;\r
- \r
-\r
- Impl()\r
- : frame(0) , \r
- bounds(mof::Rectangle<int>(0 , 0 , 0 , 0)) , pCaption(NULL)\r
- {\r
- }\r
-\r
- ~Impl(){\r
- delete pCaption;\r
- }\r
-};\r
-\r
-\r
-mof::PlainWidgetView::PlainWidgetView\r
-(\r
- mof::Color begin , mof::Color end\r
-)\r
-: m_pImpl( new Impl( ) )\r
-{\r
-\r
- \r
- //m_pImpl->pFrame = new mof::Frame(m_pImpl->pGraphicsDevice , pTexture);\r
- m_pImpl->transform = mof::makeConstantHandler(mof::Matrix2D::createIdentity());\r
- {\r
- //visible\82Ì\90Ý\92è\r
- m_pImpl->visible = mof::makeConstantHandler(false);\r
- }\r
-\r
- //m_pImpl->pCaption = mof::Sprite::createTextSprite(pGraphicsDevice , mof::Font(mof::Font::MS_P_GOTHIC , 25) , title );\r
-}\r
- \r
-mof::PlainWidgetView::~PlainWidgetView(){\r
-\r
-}\r
-\r
-\r
-\r
-void mof::PlainWidgetView::setBounds(const mof::Rectangle<int>& bounds){\r
- m_pImpl->bounds = bounds;\r
-}\r
-\r
-mof::Rectangle<int> mof::PlainWidgetView::getBounds() const{\r
- return m_pImpl->transform->getValue(m_pImpl->frame).toBoundingBox();\r
-}\r
-\r
-\r
-\r
-void mof::PlainWidgetView::focus(){\r
-\r
-}\r
- \r
-void mof::PlainWidgetView::blur(){\r
-\r
-}\r
-\r
-\r
-void mof::PlainWidgetView::show(){\r
- const int width = m_pImpl->bounds.endX - m_pImpl->bounds.beginX;\r
- const int height = m_pImpl->bounds.endY - m_pImpl->bounds.beginY;\r
-\r
- mof::Animation<mof::Matrix2D>::Handler list[] = {\r
- mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(mof::Matrix2D::createScaling(mof::Vector2D(width , height)))) ,\r
- mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(\r
- mof::Matrix2D::createTranslation(mof::Vector2D(m_pImpl->bounds.beginX , m_pImpl->bounds.beginY))\r
- )) \r
- };\r
- m_pImpl->transform = mof::Animation<mof::Matrix2D>::Handler(new mof::CascadingAnimation<mof::Matrix2D>(list[0] , list[1]));\r
- \r
- {\r
- //visible\82Ì\90Ý\92è\r
- m_pImpl->visible = mof::makeConstantHandler(true);\r
- }\r
- m_pImpl->frame = 0;\r
-\r
-}\r
- \r
-void mof::PlainWidgetView::close(){\r
- const int width = m_pImpl->bounds.endX - m_pImpl->bounds.beginX;\r
- const int height = m_pImpl->bounds.endY - m_pImpl->bounds.beginY;\r
-\r
- mof::Animation<mof::Matrix2D>::Handler list[] = {\r
- mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(mof::Matrix2D::createScaling(mof::Vector2D(width , height)))) ,\r
- mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(\r
- mof::Matrix2D::createTranslation(mof::Vector2D(m_pImpl->bounds.beginX , m_pImpl->bounds.beginY))\r
- )) \r
- };\r
- m_pImpl->transform = mof::Animation<mof::Matrix2D>::Handler(new mof::CascadingAnimation<mof::Matrix2D>(list[0] , list[1]));\r
- \r
- {\r
- //visible\82Ì\90Ý\92è\r
- mof::KeyFrameAnimation<bool>::KeyFrame keyFrames[] = {\r
- mof::makeKeyFrame(0 , true) ,\r
- mof::makeKeyFrame(20 , false) \r
- };\r
- m_pImpl->visible = mof::Animation<bool>::Handler(\r
- new mof::KeyFrameAnimation<bool>(keyFrames[0] , keyFrames[1] , &mof::stepInterpolate<bool> )\r
- );\r
- }\r
- m_pImpl->frame = 0;\r
-}\r
-\r
-\r
-\r
-void mof::PlainWidgetView::update(){\r
- m_pImpl->frame++;\r
- //m_pImpl->pCaption->update();\r
- \r
-}\r
- \r
-void mof::PlainWidgetView::draw(){\r
- if(m_pImpl->visible->getValue(m_pImpl->frame)){\r
- //m_pImpl->pCaption->draw();\r
- }\r
-}\r
+#include "mof/PlainWidgetView.hpp"
+#include "mof/GraphicsDevice.hpp"
+#include "mof/Sprite.hpp"
+#include "mof/mofAnimations.hpp"
+#include "mof/Font.hpp"
+
+
+struct mof::PlainWidgetView::Impl{
+ mof::Animation<mof::Matrix2D>::Handler transform;
+ mof::Animation<bool>::Handler visible;
+ mof::FrameNumber frame;
+ mof::Rectangle<int> bounds;
+ mof::Sprite* pCaption;
+
+
+ Impl()
+ : frame(0) ,
+ bounds(mof::Rectangle<int>(0 , 0 , 0 , 0)) , pCaption(NULL)
+ {
+ }
+
+ ~Impl(){
+ delete pCaption;
+ }
+};
+
+
+mof::PlainWidgetView::PlainWidgetView
+(
+ mof::Color begin , mof::Color end
+)
+: m_pImpl( new Impl( ) )
+{
+
+
+ //m_pImpl->pFrame = new mof::Frame(m_pImpl->pGraphicsDevice , pTexture);
+ m_pImpl->transform = mof::makeConstantHandler(mof::Matrix2D::createIdentity());
+ {
+ //visible\82Ì\90Ý\92è
+ m_pImpl->visible = mof::makeConstantHandler(false);
+ }
+
+ //m_pImpl->pCaption = mof::Sprite::createTextSprite(pGraphicsDevice , mof::Font(mof::Font::MS_P_GOTHIC , 25) , title );
+}
+
+mof::PlainWidgetView::~PlainWidgetView(){
+
+}
+
+
+
+void mof::PlainWidgetView::setBounds(const mof::Rectangle<int>& bounds){
+ m_pImpl->bounds = bounds;
+}
+
+mof::Rectangle<int> mof::PlainWidgetView::getBounds() const{
+ return m_pImpl->transform->getValue(m_pImpl->frame).toBoundingBox();
+}
+
+
+
+void mof::PlainWidgetView::focus(){
+
+}
+
+void mof::PlainWidgetView::blur(){
+
+}
+
+
+void mof::PlainWidgetView::show(){
+ const int width = m_pImpl->bounds.endX - m_pImpl->bounds.beginX;
+ const int height = m_pImpl->bounds.endY - m_pImpl->bounds.beginY;
+
+ mof::Animation<mof::Matrix2D>::Handler list[] = {
+ mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(mof::Matrix2D::createScaling(mof::Vector2D(width , height)))) ,
+ mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(
+ mof::Matrix2D::createTranslation(mof::Vector2D(m_pImpl->bounds.beginX , m_pImpl->bounds.beginY))
+ ))
+ };
+ m_pImpl->transform = mof::Animation<mof::Matrix2D>::Handler(new mof::CascadingAnimation<mof::Matrix2D>(list[0] , list[1]));
+
+ {
+ //visible\82Ì\90Ý\92è
+ m_pImpl->visible = mof::makeConstantHandler(true);
+ }
+ m_pImpl->frame = 0;
+
+}
+
+void mof::PlainWidgetView::close(){
+ const int width = m_pImpl->bounds.endX - m_pImpl->bounds.beginX;
+ const int height = m_pImpl->bounds.endY - m_pImpl->bounds.beginY;
+
+ mof::Animation<mof::Matrix2D>::Handler list[] = {
+ mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(mof::Matrix2D::createScaling(mof::Vector2D(width , height)))) ,
+ mof::Animation<mof::Matrix2D>::Handler(mof::makeConstantHandler(
+ mof::Matrix2D::createTranslation(mof::Vector2D(m_pImpl->bounds.beginX , m_pImpl->bounds.beginY))
+ ))
+ };
+ m_pImpl->transform = mof::Animation<mof::Matrix2D>::Handler(new mof::CascadingAnimation<mof::Matrix2D>(list[0] , list[1]));
+
+ {
+ //visible\82Ì\90Ý\92è
+ mof::KeyFrameAnimation<bool>::KeyFrame keyFrames[] = {
+ mof::makeKeyFrame(0 , true) ,
+ mof::makeKeyFrame(20 , false)
+ };
+ m_pImpl->visible = mof::Animation<bool>::Handler(
+ new mof::KeyFrameAnimation<bool>(keyFrames[0] , keyFrames[1] , &mof::stepInterpolate<bool> )
+ );
+ }
+ m_pImpl->frame = 0;
+}
+
+
+
+void mof::PlainWidgetView::update(){
+ m_pImpl->frame++;
+ //m_pImpl->pCaption->update();
+
+}
+
+void mof::PlainWidgetView::draw(){
+ if(m_pImpl->visible->getValue(m_pImpl->frame)){
+ //m_pImpl->pCaption->draw();
+ }
+}
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/WidgetView.hpp"\r
-#include "mof/tstring.hpp"\r
-#include "mof/Color.hpp"\r
-\r
-namespace mof{\r
- \r
- \r
- class PlainWidgetView : public WidgetView{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- public:\r
- PlainWidgetView( mof::Color begin , mof::Color end);\r
- ~PlainWidgetView();\r
-\r
- virtual void setBounds(const mof::Rectangle<int>& bounds);\r
- virtual mof::Rectangle<int> getBounds() const;\r
-\r
- virtual void show();\r
- virtual void close();\r
- virtual void focus();\r
- virtual void blur();\r
-\r
- virtual void update();\r
- virtual void draw();\r
- };\r
-\r
-}\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include "mof/WidgetView.hpp"
+#include "mof/tstring.hpp"
+#include "mof/Color.hpp"
+
+namespace mof{
+
+
+ class PlainWidgetView : public WidgetView{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ public:
+ PlainWidgetView( mof::Color begin , mof::Color end);
+ ~PlainWidgetView();
+
+ virtual void setBounds(const mof::Rectangle<int>& bounds);
+ virtual mof::Rectangle<int> getBounds() const;
+
+ virtual void show();
+ virtual void close();
+ virtual void focus();
+ virtual void blur();
+
+ virtual void update();
+ virtual void draw();
+ };
+
+}
-#pragma once\r
-#include <iostream>\r
-\r
-namespace mof\r
-{\r
- template<typename E>\r
- struct Rectangle\r
- {\r
- E beginX;\r
- E beginY;\r
- E endX;\r
- E endY;\r
-\r
- Rectangle(){}\r
-\r
- template< typename T >\r
- Rectangle(const Rectangle<T>& obj)\r
- { \r
- beginX = obj.beginX;\r
- beginY = obj.beginY;\r
- endX = obj.endX;\r
- endY = obj.endY;\r
- }\r
-\r
- Rectangle(const E& beginX_ , const E& beginY_ , const E& endX_ , const E& endY_)\r
- : beginX(beginX_) , beginY(beginY_) , endX(endX_) , endY(endY_)\r
- {\r
- }\r
- \r
- template< typename T >\r
- Rectangle& operator = ( const Rectangle<T>& obj )\r
- { \r
- beginX = obj.beginX;\r
- beginY = obj.beginY;\r
- endX = obj.endX;\r
- endY = obj.endY;\r
- return *this;\r
- }\r
-\r
- E getWidth( ) const\r
- {\r
- E width = endX - beginX;\r
- return width < 0 ? -width : width;\r
- }\r
- \r
- E getHeight( ) const\r
- {\r
- E height = endY - beginY;\r
- return height < 0 ? -height : height;\r
- }\r
-\r
-\r
- bool operator ==(const mof::Rectangle<E>& rect){\r
- if(\r
- beginX == rect.beginX &&\r
- beginY == rect.beginY &&\r
- endX == rect.endX &&\r
- endY == rect.endY )return true;\r
- else return false;\r
- }\r
-\r
- \r
- };\r
-\r
- template<typename E>\r
- std::ostream& operator <<(std::ostream& os , const mof::Rectangle<E>& rect){\r
- os << '(' << rect.beginX << ',' << rect.beginY << ','\r
- << rect.endX << ',' << rect.endY << ')';\r
- return os; \r
- }\r
- \r
-}\r
+#pragma once
+#include <iostream>
+
+namespace mof
+{
+ template<typename E>
+ struct Rectangle
+ {
+ E beginX;
+ E beginY;
+ E endX;
+ E endY;
+
+ Rectangle(){}
+
+ template< typename T >
+ Rectangle(const Rectangle<T>& obj)
+ {
+ beginX = obj.beginX;
+ beginY = obj.beginY;
+ endX = obj.endX;
+ endY = obj.endY;
+ }
+
+ Rectangle(const E& beginX_ , const E& beginY_ , const E& endX_ , const E& endY_)
+ : beginX(beginX_) , beginY(beginY_) , endX(endX_) , endY(endY_)
+ {
+ }
+
+ template< typename T >
+ Rectangle& operator = ( const Rectangle<T>& obj )
+ {
+ beginX = obj.beginX;
+ beginY = obj.beginY;
+ endX = obj.endX;
+ endY = obj.endY;
+ return *this;
+ }
+
+ E getWidth( ) const
+ {
+ E width = endX - beginX;
+ return width < 0 ? -width : width;
+ }
+
+ E getHeight( ) const
+ {
+ E height = endY - beginY;
+ return height < 0 ? -height : height;
+ }
+
+
+ bool operator ==(const mof::Rectangle<E>& rect){
+ if(
+ beginX == rect.beginX &&
+ beginY == rect.beginY &&
+ endX == rect.endX &&
+ endY == rect.endY )return true;
+ else return false;
+ }
+
+
+ };
+
+ template<typename E>
+ std::ostream& operator <<(std::ostream& os , const mof::Rectangle<E>& rect){
+ os << '(' << rect.beginX << ',' << rect.beginY << ','
+ << rect.endX << ',' << rect.endY << ')';
+ return os;
+ }
+
+}
-#pragma once\r
-#include "mof/tstring.hpp"\r
-#include <map>\r
-#include <list>\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-namespace mof{\r
- \r
- \r
-\r
- /** \83\8a\83\\81[\83X\82Ì\83v\81[\83\8b\81A\92x\89\84\83\8d\81[\83h\8b@\94\\82ð\92ñ\8b\9f\82·\82é\83e\83\93\83v\83\8c\81[\83g\r
- *\r
- *\r
- */\r
- template <class T >\r
- class ResourceManager\r
- {\r
- typedef std::list<boost::shared_ptr<ResourceManager<T > > > MANAGER_LIST;\r
- typedef std::map<mof::tstring , boost::shared_ptr<T>> RESOURCE_MAP;\r
- \r
-\r
- ResourceManager<T>* m_pParent;\r
- RESOURCE_MAP m_resources;\r
- MANAGER_LIST m_children;\r
- \r
- static boost::shared_ptr<T> nullPtr;\r
- //void addResouce(Resouce* pResource);\r
- public:\r
- ResourceManager();\r
- virtual ~ResourceManager(void);\r
-\r
- boost::shared_ptr<T>& getResource(tstring& name );\r
- boost::shared_ptr<T>& getResource(const TCHAR * const name );\r
- void addResource(const TCHAR * const name , boost::shared_ptr<T>& resource);\r
- boost::shared_ptr< ResourceManager<T> > createChild();\r
- };\r
-\r
-\r
-\r
- template <class T>\r
- boost::shared_ptr<T> ResourceManager<T>::nullPtr = boost::shared_ptr<T>();\r
-\r
-\r
-\r
- /** \90e\82È\82µ\82Æ\82µ\82Ä\83I\83u\83W\83F\83N\83g\90¶\90¬\r
- *\r
- */\r
- template <class T >\r
- ResourceManager<T >::ResourceManager( ){\r
- m_pParent = NULL;\r
- }\r
-\r
- /** \8e©\90g\82Ì\83\8a\83\\81[\83X\82Æ\8eq\82ð\89ð\95ú\82µ\81A\90e\82Ì\8eq\83\8a\83X\83g\82©\82ç\8e©\90g\82ð\8dí\8f\9c\r
- */\r
- template <class T >\r
- ResourceManager<T >::~ResourceManager(){\r
- //\8e©\90g\82Ì\8aÇ\97\9d\82·\82é\83\8a\83\\81[\83X\82ð\83A\83\93\83\8d\81[\83h\r
- m_resources.clear();\r
-\r
- //\8eq\83I\83u\83W\83F\83N\83g\82ð\8dí\8f\9c\r
- m_children.clear();\r
- \r
- //\90e\82©\82ç\8e©\90g\82ð\8dí\8f\9c\r
- if(m_pParent != NULL){\r
- for(MANAGER_LIST::iterator itr = m_pParent->m_children.begin() ; itr != m_pParent->m_children.end() ; ++itr){\r
- if(this == itr->get() ){\r
- m_pParent->m_children.erase(itr);\r
- return;\r
- }\r
- }\r
- }\r
- }\r
-\r
- \r
-\r
- /** \90V\82½\82È\8eq\82ð\92Ç\89Á\82µ\81A\95Ô\82·\r
- * @return \90¶\90¬\82µ\82½\8eq\r
- */\r
- template <class T >\r
- boost::shared_ptr< ResourceManager<T> > ResourceManager<T >::createChild(){\r
- boost::shared_ptr< ResourceManager<T > > manager(new ResourceManager<T>( ));\r
- manager->m_pParent = this;\r
- m_children.push_back(manager);\r
- return manager;\r
- }\r
-\r
- \r
- /** \96Ø\8d\\91¢\91S\91Ì\82©\82ç\8ew\92è\82³\82ê\82½\96¼\91O\82Ì\83\8a\83\\81[\83X\82ð\8c\9f\8dõ\81E\8eæ\93¾<br>\r
- * \8c©\82Â\82©\82ç\82È\82¯\82ê\82Î\81A\88ø\90\94\82ð\8c³\82É\90V\82½\82É\90¶\90¬\82·\82é\81B\r
- * @param name \83\8a\83\\81[\83X\96¼\r
- * @param parameter \83\8a\83\\81[\83X\8dì\90¬\8e\9e\82Ì\88ø\90\94\81i\8ew\92è\82µ\82È\82\82Ä\82à\82æ\82¢\81j \r
- * @return \97v\8b\81\82³\82ê\82½\83\8a\83\\81[\83X\r
- */\r
- template <class T >\r
- boost::shared_ptr<T>& ResourceManager<T >::getResource(mof::tstring& name){\r
- //\8e©\95ª\82Ì\83\8a\83X\83g\82©\82ç\92T\82·\r
- RESOURCE_MAP::const_iterator n = m_resources.find(name);\r
- if (n != m_resources.end()){\r
- return (boost::shared_ptr<T>&)n->second;\r
- }\r
- \r
- //\8eq\82Ì\83\8a\83X\83g\82©\82ç\92T\82·\r
-\r
- //\90e\82Ì\83\8a\83X\83g\82©\82ç\92T\82·\r
-\r
- //\82È\82¯\82ê\82Î\8dì\90¬\82·\82é\r
- boost::shared_ptr<T> resource( new T( name ) );\r
- //DEBUG_PRINT(resource->getName() << _T("\82ª\90¶\90¬\82³\82ê\82Ü\82µ\82½") );\r
- m_resources.insert(RESOURCE_MAP::value_type(name , resource));\r
- n = m_resources.find(name);\r
- return (boost::shared_ptr<T>&)n->second;\r
- }\r
-\r
- \r
-\r
- template <class T >\r
- boost::shared_ptr<T>& ResourceManager<T >::getResource(const TCHAR* const name){\r
- return getResource(mof::tstring(name));\r
- }\r
- \r
- template <class T>\r
- void ResourceManager<T>::addResource(const TCHAR* const name , boost::shared_ptr<T>& resource){\r
- m_resources.insert(RESOURCE_MAP::value_type(mof::tstring(name) , resource));\r
- }\r
-\r
-\r
- /*template <class T , typename K >\r
- boost::shared_ptr<T>& ResourceManager<T , K>::findResource(mof::tstring& name , K parameter){\r
-\r
- }*/\r
-\r
-\r
-};\r
+#pragma once
+#include "mof/tstring.hpp"
+#include <map>
+#include <list>
+#include <boost/shared_ptr.hpp>
+#include "mof/ConsoleIO.hpp"
+
+namespace mof{
+
+
+
+ /** \83\8a\83\\81[\83X\82Ì\83v\81[\83\8b\81A\92x\89\84\83\8d\81[\83h\8b@\94\\82ð\92ñ\8b\9f\82·\82é\83e\83\93\83v\83\8c\81[\83g
+ *
+ *
+ */
+ template <class T >
+ class ResourceManager
+ {
+ typedef std::list<boost::shared_ptr<ResourceManager<T > > > MANAGER_LIST;
+ typedef std::map<mof::tstring , boost::shared_ptr<T>> RESOURCE_MAP;
+
+
+ ResourceManager<T>* m_pParent;
+ RESOURCE_MAP m_resources;
+ MANAGER_LIST m_children;
+
+ static boost::shared_ptr<T> nullPtr;
+ //void addResouce(Resouce* pResource);
+ public:
+ ResourceManager();
+ virtual ~ResourceManager(void);
+
+ boost::shared_ptr<T>& getResource(tstring& name );
+ boost::shared_ptr<T>& getResource(const TCHAR * const name );
+ void addResource(const TCHAR * const name , boost::shared_ptr<T>& resource);
+ boost::shared_ptr< ResourceManager<T> > createChild();
+ };
+
+
+
+ template <class T>
+ boost::shared_ptr<T> ResourceManager<T>::nullPtr = boost::shared_ptr<T>();
+
+
+
+ /** \90e\82È\82µ\82Æ\82µ\82Ä\83I\83u\83W\83F\83N\83g\90¶\90¬
+ *
+ */
+ template <class T >
+ ResourceManager<T >::ResourceManager( ){
+ m_pParent = NULL;
+ }
+
+ /** \8e©\90g\82Ì\83\8a\83\\81[\83X\82Æ\8eq\82ð\89ð\95ú\82µ\81A\90e\82Ì\8eq\83\8a\83X\83g\82©\82ç\8e©\90g\82ð\8dí\8f\9c
+ */
+ template <class T >
+ ResourceManager<T >::~ResourceManager(){
+ //\8e©\90g\82Ì\8aÇ\97\9d\82·\82é\83\8a\83\\81[\83X\82ð\83A\83\93\83\8d\81[\83h
+ m_resources.clear();
+
+ //\8eq\83I\83u\83W\83F\83N\83g\82ð\8dí\8f\9c
+ m_children.clear();
+
+ //\90e\82©\82ç\8e©\90g\82ð\8dí\8f\9c
+ if(m_pParent != NULL){
+ for(MANAGER_LIST::iterator itr = m_pParent->m_children.begin() ; itr != m_pParent->m_children.end() ; ++itr){
+ if(this == itr->get() ){
+ m_pParent->m_children.erase(itr);
+ return;
+ }
+ }
+ }
+ }
+
+
+
+ /** \90V\82½\82È\8eq\82ð\92Ç\89Á\82µ\81A\95Ô\82·
+ * @return \90¶\90¬\82µ\82½\8eq
+ */
+ template <class T >
+ boost::shared_ptr< ResourceManager<T> > ResourceManager<T >::createChild(){
+ boost::shared_ptr< ResourceManager<T > > manager(new ResourceManager<T>( ));
+ manager->m_pParent = this;
+ m_children.push_back(manager);
+ return manager;
+ }
+
+
+ /** \96Ø\8d\\91¢\91S\91Ì\82©\82ç\8ew\92è\82³\82ê\82½\96¼\91O\82Ì\83\8a\83\\81[\83X\82ð\8c\9f\8dõ\81E\8eæ\93¾<br>
+ * \8c©\82Â\82©\82ç\82È\82¯\82ê\82Î\81A\88ø\90\94\82ð\8c³\82É\90V\82½\82É\90¶\90¬\82·\82é\81B
+ * @param name \83\8a\83\\81[\83X\96¼
+ * @param parameter \83\8a\83\\81[\83X\8dì\90¬\8e\9e\82Ì\88ø\90\94\81i\8ew\92è\82µ\82È\82\82Ä\82à\82æ\82¢\81j
+ * @return \97v\8b\81\82³\82ê\82½\83\8a\83\\81[\83X
+ */
+ template <class T >
+ boost::shared_ptr<T>& ResourceManager<T >::getResource(mof::tstring& name){
+ //\8e©\95ª\82Ì\83\8a\83X\83g\82©\82ç\92T\82·
+ RESOURCE_MAP::const_iterator n = m_resources.find(name);
+ if (n != m_resources.end()){
+ return (boost::shared_ptr<T>&)n->second;
+ }
+
+ //\8eq\82Ì\83\8a\83X\83g\82©\82ç\92T\82·
+
+ //\90e\82Ì\83\8a\83X\83g\82©\82ç\92T\82·
+
+ //\82È\82¯\82ê\82Î\8dì\90¬\82·\82é
+ boost::shared_ptr<T> resource( new T( name ) );
+ //DEBUG_PRINT(resource->getName() << _T("\82ª\90¶\90¬\82³\82ê\82Ü\82µ\82½") );
+ m_resources.insert(RESOURCE_MAP::value_type(name , resource));
+ n = m_resources.find(name);
+ return (boost::shared_ptr<T>&)n->second;
+ }
+
+
+
+ template <class T >
+ boost::shared_ptr<T>& ResourceManager<T >::getResource(const TCHAR* const name){
+ return getResource(mof::tstring(name));
+ }
+
+ template <class T>
+ void ResourceManager<T>::addResource(const TCHAR* const name , boost::shared_ptr<T>& resource){
+ m_resources.insert(RESOURCE_MAP::value_type(mof::tstring(name) , resource));
+ }
+
+
+ /*template <class T , typename K >
+ boost::shared_ptr<T>& ResourceManager<T , K>::findResource(mof::tstring& name , K parameter){
+
+ }*/
+
+
+};
-#ifndef SCENE_GRAPH_HPP\r
-#define SCENE_GRAPH_HPP\r
-\r
-\r
-\r
-namespace mof{\r
-\r
-\r
-\r
-class SceneGraph \r
-{\r
-public:\r
- virtual ~SceneGraph(){}\r
- virtual bool isVisible() const = 0;\r
- virtual void update() = 0;\r
- virtual void draw() const = 0;\r
- //virtual bool isDisposable() const = 0;\r
-\r
-};\r
-\r
-}\r
-\r
-#endif\r
+#ifndef SCENE_GRAPH_HPP
+#define SCENE_GRAPH_HPP
+
+
+
+namespace mof{
+
+
+
+class SceneGraph
+{
+public:
+ virtual ~SceneGraph(){}
+ virtual bool isVisible() const = 0;
+ virtual void update() = 0;
+ virtual void draw() const = 0;
+ //virtual bool isDisposable() const = 0;
+
+};
+
+}
+
+#endif
-#include "mof/SelectionModel.h"\r
-#include "mof/ConsoleIO.h"\r
-\r
-mof::SelectionModel::SelectionModel( std::vector<mof::Window*>& selectables , mof::AnimationResource& pMenuAnimation , int nColumns)\r
-{\r
- m_nColumns = nColumns;\r
- m_pMenuAnimation = pMenuAnimation;\r
- m_selectables = selectables;\r
- m_selectingIndex = 0;\r
- m_selectables.at(m_selectingIndex)->setFocused(true);\r
-\r
-}\r
-\r
-mof::SelectionModel::~SelectionModel(){\r
- \r
-}\r
-\r
-void mof::SelectionModel::next(){\r
- if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;\r
- m_selectables.at(m_selectingIndex)->setFocused(false);\r
- m_selectingIndex = (m_selectingIndex+1)%m_selectables.size();\r
- m_selectables.at(m_selectingIndex)->setFocused(true);\r
-}\r
-\r
-void mof::SelectionModel::previous(){\r
- if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;\r
- m_selectables.at(m_selectingIndex)->setFocused(false);\r
- m_selectingIndex = (m_selectingIndex == 0)? m_selectables.size()-1 : m_selectingIndex-1;\r
- m_selectables.at(m_selectingIndex)->setFocused(true);\r
-\r
-}\r
-\r
-void mof::SelectionModel::up(){\r
- if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;\r
- m_selectables.at(m_selectingIndex)->setFocused(false);\r
- m_selectingIndex = (m_selectingIndex - m_nColumns);\r
- if(m_selectingIndex < 0)m_selectingIndex += m_selectables.size();\r
- m_selectables.at(m_selectingIndex)->setFocused(true);\r
-}\r
-\r
-void mof::SelectionModel::down(){\r
- if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;\r
- m_selectables.at(m_selectingIndex)->setFocused(false);\r
- m_selectingIndex = (m_selectingIndex + m_nColumns)% m_selectables.size();\r
- m_selectables.at(m_selectingIndex)->setFocused(true);\r
-}\r
-\r
-void mof::SelectionModel::left(){\r
- if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;\r
- m_selectables.at(m_selectingIndex)->setFocused(false);\r
- m_selectingIndex += (m_selectingIndex % m_nColumns == 0)? m_nColumns-1 : -1;\r
- m_selectables.at(m_selectingIndex)->setFocused(true);\r
-}\r
-\r
-void mof::SelectionModel::right(){\r
- if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;\r
- m_selectables.at(m_selectingIndex)->setFocused(false);\r
- m_selectingIndex += (m_selectingIndex % m_nColumns == m_nColumns-1)? -(m_selectingIndex % m_nColumns) : 1;\r
- m_selectables.at(m_selectingIndex)->setFocused(true);\r
-}\r
-\r
-\r
-int mof::SelectionModel::getSelectingIndex(){\r
- return m_selectingIndex;\r
-}\r
-\r
-mof::Window* mof::SelectionModel::getSelectingItem(){\r
- return m_selectables.at(m_selectingIndex);\r
-}\r
-\r
-void mof::SelectionModel::setMenuAnimation(mof::AnimationResource& pMenuAnimation){\r
- m_pMenuAnimation = pMenuAnimation;\r
-}\r
+#include "mof/SelectionModel.h"
+#include "mof/ConsoleIO.h"
+
+mof::SelectionModel::SelectionModel( std::vector<mof::Window*>& selectables , mof::AnimationResource& pMenuAnimation , int nColumns)
+{
+ m_nColumns = nColumns;
+ m_pMenuAnimation = pMenuAnimation;
+ m_selectables = selectables;
+ m_selectingIndex = 0;
+ m_selectables.at(m_selectingIndex)->setFocused(true);
+
+}
+
+mof::SelectionModel::~SelectionModel(){
+
+}
+
+void mof::SelectionModel::next(){
+ if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;
+ m_selectables.at(m_selectingIndex)->setFocused(false);
+ m_selectingIndex = (m_selectingIndex+1)%m_selectables.size();
+ m_selectables.at(m_selectingIndex)->setFocused(true);
+}
+
+void mof::SelectionModel::previous(){
+ if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;
+ m_selectables.at(m_selectingIndex)->setFocused(false);
+ m_selectingIndex = (m_selectingIndex == 0)? m_selectables.size()-1 : m_selectingIndex-1;
+ m_selectables.at(m_selectingIndex)->setFocused(true);
+
+}
+
+void mof::SelectionModel::up(){
+ if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;
+ m_selectables.at(m_selectingIndex)->setFocused(false);
+ m_selectingIndex = (m_selectingIndex - m_nColumns);
+ if(m_selectingIndex < 0)m_selectingIndex += m_selectables.size();
+ m_selectables.at(m_selectingIndex)->setFocused(true);
+}
+
+void mof::SelectionModel::down(){
+ if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;
+ m_selectables.at(m_selectingIndex)->setFocused(false);
+ m_selectingIndex = (m_selectingIndex + m_nColumns)% m_selectables.size();
+ m_selectables.at(m_selectingIndex)->setFocused(true);
+}
+
+void mof::SelectionModel::left(){
+ if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;
+ m_selectables.at(m_selectingIndex)->setFocused(false);
+ m_selectingIndex += (m_selectingIndex % m_nColumns == 0)? m_nColumns-1 : -1;
+ m_selectables.at(m_selectingIndex)->setFocused(true);
+}
+
+void mof::SelectionModel::right(){
+ if(m_pMenuAnimation.get() != NULL && !m_pMenuAnimation->isFinalized())return;
+ m_selectables.at(m_selectingIndex)->setFocused(false);
+ m_selectingIndex += (m_selectingIndex % m_nColumns == m_nColumns-1)? -(m_selectingIndex % m_nColumns) : 1;
+ m_selectables.at(m_selectingIndex)->setFocused(true);
+}
+
+
+int mof::SelectionModel::getSelectingIndex(){
+ return m_selectingIndex;
+}
+
+mof::Window* mof::SelectionModel::getSelectingItem(){
+ return m_selectables.at(m_selectingIndex);
+}
+
+void mof::SelectionModel::setMenuAnimation(mof::AnimationResource& pMenuAnimation){
+ m_pMenuAnimation = pMenuAnimation;
+}
-#pragma once\r
-#include "mof/Window.h"\r
-#include <vector>\r
-\r
-namespace mof{\r
- \r
- class SelectionModel {\r
- \r
- mof::AnimationResource m_pMenuAnimation;\r
- std::vector<mof::Window*> m_selectables;\r
- int m_selectingIndex;\r
- int m_nColumns;\r
- public:\r
- SelectionModel( std::vector<mof::Window*>& selectables , mof::AnimationResource& pOpenedAnimation , int nColumn = 1);\r
- ~SelectionModel();\r
-\r
-\r
- void next();\r
- void previous();\r
-\r
- void up();\r
- void down();\r
- void left();\r
- void right();\r
-\r
- int getSelectingIndex();\r
- Window* getSelectingItem();\r
- void setMenuAnimation(mof::AnimationResource& pMenuAnimation);\r
- \r
-\r
- \r
- };\r
-\r
+#pragma once
+#include "mof/Window.h"
+#include <vector>
+
+namespace mof{
+
+ class SelectionModel {
+
+ mof::AnimationResource m_pMenuAnimation;
+ std::vector<mof::Window*> m_selectables;
+ int m_selectingIndex;
+ int m_nColumns;
+ public:
+ SelectionModel( std::vector<mof::Window*>& selectables , mof::AnimationResource& pOpenedAnimation , int nColumn = 1);
+ ~SelectionModel();
+
+
+ void next();
+ void previous();
+
+ void up();
+ void down();
+ void left();
+ void right();
+
+ int getSelectingIndex();
+ Window* getSelectingItem();
+ void setMenuAnimation(mof::AnimationResource& pMenuAnimation);
+
+
+
+ };
+
};
\ No newline at end of file
-#include "mof/Sprite.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include "mof/stream/Constant.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/Font.hpp"\r
-\r
-namespace mof\r
-{\r
- struct Sprite::Impl{\r
- boost::shared_ptr<Texture> pTexture;\r
-\r
- Impl()\r
- {\r
- }\r
-\r
- ~Impl(){\r
- }\r
- };\r
-\r
- Sprite::Sprite\r
- (\r
- const Rectangle<int>& rect ,\r
- const boost::shared_ptr<Texture>& pTexture , \r
- const Rectangle<float>& tRect \r
- )\r
- : \r
- m_pImpl( new Impl( ) ) ,\r
- Component2D( rect ) ,\r
- TextureComponent( tRect ) \r
- {\r
- m_pImpl->pTexture = pTexture;\r
- }\r
-\r
-\r
- Sprite::Sprite\r
- (\r
- const boost::shared_ptr<Texture>& pTexture , \r
- const Rectangle<float>& tRect \r
- )\r
- : \r
- m_pImpl(new Impl()) ,\r
- Component2D( Rectangle<int>( 0 , 0 , pTexture->getWidth() , pTexture->getHeight() ) ) ,\r
- TextureComponent( tRect ) \r
- {\r
- m_pImpl->pTexture = pTexture;\r
- }\r
-\r
-\r
- Sprite::~Sprite()\r
- {\r
- } \r
-\r
- void Sprite::update()\r
- {\r
- m_textureStream.update();\r
- m_colorStream.update();\r
- m_sizeStream.update();\r
- m_positionStream.update();\r
- }\r
-\r
- void Sprite::draw() const\r
- {\r
- static VertexXYZRHWCUV vertices[4];\r
- \r
- Rectangle<float> textureCoordinates = m_textureStream.value( );\r
- Color color = m_colorStream.value( ).toColorCode( );\r
- \r
- //textureCoordinates = mof::Rectangle<float>( 0 , 0 , 0.625 , 0.546875 );\r
- Vector2D position = m_positionStream.value( );\r
- Vector2D size = m_sizeStream.value( );\r
- Vector2D begin = Vector2D( position.x , position.y );\r
- Vector2D end = begin + Vector2D( size.x , size.y );\r
- \r
- vertices[0].x = static_cast<float>(begin.x);\r
- vertices[0].y = static_cast<float>(begin.y);\r
- vertices[0].z = 0;\r
- vertices[0].rhw = 1;\r
- vertices[0].color = color;\r
- vertices[0].tu = textureCoordinates.beginX;\r
- vertices[0].tv = textureCoordinates.beginY;\r
-\r
- vertices[1].x = static_cast<float>(end.x);\r
- vertices[1].y = static_cast<float>(begin.y);\r
- vertices[1].z = 0;\r
- vertices[1].rhw = 1;\r
- vertices[1].color = color;\r
- vertices[1].tu = textureCoordinates.endX;\r
- vertices[1].tv = textureCoordinates.beginY;\r
-\r
- vertices[2].x = static_cast<float>(begin.x);\r
- vertices[2].y = static_cast<float>(end.y);\r
- vertices[2].z = 0;\r
- vertices[2].rhw = 1;\r
- vertices[2].color = color;\r
- vertices[2].tu = textureCoordinates.beginX;\r
- vertices[2].tv = textureCoordinates.endY;\r
-\r
- vertices[3].x = static_cast<float>(end.x);\r
- vertices[3].y = static_cast<float>(end.y);\r
- vertices[3].z = 0;\r
- vertices[3].rhw = 1;\r
- vertices[3].color = color;\r
- vertices[3].tu = textureCoordinates.endX;\r
- vertices[3].tv = textureCoordinates.endY;\r
-\r
- GraphicsDevice::setTexture(m_pImpl->pTexture.get());\r
- GraphicsDevice::drawVertexArray(vertices[0] , vertices[3] , PRIMITIVE_TYPE_TRIANGLESTRIP);\r
- \r
- }\r
-\r
- void Sprite::setPositionStream( const Vector2DStream& stream )\r
- {\r
- m_positionStream = stream;\r
- }\r
- \r
- void Sprite::setSizeStream( const Vector2DStream& stream )\r
- {\r
- m_sizeStream = stream;\r
- }\r
-\r
-\r
- void Sprite::append\r
- (\r
- std::vector<VertexXYZRHWCUV>& list ,\r
- const Rectangle<float>& region , \r
- Color color , \r
- const Rectangle<float>& textureCoordinates\r
- )\r
- {\r
- list.push_back\r
- (\r
- VertexXYZRHWCUV(Vector2D(region.beginX , region.beginY) , \r
- color , textureCoordinates.beginX , textureCoordinates.beginY)\r
- );\r
-\r
- list.push_back\r
- (\r
- VertexXYZRHWCUV(Vector2D(region.endX , region.beginY) , \r
- color , textureCoordinates.endX , textureCoordinates.beginY)\r
- );\r
-\r
- list.push_back\r
- (\r
- VertexXYZRHWCUV(Vector2D(region.beginX , region.endY) , \r
- color , textureCoordinates.beginX , textureCoordinates.endY)\r
- );\r
-\r
- list.push_back\r
- (\r
- VertexXYZRHWCUV(Vector2D(region.beginX , region.endY) , \r
- color , textureCoordinates.beginX , textureCoordinates.endY)\r
- );\r
-\r
- list.push_back\r
- (\r
- VertexXYZRHWCUV(Vector2D(region.endX , region.beginY) , \r
- color , textureCoordinates.endX , textureCoordinates.beginY)\r
- );\r
-\r
-\r
- list.push_back\r
- (\r
- VertexXYZRHWCUV(Vector2D(region.endX , region.endY) , \r
- color , textureCoordinates.endX , textureCoordinates.endY)\r
- );\r
-\r
- }\r
-\r
- Sprite* Sprite::createTextSprite( const Font& font , const tstring& text)\r
- {\r
- boost::shared_ptr<PixelMap> pPixelMap( font.createText(text) );\r
- boost::shared_ptr<Texture> pTexture(new Texture( pPixelMap));\r
-\r
- return new Sprite\r
- (\r
- Rectangle<int>( 0 , 0 , pPixelMap->shape()[0] , pPixelMap->shape()[1]) ,\r
- pTexture ,\r
- Rectangle<real>\r
- (\r
- 0 , 0 , \r
- static_cast<real>(pPixelMap->shape()[0]) / pTexture->getWidth() ,\r
- static_cast<real>(pPixelMap->shape()[1]) / pTexture->getHeight() \r
- )\r
- );\r
-\r
- }\r
-\r
-\r
-} // namespace mof\r
-\r
-\r
-\r
+#include "mof/Sprite.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include "mof/stream/Constant.hpp"
+#include "mof/ConsoleIO.hpp"
+#include "mof/Font.hpp"
+
+namespace mof
+{
+ struct Sprite::Impl{
+ boost::shared_ptr<Texture> pTexture;
+
+ Impl()
+ {
+ }
+
+ ~Impl(){
+ }
+ };
+
+ Sprite::Sprite
+ (
+ const Rectangle<int>& rect ,
+ const boost::shared_ptr<Texture>& pTexture ,
+ const Rectangle<float>& tRect
+ )
+ :
+ m_pImpl( new Impl( ) ) ,
+ Component2D( rect ) ,
+ TextureComponent( tRect )
+ {
+ m_pImpl->pTexture = pTexture;
+ }
+
+
+ Sprite::Sprite
+ (
+ const boost::shared_ptr<Texture>& pTexture ,
+ const Rectangle<float>& tRect
+ )
+ :
+ m_pImpl(new Impl()) ,
+ Component2D( Rectangle<int>( 0 , 0 , pTexture->getWidth() , pTexture->getHeight() ) ) ,
+ TextureComponent( tRect )
+ {
+ m_pImpl->pTexture = pTexture;
+ }
+
+
+ Sprite::~Sprite()
+ {
+ }
+
+ void Sprite::update()
+ {
+ m_textureStream.update();
+ m_colorStream.update();
+ m_sizeStream.update();
+ m_positionStream.update();
+ }
+
+ void Sprite::draw() const
+ {
+ static VertexXYZRHWCUV vertices[4];
+
+ Rectangle<float> textureCoordinates = m_textureStream.value( );
+ Color color = m_colorStream.value( ).toColorCode( );
+
+ //textureCoordinates = mof::Rectangle<float>( 0 , 0 , 0.625 , 0.546875 );
+ Vector2D position = m_positionStream.value( );
+ Vector2D size = m_sizeStream.value( );
+ Vector2D begin = Vector2D( position.x , position.y );
+ Vector2D end = begin + Vector2D( size.x , size.y );
+
+ vertices[0].x = static_cast<float>(begin.x);
+ vertices[0].y = static_cast<float>(begin.y);
+ vertices[0].z = 0;
+ vertices[0].rhw = 1;
+ vertices[0].color = color;
+ vertices[0].tu = textureCoordinates.beginX;
+ vertices[0].tv = textureCoordinates.beginY;
+
+ vertices[1].x = static_cast<float>(end.x);
+ vertices[1].y = static_cast<float>(begin.y);
+ vertices[1].z = 0;
+ vertices[1].rhw = 1;
+ vertices[1].color = color;
+ vertices[1].tu = textureCoordinates.endX;
+ vertices[1].tv = textureCoordinates.beginY;
+
+ vertices[2].x = static_cast<float>(begin.x);
+ vertices[2].y = static_cast<float>(end.y);
+ vertices[2].z = 0;
+ vertices[2].rhw = 1;
+ vertices[2].color = color;
+ vertices[2].tu = textureCoordinates.beginX;
+ vertices[2].tv = textureCoordinates.endY;
+
+ vertices[3].x = static_cast<float>(end.x);
+ vertices[3].y = static_cast<float>(end.y);
+ vertices[3].z = 0;
+ vertices[3].rhw = 1;
+ vertices[3].color = color;
+ vertices[3].tu = textureCoordinates.endX;
+ vertices[3].tv = textureCoordinates.endY;
+
+ GraphicsDevice::setTexture(m_pImpl->pTexture.get());
+ GraphicsDevice::drawVertexArray(vertices[0] , vertices[3] , PRIMITIVE_TYPE_TRIANGLESTRIP);
+
+ }
+
+ void Sprite::setPositionStream( const Vector2DStream& stream )
+ {
+ m_positionStream = stream;
+ }
+
+ void Sprite::setSizeStream( const Vector2DStream& stream )
+ {
+ m_sizeStream = stream;
+ }
+
+
+ void Sprite::append
+ (
+ std::vector<VertexXYZRHWCUV>& list ,
+ const Rectangle<float>& region ,
+ Color color ,
+ const Rectangle<float>& textureCoordinates
+ )
+ {
+ list.push_back
+ (
+ VertexXYZRHWCUV(Vector2D(region.beginX , region.beginY) ,
+ color , textureCoordinates.beginX , textureCoordinates.beginY)
+ );
+
+ list.push_back
+ (
+ VertexXYZRHWCUV(Vector2D(region.endX , region.beginY) ,
+ color , textureCoordinates.endX , textureCoordinates.beginY)
+ );
+
+ list.push_back
+ (
+ VertexXYZRHWCUV(Vector2D(region.beginX , region.endY) ,
+ color , textureCoordinates.beginX , textureCoordinates.endY)
+ );
+
+ list.push_back
+ (
+ VertexXYZRHWCUV(Vector2D(region.beginX , region.endY) ,
+ color , textureCoordinates.beginX , textureCoordinates.endY)
+ );
+
+ list.push_back
+ (
+ VertexXYZRHWCUV(Vector2D(region.endX , region.beginY) ,
+ color , textureCoordinates.endX , textureCoordinates.beginY)
+ );
+
+
+ list.push_back
+ (
+ VertexXYZRHWCUV(Vector2D(region.endX , region.endY) ,
+ color , textureCoordinates.endX , textureCoordinates.endY)
+ );
+
+ }
+
+ Sprite* Sprite::createTextSprite( const Font& font , const tstring& text)
+ {
+ boost::shared_ptr<PixelMap> pPixelMap( font.createText(text) );
+ boost::shared_ptr<Texture> pTexture(new Texture( pPixelMap));
+
+ return new Sprite
+ (
+ Rectangle<int>( 0 , 0 , pPixelMap->shape()[0] , pPixelMap->shape()[1]) ,
+ pTexture ,
+ Rectangle<real>
+ (
+ 0 , 0 ,
+ static_cast<real>(pPixelMap->shape()[0]) / pTexture->getWidth() ,
+ static_cast<real>(pPixelMap->shape()[1]) / pTexture->getHeight()
+ )
+ );
+
+ }
+
+
+} // namespace mof
+
+
+
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/Rectangle.hpp"\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/Texture.hpp"\r
-#include "mof/VertexTypes.hpp"\r
-#include "mof/stream/Manipulator.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-#include "mof/Component2D.hpp"\r
-#include "mof/ColorComponent.hpp"\r
-#include "mof/TextureComponent.hpp"\r
-#include "mof/Drawable.hpp"\r
-#include <vector>\r
-\r
-\r
-namespace mof{\r
- \r
- class Font;\r
-\r
- class Sprite\r
- : \r
- public Component2D ,\r
- public ColorComponent ,\r
- public TextureComponent ,\r
- public Drawable\r
- {\r
-\r
- public : \r
- Sprite\r
- (\r
- const Rectangle<int>& rect ,\r
- const boost::shared_ptr<Texture>& pTexture ,\r
- const Rectangle<real>& tRect\r
- );\r
-\r
- Sprite\r
- (\r
- const boost::shared_ptr<Texture>& pTexture ,\r
- const Rectangle<real>& tRect\r
- );\r
-\r
- virtual ~Sprite();\r
- virtual void update();\r
- virtual void draw() const;\r
- virtual void setPositionStream( const Vector2DStream& stream );\r
- virtual void setSizeStream( const Vector2DStream& stream );\r
-\r
-\r
-\r
- static void append\r
- (\r
- std::vector<VertexXYZRHWCUV>& list ,\r
- const Rectangle<float>& region , \r
- Color color ,\r
- const Rectangle<real>& textureCoordinates\r
- );\r
-\r
- static Sprite* createTextSprite\r
- (\r
- const Font& font , \r
- const tstring& text\r
- );\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-\r
-} // namespace mof\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include "mof/Rectangle.hpp"
+#include <boost/shared_ptr.hpp>
+#include "mof/Texture.hpp"
+#include "mof/VertexTypes.hpp"
+#include "mof/stream/Manipulator.hpp"
+#include "mof/Matrix2D.hpp"
+#include "mof/Component2D.hpp"
+#include "mof/ColorComponent.hpp"
+#include "mof/TextureComponent.hpp"
+#include "mof/Drawable.hpp"
+#include <vector>
+
+
+namespace mof{
+
+ class Font;
+
+ class Sprite
+ :
+ public Component2D ,
+ public ColorComponent ,
+ public TextureComponent ,
+ public Drawable
+ {
+
+ public :
+ Sprite
+ (
+ const Rectangle<int>& rect ,
+ const boost::shared_ptr<Texture>& pTexture ,
+ const Rectangle<real>& tRect
+ );
+
+ Sprite
+ (
+ const boost::shared_ptr<Texture>& pTexture ,
+ const Rectangle<real>& tRect
+ );
+
+ virtual ~Sprite();
+ virtual void update();
+ virtual void draw() const;
+ virtual void setPositionStream( const Vector2DStream& stream );
+ virtual void setSizeStream( const Vector2DStream& stream );
+
+
+
+ static void append
+ (
+ std::vector<VertexXYZRHWCUV>& list ,
+ const Rectangle<float>& region ,
+ Color color ,
+ const Rectangle<real>& textureCoordinates
+ );
+
+ static Sprite* createTextSprite
+ (
+ const Font& font ,
+ const tstring& text
+ );
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+
+} // namespace mof
-#include "mof/TextCompiler.hpp"\r
-#include <boost/regex.hpp>\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-namespace {\r
- enum NodeType{\r
- PLANE ,\r
- NEWLINE\r
- } ;\r
-\r
- struct Node{\r
- mof::tstring subtext;\r
- NodeType type;\r
- };\r
-\r
-}\r
-\r
-void recursive(const mof::tstring& text , std::vector<mof::Sprite*>& result, const mof::Font& font){\r
- boost::basic_regex<TCHAR> regex("(.*)<\\s*nl\\s*/\\s*>(.*)");\r
- boost::smatch results;\r
- if(boost::regex_search(text , results , regex)){\r
- if( results.str(1).length() != 0)recursive(results.str(1) , result , font);\r
- if( results.str(2).length() != 0)recursive(results.str(2) , result , font);\r
- }\r
- else {\r
- result.push_back(mof::Sprite::createTextSprite(font , text) );\r
- }\r
-}\r
- \r
-bool mof::compileText\r
-(\r
- const mof::tstring &text ,\r
- const mof::Font &font ,\r
- std::vector<mof::Sprite*> &result \r
-){\r
- \r
- recursive(text , result , font);\r
- \r
-\r
-\r
- return true;\r
+#include "mof/TextCompiler.hpp"
+#include <boost/regex.hpp>
+#include "mof/ConsoleIO.hpp"
+
+namespace {
+ enum NodeType{
+ PLANE ,
+ NEWLINE
+ } ;
+
+ struct Node{
+ mof::tstring subtext;
+ NodeType type;
+ };
+
+}
+
+void recursive(const mof::tstring& text , std::vector<mof::Sprite*>& result, const mof::Font& font){
+ boost::basic_regex<TCHAR> regex("(.*)<\\s*nl\\s*/\\s*>(.*)");
+ boost::smatch results;
+ if(boost::regex_search(text , results , regex)){
+ if( results.str(1).length() != 0)recursive(results.str(1) , result , font);
+ if( results.str(2).length() != 0)recursive(results.str(2) , result , font);
+ }
+ else {
+ result.push_back(mof::Sprite::createTextSprite(font , text) );
+ }
+}
+
+bool mof::compileText
+(
+ const mof::tstring &text ,
+ const mof::Font &font ,
+ std::vector<mof::Sprite*> &result
+){
+
+ recursive(text , result , font);
+
+
+
+ return true;
}
\ No newline at end of file
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <vector>\r
-#include "mof/Sprite.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/Font.hpp"\r
-#include "mof/tstring.hpp"\r
-\r
-namespace mof{\r
-\r
- \r
- bool compileText(\r
- const mof::tstring& text , \r
- const mof::Font& font , \r
- std::vector<mof::Sprite*>& result\r
- );\r
-\r
-}\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <vector>
+#include "mof/Sprite.hpp"
+#include "mof/utilities.hpp"
+#include "mof/Font.hpp"
+#include "mof/tstring.hpp"
+
+namespace mof{
+
+
+ bool compileText(
+ const mof::tstring& text ,
+ const mof::Font& font ,
+ std::vector<mof::Sprite*>& result
+ );
+
+}
-#include "mof/TextView.hpp"\r
-#include "mof/MenuItemInfo.hpp"\r
-#include "mof/Sprite.hpp"\r
-#include "mof/Effect.hpp"\r
-#include "mof/Frame.hpp"\r
-#include "mof/mofAnimations.hpp"\r
-#include "mof/utilities.hpp"\r
-\r
-namespace mof\r
-{\r
- struct TextView::Impl\r
- {\r
- mof::Font font;\r
- mof::tstring caption;\r
- mof::Effect* pEffect;\r
- mof::Vector2D scaling;\r
- mof::Frame* pFrame;\r
-\r
- Impl(const mof::tstring& _caption , const mof::Font& _font)\r
- : font(_font) , caption(_caption) , pEffect(NULL) , pFrame( NULL )\r
- {\r
-\r
- }\r
-\r
-\r
- ~Impl(){\r
- delete pEffect;\r
- }\r
- };\r
-//{{{ TextView\r
- TextView::TextView(const mof::tstring& caption , const mof::Font& font)\r
- : m_pImpl(new Impl(caption , font))\r
- {\r
- m_pImpl->pEffect = new mof::Effect();\r
- }\r
-//}}}\r
-//{{{ ~TextView \r
- TextView::~TextView( )\r
- {\r
- }\r
-//}}}\r
-//{{{ initialize\r
- mof::Rectangle<int> TextView::initialize( )\r
- {\r
-\r
- \r
- mof::Sprite* pSprite = mof::Sprite::createTextSprite\r
- (\r
- m_pImpl->font , m_pImpl->caption\r
- );\r
-\r
- m_pImpl->pEffect->addSprite(_T("text") , pSprite);\r
- m_pImpl->scaling = pSprite->getWorldTransform().mof::Matrix2D::getDiagonal();\r
-\r
- {\r
- //color\r
- pSprite->setColor( mof::makeConstantHandler(mof::Color4f(0 , 1 , 1 , 1)) );\r
- }\r
- mof::Rectangle<int> bounds = pSprite->getWorldTransform().toBoundingBox();\r
- \r
- boost::shared_ptr<mof::Texture> pTexture(new mof::Texture( _T("image/frame3.png") ));\r
- m_pImpl->pFrame = new mof::Frame( pTexture );\r
- m_pImpl->pEffect->addDrawable( _T("bg") , m_pImpl->pFrame );\r
- m_pImpl->pFrame->setRegion( mof::Rectangle<int>( 100 , 100 , 200 , 132 ) );\r
- return bounds;\r
- }\r
-//}}}\r
-//{{{ show\r
- void TextView::show( )\r
- {\r
- mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));\r
- {\r
- //color\r
- mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] =\r
- {\r
- mof::makeKeyFrame( 0 , mof::Color4f(0 , 1, 1 , 1) ),\r
- mof::makeKeyFrame( 30 , mof::Color4f(1 , 1, 1 , 1) )\r
- };\r
- mof::Animation<mof::Color4f>::Handler handler\r
- (\r
- new mof::KeyFrameAnimation<mof::Color4f>\r
- (\r
- keyFrames[0] , keyFrames[1] \r
- )\r
- );\r
- pText->setColor( handler );\r
- pText->setFrameNumber( 0 );\r
- }\r
-\r
- }\r
-//}}}\r
-//{{{ close\r
- void mof::TextView::close(){\r
- mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));\r
- {\r
- //color\r
- mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));\r
- mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {\r
- mof::makeKeyFrame( 0 , mof::Color4f(1 , 1, 1 , 1) ),\r
- mof::makeKeyFrame( 10 , mof::Color4f(0 , 1, 1 , 1) )\r
- };\r
- mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(\r
- keyFrames[0] , keyFrames[1] \r
- ));\r
- pText->setColor( handler );\r
- pText->setFrameNumber(0);\r
- }\r
- }\r
-//}}}\r
-//{{{ focus\r
- void mof::TextView::focus( ) \r
- {\r
- }\r
-//}}}\r
-//{{{ blur\r
- void mof::TextView::blur()\r
- {\r
- }\r
-//}}}\r
-//{{{ setPosition\r
- void mof::TextView::setPosition\r
- (\r
- const mof::Animation<mof::Matrix2D>::Handler& handler \r
- ) \r
- {\r
- mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));\r
- mof::Animation<mof::Matrix2D>::Handler cascading[] = {\r
- mof::makeConstantHandler<mof::Matrix2D>(mof::Matrix2D::createScaling(m_pImpl->scaling)) , \r
- handler\r
- };\r
- mof::Animation<mof::Matrix2D>::Handler pAnimation(\r
- new mof::CascadingAnimation<mof::Matrix2D>(cascading[0] , cascading[1])\r
- );\r
- pText->setWorldTransform(pAnimation);\r
- /*pText->setWorldTransform(\r
- mof::cascadingHandler2(\r
- mof::Multiply<mof::Matrix2D> cascaor ,\r
- mof::makeConstantHandler<mof::Matrix2D>(mof::Matrix2D::createScaling(m_pImpl->scaling)) , \r
- handler\r
- ));*/\r
- }\r
-//}}}\r
-//{{{ setWorldTransform\r
- void mof::TextView::setWorldTransform\r
- (\r
- const mof::Animation<mof::Matrix2D>::Handler& handler \r
- ) \r
- {\r
- mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));\r
- pText->setWorldTransform( handler );\r
- \r
- }\r
-//}}}\r
-//{{{ setBounds\r
- void mof::TextView::setBounds( const mof::Rectangle<int>& bounds )\r
- {\r
- mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));\r
- //m_pImpl->scaling = mof::Vector2D( bounds.endX - bounds.beginX , bounds.endY - bounds.beginY );\r
- mof::Vector2D translation( bounds.beginX , bounds.beginY );\r
- mof::Animation<mof::Matrix2D>::Handler cascading[] = \r
- {\r
- mof::makeConstantHandler( mof::Matrix2D::createScaling( m_pImpl->scaling ) ) ,\r
- mof::makeConstantHandler( mof::Matrix2D::createTranslation( translation ) ) ,\r
- };\r
- mof::Animation<mof::Matrix2D>::Handler pAnimation(\r
- new mof::CascadingAnimation<mof::Matrix2D>(cascading[0] , mof::lastOf( cascading ) )\r
- );\r
- pText->setWorldTransform(pAnimation);\r
- }\r
-//}}}\r
-//{{{ getEffect\r
- const mof::Effect* TextView::getEffect() const\r
- {\r
- return m_pImpl->pEffect;\r
- }\r
-//}}}\r
-//{{{ update\r
- void mof::TextView::update()\r
- {\r
- m_pImpl->pEffect->update();\r
-\r
- }\r
-//}}}\r
-}\r
+#include "mof/TextView.hpp"
+#include "mof/MenuItemInfo.hpp"
+#include "mof/Sprite.hpp"
+#include "mof/Effect.hpp"
+#include "mof/Frame.hpp"
+#include "mof/mofAnimations.hpp"
+#include "mof/utilities.hpp"
+
+namespace mof
+{
+ struct TextView::Impl
+ {
+ mof::Font font;
+ mof::tstring caption;
+ mof::Effect* pEffect;
+ mof::Vector2D scaling;
+ mof::Frame* pFrame;
+
+ Impl(const mof::tstring& _caption , const mof::Font& _font)
+ : font(_font) , caption(_caption) , pEffect(NULL) , pFrame( NULL )
+ {
+
+ }
+
+
+ ~Impl(){
+ delete pEffect;
+ }
+ };
+//{{{ TextView
+ TextView::TextView(const mof::tstring& caption , const mof::Font& font)
+ : m_pImpl(new Impl(caption , font))
+ {
+ m_pImpl->pEffect = new mof::Effect();
+ }
+//}}}
+//{{{ ~TextView
+ TextView::~TextView( )
+ {
+ }
+//}}}
+//{{{ initialize
+ mof::Rectangle<int> TextView::initialize( )
+ {
+
+
+ mof::Sprite* pSprite = mof::Sprite::createTextSprite
+ (
+ m_pImpl->font , m_pImpl->caption
+ );
+
+ m_pImpl->pEffect->addSprite(_T("text") , pSprite);
+ m_pImpl->scaling = pSprite->getWorldTransform().mof::Matrix2D::getDiagonal();
+
+ {
+ //color
+ pSprite->setColor( mof::makeConstantHandler(mof::Color4f(0 , 1 , 1 , 1)) );
+ }
+ mof::Rectangle<int> bounds = pSprite->getWorldTransform().toBoundingBox();
+
+ boost::shared_ptr<mof::Texture> pTexture(new mof::Texture( _T("image/frame3.png") ));
+ m_pImpl->pFrame = new mof::Frame( pTexture );
+ m_pImpl->pEffect->addDrawable( _T("bg") , m_pImpl->pFrame );
+ m_pImpl->pFrame->setRegion( mof::Rectangle<int>( 100 , 100 , 200 , 132 ) );
+ return bounds;
+ }
+//}}}
+//{{{ show
+ void TextView::show( )
+ {
+ mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));
+ {
+ //color
+ mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] =
+ {
+ mof::makeKeyFrame( 0 , mof::Color4f(0 , 1, 1 , 1) ),
+ mof::makeKeyFrame( 30 , mof::Color4f(1 , 1, 1 , 1) )
+ };
+ mof::Animation<mof::Color4f>::Handler handler
+ (
+ new mof::KeyFrameAnimation<mof::Color4f>
+ (
+ keyFrames[0] , keyFrames[1]
+ )
+ );
+ pText->setColor( handler );
+ pText->setFrameNumber( 0 );
+ }
+
+ }
+//}}}
+//{{{ close
+ void mof::TextView::close(){
+ mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));
+ {
+ //color
+ mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));
+ mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {
+ mof::makeKeyFrame( 0 , mof::Color4f(1 , 1, 1 , 1) ),
+ mof::makeKeyFrame( 10 , mof::Color4f(0 , 1, 1 , 1) )
+ };
+ mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(
+ keyFrames[0] , keyFrames[1]
+ ));
+ pText->setColor( handler );
+ pText->setFrameNumber(0);
+ }
+ }
+//}}}
+//{{{ focus
+ void mof::TextView::focus( )
+ {
+ }
+//}}}
+//{{{ blur
+ void mof::TextView::blur()
+ {
+ }
+//}}}
+//{{{ setPosition
+ void mof::TextView::setPosition
+ (
+ const mof::Animation<mof::Matrix2D>::Handler& handler
+ )
+ {
+ mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));
+ mof::Animation<mof::Matrix2D>::Handler cascading[] = {
+ mof::makeConstantHandler<mof::Matrix2D>(mof::Matrix2D::createScaling(m_pImpl->scaling)) ,
+ handler
+ };
+ mof::Animation<mof::Matrix2D>::Handler pAnimation(
+ new mof::CascadingAnimation<mof::Matrix2D>(cascading[0] , cascading[1])
+ );
+ pText->setWorldTransform(pAnimation);
+ /*pText->setWorldTransform(
+ mof::cascadingHandler2(
+ mof::Multiply<mof::Matrix2D> cascaor ,
+ mof::makeConstantHandler<mof::Matrix2D>(mof::Matrix2D::createScaling(m_pImpl->scaling)) ,
+ handler
+ ));*/
+ }
+//}}}
+//{{{ setWorldTransform
+ void mof::TextView::setWorldTransform
+ (
+ const mof::Animation<mof::Matrix2D>::Handler& handler
+ )
+ {
+ mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));
+ pText->setWorldTransform( handler );
+
+ }
+//}}}
+//{{{ setBounds
+ void mof::TextView::setBounds( const mof::Rectangle<int>& bounds )
+ {
+ mof::Sprite* pText = m_pImpl->pEffect->getSpriteByName(_T("text"));
+ //m_pImpl->scaling = mof::Vector2D( bounds.endX - bounds.beginX , bounds.endY - bounds.beginY );
+ mof::Vector2D translation( bounds.beginX , bounds.beginY );
+ mof::Animation<mof::Matrix2D>::Handler cascading[] =
+ {
+ mof::makeConstantHandler( mof::Matrix2D::createScaling( m_pImpl->scaling ) ) ,
+ mof::makeConstantHandler( mof::Matrix2D::createTranslation( translation ) ) ,
+ };
+ mof::Animation<mof::Matrix2D>::Handler pAnimation(
+ new mof::CascadingAnimation<mof::Matrix2D>(cascading[0] , mof::lastOf( cascading ) )
+ );
+ pText->setWorldTransform(pAnimation);
+ }
+//}}}
+//{{{ getEffect
+ const mof::Effect* TextView::getEffect() const
+ {
+ return m_pImpl->pEffect;
+ }
+//}}}
+//{{{ update
+ void mof::TextView::update()
+ {
+ m_pImpl->pEffect->update();
+
+ }
+//}}}
+}
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/MenuView.hpp"\r
-#include "mof/tstring.hpp"\r
-#include "mof/Font.hpp"\r
-\r
-namespace mof\r
-{\r
-\r
-\r
- class TextView : public MenuView \r
- {\r
- public:\r
- TextView( const mof::tstring& caption , const mof::Font& font );\r
- virtual ~TextView();\r
- virtual mof::Rectangle<int> initialize();\r
- virtual void show();\r
- virtual void close();\r
- virtual void focus();\r
- virtual void blur();\r
- /* diprecated */\r
- virtual void setPosition\r
- (\r
- const mof::Animation<mof::Matrix2D>::Handler& handler \r
- );\r
- void setBounds( const mof::Rectangle<int>& bounds );\r
-\r
- /* candidate */\r
- virtual void setWorldTransform\r
- (\r
- const mof::Animation<mof::Matrix2D>::Handler& handler \r
- );\r
-\r
- virtual const mof::Effect* getEffect() const;\r
- virtual void update();\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- };\r
-\r
-\r
-} // namespace mof\r
-\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include "mof/MenuView.hpp"
+#include "mof/tstring.hpp"
+#include "mof/Font.hpp"
+
+namespace mof
+{
+
+
+ class TextView : public MenuView
+ {
+ public:
+ TextView( const mof::tstring& caption , const mof::Font& font );
+ virtual ~TextView();
+ virtual mof::Rectangle<int> initialize();
+ virtual void show();
+ virtual void close();
+ virtual void focus();
+ virtual void blur();
+ /* diprecated */
+ virtual void setPosition
+ (
+ const mof::Animation<mof::Matrix2D>::Handler& handler
+ );
+ void setBounds( const mof::Rectangle<int>& bounds );
+
+ /* candidate */
+ virtual void setWorldTransform
+ (
+ const mof::Animation<mof::Matrix2D>::Handler& handler
+ );
+
+ virtual const mof::Effect* getEffect() const;
+ virtual void update();
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+
+} // namespace mof
+
-#include "mof/private/TextureImpl.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/private/FileTextureBuilder.hpp"\r
-#include "mof/private/PixelMapTextureBuilder.hpp"\r
-\r
-mof::Texture::Texture( const tstring& filename)\r
-: m_pImpl(new Impl())\r
-{\r
- m_pImpl->pTexture = mof::FileTextureBuilder( filename).create();\r
- D3DSURFACE_DESC desc;\r
- m_pImpl->pTexture->GetLevelDesc(0 , &desc);\r
- m_pImpl->width = desc.Width;\r
- m_pImpl->height = desc.Height;\r
-}\r
-\r
-mof::Texture::Texture( const boost::shared_ptr<mof::PixelMap>& pPixelMap)\r
-: m_pImpl(new Impl())\r
-{\r
- m_pImpl->pTexture = mof::PixelMapTextureBuilder( pPixelMap).create();\r
- D3DSURFACE_DESC desc;\r
- m_pImpl->pTexture->GetLevelDesc(0 , &desc);\r
- m_pImpl->width = desc.Width;\r
- m_pImpl->height = desc.Height;\r
-}\r
-\r
-mof::Texture::~Texture(){}\r
-\r
-boost::shared_ptr<mof::PixelMap> mof::Texture::getPixelMap(){\r
- typedef mof::PixelMap::size_type size_type;\r
- boost::array<size_type , 2> sizes = {{getWidth() , getHeight()}};\r
- \r
- boost::shared_ptr<mof::PixelMap> pMap(new mof::PixelMap(sizes));\r
- D3DLOCKED_RECT rect;\r
- m_pImpl->pTexture->LockRect(0 , &rect , NULL , 0);\r
- for(int y = 0 ; y < getHeight() ; y++){ \r
- for(int x = 0 ; x < getWidth() ; x++){\r
- BYTE* pPixel = (BYTE*)rect.pBits + x * 4 + y * rect.Pitch;\r
- (*pMap)[x][y] = mof::createColor(*(pPixel + 3) , *(pPixel+2) , *(pPixel+1) , *(pPixel));\r
- }\r
- }\r
- m_pImpl->pTexture->UnlockRect(0);\r
- return pMap;\r
-}\r
-\r
-int mof::Texture::getWidth(){\r
- return m_pImpl->width;\r
-}\r
-\r
-int mof::Texture::getHeight(){\r
- return m_pImpl->height;\r
-}\r
-\r
-\r
+#include "mof/private/TextureImpl.hpp"
+#include "mof/ConsoleIO.hpp"
+#include "mof/private/FileTextureBuilder.hpp"
+#include "mof/private/PixelMapTextureBuilder.hpp"
+
+mof::Texture::Texture( const tstring& filename)
+: m_pImpl(new Impl())
+{
+ m_pImpl->pTexture = mof::FileTextureBuilder( filename).create();
+ D3DSURFACE_DESC desc;
+ m_pImpl->pTexture->GetLevelDesc(0 , &desc);
+ m_pImpl->width = desc.Width;
+ m_pImpl->height = desc.Height;
+}
+
+mof::Texture::Texture( const boost::shared_ptr<mof::PixelMap>& pPixelMap)
+: m_pImpl(new Impl())
+{
+ m_pImpl->pTexture = mof::PixelMapTextureBuilder( pPixelMap).create();
+ D3DSURFACE_DESC desc;
+ m_pImpl->pTexture->GetLevelDesc(0 , &desc);
+ m_pImpl->width = desc.Width;
+ m_pImpl->height = desc.Height;
+}
+
+mof::Texture::~Texture(){}
+
+boost::shared_ptr<mof::PixelMap> mof::Texture::getPixelMap(){
+ typedef mof::PixelMap::size_type size_type;
+ boost::array<size_type , 2> sizes = {{getWidth() , getHeight()}};
+
+ boost::shared_ptr<mof::PixelMap> pMap(new mof::PixelMap(sizes));
+ D3DLOCKED_RECT rect;
+ m_pImpl->pTexture->LockRect(0 , &rect , NULL , 0);
+ for(int y = 0 ; y < getHeight() ; y++){
+ for(int x = 0 ; x < getWidth() ; x++){
+ BYTE* pPixel = (BYTE*)rect.pBits + x * 4 + y * rect.Pitch;
+ (*pMap)[x][y] = mof::createColor(*(pPixel + 3) , *(pPixel+2) , *(pPixel+1) , *(pPixel));
+ }
+ }
+ m_pImpl->pTexture->UnlockRect(0);
+ return pMap;
+}
+
+int mof::Texture::getWidth(){
+ return m_pImpl->width;
+}
+
+int mof::Texture::getHeight(){
+ return m_pImpl->height;
+}
+
+
-#pragma once\r
-\r
-#include "mof/PixelMap.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-#include <boost/noncopyable.hpp>\r
-#include "mof/GraphicsDevice.hpp"\r
-\r
-namespace mof{\r
- \r
- class Texture : boost::noncopyable\r
- {\r
- friend void GraphicsDevice::setTexture( const Texture* );\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- public:\r
- Texture( const tstring& filename );\r
- Texture( const boost::shared_ptr<mof::PixelMap>& pPixelMap);\r
- ~Texture();\r
- \r
- boost::shared_ptr<mof::PixelMap> getPixelMap();\r
-\r
- int getWidth();\r
- int getHeight();\r
- \r
- };\r
-}\r
+#pragma once
+
+#include "mof/PixelMap.hpp"
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/noncopyable.hpp>
+#include "mof/GraphicsDevice.hpp"
+
+namespace mof{
+
+ class Texture : boost::noncopyable
+ {
+ friend void GraphicsDevice::setTexture( const Texture* );
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ public:
+ Texture( const tstring& filename );
+ Texture( const boost::shared_ptr<mof::PixelMap>& pPixelMap);
+ ~Texture();
+
+ boost::shared_ptr<mof::PixelMap> getPixelMap();
+
+ int getWidth();
+ int getHeight();
+
+ };
+}
-#pragma once\r
-#include "mof/stream/utilities.hpp"\r
-\r
-namespace mof\r
-{\r
-\r
- class TextureComponent\r
- {\r
- public:\r
- virtual ~TextureComponent( ){}\r
-\r
- virtual void setRectangleCoordinatesStream( const RectangleStream& stream )\r
- {\r
- m_textureStream = stream;\r
- }\r
-\r
- virtual const RectangleStream& getRectangleCoordinatesStream( ) const\r
- {\r
- return m_textureStream;\r
- }\r
-\r
- protected:\r
- RectangleStream m_textureStream;\r
-\r
- TextureComponent( )\r
- : \r
- m_textureStream( makeConstantHandler( Rectangle< real >( 0 , 0 , 1 , 1 ) ) ) \r
- {\r
- }\r
-\r
- TextureComponent( const Rectangle< real >& rect )\r
- : \r
- m_textureStream( makeConstantHandler( rect ) ) \r
- {\r
- }\r
-\r
- TextureComponent( const RectangleStream& stream )\r
- : \r
- m_textureStream( stream ) \r
- {\r
- }\r
-\r
- };\r
-\r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/utilities.hpp"
+
+namespace mof
+{
+
+ class TextureComponent
+ {
+ public:
+ virtual ~TextureComponent( ){}
+
+ virtual void setRectangleCoordinatesStream( const RectangleStream& stream )
+ {
+ m_textureStream = stream;
+ }
+
+ virtual const RectangleStream& getRectangleCoordinatesStream( ) const
+ {
+ return m_textureStream;
+ }
+
+ protected:
+ RectangleStream m_textureStream;
+
+ TextureComponent( )
+ :
+ m_textureStream( makeConstantHandler( Rectangle< real >( 0 , 0 , 1 , 1 ) ) )
+ {
+ }
+
+ TextureComponent( const Rectangle< real >& rect )
+ :
+ m_textureStream( makeConstantHandler( rect ) )
+ {
+ }
+
+ TextureComponent( const RectangleStream& stream )
+ :
+ m_textureStream( stream )
+ {
+ }
+
+ };
+
+} // namespace mof
-#pragma once\r
-\r
-#include "mof/ResourceManager.h"\r
-#include "mof/Texture.h"\r
-#include "mof/Animation.h"\r
-//#include "mof/MultipleAnimation.h"\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof{\r
- typedef boost::shared_ptr<mof::Texture> TextureResource;\r
- typedef mof::ResourceManager<mof::Texture> TextureManager;\r
-\r
- \r
- \r
- //typedef boost::shared_ptr<mof::MultipleAnimation> MultipleAnimation;\r
-\r
-\r
+#pragma once
+
+#include "mof/ResourceManager.h"
+#include "mof/Texture.h"
+#include "mof/Animation.h"
+//#include "mof/MultipleAnimation.h"
+#include <boost/shared_ptr.hpp>
+
+namespace mof{
+ typedef boost::shared_ptr<mof::Texture> TextureResource;
+ typedef mof::ResourceManager<mof::Texture> TextureManager;
+
+
+
+ //typedef boost::shared_ptr<mof::MultipleAnimation> MultipleAnimation;
+
+
};
\ No newline at end of file
-#include "mof/Timer.hpp"\r
-#include <windows.h>\r
-\r
-bool mof::Timer::initialized = false;\r
-\r
-\r
-\r
-mof::Timer::Timer() : m_startTime(timeGetTime()){\r
- if(!initialized){\r
- TIMECAPS caps;\r
- timeGetDevCaps(&caps, sizeof(TIMECAPS)); \r
- timeBeginPeriod(caps.wPeriodMin);//\8dÅ\8d\82\90«\94\\82Å\8cv\91ª\r
- initialized = true;\r
- }\r
-}\r
-\r
-void mof::Timer::reset(){\r
- m_startTime = timeGetTime();\r
-}\r
-\r
-int mof::Timer::getTime() const{\r
- return timeGetTime() - m_startTime;\r
-}\r
-\r
-/*\r
-//-----------------------------------------------\r
-// Clock::Clock\r
-// \r
-//-----------------------------------------------\r
-mof::Clock::Clock()\r
-\r
-{\r
- \r
- m_begintime = 0;\r
- \r
-\r
-}\r
-\r
-//-----------------------------------------------\r
-// Clock::SetTimer\r
-// \r
-//-----------------------------------------------\r
-void mof::Clock::setTimer(){\r
- \r
- m_begintime = timeGetTime();\r
- \r
-\r
-}\r
-\r
-\r
-//-----------------------------------------------\r
-// Clock::GetBetweenTime\r
-// \r
-//-----------------------------------------------\r
-DWORD mof::Clock::getBetweenTime(){\r
- DWORD temp_time = m_begintime;\r
- m_begintime = timeGetTime(); \r
- return m_begintime - temp_time;\r
-\r
-}\r
-\r
-\r
-\r
-// void StopTimer();\r
-// DWORD GetAvgTime();\r
-\r
-\r
-//-----------------------------------------------\r
-// Clock::GetFPS\r
-// \82 \82é\83t\83\8c\81[\83\80\90\94\82É\82©\82©\82Á\82½\8e\9e\8aÔ\82©\82ç\81AFPS\82ð\8eZ\8fo\82·\82é\r
-//-----------------------------------------------\r
-float mof::Clock::getFPS(DWORD in_time , UINT in_cnt_frame){\r
- if(in_time == 0)return 0.0f;//\82O\82Å\8f\9c\8eZ\82ð\89ñ\94ð\r
- return (float)in_cnt_frame / (float)in_time * 1000.0f;\r
-\r
-}*/\r
+#include "mof/Timer.hpp"
+#include <windows.h>
+
+bool mof::Timer::initialized = false;
+
+
+
+mof::Timer::Timer() : m_startTime(timeGetTime()){
+ if(!initialized){
+ TIMECAPS caps;
+ timeGetDevCaps(&caps, sizeof(TIMECAPS));
+ timeBeginPeriod(caps.wPeriodMin);//\8dÅ\8d\82\90«\94\\82Å\8cv\91ª
+ initialized = true;
+ }
+}
+
+void mof::Timer::reset(){
+ m_startTime = timeGetTime();
+}
+
+int mof::Timer::getTime() const{
+ return timeGetTime() - m_startTime;
+}
+
+/*
+//-----------------------------------------------
+// Clock::Clock
+//
+//-----------------------------------------------
+mof::Clock::Clock()
+
+{
+
+ m_begintime = 0;
+
+
+}
+
+//-----------------------------------------------
+// Clock::SetTimer
+//
+//-----------------------------------------------
+void mof::Clock::setTimer(){
+
+ m_begintime = timeGetTime();
+
+
+}
+
+
+//-----------------------------------------------
+// Clock::GetBetweenTime
+//
+//-----------------------------------------------
+DWORD mof::Clock::getBetweenTime(){
+ DWORD temp_time = m_begintime;
+ m_begintime = timeGetTime();
+ return m_begintime - temp_time;
+
+}
+
+
+
+// void StopTimer();
+// DWORD GetAvgTime();
+
+
+//-----------------------------------------------
+// Clock::GetFPS
+// \82 \82é\83t\83\8c\81[\83\80\90\94\82É\82©\82©\82Á\82½\8e\9e\8aÔ\82©\82ç\81AFPS\82ð\8eZ\8fo\82·\82é
+//-----------------------------------------------
+float mof::Clock::getFPS(DWORD in_time , UINT in_cnt_frame){
+ if(in_time == 0)return 0.0f;//\82O\82Å\8f\9c\8eZ\82ð\89ñ\94ð
+ return (float)in_cnt_frame / (float)in_time * 1000.0f;
+
+}*/
-#ifndef TIMER_HPP\r
-#define TIMER_HPP\r
-\r
-#pragma comment(lib , "winmm.lib")\r
-\r
-namespace mof{\r
-\r
-\r
-class Timer{\r
- int m_startTime;\r
- static bool initialized;\r
-public:\r
- Timer();\r
-\r
- void reset();\r
- int getTime() const;\r
-\r
-};\r
-\r
-}\r
-\r
-#endif\r
+#ifndef TIMER_HPP
+#define TIMER_HPP
+
+#pragma comment(lib , "winmm.lib")
+
+namespace mof{
+
+
+class Timer{
+ int m_startTime;
+ static bool initialized;
+public:
+ Timer();
+
+ void reset();
+ int getTime() const;
+
+};
+
+}
+
+#endif
-\r
-#include "mof/Vector2D.hpp"\r
-\r
-mof::Vector2D::Vector2D(real x_ , real y_)\r
-: x(x_) , y(y_)\r
-{}\r
-\r
-mof::Vector2D::Vector2D(int x_ , int y_)\r
-: x(mof::int2real(x_)) , y(mof::int2real(y_))\r
-{}\r
-\r
-\r
-mof::Vector2D::Vector2D(){\r
- x = y = 0;\r
-}\r
-\r
-mof::Vector2D::~Vector2D(void)\r
-{\r
-}\r
-\r
-\r
-bool mof::Vector2D::operator == (const mof::Vector2D& obj) const{\r
- if(x == obj.x && y == obj.y)return true;\r
- else return false;\r
-}\r
-\r
-bool mof::Vector2D::operator != (const mof::Vector2D& obj) const{\r
- return !(*this == obj);\r
-}\r
- \r
-mof::Vector2D mof::Vector2D::operator - () const{\r
- return mof::Vector2D( -x , -y);\r
-}\r
- \r
-\r
-\r
-mof::Vector2D mof::Vector2D::operator +( const mof::Vector2D& rhs) const{\r
- return mof::Vector2D(this->x + rhs.x , this->y + rhs.y);\r
-}\r
-\r
-\r
-mof::Vector2D mof::Vector2D::operator -( const mof::Vector2D& rhs) const{\r
- return mof::Vector2D(this->x - rhs.x , this->y - rhs.y);\r
-}\r
- \r
-mof::Vector2D mof::Vector2D::operator *(float rhs) const{\r
- return mof::Vector2D(this->x * rhs , this->y * rhs);\r
-}\r
-\r
-\r
-mof::Vector2D mof::Vector2D::operator /(float rhs) const{\r
- return mof::Vector2D(this->x / rhs , this->y / rhs);\r
-}\r
-\r
-\r
-mof::Vector2D mof::operator *(const mof::Vector2D& vec , float f){\r
- mof::Vector2D obj;\r
- obj.x = vec.x * f;\r
- obj.y = vec.y * f;\r
- return obj;\r
-}\r
- \r
-mof::Vector2D mof::operator *(float f , const mof::Vector2D& vec ){\r
- mof::Vector2D obj;\r
- obj.x = vec.x * f;\r
- obj.y = vec.y * f;\r
- return obj;\r
-}\r
-\r
-std::ostream& mof::operator <<(std::ostream& os , const mof::Vector2D& obj)\r
-{\r
- os << '(' << obj.x << ',' << obj.y << ')';\r
- return os; \r
-}\r
-\r
+
+#include "mof/Vector2D.hpp"
+
+mof::Vector2D::Vector2D(real x_ , real y_)
+: x(x_) , y(y_)
+{}
+
+mof::Vector2D::Vector2D(int x_ , int y_)
+: x(mof::int2real(x_)) , y(mof::int2real(y_))
+{}
+
+
+mof::Vector2D::Vector2D(){
+ x = y = 0;
+}
+
+mof::Vector2D::~Vector2D(void)
+{
+}
+
+
+bool mof::Vector2D::operator == (const mof::Vector2D& obj) const{
+ if(x == obj.x && y == obj.y)return true;
+ else return false;
+}
+
+bool mof::Vector2D::operator != (const mof::Vector2D& obj) const{
+ return !(*this == obj);
+}
+
+mof::Vector2D mof::Vector2D::operator - () const{
+ return mof::Vector2D( -x , -y);
+}
+
+
+
+mof::Vector2D mof::Vector2D::operator +( const mof::Vector2D& rhs) const{
+ return mof::Vector2D(this->x + rhs.x , this->y + rhs.y);
+}
+
+
+mof::Vector2D mof::Vector2D::operator -( const mof::Vector2D& rhs) const{
+ return mof::Vector2D(this->x - rhs.x , this->y - rhs.y);
+}
+
+mof::Vector2D mof::Vector2D::operator *(float rhs) const{
+ return mof::Vector2D(this->x * rhs , this->y * rhs);
+}
+
+
+mof::Vector2D mof::Vector2D::operator /(float rhs) const{
+ return mof::Vector2D(this->x / rhs , this->y / rhs);
+}
+
+
+mof::Vector2D mof::operator *(const mof::Vector2D& vec , float f){
+ mof::Vector2D obj;
+ obj.x = vec.x * f;
+ obj.y = vec.y * f;
+ return obj;
+}
+
+mof::Vector2D mof::operator *(float f , const mof::Vector2D& vec ){
+ mof::Vector2D obj;
+ obj.x = vec.x * f;
+ obj.y = vec.y * f;
+ return obj;
+}
+
+std::ostream& mof::operator <<(std::ostream& os , const mof::Vector2D& obj)
+{
+ os << '(' << obj.x << ',' << obj.y << ')';
+ return os;
+}
+
-#ifndef VECTOR2D_HPP\r
-#define VECTOR2D_HPP\r
-#include <mof/real.hpp>\r
-#include <iostream>\r
-\r
-namespace mof{\r
-\r
- struct Vector2D\r
- {\r
- real x , y;\r
- \r
- Vector2D(real x_ , real y_);\r
- Vector2D(int x_ , int y_);\r
- Vector2D();\r
- ~Vector2D(void);\r
- \r
- mof::Vector2D operator +(const mof::Vector2D& rhs) const;\r
- mof::Vector2D operator -(const mof::Vector2D& rhs) const;\r
- mof::Vector2D operator *(float rhs) const;\r
- mof::Vector2D operator /(float rhs) const;\r
-\r
- bool operator ==(const mof::Vector2D& obj) const;\r
- bool operator !=(const mof::Vector2D& obj) const;\r
- mof::Vector2D operator -( ) const;\r
-\r
- friend mof::Vector2D operator *(const mof::Vector2D& vec , real f);\r
- friend mof::Vector2D operator *(real f , const mof::Vector2D & vec);\r
- friend std::ostream& operator <<(std::ostream& os , const Vector2D& obj );\r
-\r
- };\r
-\r
-};\r
-\r
-#endif\r
+#ifndef VECTOR2D_HPP
+#define VECTOR2D_HPP
+#include <mof/real.hpp>
+#include <iostream>
+
+namespace mof{
+
+ struct Vector2D
+ {
+ real x , y;
+
+ Vector2D(real x_ , real y_);
+ Vector2D(int x_ , int y_);
+ Vector2D();
+ ~Vector2D(void);
+
+ mof::Vector2D operator +(const mof::Vector2D& rhs) const;
+ mof::Vector2D operator -(const mof::Vector2D& rhs) const;
+ mof::Vector2D operator *(float rhs) const;
+ mof::Vector2D operator /(float rhs) const;
+
+ bool operator ==(const mof::Vector2D& obj) const;
+ bool operator !=(const mof::Vector2D& obj) const;
+ mof::Vector2D operator -( ) const;
+
+ friend mof::Vector2D operator *(const mof::Vector2D& vec , real f);
+ friend mof::Vector2D operator *(real f , const mof::Vector2D & vec);
+ friend std::ostream& operator <<(std::ostream& os , const Vector2D& obj );
+
+ };
+
+};
+
+#endif
- #include "mof/Vector3D.hpp"\r
- #include <math.h>\r
- \r
- mof::Vector3D::Vector3D(real _x , float _y , float _z)\r
- {\r
- x = _x;\r
- y = _y;\r
- z = _z;\r
- }\r
- \r
- mof::Vector3D::Vector3D(){\r
- x = y = z = 0.0f;\r
- }\r
- \r
- mof::Vector3D::~Vector3D(void)\r
- {\r
- }\r
- \r
- \r
- void mof::Vector3D::normalize(){\r
- real norm = sqrt(x*x + y*y + z*z);\r
- if(norm < 1E-7 )return ;\r
- x = x / norm;\r
- y = y / norm;\r
- z = z / norm;\r
- }\r
- \r
- \r
- bool mof::Vector3D::operator ==(const mof::Vector3D& rhs) const{\r
- if(x == rhs.x && y == rhs.y && rhs.z == z)return true;\r
- else return false;\r
- }\r
- \r
- bool mof::Vector3D::operator != (const mof::Vector3D& obj) const{\r
- return !(*this == obj);\r
- }\r
- \r
- \r
- mof::Vector3D mof::Vector3D::operator +(const mof::Vector3D& rhs) const{\r
- return mof::Vector3D(this->x + rhs.x , this->y + rhs.y , this->z + rhs.z);\r
- }\r
- \r
- \r
- mof::Vector3D mof::Vector3D::operator -(const mof::Vector3D& rhs) const{\r
- return mof::Vector3D(this->x - rhs.x , this->y - rhs.y , this->z - rhs.z);\r
- }\r
- \r
- mof::Vector3D mof::Vector3D::operator *(real rhs) const{\r
- return mof::Vector3D(this->x * rhs , this->y * rhs ,this->z * rhs);\r
- }\r
- \r
- \r
- mof::Vector3D mof::Vector3D::operator /(real rhs) const{\r
- return mof::Vector3D(this->x / rhs , this->y / rhs , this->z / rhs);\r
- }\r
- \r
- /*\r
- mof::Vector3D mof::operator *(const mof::Vector3D& vec , real f){\r
- mof::Vector3D obj;\r
- obj.x = vec.x * f;\r
- obj.y = vec.y * f;\r
- obj.z = vec.z * f;\r
- return obj;\r
- }*/\r
- \r
- mof::Vector3D mof::operator *(real f , const mof::Vector3D& vec ){\r
- mof::Vector3D obj;\r
- obj.x = vec.x * f;\r
- obj.y = vec.y * f;\r
- obj.z = vec.z * f;\r
- return obj;\r
- }\r
+ #include "mof/Vector3D.hpp"
+ #include <math.h>
+
+ mof::Vector3D::Vector3D(real _x , float _y , float _z)
+ {
+ x = _x;
+ y = _y;
+ z = _z;
+ }
+
+ mof::Vector3D::Vector3D(){
+ x = y = z = 0.0f;
+ }
+
+ mof::Vector3D::~Vector3D(void)
+ {
+ }
+
+
+ void mof::Vector3D::normalize(){
+ real norm = sqrt(x*x + y*y + z*z);
+ if(norm < 1E-7 )return ;
+ x = x / norm;
+ y = y / norm;
+ z = z / norm;
+ }
+
+
+ bool mof::Vector3D::operator ==(const mof::Vector3D& rhs) const{
+ if(x == rhs.x && y == rhs.y && rhs.z == z)return true;
+ else return false;
+ }
+
+ bool mof::Vector3D::operator != (const mof::Vector3D& obj) const{
+ return !(*this == obj);
+ }
+
+
+ mof::Vector3D mof::Vector3D::operator +(const mof::Vector3D& rhs) const{
+ return mof::Vector3D(this->x + rhs.x , this->y + rhs.y , this->z + rhs.z);
+ }
+
+
+ mof::Vector3D mof::Vector3D::operator -(const mof::Vector3D& rhs) const{
+ return mof::Vector3D(this->x - rhs.x , this->y - rhs.y , this->z - rhs.z);
+ }
+
+ mof::Vector3D mof::Vector3D::operator *(real rhs) const{
+ return mof::Vector3D(this->x * rhs , this->y * rhs ,this->z * rhs);
+ }
+
+
+ mof::Vector3D mof::Vector3D::operator /(real rhs) const{
+ return mof::Vector3D(this->x / rhs , this->y / rhs , this->z / rhs);
+ }
+
+ /*
+ mof::Vector3D mof::operator *(const mof::Vector3D& vec , real f){
+ mof::Vector3D obj;
+ obj.x = vec.x * f;
+ obj.y = vec.y * f;
+ obj.z = vec.z * f;
+ return obj;
+ }*/
+
+ mof::Vector3D mof::operator *(real f , const mof::Vector3D& vec ){
+ mof::Vector3D obj;
+ obj.x = vec.x * f;
+ obj.y = vec.y * f;
+ obj.z = vec.z * f;
+ return obj;
+ }
- #pragma once \r
-#include <mof/real.hpp>\r
-\r
- namespace mof{\r
- struct Vector3D\r
- {\r
- real x , y , z;\r
- Vector3D(real _x , real _y , real _z);\r
- Vector3D();\r
- ~Vector3D(void);\r
- void normalize();\r
- \r
- mof::Vector3D operator +(const mof::Vector3D& rhs) const ;\r
- mof::Vector3D operator -(const mof::Vector3D& rhs) const ;\r
- mof::Vector3D operator *(real rhs) const;\r
- mof::Vector3D operator /(real rhs) const;\r
- \r
- //friend mof::Vector3D operator *(const mof::Vector3D& vec , real f);\r
- friend mof::Vector3D operator *(real f , const mof::Vector3D & vec);\r
- \r
- \r
- bool operator ==(const mof::Vector3D& rhs) const;\r
- bool operator !=(const mof::Vector3D& rhs) const;\r
- };\r
- \r
- Vector3D operator *(real f , const mof::Vector3D & vec);\r
- } //namespace mof\r
- \r
+ #pragma once
+#include <mof/real.hpp>
+
+ namespace mof{
+ struct Vector3D
+ {
+ real x , y , z;
+ Vector3D(real _x , real _y , real _z);
+ Vector3D();
+ ~Vector3D(void);
+ void normalize();
+
+ mof::Vector3D operator +(const mof::Vector3D& rhs) const ;
+ mof::Vector3D operator -(const mof::Vector3D& rhs) const ;
+ mof::Vector3D operator *(real rhs) const;
+ mof::Vector3D operator /(real rhs) const;
+
+ //friend mof::Vector3D operator *(const mof::Vector3D& vec , real f);
+ friend mof::Vector3D operator *(real f , const mof::Vector3D & vec);
+
+
+ bool operator ==(const mof::Vector3D& rhs) const;
+ bool operator !=(const mof::Vector3D& rhs) const;
+ };
+
+ Vector3D operator *(real f , const mof::Vector3D & vec);
+ } //namespace mof
+
-#pragma once\r
-#include "mof/VertexBuffer.hpp"\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include <d3dx9.h>\r
-#include "mof/VertexTypes.hpp"\r
-#include "mof/private/VertexFVF.hpp"\r
-#include <stdlib.h>\r
-\r
-template class mof::VertexBuffer<mof::VertexXYZRHWCUV>;\r
-template class mof::VertexBuffer<mof::VertexXYZRHWC>;\r
-template class mof::VertexBuffer<mof::VertexXYZCUV>;\r
-template class mof::VertexBuffer<mof::VertexXYZNUV>;\r
-template class mof::VertexBuffer<mof::VertexXYZC>;\r
-\r
-\r
-template <class T>\r
-struct mof::VertexBuffer<T>::Impl{\r
- IDirect3DVertexBuffer9* pBuffer;\r
- mof::PRIMITIVE_TYPE primitiveType;\r
- \r
- \r
- Impl(mof::PRIMITIVE_TYPE primitiveType_);\r
- ~Impl();\r
-};\r
-\r
-\r
-template <class T>\r
-mof::VertexBuffer<T>::Impl::Impl(mof::PRIMITIVE_TYPE primitiveType_ )\r
-: pBuffer(NULL) , primitiveType(primitiveType_) \r
-{ \r
-}\r
-\r
-template <class T>\r
-mof::VertexBuffer<T>::Impl::~Impl()\r
-{ \r
- if(pBuffer != NULL)pBuffer->Release();\r
-}\r
-\r
-\r
-template <class T>\r
-mof::VertexBuffer<T>::VertexBuffer(const T& front , const T& back , mof::PRIMITIVE_TYPE primitiveType )\r
-: m_pImpl(new Impl( primitiveType ))\r
-{\r
- int length = &back - &front + 1;\r
- if(length <= 0)throw std::invalid_argument("\95s\90³\82È\92¸\93_\94z\97ñ\8ew\92è");\r
- \r
- const LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();\r
- HRESULT hr = pDevice->CreateVertexBuffer( sizeof(T) * length , 0 , mof::getFVF<T>() , D3DPOOL_DEFAULT , &m_pImpl->pBuffer , NULL);\r
- if(FAILED(hr))throw std::runtime_error("Failed -- CreateVertexBuffer");\r
- \r
- T* pBuffer;\r
- hr = m_pImpl->pBuffer->Lock( 0, 0 ,(LPVOID*)&pBuffer , 0);\r
- if(FAILED(hr))throw std::invalid_argument(std::string("\92¸\93_\83o\83b\83t\83@\82Ì\83\8d\83b\83N\82É\8e¸\94s\82µ\82Ü\82µ\82½"));\r
- \r
- memcpy( pBuffer , &front , sizeof(T) * length );\r
- m_pImpl->pBuffer->Unlock();\r
-}\r
-\r
-\r
-\r
-template<class T>\r
-mof::VertexBuffer<T>::~VertexBuffer(){\r
-}\r
-\r
-\r
-template<class T>\r
-int mof::VertexBuffer<T>::getLength() const{\r
- D3DVERTEXBUFFER_DESC desc;\r
- m_pImpl->pBuffer->GetDesc(&desc);\r
- return desc.Size / sizeof(T);\r
-}\r
-\r
-\r
-template<class T>\r
-mof::PRIMITIVE_TYPE mof::VertexBuffer<T>::getPrimitiveType() const{\r
- return m_pImpl->primitiveType;\r
-}\r
-\r
-\r
-template<class T>\r
-void mof::VertexBuffer<T>::draw() const{\r
- HRESULT hr = E_FAIL;\r
-\r
- const LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();\r
-\r
- pDevice->SetFVF(mof::getFVF<T>());\r
- pDevice->SetStreamSource(0 , m_pImpl->pBuffer , 0 , sizeof(T));\r
-\r
- \r
- int length = getLength();\r
-\r
- if(m_pImpl->primitiveType == mof::PRIMITIVE_TYPE_TRIANGLESTRIP){\r
- hr = pDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP , 0 , length -2 );\r
- }\r
- else if(m_pImpl->primitiveType == mof::PRIMITIVE_TYPE_TRIANGLELIST){\r
- hr = pDevice->DrawPrimitive( D3DPT_TRIANGLELIST , 0 , length /3 );\r
- }\r
- \r
- if(FAILED(hr))throw std::runtime_error("Failed -- DrawPrimitive");\r
-\r
-}\r
-\r
+#pragma once
+#include "mof/VertexBuffer.hpp"
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include <d3dx9.h>
+#include "mof/VertexTypes.hpp"
+#include "mof/private/VertexFVF.hpp"
+#include <stdlib.h>
+
+template class mof::VertexBuffer<mof::VertexXYZRHWCUV>;
+template class mof::VertexBuffer<mof::VertexXYZRHWC>;
+template class mof::VertexBuffer<mof::VertexXYZCUV>;
+template class mof::VertexBuffer<mof::VertexXYZNUV>;
+template class mof::VertexBuffer<mof::VertexXYZC>;
+
+
+template <class T>
+struct mof::VertexBuffer<T>::Impl{
+ IDirect3DVertexBuffer9* pBuffer;
+ mof::PRIMITIVE_TYPE primitiveType;
+
+
+ Impl(mof::PRIMITIVE_TYPE primitiveType_);
+ ~Impl();
+};
+
+
+template <class T>
+mof::VertexBuffer<T>::Impl::Impl(mof::PRIMITIVE_TYPE primitiveType_ )
+: pBuffer(NULL) , primitiveType(primitiveType_)
+{
+}
+
+template <class T>
+mof::VertexBuffer<T>::Impl::~Impl()
+{
+ if(pBuffer != NULL)pBuffer->Release();
+}
+
+
+template <class T>
+mof::VertexBuffer<T>::VertexBuffer(const T& front , const T& back , mof::PRIMITIVE_TYPE primitiveType )
+: m_pImpl(new Impl( primitiveType ))
+{
+ int length = &back - &front + 1;
+ if(length <= 0)throw std::invalid_argument("\95s\90³\82È\92¸\93_\94z\97ñ\8ew\92è");
+
+ const LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();
+ HRESULT hr = pDevice->CreateVertexBuffer( sizeof(T) * length , 0 , mof::getFVF<T>() , D3DPOOL_DEFAULT , &m_pImpl->pBuffer , NULL);
+ if(FAILED(hr))throw std::runtime_error("Failed -- CreateVertexBuffer");
+
+ T* pBuffer;
+ hr = m_pImpl->pBuffer->Lock( 0, 0 ,(LPVOID*)&pBuffer , 0);
+ if(FAILED(hr))throw std::invalid_argument(std::string("\92¸\93_\83o\83b\83t\83@\82Ì\83\8d\83b\83N\82É\8e¸\94s\82µ\82Ü\82µ\82½"));
+
+ memcpy( pBuffer , &front , sizeof(T) * length );
+ m_pImpl->pBuffer->Unlock();
+}
+
+
+
+template<class T>
+mof::VertexBuffer<T>::~VertexBuffer(){
+}
+
+
+template<class T>
+int mof::VertexBuffer<T>::getLength() const{
+ D3DVERTEXBUFFER_DESC desc;
+ m_pImpl->pBuffer->GetDesc(&desc);
+ return desc.Size / sizeof(T);
+}
+
+
+template<class T>
+mof::PRIMITIVE_TYPE mof::VertexBuffer<T>::getPrimitiveType() const{
+ return m_pImpl->primitiveType;
+}
+
+
+template<class T>
+void mof::VertexBuffer<T>::draw() const{
+ HRESULT hr = E_FAIL;
+
+ const LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();
+
+ pDevice->SetFVF(mof::getFVF<T>());
+ pDevice->SetStreamSource(0 , m_pImpl->pBuffer , 0 , sizeof(T));
+
+
+ int length = getLength();
+
+ if(m_pImpl->primitiveType == mof::PRIMITIVE_TYPE_TRIANGLESTRIP){
+ hr = pDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP , 0 , length -2 );
+ }
+ else if(m_pImpl->primitiveType == mof::PRIMITIVE_TYPE_TRIANGLELIST){
+ hr = pDevice->DrawPrimitive( D3DPT_TRIANGLELIST , 0 , length /3 );
+ }
+
+ if(FAILED(hr))throw std::runtime_error("Failed -- DrawPrimitive");
+
+}
+
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/VertexTypes.hpp"\r
-#include <boost/utility.hpp>\r
-\r
-namespace mof{\r
-\r
-\r
-\r
-template <class T>\r
-class VertexBuffer : boost::noncopyable{\r
- \r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-public:\r
- VertexBuffer\r
- (\r
- const T& front , const T& back , \r
- mof::PRIMITIVE_TYPE primitiveType = PRIMITIVE_TYPE_TRIANGLELIST \r
- );\r
- ~VertexBuffer();\r
-\r
- int getLength() const;\r
- mof::PRIMITIVE_TYPE getPrimitiveType() const;\r
- void draw() const;\r
-\r
-};\r
-\r
- \r
-}\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include "mof/VertexTypes.hpp"
+#include <boost/utility.hpp>
+
+namespace mof{
+
+
+
+template <class T>
+class VertexBuffer : boost::noncopyable{
+
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+public:
+ VertexBuffer
+ (
+ const T& front , const T& back ,
+ mof::PRIMITIVE_TYPE primitiveType = PRIMITIVE_TYPE_TRIANGLELIST
+ );
+ ~VertexBuffer();
+
+ int getLength() const;
+ mof::PRIMITIVE_TYPE getPrimitiveType() const;
+ void draw() const;
+
+};
+
+
+}
-#pragma once\r
-#include "mof/Color.hpp"\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/Vector3D.hpp"\r
-namespace mof{\r
-\r
-\r
-struct VertexXYZRHWCUV{\r
- float x , y , z , rhw;\r
- mof::Color color;\r
- float tu , tv; \r
-\r
- VertexXYZRHWCUV(){\r
- }\r
-\r
- VertexXYZRHWCUV(const mof::Vector2D& position , mof::Color color , float tu , float tv){\r
- x = static_cast<float>(position.x);\r
- y = static_cast<float>(position.y);\r
- z = 0.0f;\r
- rhw = 1.0f;\r
- this->color = color;\r
- this->tu = tu;\r
- this->tv = tv;\r
- }\r
-};\r
-\r
-struct VertexXYZRHWC{\r
- float x , y , z , rhw;\r
- mof::Color color;\r
-\r
- VertexXYZRHWC(){\r
- }\r
-\r
- VertexXYZRHWC(const mof::Vector2D& position , mof::Color color){\r
- x = static_cast<float>(position.x);\r
- y = static_cast<float>(position.y);\r
- z = 0.0f;\r
- rhw = 1.0f;\r
- this->color = color;\r
- }\r
-};\r
-\r
-\r
-struct VertexXYZCUV{\r
- float x , y , z;\r
- mof::Color color;\r
- float tu , tv;\r
-\r
- VertexXYZCUV(){\r
- }\r
-\r
- VertexXYZCUV(const mof::Vector3D& position , mof::Color color ,float tu , float tv){\r
- x = position.x;\r
- y = position.y;\r
- z = position.z;\r
- this->color = color;\r
- this->tu = tu;\r
- this->tv = tv;\r
- }\r
-};\r
-\r
-struct VertexXYZNUV{\r
- float x , y , z;\r
- float nx , ny , nz;\r
- float tu , tv;\r
-\r
- VertexXYZNUV(){\r
- }\r
-\r
- VertexXYZNUV(const mof::Vector3D& position , const mof::Vector3D& normal , float tu , float tv){\r
- x = position.x;\r
- y = position.y;\r
- z = position.z;\r
- nx = normal.x; \r
- ny = normal.y;\r
- nz = normal.z;\r
- this->tu = tu;\r
- this->tv = tv;\r
- }\r
-};\r
-\r
-struct VertexXYZC{\r
- float x , y , z;\r
- mof::Color color;\r
-\r
- VertexXYZC(){\r
- }\r
-\r
- VertexXYZC(const mof::Vector3D& position , const mof::Color _color){\r
- x = position.x;\r
- y = position.y;\r
- z = position.z;\r
- color = _color;\r
- }\r
-};\r
-\r
-enum PRIMITIVE_TYPE{\r
- PRIMITIVE_TYPE_TRIANGLESTRIP,\r
- PRIMITIVE_TYPE_TRIANGLELIST ,\r
- PRIMITIVE_TYPE_LINELIST\r
-};\r
-\r
-\r
-}\r
+#pragma once
+#include "mof/Color.hpp"
+#include "mof/Vector2D.hpp"
+#include "mof/Vector3D.hpp"
+namespace mof{
+
+
+struct VertexXYZRHWCUV{
+ float x , y , z , rhw;
+ mof::Color color;
+ float tu , tv;
+
+ VertexXYZRHWCUV(){
+ }
+
+ VertexXYZRHWCUV(const mof::Vector2D& position , mof::Color color , float tu , float tv){
+ x = static_cast<float>(position.x);
+ y = static_cast<float>(position.y);
+ z = 0.0f;
+ rhw = 1.0f;
+ this->color = color;
+ this->tu = tu;
+ this->tv = tv;
+ }
+};
+
+struct VertexXYZRHWC{
+ float x , y , z , rhw;
+ mof::Color color;
+
+ VertexXYZRHWC(){
+ }
+
+ VertexXYZRHWC(const mof::Vector2D& position , mof::Color color){
+ x = static_cast<float>(position.x);
+ y = static_cast<float>(position.y);
+ z = 0.0f;
+ rhw = 1.0f;
+ this->color = color;
+ }
+};
+
+
+struct VertexXYZCUV{
+ float x , y , z;
+ mof::Color color;
+ float tu , tv;
+
+ VertexXYZCUV(){
+ }
+
+ VertexXYZCUV(const mof::Vector3D& position , mof::Color color ,float tu , float tv){
+ x = position.x;
+ y = position.y;
+ z = position.z;
+ this->color = color;
+ this->tu = tu;
+ this->tv = tv;
+ }
+};
+
+struct VertexXYZNUV{
+ float x , y , z;
+ float nx , ny , nz;
+ float tu , tv;
+
+ VertexXYZNUV(){
+ }
+
+ VertexXYZNUV(const mof::Vector3D& position , const mof::Vector3D& normal , float tu , float tv){
+ x = position.x;
+ y = position.y;
+ z = position.z;
+ nx = normal.x;
+ ny = normal.y;
+ nz = normal.z;
+ this->tu = tu;
+ this->tv = tv;
+ }
+};
+
+struct VertexXYZC{
+ float x , y , z;
+ mof::Color color;
+
+ VertexXYZC(){
+ }
+
+ VertexXYZC(const mof::Vector3D& position , const mof::Color _color){
+ x = position.x;
+ y = position.y;
+ z = position.z;
+ color = _color;
+ }
+};
+
+enum PRIMITIVE_TYPE{
+ PRIMITIVE_TYPE_TRIANGLESTRIP,
+ PRIMITIVE_TYPE_TRIANGLELIST ,
+ PRIMITIVE_TYPE_LINELIST
+};
+
+
+}
-#include "mof/Window.hpp"\r
-#include "mof/InputDevice.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-#include <stdexcept>\r
-\r
-LRESULT WINAPI wndProc( HWND hWnd , UINT msg, WPARAM wParam, LPARAM lParam)\r
-{\r
- switch(msg)\r
- {\r
- case WM_ACTIVATEAPP:\r
- if(LOWORD(wParam) == 0)\r
- {\r
- /* *ConsoleOut::getInstance() << "Window\82ª\94ñ\83A\83N\83e\83B\83u\82É\82È\82è\82Ü\82µ\82½" << std::endl;\r
- mof::System::getInstance()->activate(false);\r
- mof::InputDevice::getInstance()->activate(false);*/\r
- mof::InputDevice::setActivation(false);\r
- }\r
- else \r
- {\r
- /* *ConsoleOut::getInstance() << "Window\82ª\83A\83N\83e\83B\83u\82É\82È\82è\82Ü\82µ\82½" << std::endl;\r
- mof::System::getInstance()->activate(true);\r
- mof::InputDevice::getInstance()->activate(true);*/\r
- mof::InputDevice::setActivation(true);\r
- }\r
- break;\r
- case WM_DESTROY:\r
- PostQuitMessage(0);\r
- break;\r
- case WM_SETCURSOR:\r
- SetCursor(NULL);\r
- break;\r
- }\r
- \r
- return DefWindowProc( hWnd, msg, wParam, lParam );\r
-}\r
-\r
-\r
-\r
-\r
-namespace mof\r
-{\r
- \r
- struct Window::Impl\r
- {\r
- mof::tstring appName;\r
- HINSTANCE hInstance;\r
- HWND hWindow;\r
- \r
- Impl(const mof::tstring& appname , HINSTANCE hInstance );\r
- };\r
-\r
- Window::Impl::Impl(const mof::tstring &appname, HINSTANCE hInstance )\r
- : appName( appname ) , hInstance( hInstance ) , hWindow( NULL )\r
- {\r
- // do nothing\r
- } \r
-\r
- Window::Window( const mof::tstring &appname , int width , int height , bool fullscreen )\r
- : m_pImpl( new mof::Window::Impl( appname , GetModuleHandle(NULL) ) )\r
- {\r
-\r
- // \83E\83B\83\93\83h\83E\83N\83\89\83X\90Ý\92è\r
- WNDCLASSEX wc = \r
- { \r
- sizeof(WNDCLASSEX), CS_CLASSDC, wndProc, 0L, 0L, \r
- m_pImpl->hInstance , NULL, NULL, NULL, NULL,\r
- m_pImpl->appName.c_str() , NULL\r
- };\r
- RegisterClassEx( &wc );\r
-\r
- // \83E\83B\83\93\83h\83E\90¶\90¬\r
- if( !fullscreen )\r
- {\r
- // \8ew\92è\82³\82ê\82½\83N\83\89\83C\83A\83\93\83g\97Ì\88æ\82ð\8am\95Û\82·\82é\82½\82ß\82É\95K\97v\82È\83E\83B\83\93\83h\83E\83T\83C\83Y\82ð\93¾\82é\r
- RECT rect_win;\r
- SetRect( &rect_win , 0 , 0 , width , height );\r
- AdjustWindowRect( &rect_win , WS_OVERLAPPEDWINDOW , false );\r
- \r
- //Window\83\82\81[\83h\r
- m_pImpl->hWindow = \r
- CreateWindow\r
- ( \r
- m_pImpl->appName.c_str() , m_pImpl->appName.c_str() , \r
- WS_OVERLAPPEDWINDOW , CW_USEDEFAULT, CW_USEDEFAULT, (rect_win.right - rect_win.left) ,\r
- (rect_win.bottom - rect_win.top) , GetDesktopWindow() , NULL , wc.hInstance , NULL\r
- );\r
- }\r
- else\r
- {\r
- //\83t\83\8b\83X\83N\83\8a\81[\83\93\r
- m_pImpl->hWindow = \r
- CreateWindow\r
- (\r
- m_pImpl->appName.c_str() , m_pImpl->appName.c_str() , \r
- WS_VISIBLE , CW_USEDEFAULT , CW_USEDEFAULT , width , height ,\r
- HWND_DESKTOP , NULL , wc.hInstance , NULL\r
- );\r
- }\r
- \r
- \r
- // \83E\83B\83\93\83h\83E\95`\89æ\r
- ShowWindow( m_pImpl->hWindow , SW_SHOWDEFAULT );\r
- UpdateWindow( m_pImpl->hWindow );\r
-\r
-\r
- } // function constructor \r
-\r
-\r
-\r
- Window::~Window( )\r
- {\r
- try\r
- {\r
- \r
- //\97á\8aO\82È\82°\82é\81H\r
- UnregisterClass(m_pImpl->appName.c_str() , m_pImpl->hInstance );\r
- }\r
- catch(...)\r
- {\r
- }\r
- \r
- }\r
- \r
- HWND Window::getHandler() const {\r
- return m_pImpl->hWindow;\r
- }\r
-\r
+#include "mof/Window.hpp"
+#include "mof/InputDevice.hpp"
+#include "mof/ConsoleIO.hpp"
+#include <stdexcept>
+
+LRESULT WINAPI wndProc( HWND hWnd , UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ switch(msg)
+ {
+ case WM_ACTIVATEAPP:
+ if(LOWORD(wParam) == 0)
+ {
+ /* *ConsoleOut::getInstance() << "Window\82ª\94ñ\83A\83N\83e\83B\83u\82É\82È\82è\82Ü\82µ\82½" << std::endl;
+ mof::System::getInstance()->activate(false);
+ mof::InputDevice::getInstance()->activate(false);*/
+ mof::InputDevice::setActivation(false);
+ }
+ else
+ {
+ /* *ConsoleOut::getInstance() << "Window\82ª\83A\83N\83e\83B\83u\82É\82È\82è\82Ü\82µ\82½" << std::endl;
+ mof::System::getInstance()->activate(true);
+ mof::InputDevice::getInstance()->activate(true);*/
+ mof::InputDevice::setActivation(true);
+ }
+ break;
+ case WM_DESTROY:
+ PostQuitMessage(0);
+ break;
+ case WM_SETCURSOR:
+ SetCursor(NULL);
+ break;
+ }
+
+ return DefWindowProc( hWnd, msg, wParam, lParam );
+}
+
+
+
+
+namespace mof
+{
+
+ struct Window::Impl
+ {
+ mof::tstring appName;
+ HINSTANCE hInstance;
+ HWND hWindow;
+
+ Impl(const mof::tstring& appname , HINSTANCE hInstance );
+ };
+
+ Window::Impl::Impl(const mof::tstring &appname, HINSTANCE hInstance )
+ : appName( appname ) , hInstance( hInstance ) , hWindow( NULL )
+ {
+ // do nothing
+ }
+
+ Window::Window( const mof::tstring &appname , int width , int height , bool fullscreen )
+ : m_pImpl( new mof::Window::Impl( appname , GetModuleHandle(NULL) ) )
+ {
+
+ // \83E\83B\83\93\83h\83E\83N\83\89\83X\90Ý\92è
+ WNDCLASSEX wc =
+ {
+ sizeof(WNDCLASSEX), CS_CLASSDC, wndProc, 0L, 0L,
+ m_pImpl->hInstance , NULL, NULL, NULL, NULL,
+ m_pImpl->appName.c_str() , NULL
+ };
+ RegisterClassEx( &wc );
+
+ // \83E\83B\83\93\83h\83E\90¶\90¬
+ if( !fullscreen )
+ {
+ // \8ew\92è\82³\82ê\82½\83N\83\89\83C\83A\83\93\83g\97Ì\88æ\82ð\8am\95Û\82·\82é\82½\82ß\82É\95K\97v\82È\83E\83B\83\93\83h\83E\83T\83C\83Y\82ð\93¾\82é
+ RECT rect_win;
+ SetRect( &rect_win , 0 , 0 , width , height );
+ AdjustWindowRect( &rect_win , WS_OVERLAPPEDWINDOW , false );
+
+ //Window\83\82\81[\83h
+ m_pImpl->hWindow =
+ CreateWindow
+ (
+ m_pImpl->appName.c_str() , m_pImpl->appName.c_str() ,
+ WS_OVERLAPPEDWINDOW , CW_USEDEFAULT, CW_USEDEFAULT, (rect_win.right - rect_win.left) ,
+ (rect_win.bottom - rect_win.top) , GetDesktopWindow() , NULL , wc.hInstance , NULL
+ );
+ }
+ else
+ {
+ //\83t\83\8b\83X\83N\83\8a\81[\83\93
+ m_pImpl->hWindow =
+ CreateWindow
+ (
+ m_pImpl->appName.c_str() , m_pImpl->appName.c_str() ,
+ WS_VISIBLE , CW_USEDEFAULT , CW_USEDEFAULT , width , height ,
+ HWND_DESKTOP , NULL , wc.hInstance , NULL
+ );
+ }
+
+
+ // \83E\83B\83\93\83h\83E\95`\89æ
+ ShowWindow( m_pImpl->hWindow , SW_SHOWDEFAULT );
+ UpdateWindow( m_pImpl->hWindow );
+
+
+ } // function constructor
+
+
+
+ Window::~Window( )
+ {
+ try
+ {
+
+ //\97á\8aO\82È\82°\82é\81H
+ UnregisterClass(m_pImpl->appName.c_str() , m_pImpl->hInstance );
+ }
+ catch(...)
+ {
+ }
+
+ }
+
+ HWND Window::getHandler() const {
+ return m_pImpl->hWindow;
+ }
+
} // namespace mof
\ No newline at end of file
-#pragma once\r
-\r
-#include "mof/tstring.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/utility.hpp>\r
-#include <windows.h>\r
-\r
-namespace mof\r
-{\r
- \r
- \r
- class Window : boost::noncopyable\r
- {\r
- \r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- public:\r
- Window( const mof::tstring& appname , int width , int height , bool fullscreen );\r
- ~Window( );\r
- HWND getHandler() const;\r
- \r
- \r
- };\r
-\r
-\r
-}\r
+#pragma once
+
+#include "mof/tstring.hpp"
+#include <boost/scoped_ptr.hpp>
+#include <boost/utility.hpp>
+#include <windows.h>
+
+namespace mof
+{
+
+
+ class Window : boost::noncopyable
+ {
+
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ public:
+ Window( const mof::tstring& appname , int width , int height , bool fullscreen );
+ ~Window( );
+ HWND getHandler() const;
+
+
+ };
+
+
+}
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-#include <mof/Texture.hpp>\r
-#include <mof/ResourceManager.hpp>\r
-\r
-namespace mof\r
-{\r
- typedef boost::shared_ptr< Texture > TextureHandler;\r
- typedef ResourceManager< Texture > TextureManager;\r
- typedef boost::shared_ptr< TextureManager > TextureManagerHandler;\r
-}\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+#include <mof/Texture.hpp>
+#include <mof/ResourceManager.hpp>
+
+namespace mof
+{
+ typedef boost::shared_ptr< Texture > TextureHandler;
+ typedef ResourceManager< Texture > TextureManager;
+ typedef boost::shared_ptr< TextureManager > TextureManagerHandler;
+}
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-#include <mof/Texture.hpp>\r
-#include <mof/ResourceManager.hpp>\r
-\r
-namespace mof\r
-{\r
- typedef boost::shared_ptr< Texture > TextureHandler;\r
- typedef ResourceManager< Texture > TextureManager;\r
- typedef boost::shared_ptr< TextureManager > TextureManagerHandler;\r
-}\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+#include <mof/Texture.hpp>
+#include <mof/ResourceManager.hpp>
+
+namespace mof
+{
+ typedef boost::shared_ptr< Texture > TextureHandler;
+ typedef ResourceManager< Texture > TextureManager;
+ typedef boost::shared_ptr< TextureManager > TextureManagerHandler;
+}
-#pragma once\r
-//#include "mof/AmbientLight.hpp"\r
-#include "mof/GraphicsDevice.hpp"\r
-//#include "mof/Camera.hpp"\r
-#include "mof/Captor.hpp"\r
-#include "mof/Color.hpp"\r
-#include "mof/GraphicsUnit.hpp"\r
-//#include "mof/Light.hpp"\r
-//#include "mof/Material.hpp"\r
-//#include "mof/MaterialBuilder.hpp"\r
-#include "mof/PixelMap.hpp"\r
-#include "mof/Texture.hpp"\r
-#include "mof/VertexBuffer.hpp"\r
-#include "mof/VertexTypes.hpp"\r
-#include "mof/graphics/utilities.hpp"\r
+#pragma once
+//#include "mof/AmbientLight.hpp"
+#include "mof/GraphicsDevice.hpp"
+//#include "mof/Camera.hpp"
+#include "mof/Captor.hpp"
+#include "mof/Color.hpp"
+#include "mof/GraphicsUnit.hpp"
+//#include "mof/Light.hpp"
+//#include "mof/Material.hpp"
+//#include "mof/MaterialBuilder.hpp"
+#include "mof/PixelMap.hpp"
+#include "mof/Texture.hpp"
+#include "mof/VertexBuffer.hpp"
+#include "mof/VertexTypes.hpp"
+#include "mof/graphics/utilities.hpp"
-#pragma\r
-#include "mof/InputDevice.hpp"\r
-#include "mof/InputEventCondition.hpp"\r
-#include "mof/KeyPressedEventCondition.hpp"\r
-#include "mof/private/DeviceInputReceiver.hpp"\r
-#include "mof/LoggedInputReceiver.hpp"\r
-#include "mof/LoggingInputReceiver.hpp"\r
+#pragma
+#include "mof/InputDevice.hpp"
+#include "mof/InputEventCondition.hpp"
+#include "mof/KeyPressedEventCondition.hpp"
+#include "mof/private/DeviceInputReceiver.hpp"
+#include "mof/LoggedInputReceiver.hpp"
+#include "mof/LoggingInputReceiver.hpp"
-<?xml version="1.0" encoding="shift_jis"?>\r
-<VisualStudioProject\r
- ProjectType="Visual C++"\r
- Version="8.00"\r
- Name="moflib"\r
- ProjectGUID="{04CD4817-1559-4830-BCB0-C5AE997CD904}"\r
- >\r
- <Platforms>\r
- <Platform\r
- Name="Win32"\r
- />\r
- </Platforms>\r
- <ToolFiles>\r
- </ToolFiles>\r
- <Configurations>\r
- <Configuration\r
- Name="Debug|Win32"\r
- OutputDirectory="$(SolutionDir)$(ConfigurationName)"\r
- IntermediateDirectory="$(ConfigurationName)"\r
- ConfigurationType="4"\r
- >\r
- <Tool\r
- Name="VCPreBuildEventTool"\r
- />\r
- <Tool\r
- Name="VCCustomBuildTool"\r
- />\r
- <Tool\r
- Name="VCXMLDataGeneratorTool"\r
- />\r
- <Tool\r
- Name="VCWebServiceProxyGeneratorTool"\r
- />\r
- <Tool\r
- Name="VCMIDLTool"\r
- />\r
- <Tool\r
- Name="VCCLCompilerTool"\r
- />\r
- <Tool\r
- Name="VCManagedResourceCompilerTool"\r
- />\r
- <Tool\r
- Name="VCResourceCompilerTool"\r
- />\r
- <Tool\r
- Name="VCPreLinkEventTool"\r
- />\r
- <Tool\r
- Name="VCLibrarianTool"\r
- />\r
- <Tool\r
- Name="VCALinkTool"\r
- />\r
- <Tool\r
- Name="VCXDCMakeTool"\r
- />\r
- <Tool\r
- Name="VCBscMakeTool"\r
- />\r
- <Tool\r
- Name="VCFxCopTool"\r
- />\r
- <Tool\r
- Name="VCPostBuildEventTool"\r
- />\r
- </Configuration>\r
- <Configuration\r
- Name="Release|Win32"\r
- IntermediateDirectory="$(ConfigurationName)"\r
- ConfigurationType="1"\r
- >\r
- <Tool\r
- Name="VCPreBuildEventTool"\r
- />\r
- <Tool\r
- Name="VCCustomBuildTool"\r
- />\r
- <Tool\r
- Name="VCXMLDataGeneratorTool"\r
- />\r
- <Tool\r
- Name="VCWebServiceProxyGeneratorTool"\r
- />\r
- <Tool\r
- Name="VCMIDLTool"\r
- />\r
- <Tool\r
- Name="VCCLCompilerTool"\r
- />\r
- <Tool\r
- Name="VCManagedResourceCompilerTool"\r
- />\r
- <Tool\r
- Name="VCResourceCompilerTool"\r
- />\r
- <Tool\r
- Name="VCPreLinkEventTool"\r
- />\r
- <Tool\r
- Name="VCLinkerTool"\r
- />\r
- <Tool\r
- Name="VCALinkTool"\r
- />\r
- <Tool\r
- Name="VCManifestTool"\r
- />\r
- <Tool\r
- Name="VCXDCMakeTool"\r
- />\r
- <Tool\r
- Name="VCBscMakeTool"\r
- />\r
- <Tool\r
- Name="VCFxCopTool"\r
- />\r
- <Tool\r
- Name="VCAppVerifierTool"\r
- />\r
- <Tool\r
- Name="VCWebDeploymentTool"\r
- />\r
- <Tool\r
- Name="VCPostBuildEventTool"\r
- />\r
- </Configuration>\r
- </Configurations>\r
- <References>\r
- </References>\r
- <Files>\r
- <Filter\r
- Name="\83\\81[\83X \83t\83@\83C\83\8b"\r
- Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
- UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
- >\r
- <File\r
- RelativePath=".\AbstractScene.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\AmbientLight.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Animation.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\AnimationScheduler.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\BackGroundModel.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Billboard.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Button.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Camera.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Capturer.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\CascadeAnimation.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Color.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Component2D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Component3D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\ConsoleIO.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Container2D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Container3D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\CSVFile.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\DataTable.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\DeviceInputReceiver.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\DirectionalLight.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\FileMeshBuilder.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\FilePath.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\FileTextureBuilder.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Frame.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\GraphicsDevice.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\GraphicsObject.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\GraphicsSchedule.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\InputDevice.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\KeyFrameAnimation.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\LayoutManager.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Light.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Line2D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Line3D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\List.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\LoggedInputReceiver.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\LoggingInputReceiver.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Material.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Matrix3D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Mesh.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\PixelMap.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\PixelMapTextureBuilder.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\RectangleModel.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Resource.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\SelectionModel.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Sprite.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\System.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\TextTextureBuilder.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Texture.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Timer.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\VBMeshBuilder.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Vector2D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Vector3D.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Window.cpp"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\WindowSystem.cpp"\r
- >\r
- </File>\r
- </Filter>\r
- <Filter\r
- Name="\83w\83b\83_\81[ \83t\83@\83C\83\8b"\r
- Filter="h;hpp;hxx;hm;inl;inc;xsd"\r
- UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"\r
- >\r
- <File\r
- RelativePath=".\AbstractScene.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\AmbientLight.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Animation.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\AnimationScheduler.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\BackGroundModel.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Billboard.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Button.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\ButtonListener.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Camera.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Capturer.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\CascadeAnimation.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Color.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Component2D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Component3D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\ConsoleIO.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Container2D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Container3D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\CSVFile.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\DataTable.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\DeviceInputReceiver.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\DirectionalLight.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\FileMeshBuilder.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\FilePath.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\FileTextureBuilder.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Frame.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\GeneralMap.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Graphics.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\GraphicsDevice.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\GraphicsObject.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\GraphicsSchedule.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\HardVertexBuffer.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\HardVertexBufferImpl.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\InputDevice.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\InputReceiver.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Interpolation.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\InterpolationImpl.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\KeyFrameAnimation.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\LayoutManager.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Light.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Line2D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Line3D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\List.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\LoggedInputReceiver.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\LoggingInputReceiver.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Material.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Matrix3D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Mesh.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\MeshBuilder.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\MeshResource.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\PixelMap.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\PixelMapTextureBuilder.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\RectangleModel.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Resource.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\ResourceManager.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\SelectionModel.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\SoftVertexBuffer.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\SoftVertexBufferImpl.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Sprite.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\SquareMap.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\System.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\TextTextureBuilder.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Texture.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\TextureBuilder.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\TextureResource.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Timer.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\tstring.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\VBMeshBuilder.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Vector2D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Vector3D.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\VertexBuffer.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\VertexFVF.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\VertexTypes.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\Window.h"\r
- >\r
- </File>\r
- <File\r
- RelativePath=".\WindowSystem.h"\r
- >\r
- </File>\r
- </Filter>\r
- <Filter\r
- Name="\83\8a\83\\81[\83X \83t\83@\83C\83\8b"\r
- Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"\r
- UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"\r
- >\r
- </Filter>\r
- </Files>\r
- <Globals>\r
- </Globals>\r
-</VisualStudioProject>\r
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="moflib"
+ ProjectGUID="{04CD4817-1559-4830-BCB0-C5AE997CD904}"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="4"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLibrarianTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="\83\\81[\83X \83t\83@\83C\83\8b"
+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\AbstractScene.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\AmbientLight.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Animation.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\AnimationScheduler.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\BackGroundModel.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Billboard.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Button.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Camera.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Capturer.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CascadeAnimation.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Color.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Component2D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Component3D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ConsoleIO.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Container2D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Container3D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\CSVFile.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\DataTable.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\DeviceInputReceiver.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\DirectionalLight.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\FileMeshBuilder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\FilePath.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\FileTextureBuilder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Frame.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\GraphicsDevice.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\GraphicsObject.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\GraphicsSchedule.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\InputDevice.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\KeyFrameAnimation.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LayoutManager.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Light.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Line2D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Line3D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\List.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LoggedInputReceiver.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\LoggingInputReceiver.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Material.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Matrix3D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Mesh.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\PixelMap.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\PixelMapTextureBuilder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\RectangleModel.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Resource.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\SelectionModel.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Sprite.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\System.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\TextTextureBuilder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Texture.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Timer.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\VBMeshBuilder.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Vector2D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Vector3D.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\Window.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\WindowSystem.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="\83w\83b\83_\81[ \83t\83@\83C\83\8b"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\AbstractScene.h"
+ >
+ </File>
+ <File
+ RelativePath=".\AmbientLight.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Animation.h"
+ >
+ </File>
+ <File
+ RelativePath=".\AnimationScheduler.h"
+ >
+ </File>
+ <File
+ RelativePath=".\BackGroundModel.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Billboard.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Button.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ButtonListener.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Camera.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Capturer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\CascadeAnimation.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Color.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Component2D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Component3D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ConsoleIO.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Container2D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Container3D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\CSVFile.h"
+ >
+ </File>
+ <File
+ RelativePath=".\DataTable.h"
+ >
+ </File>
+ <File
+ RelativePath=".\DeviceInputReceiver.h"
+ >
+ </File>
+ <File
+ RelativePath=".\DirectionalLight.h"
+ >
+ </File>
+ <File
+ RelativePath=".\FileMeshBuilder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\FilePath.h"
+ >
+ </File>
+ <File
+ RelativePath=".\FileTextureBuilder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Frame.h"
+ >
+ </File>
+ <File
+ RelativePath=".\GeneralMap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Graphics.h"
+ >
+ </File>
+ <File
+ RelativePath=".\GraphicsDevice.h"
+ >
+ </File>
+ <File
+ RelativePath=".\GraphicsObject.h"
+ >
+ </File>
+ <File
+ RelativePath=".\GraphicsSchedule.h"
+ >
+ </File>
+ <File
+ RelativePath=".\HardVertexBuffer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\HardVertexBufferImpl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\InputDevice.h"
+ >
+ </File>
+ <File
+ RelativePath=".\InputReceiver.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Interpolation.h"
+ >
+ </File>
+ <File
+ RelativePath=".\InterpolationImpl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\KeyFrameAnimation.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LayoutManager.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Light.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Line2D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Line3D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\List.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LoggedInputReceiver.h"
+ >
+ </File>
+ <File
+ RelativePath=".\LoggingInputReceiver.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Material.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Matrix3D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Mesh.h"
+ >
+ </File>
+ <File
+ RelativePath=".\MeshBuilder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\MeshResource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\PixelMap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\PixelMapTextureBuilder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\RectangleModel.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Resource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\ResourceManager.h"
+ >
+ </File>
+ <File
+ RelativePath=".\SelectionModel.h"
+ >
+ </File>
+ <File
+ RelativePath=".\SoftVertexBuffer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\SoftVertexBufferImpl.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Sprite.h"
+ >
+ </File>
+ <File
+ RelativePath=".\SquareMap.h"
+ >
+ </File>
+ <File
+ RelativePath=".\System.h"
+ >
+ </File>
+ <File
+ RelativePath=".\TextTextureBuilder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Texture.h"
+ >
+ </File>
+ <File
+ RelativePath=".\TextureBuilder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\TextureResource.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Timer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\tstring.h"
+ >
+ </File>
+ <File
+ RelativePath=".\VBMeshBuilder.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Vector2D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Vector3D.h"
+ >
+ </File>
+ <File
+ RelativePath=".\VertexBuffer.h"
+ >
+ </File>
+ <File
+ RelativePath=".\VertexFVF.h"
+ >
+ </File>
+ <File
+ RelativePath=".\VertexTypes.h"
+ >
+ </File>
+ <File
+ RelativePath=".\Window.h"
+ >
+ </File>
+ <File
+ RelativePath=".\WindowSystem.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="\83\8a\83\\81[\83X \83t\83@\83C\83\8b"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
+ >
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
-<?xml version="1.0" encoding="shift_jis"?>\r
-<VisualStudioUserFile\r
- ProjectType="Visual C++"\r
- Version="8.00"\r
- ShowAllFiles="false"\r
- >\r
- <Configurations>\r
- <Configuration\r
- Name="Debug|Win32"\r
- >\r
- <DebugSettings\r
- Command="$(TargetPath)"\r
- WorkingDirectory=""\r
- CommandArguments=""\r
- Attach="false"\r
- DebuggerType="3"\r
- Remote="1"\r
- RemoteMachine="TOMOHIRO"\r
- RemoteCommand=""\r
- HttpUrl=""\r
- PDBPath=""\r
- SQLDebugging=""\r
- Environment=""\r
- EnvironmentMerge="true"\r
- DebuggerFlavor=""\r
- MPIRunCommand=""\r
- MPIRunArguments=""\r
- MPIRunWorkingDirectory=""\r
- ApplicationCommand=""\r
- ApplicationArguments=""\r
- ShimCommand=""\r
- MPIAcceptMode=""\r
- MPIAcceptFilter=""\r
- />\r
- </Configuration>\r
- <Configuration\r
- Name="Release|Win32"\r
- >\r
- <DebugSettings\r
- Command="$(TargetPath)"\r
- WorkingDirectory=""\r
- CommandArguments=""\r
- Attach="false"\r
- DebuggerType="3"\r
- Remote="1"\r
- RemoteMachine="TOMOHIRO"\r
- RemoteCommand=""\r
- HttpUrl=""\r
- PDBPath=""\r
- SQLDebugging=""\r
- Environment=""\r
- EnvironmentMerge="true"\r
- DebuggerFlavor=""\r
- MPIRunCommand=""\r
- MPIRunArguments=""\r
- MPIRunWorkingDirectory=""\r
- ApplicationCommand=""\r
- ApplicationArguments=""\r
- ShimCommand=""\r
- MPIAcceptMode=""\r
- MPIAcceptFilter=""\r
- />\r
- </Configuration>\r
- </Configurations>\r
-</VisualStudioUserFile>\r
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioUserFile
+ ProjectType="Visual C++"
+ Version="8.00"
+ ShowAllFiles="false"
+ >
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="TOMOHIRO"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ >
+ <DebugSettings
+ Command="$(TargetPath)"
+ WorkingDirectory=""
+ CommandArguments=""
+ Attach="false"
+ DebuggerType="3"
+ Remote="1"
+ RemoteMachine="TOMOHIRO"
+ RemoteCommand=""
+ HttpUrl=""
+ PDBPath=""
+ SQLDebugging=""
+ Environment=""
+ EnvironmentMerge="true"
+ DebuggerFlavor=""
+ MPIRunCommand=""
+ MPIRunArguments=""
+ MPIRunWorkingDirectory=""
+ ApplicationCommand=""
+ ApplicationArguments=""
+ ShimCommand=""
+ MPIAcceptMode=""
+ MPIAcceptFilter=""
+ />
+ </Configuration>
+ </Configurations>
+</VisualStudioUserFile>
-#pragma once\r
-#include "mof/InputReceiver.hpp"\r
-\r
-\r
-namespace mof{\r
- struct InputEvent{\r
- InputEvent(unsigned int _dwOfs , unsigned int _dwData){\r
- dwOfs = _dwOfs;\r
- dwData = _dwData;\r
- }\r
- unsigned int dwOfs;\r
- unsigned int dwData;\r
- };\r
-\r
- class DeviceInputReceiver : public InputReceiver\r
- {\r
- bool* m_pKeyStates;\r
- public:\r
- \r
- DeviceInputReceiver();\r
- virtual ~DeviceInputReceiver();\r
- virtual bool testKeyState(mof::InputReceiver::Key key);\r
- virtual void update();\r
- void notifyInputEvent(InputEvent& iEvent);\r
- };\r
-\r
+#pragma once
+#include "mof/InputReceiver.hpp"
+
+
+namespace mof{
+ struct InputEvent{
+ InputEvent(unsigned int _dwOfs , unsigned int _dwData){
+ dwOfs = _dwOfs;
+ dwData = _dwData;
+ }
+ unsigned int dwOfs;
+ unsigned int dwData;
+ };
+
+ class DeviceInputReceiver : public InputReceiver
+ {
+ bool* m_pKeyStates;
+ public:
+
+ DeviceInputReceiver();
+ virtual ~DeviceInputReceiver();
+ virtual bool testKeyState(mof::InputReceiver::Key key);
+ virtual void update();
+ void notifyInputEvent(InputEvent& iEvent);
+ };
+
};
\ No newline at end of file
-#pragma\r
-\r
-#pragma comment(lib , "dinput8.lib")\r
-#pragma comment(lib , "dxguid.lib")\r
-\r
-#define DIRECTINPUT_VERSION 0x0800\r
-#include <windows.h>\r
+#pragma
+
+#pragma comment(lib , "dinput8.lib")
+#pragma comment(lib , "dxguid.lib")
+
+#define DIRECTINPUT_VERSION 0x0800
+#include <windows.h>
#include <dinput.h>
\ No newline at end of file
-\r
-#include "mof/private/FileTextureBuilder.hpp"\r
-#include <d3dx9.h>\r
-#include <dxerr9.h>\r
-#include "mof/private/GraphicsDeviceImpl.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-mof::FileTextureBuilder::FileTextureBuilder( const mof::tstring& path)\r
-{\r
- m_path = path;\r
- \r
-}\r
-\r
-mof::FileTextureBuilder::~FileTextureBuilder(void)\r
-{\r
-}\r
-\r
-\r
-LPDIRECT3DTEXTURE9 mof::FileTextureBuilder::create(){\r
- LPDIRECT3DTEXTURE9 texture;\r
- LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();\r
- HRESULT hr = D3DXCreateTextureFromFileEx(pDevice , m_path.c_str() , \r
- 0 , 0 , 1 , 0/*RENDER*/ , D3DFMT_UNKNOWN , D3DPOOL_MANAGED ,\r
- D3DX_DEFAULT , D3DX_DEFAULT , mof::createColor(0 , 0 , 0) , NULL , NULL , &texture);\r
-\r
- if(FAILED(hr))throw std::runtime_error("Failed --- CreateTextureFromFileEx");\r
- \r
- return texture; \r
-\r
- \r
-\r
+
+#include "mof/private/FileTextureBuilder.hpp"
+#include <d3dx9.h>
+#include <dxerr9.h>
+#include "mof/private/GraphicsDeviceImpl.hpp"
+#include "mof/ConsoleIO.hpp"
+
+mof::FileTextureBuilder::FileTextureBuilder( const mof::tstring& path)
+{
+ m_path = path;
+
+}
+
+mof::FileTextureBuilder::~FileTextureBuilder(void)
+{
+}
+
+
+LPDIRECT3DTEXTURE9 mof::FileTextureBuilder::create(){
+ LPDIRECT3DTEXTURE9 texture;
+ LPDIRECT3DDEVICE9 pDevice = mof::GraphicsDevice::getRawDevice();
+ HRESULT hr = D3DXCreateTextureFromFileEx(pDevice , m_path.c_str() ,
+ 0 , 0 , 1 , 0/*RENDER*/ , D3DFMT_UNKNOWN , D3DPOOL_MANAGED ,
+ D3DX_DEFAULT , D3DX_DEFAULT , mof::createColor(0 , 0 , 0) , NULL , NULL , &texture);
+
+ if(FAILED(hr))throw std::runtime_error("Failed --- CreateTextureFromFileEx");
+
+ return texture;
+
+
+
}
\ No newline at end of file
-#ifndef MOF_FILE_TEXTURE_BUILDER_HPP\r
-#define MOF_FILE_TEXTURE_BUILDER_HPP\r
-\r
-#include "mof/private/TextureBuilder.hpp"\r
-#include "mof/tstring.hpp"\r
-\r
-namespace mof{\r
- \r
- class FileTextureBuilder : public TextureBuilder\r
- {\r
- mof::tstring m_path;\r
- public:\r
- FileTextureBuilder( const mof::tstring& path);\r
- virtual ~FileTextureBuilder(void);\r
- virtual LPDIRECT3DTEXTURE9 create();\r
- };\r
-\r
-\r
-};\r
-\r
+#ifndef MOF_FILE_TEXTURE_BUILDER_HPP
+#define MOF_FILE_TEXTURE_BUILDER_HPP
+
+#include "mof/private/TextureBuilder.hpp"
+#include "mof/tstring.hpp"
+
+namespace mof{
+
+ class FileTextureBuilder : public TextureBuilder
+ {
+ mof::tstring m_path;
+ public:
+ FileTextureBuilder( const mof::tstring& path);
+ virtual ~FileTextureBuilder(void);
+ virtual LPDIRECT3DTEXTURE9 create();
+ };
+
+
+};
+
#endif
\ No newline at end of file
-#pragma once\r
-\r
-#include <windows.h>\r
-#include "mof/GraphicsDevice.hpp"\r
-\r
-#include <d3dx9.h>\r
-#pragma comment(lib, "d3dxof.lib")\r
-#pragma comment(lib , "dxguid.lib")\r
-#pragma comment(lib , "d3dx9dt.lib")\r
-#pragma comment(lib , "d3d9.lib")\r
-#pragma comment(lib , "dxerr9.lib")\r
-\r
-namespace mof\r
-{\r
- class Window;\r
- \r
- namespace GraphicsDevice\r
- {\r
- // private\r
- void initialize(const Window& window , int width , int height , bool fullscreen);\r
- void finalize();\r
- void beginScene();\r
- void endScene();\r
- LPDIRECT3DDEVICE9 getRawDevice( );\r
- }\r
-}\r
+#pragma once
+
+#include <windows.h>
+#include "mof/GraphicsDevice.hpp"
+
+#include <d3dx9.h>
+#pragma comment(lib, "d3dxof.lib")
+#pragma comment(lib , "dxguid.lib")
+#pragma comment(lib , "d3dx9dt.lib")
+#pragma comment(lib , "d3d9.lib")
+#pragma comment(lib , "dxerr9.lib")
+
+namespace mof
+{
+ class Window;
+
+ namespace GraphicsDevice
+ {
+ // private
+ void initialize(const Window& window , int width , int height , bool fullscreen);
+ void finalize();
+ void beginScene();
+ void endScene();
+ LPDIRECT3DDEVICE9 getRawDevice( );
+ }
+}
-#pragma once\r
-#include "../Interpreter.hpp"\r
-\r
-namespace mof\r
-{\r
- namespace Interpreter\r
- {\r
- \r
- int _createMessageWidget( );\r
- \r
- int _addMessageWidgetPage\r
- ( \r
- int id ,\r
- const tstring& title ,\r
- const tstring& text \r
- );\r
- \r
- int _hideMessageWidget( int id );\r
- \r
- void _waitKey( const tstring& keystring );\r
-\r
- void _waitFrame( int frame );\r
- }\r
-}\r
-\r
-\r
+#pragma once
+#include "../Interpreter.hpp"
+
+namespace mof
+{
+ namespace Interpreter
+ {
+
+ int _createMessageWidget( );
+
+ int _addMessageWidgetPage
+ (
+ int id ,
+ const tstring& title ,
+ const tstring& text
+ );
+
+ int _hideMessageWidget( int id );
+
+ void _waitKey( const tstring& keystring );
+
+ void _waitFrame( int frame );
+ }
+}
+
+
-#pragma once\r
-#include "../Interpreter.hpp"\r
-\r
-namespace mof\r
-{\r
- namespace Interpreter\r
- {\r
- \r
- int _createMessageWidget();\r
- \r
- int _addMessageWidgetPage\r
- ( \r
- int id ,\r
- const tstring& title ,\r
- const tstring& text \r
- );\r
- \r
- int _hideMessageWidget( int id );\r
- \r
- void _waitKey( const tstring& keystring );\r
-\r
- void _waitFrame( int frame );\r
- }\r
-}\r
-\r
-\r
+#pragma once
+#include "../Interpreter.hpp"
+
+namespace mof
+{
+ namespace Interpreter
+ {
+
+ int _createMessageWidget();
+
+ int _addMessageWidgetPage
+ (
+ int id ,
+ const tstring& title ,
+ const tstring& text
+ );
+
+ int _hideMessageWidget( int id );
+
+ void _waitKey( const tstring& keystring );
+
+ void _waitFrame( int frame );
+ }
+}
+
+
-#ifndef MOF_MESH_HPP\r
-#define MOF_MESH_HPP\r
-#include <d3d9.h>\r
-#include "mof/Graphics3D.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/Material.hpp"\r
-#include "mof/Texture.hpp"\r
-#include "mof/DefaultAnimationPlayer.hpp"\r
-\r
-namespace mof{\r
-\r
-struct MeshDisposer;\r
-\r
-class Mesh : public Graphics3D , public DefaultAnimationPlayer{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
-public :\r
- Mesh(\r
- boost::shared_ptr<mof::MeshDisposer> pMeshDisposer ,\r
- unsigned long nMaterials ,\r
- const boost::shared_ptr<mof::Material>* pMaterials , \r
- const boost::shared_ptr<mof::Texture>* pTextures );\r
- virtual ~Mesh();\r
-\r
- virtual void setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler);\r
- virtual void setTexture( \r
- unsigned int num ,\r
- const boost::shared_ptr<mof::Texture>& pTexture);\r
-\r
- virtual bool isVisible() const;\r
- virtual void update();\r
- virtual void draw() const;\r
- //virtual bool isDisposable() const;\r
-\r
-};\r
-\r
-}\r
-\r
+#ifndef MOF_MESH_HPP
+#define MOF_MESH_HPP
+#include <d3d9.h>
+#include "mof/Graphics3D.hpp"
+#include <boost/scoped_ptr.hpp>
+#include "mof/Material.hpp"
+#include "mof/Texture.hpp"
+#include "mof/DefaultAnimationPlayer.hpp"
+
+namespace mof{
+
+struct MeshDisposer;
+
+class Mesh : public Graphics3D , public DefaultAnimationPlayer{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+public :
+ Mesh(
+ boost::shared_ptr<mof::MeshDisposer> pMeshDisposer ,
+ unsigned long nMaterials ,
+ const boost::shared_ptr<mof::Material>* pMaterials ,
+ const boost::shared_ptr<mof::Texture>* pTextures );
+ virtual ~Mesh();
+
+ virtual void setWorldMatrix(const mof::Animation<mof::Matrix3D>::Handler& handler);
+ virtual void setTexture(
+ unsigned int num ,
+ const boost::shared_ptr<mof::Texture>& pTexture);
+
+ virtual bool isVisible() const;
+ virtual void update();
+ virtual void draw() const;
+ //virtual bool isDisposable() const;
+
+};
+
+}
+
#endif
\ No newline at end of file
-#pragma once\r
-#include <d3d9.h>\r
-#include <d3dx9.h>\r
-\r
-namespace mof{\r
-\r
-struct MeshDisposer{\r
- \r
- LPD3DXMESH pMesh; //\83\81\83b\83V\83\85\r
- LPD3DXBUFFER pAdjacency; //\83\81\83b\83V\83\85\82É\8aÜ\82Ü\82ê\82é\8ae\96Ê\82Ì\97×\90Ú\96Ê\82ð\8ai\94[\82·\82é\83|\83C\83\93\83^\r
-\r
- ~MeshDisposer(){\r
- if(pAdjacency != NULL)pAdjacency->Release();\r
- if(pMesh != NULL)pMesh->Release();\r
- }\r
-};\r
-\r
-}\r
+#pragma once
+#include <d3d9.h>
+#include <d3dx9.h>
+
+namespace mof{
+
+struct MeshDisposer{
+
+ LPD3DXMESH pMesh; //\83\81\83b\83V\83\85
+ LPD3DXBUFFER pAdjacency; //\83\81\83b\83V\83\85\82É\8aÜ\82Ü\82ê\82é\8ae\96Ê\82Ì\97×\90Ú\96Ê\82ð\8ai\94[\82·\82é\83|\83C\83\93\83^
+
+ ~MeshDisposer(){
+ if(pAdjacency != NULL)pAdjacency->Release();
+ if(pMesh != NULL)pMesh->Release();
+ }
+};
+
+}
-#ifndef MOF_PIXEL_TEXTURE_BUILDER_HPP\r
-#define MOF_PIXEL_TEXTURE_BUILDER_HPP\r
-\r
-#include "mof/private/TextureBuilder.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/PixelMap.hpp"\r
-\r
-namespace mof{\r
-\r
- class PixelMapTextureBuilder : public TextureBuilder\r
- {\r
- boost::shared_ptr<mof::PixelMap> m_pPixelMap;\r
- public:\r
- PixelMapTextureBuilder( const boost::shared_ptr<mof::PixelMap>& pPixelMap);\r
- virtual ~PixelMapTextureBuilder();\r
- virtual LPDIRECT3DTEXTURE9 create();\r
- };\r
-\r
-\r
-};\r
-\r
+#ifndef MOF_PIXEL_TEXTURE_BUILDER_HPP
+#define MOF_PIXEL_TEXTURE_BUILDER_HPP
+
+#include "mof/private/TextureBuilder.hpp"
+#include "mof/tstring.hpp"
+#include <boost/shared_ptr.hpp>
+#include "mof/PixelMap.hpp"
+
+namespace mof{
+
+ class PixelMapTextureBuilder : public TextureBuilder
+ {
+ boost::shared_ptr<mof::PixelMap> m_pPixelMap;
+ public:
+ PixelMapTextureBuilder( const boost::shared_ptr<mof::PixelMap>& pPixelMap);
+ virtual ~PixelMapTextureBuilder();
+ virtual LPDIRECT3DTEXTURE9 create();
+ };
+
+
+};
+
#endif
\ No newline at end of file
-#ifndef MOF_TEXTURE_BUILDER_HPP\r
-#define MOF_TEXTURE_BUILDER_HPP\r
-#include <d3d9.h>\r
-\r
-namespace mof{\r
- \r
- class TextureBuilder\r
- {\r
- public:\r
- virtual ~TextureBuilder(){}\r
- virtual LPDIRECT3DTEXTURE9 create() = 0;\r
- };\r
-\r
-\r
-}\r
-\r
+#ifndef MOF_TEXTURE_BUILDER_HPP
+#define MOF_TEXTURE_BUILDER_HPP
+#include <d3d9.h>
+
+namespace mof{
+
+ class TextureBuilder
+ {
+ public:
+ virtual ~TextureBuilder(){}
+ virtual LPDIRECT3DTEXTURE9 create() = 0;
+ };
+
+
+}
+
#endif
\ No newline at end of file
-#ifndef MOF_TEXTURE_IMPL_HPP\r
-#define MOF_TEXTURE_IMPL_HPP\r
-#include "Texture.hpp"\r
-\r
-\r
-#include "mof/GraphicsDevice.hpp"\r
-#include <d3dx9.h>\r
-\r
-\r
-struct mof::Texture::Impl{\r
- LPDIRECT3DTEXTURE9 pTexture;\r
- int width , height;\r
-\r
- Impl() : pTexture(NULL) , width(0) , height(0){}\r
- ~Impl(){\r
- if(pTexture != NULL)pTexture->Release();\r
- }\r
-};\r
-\r
+#ifndef MOF_TEXTURE_IMPL_HPP
+#define MOF_TEXTURE_IMPL_HPP
+#include "Texture.hpp"
+
+
+#include "mof/GraphicsDevice.hpp"
+#include <d3dx9.h>
+
+
+struct mof::Texture::Impl{
+ LPDIRECT3DTEXTURE9 pTexture;
+ int width , height;
+
+ Impl() : pTexture(NULL) , width(0) , height(0){}
+ ~Impl(){
+ if(pTexture != NULL)pTexture->Release();
+ }
+};
+
#endif
\ No newline at end of file
-#pragma once\r
-#include "VertexTypes.hpp"\r
-#include <d3dx9.h>\r
-\r
-\r
-namespace mof{\r
-\r
-template<class T>\r
-DWORD getFVF();\r
-\r
-template<>\r
-inline DWORD getFVF<VertexXYZRHWCUV>(){\r
- return D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;\r
-}\r
-\r
-template<>\r
-inline DWORD getFVF<VertexXYZRHWC>(){\r
- return D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX0;\r
-}\r
-\r
-template<>\r
-inline DWORD getFVF<VertexXYZCUV>(){\r
- return D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1;\r
-}\r
-\r
-template<>\r
-inline DWORD getFVF<VertexXYZNUV>(){\r
- return D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;\r
-}\r
-\r
-template<>\r
-inline DWORD getFVF<VertexXYZC>(){\r
- return D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX0;\r
-}\r
-\r
-\r
+#pragma once
+#include "VertexTypes.hpp"
+#include <d3dx9.h>
+
+
+namespace mof{
+
+template<class T>
+DWORD getFVF();
+
+template<>
+inline DWORD getFVF<VertexXYZRHWCUV>(){
+ return D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;
+}
+
+template<>
+inline DWORD getFVF<VertexXYZRHWC>(){
+ return D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX0;
+}
+
+template<>
+inline DWORD getFVF<VertexXYZCUV>(){
+ return D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1;
+}
+
+template<>
+inline DWORD getFVF<VertexXYZNUV>(){
+ return D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_TEX1;
+}
+
+template<>
+inline DWORD getFVF<VertexXYZC>(){
+ return D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX0;
+}
+
+
};
\ No newline at end of file
-#pragma once \r
-#include "mof/tstring.hpp"\r
-#include "luabind/luabind.hpp"\r
-#include <boost/bind.hpp>\r
-\r
-struct lua_State;\r
-\r
-namespace mof\r
-{\r
- namespace command\r
- {\r
- void registMessage( lua_State* l );\r
- }\r
-}\r
+#pragma once
+#include "mof/tstring.hpp"
+#include "luabind/luabind.hpp"
+#include <boost/bind.hpp>
+
+struct lua_State;
+
+namespace mof
+{
+ namespace command
+ {
+ void registMessage( lua_State* l );
+ }
+}
-#include "mof/Interpreter.hpp"\r
-#include "mof/private/Interpreter.hpp"\r
-#include "mof/private/commands.hpp"\r
-#include "luabind/luabind.hpp"\r
-\r
-namespace mof\r
-{\r
-//{{{ _messageNewImplGlue old\r
-/* int _messageNewImplGlue( lua_State* l ){\r
- int n = lua_gettop(l);\r
- if(!lua_isstring(l , 1))throw std::runtime_error("invalid call");\r
- if(!lua_istable(l , 2))throw std::runtime_error("invalid call");\r
- mof::tstring title = lua_tostring(l , 1);\r
- \r
- std::vector<mof::tstring> texts;\r
- for(int i = 1 ; ; i++){\r
- lua_pushnumber(l , i);\r
- lua_gettable(l , -2);\r
- if(lua_isnil(l , -1))break;\r
- if(!lua_isstring(l , -1))throw std::runtime_error("invalid call");\r
- texts.push_back(lua_tostring(l , -1));\r
- lua_pop(l , 1);\r
- }\r
- lua_pop(l , n);\r
-\r
- m_pMenu = m_pInstructionSet->createMessageWidget(title , texts.at(0)) ;\r
- //m_pMenu.push_back( m_pInstructionSet->createMessageWidget(title , texts.at(0)) );\r
- return 0;\r
- } */\r
-//}}}\r
-//{{{ registMessage\r
- void command::registMessage( lua_State* l )\r
- {\r
- luabind::module( l )[ luabind::def( "messageNewImpl" , mof::Interpreter::_createMessageWidget ) ];\r
- luabind::module( l )[ luabind::def( "messagePageImpl" , mof::Inerpreter::_addMessageWidgetPage ) ];\r
- luabind::module( l )[ luabind::def( "messageHideImpl" , mof::Interpreter::_hideMessageWidget ) ];\r
-\r
- }\r
-//}}}\r
-}\r
+#include "mof/Interpreter.hpp"
+#include "mof/private/Interpreter.hpp"
+#include "mof/private/commands.hpp"
+#include "luabind/luabind.hpp"
+
+namespace mof
+{
+//{{{ _messageNewImplGlue old
+/* int _messageNewImplGlue( lua_State* l ){
+ int n = lua_gettop(l);
+ if(!lua_isstring(l , 1))throw std::runtime_error("invalid call");
+ if(!lua_istable(l , 2))throw std::runtime_error("invalid call");
+ mof::tstring title = lua_tostring(l , 1);
+
+ std::vector<mof::tstring> texts;
+ for(int i = 1 ; ; i++){
+ lua_pushnumber(l , i);
+ lua_gettable(l , -2);
+ if(lua_isnil(l , -1))break;
+ if(!lua_isstring(l , -1))throw std::runtime_error("invalid call");
+ texts.push_back(lua_tostring(l , -1));
+ lua_pop(l , 1);
+ }
+ lua_pop(l , n);
+
+ m_pMenu = m_pInstructionSet->createMessageWidget(title , texts.at(0)) ;
+ //m_pMenu.push_back( m_pInstructionSet->createMessageWidget(title , texts.at(0)) );
+ return 0;
+ } */
+//}}}
+//{{{ registMessage
+ void command::registMessage( lua_State* l )
+ {
+ luabind::module( l )[ luabind::def( "messageNewImpl" , mof::Interpreter::_createMessageWidget ) ];
+ luabind::module( l )[ luabind::def( "messagePageImpl" , mof::Inerpreter::_addMessageWidgetPage ) ];
+ luabind::module( l )[ luabind::def( "messageHideImpl" , mof::Interpreter::_hideMessageWidget ) ];
+
+ }
+//}}}
+}
-#include "mof/Interpreter.hpp"\r
-#include "mof/private/Interpreter.hpp"\r
-#include "mof/private/regist.hpp"\r
-#include "luabind/luabind.hpp"\r
-\r
-namespace mof\r
-{\r
-//{{{ _messageNewImplGlue old\r
-/* int _messageNewImplGlue( lua_State* l ){\r
- int n = lua_gettop(l);\r
- if(!lua_isstring(l , 1))throw std::runtime_error("invalid call");\r
- if(!lua_istable(l , 2))throw std::runtime_error("invalid call");\r
- mof::tstring title = lua_tostring(l , 1);\r
- \r
- std::vector<mof::tstring> texts;\r
- for(int i = 1 ; ; i++){\r
- lua_pushnumber(l , i);\r
- lua_gettable(l , -2);\r
- if(lua_isnil(l , -1))break;\r
- if(!lua_isstring(l , -1))throw std::runtime_error("invalid call");\r
- texts.push_back(lua_tostring(l , -1));\r
- lua_pop(l , 1);\r
- }\r
- lua_pop(l , n);\r
-\r
- m_pMenu = m_pInstructionSet->createMessageWidget(title , texts.at(0)) ;\r
- //m_pMenu.push_back( m_pInstructionSet->createMessageWidget(title , texts.at(0)) );\r
- return 0;\r
- } */\r
-//}}}\r
-//{{{ registMessage\r
- void regist::registMessage( lua_State* l )\r
- {\r
- luabind::module( l )[ luabind::def( "messageNewImpl" , mof::Interpreter::_createMessageWidget ) ];\r
- luabind::module( l )[ luabind::def( "messagePageImpl" , mof::Interpreter::_addMessageWidgetPage ) ];\r
- luabind::module( l )[ luabind::def( "messageHideImpl" , mof::Interpreter::_hideMessageWidget ) ];\r
-\r
- }\r
-//}}}\r
-//{{{ registWait\r
- void regist::registWait( lua_State* l )\r
- {\r
- luabind::module( l )[ luabind::def( "waitFrameImpl" , mof::Interpreter::_waitFrame ) ];\r
- luabind::module( l )[ luabind::def( "waitKeyImpl" , mof::Interpreter::_waitKey ) ];\r
-\r
- }\r
-//}}}\r
-}\r
+#include "mof/Interpreter.hpp"
+#include "mof/private/Interpreter.hpp"
+#include "mof/private/regist.hpp"
+#include "luabind/luabind.hpp"
+
+namespace mof
+{
+//{{{ _messageNewImplGlue old
+/* int _messageNewImplGlue( lua_State* l ){
+ int n = lua_gettop(l);
+ if(!lua_isstring(l , 1))throw std::runtime_error("invalid call");
+ if(!lua_istable(l , 2))throw std::runtime_error("invalid call");
+ mof::tstring title = lua_tostring(l , 1);
+
+ std::vector<mof::tstring> texts;
+ for(int i = 1 ; ; i++){
+ lua_pushnumber(l , i);
+ lua_gettable(l , -2);
+ if(lua_isnil(l , -1))break;
+ if(!lua_isstring(l , -1))throw std::runtime_error("invalid call");
+ texts.push_back(lua_tostring(l , -1));
+ lua_pop(l , 1);
+ }
+ lua_pop(l , n);
+
+ m_pMenu = m_pInstructionSet->createMessageWidget(title , texts.at(0)) ;
+ //m_pMenu.push_back( m_pInstructionSet->createMessageWidget(title , texts.at(0)) );
+ return 0;
+ } */
+//}}}
+//{{{ registMessage
+ void regist::registMessage( lua_State* l )
+ {
+ luabind::module( l )[ luabind::def( "messageNewImpl" , mof::Interpreter::_createMessageWidget ) ];
+ luabind::module( l )[ luabind::def( "messagePageImpl" , mof::Interpreter::_addMessageWidgetPage ) ];
+ luabind::module( l )[ luabind::def( "messageHideImpl" , mof::Interpreter::_hideMessageWidget ) ];
+
+ }
+//}}}
+//{{{ registWait
+ void regist::registWait( lua_State* l )
+ {
+ luabind::module( l )[ luabind::def( "waitFrameImpl" , mof::Interpreter::_waitFrame ) ];
+ luabind::module( l )[ luabind::def( "waitKeyImpl" , mof::Interpreter::_waitKey ) ];
+
+ }
+//}}}
+}
-#include "mof/Interpreter.hpp"\r
-#include "mof/private/Interpreter.hpp"\r
-#include "mof/private/regist.hpp"\r
-#include "luabind/luabind.hpp"\r
-\r
-namespace mof\r
-{\r
-//{{{ _messageNewImplGlue old\r
-/* int _messageNewImplGlue( lua_State* l ){\r
- int n = lua_gettop(l);\r
- if(!lua_isstring(l , 1))throw std::runtime_error("invalid call");\r
- if(!lua_istable(l , 2))throw std::runtime_error("invalid call");\r
- mof::tstring title = lua_tostring(l , 1);\r
- \r
- std::vector<mof::tstring> texts;\r
- for(int i = 1 ; ; i++){\r
- lua_pushnumber(l , i);\r
- lua_gettable(l , -2);\r
- if(lua_isnil(l , -1))break;\r
- if(!lua_isstring(l , -1))throw std::runtime_error("invalid call");\r
- texts.push_back(lua_tostring(l , -1));\r
- lua_pop(l , 1);\r
- }\r
- lua_pop(l , n);\r
-\r
- m_pMenu = m_pInstructionSet->createMessageWidget(title , texts.at(0)) ;\r
- //m_pMenu.push_back( m_pInstructionSet->createMessageWidget(title , texts.at(0)) );\r
- return 0;\r
- } */\r
-//}}}\r
-//{{{ registMessage\r
- void regist::registMessage( lua_State* l )\r
- {\r
- luabind::module( l )[ luabind::def( "messageNewImpl" , mof::Interpreter::_createMessageWidget ) ];\r
- luabind::module( l )[ luabind::def( "messagePageImpl" , mof::Interpreter::_addMessageWidgetPage ) ];\r
- luabind::module( l )[ luabind::def( "messageHideImpl" , mof::Interpreter::_hideMessageWidget ) ];\r
-\r
- }\r
-//}}}\r
-//{{{ registWait\r
- void regist::registWait( lua_State* l )\r
- {\r
- luabind::module( l )[ luabind::def( "waitFrameImpl" , mof::Interpreter::_waitFrame ) ];\r
- luabind::module( l )[ luabind::def( "waitKeyImpl" , mof::Interpreter::_waitKey ) ];\r
-\r
- }\r
-//}}}\r
-}\r
+#include "mof/Interpreter.hpp"
+#include "mof/private/Interpreter.hpp"
+#include "mof/private/regist.hpp"
+#include "luabind/luabind.hpp"
+
+namespace mof
+{
+//{{{ _messageNewImplGlue old
+/* int _messageNewImplGlue( lua_State* l ){
+ int n = lua_gettop(l);
+ if(!lua_isstring(l , 1))throw std::runtime_error("invalid call");
+ if(!lua_istable(l , 2))throw std::runtime_error("invalid call");
+ mof::tstring title = lua_tostring(l , 1);
+
+ std::vector<mof::tstring> texts;
+ for(int i = 1 ; ; i++){
+ lua_pushnumber(l , i);
+ lua_gettable(l , -2);
+ if(lua_isnil(l , -1))break;
+ if(!lua_isstring(l , -1))throw std::runtime_error("invalid call");
+ texts.push_back(lua_tostring(l , -1));
+ lua_pop(l , 1);
+ }
+ lua_pop(l , n);
+
+ m_pMenu = m_pInstructionSet->createMessageWidget(title , texts.at(0)) ;
+ //m_pMenu.push_back( m_pInstructionSet->createMessageWidget(title , texts.at(0)) );
+ return 0;
+ } */
+//}}}
+//{{{ registMessage
+ void regist::registMessage( lua_State* l )
+ {
+ luabind::module( l )[ luabind::def( "messageNewImpl" , mof::Interpreter::_createMessageWidget ) ];
+ luabind::module( l )[ luabind::def( "messagePageImpl" , mof::Interpreter::_addMessageWidgetPage ) ];
+ luabind::module( l )[ luabind::def( "messageHideImpl" , mof::Interpreter::_hideMessageWidget ) ];
+
+ }
+//}}}
+//{{{ registWait
+ void regist::registWait( lua_State* l )
+ {
+ luabind::module( l )[ luabind::def( "waitFrameImpl" , mof::Interpreter::_waitFrame ) ];
+ luabind::module( l )[ luabind::def( "waitKeyImpl" , mof::Interpreter::_waitKey ) ];
+
+ }
+//}}}
+}
-#pragma once \r
-#include "mof/tstring.hpp"\r
-\r
-struct lua_State;\r
-\r
-namespace mof\r
-{\r
- namespace regist\r
- {\r
- void registMessage( lua_State* l );\r
- void registWait( lua_State* l );\r
- }\r
-}\r
+#pragma once
+#include "mof/tstring.hpp"
+
+struct lua_State;
+
+namespace mof
+{
+ namespace regist
+ {
+ void registMessage( lua_State* l );
+ void registWait( lua_State* l );
+ }
+}
-#pragma once \r
-#include "mof/tstring.hpp"\r
-\r
-struct lua_State;\r
-\r
-namespace mof\r
-{\r
- namespace command\r
- {\r
- void registMessage( lua_State* l );\r
- }\r
-}\r
+#pragma once
+#include "mof/tstring.hpp"
+
+struct lua_State;
+
+namespace mof
+{
+ namespace command
+ {
+ void registMessage( lua_State* l );
+ }
+}
-#pragma once\r
-\r
-namespace mof\r
-{\r
- typedef float real;\r
-\r
- inline real int2real(int v)\r
- {\r
- return static_cast<real>(v);\r
- }\r
- \r
- inline int real2int(real v)\r
- {\r
- return static_cast<int>(v);\r
- }\r
-}\r
+#pragma once
+
+namespace mof
+{
+ typedef float real;
+
+ inline real int2real(int v)
+ {
+ return static_cast<real>(v);
+ }
+
+ inline int real2int(real v)
+ {
+ return static_cast<int>(v);
+ }
+}
- #pragma once\r
- #include <boost/shared_ptr.hpp>\r
- #include <boost/utility.hpp>\r
- \r
- namespace mof{\r
- \r
- typedef unsigned int FrameNumber;\r
- \r
- /**\r
- * \83A\83j\83\81\81[\83V\83\87\83\93\83N\83\89\83X\82Í\95¡\90\94\83C\83\93\83X\83^\83\93\83X\8aÔ\82Å\8b¤\97L\82Å\82«\82é\82æ\82¤\82É\82·\82é\82½\82ß\82É\81A\r
- * update()\82ð\8cÄ\82Ñ\8fo\82µ\82Ä\93à\97e\82ð\8f\91\82«\8a·\82¦\82é\8b@\8d\\82É\82Í\82·\82×\82«\82Å\82Í\82È\82¢\r
- *\r
- */\r
- template<typename T>\r
- class Animation : boost::noncopyable{\r
- public:\r
- typedef boost::shared_ptr<mof::Animation<T> > Handler;\r
- \r
- virtual T getValue(mof::FrameNumber) const = 0;\r
- \r
- };\r
- \r
- \r
- } // namespace mof\r
+ #pragma once
+ #include <boost/shared_ptr.hpp>
+ #include <boost/utility.hpp>
+
+ namespace mof{
+
+ typedef unsigned int FrameNumber;
+
+ /**
+ * \83A\83j\83\81\81[\83V\83\87\83\93\83N\83\89\83X\82Í\95¡\90\94\83C\83\93\83X\83^\83\93\83X\8aÔ\82Å\8b¤\97L\82Å\82«\82é\82æ\82¤\82É\82·\82é\82½\82ß\82É\81A
+ * update()\82ð\8cÄ\82Ñ\8fo\82µ\82Ä\93à\97e\82ð\8f\91\82«\8a·\82¦\82é\8b@\8d\\82É\82Í\82·\82×\82«\82Å\82Í\82È\82¢
+ *
+ */
+ template<typename T>
+ class Animation : boost::noncopyable{
+ public:
+ typedef boost::shared_ptr<mof::Animation<T> > Handler;
+
+ virtual T getValue(mof::FrameNumber) const = 0;
+
+ };
+
+
+ } // namespace mof
-#ifndef MOF_ANIMATION_PLAYER_HPP\r
-#define MOF_ANIMATION_PLAYER_HPP\r
-#include "mof/Animation.hpp"\r
-\r
-namespace mof{\r
-\r
-\r
-class AnimationPlayer{\r
-\r
-public:\r
- virtual void setFrameNumber(mof::FrameNumber frame) = 0;\r
- virtual void nextFrame() = 0;\r
- virtual void prevFrame() = 0;\r
- //virtual void reset(){setFrameNumber(0);}\r
-};\r
-\r
-}\r
-\r
-\r
-#endif\r
+#ifndef MOF_ANIMATION_PLAYER_HPP
+#define MOF_ANIMATION_PLAYER_HPP
+#include "mof/Animation.hpp"
+
+namespace mof{
+
+
+class AnimationPlayer{
+
+public:
+ virtual void setFrameNumber(mof::FrameNumber frame) = 0;
+ virtual void nextFrame() = 0;
+ virtual void prevFrame() = 0;
+ //virtual void reset(){setFrameNumber(0);}
+};
+
+}
+
+
+#endif
-#ifndef MOF_ANIMATION_PLAYER_HPP\r
-#define MOF_ANIMATION_PLAYER_HPP\r
-#include "mof/Animation.hpp"\r
-\r
-namespace mof{\r
-\r
-\r
-class AnimationPlayer{\r
-\r
-public:\r
- virtual void setFrameNumber(mof::FrameNumber frame) = 0;\r
- virtual void nextFrame() = 0;\r
- virtual void prevFrame() = 0;\r
- //virtual void reset(){setFrameNumber(0);}\r
-};\r
-\r
-}\r
-\r
-\r
-#endif\r
+#ifndef MOF_ANIMATION_PLAYER_HPP
+#define MOF_ANIMATION_PLAYER_HPP
+#include "mof/Animation.hpp"
+
+namespace mof{
+
+
+class AnimationPlayer{
+
+public:
+ virtual void setFrameNumber(mof::FrameNumber frame) = 0;
+ virtual void nextFrame() = 0;
+ virtual void prevFrame() = 0;
+ //virtual void reset(){setFrameNumber(0);}
+};
+
+}
+
+
+#endif
-#include "mof/AnimationScheduler.h"\r
-#include "mof/ConsoleIO.h"\r
-\r
-typedef std::multimap<mof::AnimationKey , mof::AnimationResource>::iterator MapItr;\r
-\r
-mof::AnimationScheduler::AnimationScheduler(){\r
- m_key = 0;\r
-\r
-}\r
-\r
-mof::AnimationScheduler::~AnimationScheduler(){\r
-\r
-}\r
-\r
-void mof::AnimationScheduler::update(){\r
- \r
- std::pair<MapItr , MapItr> range(m_map.begin() , m_map.upper_bound(m_key));\r
- for(MapItr itr = range.first ; itr != range.second ; ++itr){\r
- if(itr->second.get() != NULL && !itr->second->isPlaying())itr->second->start();\r
- }\r
- \r
- m_key++;\r
-}\r
-\r
-void mof::AnimationScheduler::add(int index , mof::AnimationResource pAnimation){\r
- if(pAnimation.get() != NULL)pAnimation->stop();\r
- m_map.insert(std::multimap<mof::AnimationKey , mof::AnimationResource>::value_type(index , pAnimation));\r
-\r
-}\r
- \r
-bool mof::AnimationScheduler::isFinalized(){\r
- for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){\r
- if(!itr->second->isFinalized())return false;\r
- }\r
- return true;\r
-}\r
-\r
-void mof::AnimationScheduler::clear(){\r
- m_key = 0;\r
- m_map.clear();\r
+#include "mof/AnimationScheduler.h"
+#include "mof/ConsoleIO.h"
+
+typedef std::multimap<mof::AnimationKey , mof::AnimationResource>::iterator MapItr;
+
+mof::AnimationScheduler::AnimationScheduler(){
+ m_key = 0;
+
+}
+
+mof::AnimationScheduler::~AnimationScheduler(){
+
+}
+
+void mof::AnimationScheduler::update(){
+
+ std::pair<MapItr , MapItr> range(m_map.begin() , m_map.upper_bound(m_key));
+ for(MapItr itr = range.first ; itr != range.second ; ++itr){
+ if(itr->second.get() != NULL && !itr->second->isPlaying())itr->second->start();
+ }
+
+ m_key++;
+}
+
+void mof::AnimationScheduler::add(int index , mof::AnimationResource pAnimation){
+ if(pAnimation.get() != NULL)pAnimation->stop();
+ m_map.insert(std::multimap<mof::AnimationKey , mof::AnimationResource>::value_type(index , pAnimation));
+
+}
+
+bool mof::AnimationScheduler::isFinalized(){
+ for(MapItr itr = m_map.begin() ; itr != m_map.end() ; ++itr){
+ if(!itr->second->isFinalized())return false;
+ }
+ return true;
+}
+
+void mof::AnimationScheduler::clear(){
+ m_key = 0;
+ m_map.clear();
}
\ No newline at end of file
-#pragma once\r
-#include "mof/KeyFrameAnimation.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include "mof/Vector2D.hpp"\r
-\r
-namespace mof\r
-{\r
- class BoundsAnimation : public mof::Animation< mof::Rectangle<int> >\r
- {\r
- public:\r
-\r
- BoundsAnimation\r
- (\r
- const mof::Animation<mof::Vector2D>::Handler& position ,\r
- const mof::Animation<mof::Vector2D>::Handler& scale \r
- )\r
- : m_position( position) , m_scale( scale )\r
- {\r
- }\r
-\r
- mof::Rectangle<int> getValue( mof::FrameNumber frame ) const\r
- {\r
- mof::Vector2D position = m_position->getValue( frame );\r
- mof::Vector2D scale = m_scale->getValue( frame );\r
- return mof::Rectangle<int>\r
- (\r
- position.x , position.y ,\r
- position.x + scale.x ,\r
- position.y + scale.y \r
- );\r
- }\r
-\r
- private:\r
-\r
- mof::Animation<mof::Vector2D>::Handler m_position;\r
- mof::Animation<mof::Vector2D>::Handler m_scale;\r
- };\r
-}\r
+#pragma once
+#include "mof/KeyFrameAnimation.hpp"
+#include "mof/Rectangle.hpp"
+#include "mof/Vector2D.hpp"
+
+namespace mof
+{
+ class BoundsAnimation : public mof::Animation< mof::Rectangle<int> >
+ {
+ public:
+
+ BoundsAnimation
+ (
+ const mof::Animation<mof::Vector2D>::Handler& position ,
+ const mof::Animation<mof::Vector2D>::Handler& scale
+ )
+ : m_position( position) , m_scale( scale )
+ {
+ }
+
+ mof::Rectangle<int> getValue( mof::FrameNumber frame ) const
+ {
+ mof::Vector2D position = m_position->getValue( frame );
+ mof::Vector2D scale = m_scale->getValue( frame );
+ return mof::Rectangle<int>
+ (
+ position.x , position.y ,
+ position.x + scale.x ,
+ position.y + scale.y
+ );
+ }
+
+ private:
+
+ mof::Animation<mof::Vector2D>::Handler m_position;
+ mof::Animation<mof::Vector2D>::Handler m_scale;
+ };
+}
-#pragma once\r
-#include "mof/KeyFrameAnimation.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include "mof/Vector2D.hpp"\r
-\r
-namespace mof\r
-{\r
- class BoundsAnimation : public mof::Animation< mof::Rectangle<int> >\r
- {\r
- public:\r
-\r
- BoundsAnimation\r
- (\r
- const mof::Animation<mof::Vector2D>::Handler& position ,\r
- const mof::Animation<mof::Vector2D>::Handler& scale \r
- )\r
- : m_position( position) , m_scale( scale )\r
- {\r
- }\r
-\r
- mof::Rectangle<int> getValue( mof::FrameNumber frame ) const\r
- {\r
- mof::Vector2D position = m_position->getValue( frame );\r
- mof::Vector2D scale = m_scale->getValue( frame );\r
- return mof::Rectangle<int>\r
- (\r
- position.x , position.y ,\r
- position.x + scale.x ,\r
- position.y + scale.y \r
- );\r
- }\r
-\r
- private:\r
-\r
- mof::Animation<mof::Vector2D>::Handler m_position;\r
- mof::Animation<mof::Vector2D>::Handler m_scale;\r
- };\r
-}\r
+#pragma once
+#include "mof/KeyFrameAnimation.hpp"
+#include "mof/Rectangle.hpp"
+#include "mof/Vector2D.hpp"
+
+namespace mof
+{
+ class BoundsAnimation : public mof::Animation< mof::Rectangle<int> >
+ {
+ public:
+
+ BoundsAnimation
+ (
+ const mof::Animation<mof::Vector2D>::Handler& position ,
+ const mof::Animation<mof::Vector2D>::Handler& scale
+ )
+ : m_position( position) , m_scale( scale )
+ {
+ }
+
+ mof::Rectangle<int> getValue( mof::FrameNumber frame ) const
+ {
+ mof::Vector2D position = m_position->getValue( frame );
+ mof::Vector2D scale = m_scale->getValue( frame );
+ return mof::Rectangle<int>
+ (
+ position.x , position.y ,
+ position.x + scale.x ,
+ position.y + scale.y
+ );
+ }
+
+ private:
+
+ mof::Animation<mof::Vector2D>::Handler m_position;
+ mof::Animation<mof::Vector2D>::Handler m_scale;
+ };
+}
-#include <mof/stream/Cache.hpp>\r
-\r
-namespace \r
-{\r
- bool caching = true;\r
-}\r
-\r
-namespace mof\r
-{\r
- void setCaching(bool b)\r
- {\r
- caching = b;\r
- }\r
-\r
- bool getCaching()\r
- {\r
- return caching;\r
- }\r
-}\r
+#include <mof/stream/Cache.hpp>
+
+namespace
+{
+ bool caching = true;
+}
+
+namespace mof
+{
+ void setCaching(bool b)
+ {
+ caching = b;
+ }
+
+ bool getCaching()
+ {
+ return caching;
+ }
+}
-#include <mof/stream/Cache.hpp>\r
-\r
-namespace \r
-{\r
- bool g_caching = true;\r
-}\r
-\r
-namespace mof\r
-{\r
- void setCaching(bool b)\r
- {\r
- g_caching = b;\r
- }\r
-}\r
+#include <mof/stream/Cache.hpp>
+
+namespace
+{
+ bool g_caching = true;
+}
+
+namespace mof
+{
+ void setCaching(bool b)
+ {
+ g_caching = b;
+ }
+}
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-namespace mof{\r
-\r
- void setCaching(bool b);\r
- bool getCaching();\r
- \r
- \r
- template< typename T >\r
- class Cache : public Manipulator< T >\r
- {\r
- \r
- public:\r
- typedef typename boost::shared_ptr<Cache> Handler;\r
- \r
- virtual ~Cache( ){}\r
-\r
- virtual T value( FrameNumber frame ) const\r
- {\r
- if(getCaching())\r
- {\r
- if(m_lastFrame == (int)frame)return m_cached;\r
- m_lastFrame = (int)frame;\r
- m_cached = m_pBody->value(frame);\r
- return m_cached;\r
- }\r
- else\r
- {\r
- return m_pBody->value(frame);\r
- }\r
- }\r
-\r
-\r
- private:\r
- typename Manipulator<T>::Handler m_pBody;\r
- mutable int m_lastFrame;\r
- mutable T m_cached;\r
-\r
-\r
- Cache(const typename Manipulator<T>::Handler& pBody)\r
- : m_pBody(pBody) , m_lastFrame(-1)\r
- {\r
- }\r
-\r
- template<typename T > friend\r
- typename boost::shared_ptr< Cache<T> > makeCacheHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody \r
- );\r
-\r
- };\r
-\r
-\r
-\r
- template< typename T >\r
- boost::shared_ptr< Cache< T > > makeCacheHandler\r
- (\r
- const typename Manipulator< T >::Handler& pBody \r
- )\r
- {\r
- return typename Cache< T >::Handler(\r
- new Cache< T >( pBody )\r
- );\r
- }\r
-\r
-\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+
+namespace mof{
+
+ void setCaching(bool b);
+ bool getCaching();
+
+
+ template< typename T >
+ class Cache : public Manipulator< T >
+ {
+
+ public:
+ typedef typename boost::shared_ptr<Cache> Handler;
+
+ virtual ~Cache( ){}
+
+ virtual T value( FrameNumber frame ) const
+ {
+ if(getCaching())
+ {
+ if(m_lastFrame == (int)frame)return m_cached;
+ m_lastFrame = (int)frame;
+ m_cached = m_pBody->value(frame);
+ return m_cached;
+ }
+ else
+ {
+ return m_pBody->value(frame);
+ }
+ }
+
+
+ private:
+ typename Manipulator<T>::Handler m_pBody;
+ mutable int m_lastFrame;
+ mutable T m_cached;
+
+
+ Cache(const typename Manipulator<T>::Handler& pBody)
+ : m_pBody(pBody) , m_lastFrame(-1)
+ {
+ }
+
+ template<typename T > friend
+ typename boost::shared_ptr< Cache<T> > makeCacheHandler
+ (
+ const typename Manipulator<T>::Handler& pBody
+ );
+
+ };
+
+
+
+ template< typename T >
+ boost::shared_ptr< Cache< T > > makeCacheHandler
+ (
+ const typename Manipulator< T >::Handler& pBody
+ )
+ {
+ return typename Cache< T >::Handler(
+ new Cache< T >( pBody )
+ );
+ }
+
+
+} //namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-namespace mof{\r
-\r
- void setCaching(bool b);\r
- bool getCaching();\r
- \r
- \r
- template< typename T >\r
- class Cache : public Manipulator< T >\r
- {\r
- \r
- public:\r
- typedef typename boost::shared_ptr<Cache> Handler;\r
- \r
- virtual ~Cache( ){}\r
-\r
- virtual T value( FrameNumber frame ) const\r
- {\r
- if(getCaching())\r
- {\r
- //if(m_lastFrame == (int)frame)return m_cached;\r
- m_lastFrame = (int)frame;\r
- m_cached = m_pBody->value(0);\r
- return m_cached;\r
- }\r
- else\r
- {\r
- return m_pBody->value(0);\r
- }\r
- }\r
-\r
-\r
- private:\r
- typename Manipulator<T>::Handler m_pBody;\r
- mutable int m_lastFrame;\r
- mutable T m_cached;\r
-\r
-\r
- Cache(const typename Manipulator<T>::Handler& pBody)\r
- : m_pBody(pBody) , m_lastFrame(-1)\r
- {\r
- }\r
-\r
- template<typename T > friend\r
- typename boost::shared_ptr< Cache<T> > makeCacheHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody \r
- );\r
-\r
- };\r
-\r
-\r
-\r
- template< typename T >\r
- boost::shared_ptr< Cache< T > > makeCacheHandler\r
- (\r
- const typename Manipulator< T >::Handler& pBody \r
- )\r
- {\r
- return typename Cache< T >::Handler(\r
- new Cache< T >( pBody )\r
- );\r
- }\r
-\r
-\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+
+namespace mof{
+
+ void setCaching(bool b);
+ bool getCaching();
+
+
+ template< typename T >
+ class Cache : public Manipulator< T >
+ {
+
+ public:
+ typedef typename boost::shared_ptr<Cache> Handler;
+
+ virtual ~Cache( ){}
+
+ virtual T value( FrameNumber frame ) const
+ {
+ if(getCaching())
+ {
+ //if(m_lastFrame == (int)frame)return m_cached;
+ m_lastFrame = (int)frame;
+ m_cached = m_pBody->value(0);
+ return m_cached;
+ }
+ else
+ {
+ return m_pBody->value(0);
+ }
+ }
+
+
+ private:
+ typename Manipulator<T>::Handler m_pBody;
+ mutable int m_lastFrame;
+ mutable T m_cached;
+
+
+ Cache(const typename Manipulator<T>::Handler& pBody)
+ : m_pBody(pBody) , m_lastFrame(-1)
+ {
+ }
+
+ template<typename T > friend
+ typename boost::shared_ptr< Cache<T> > makeCacheHandler
+ (
+ const typename Manipulator<T>::Handler& pBody
+ );
+
+ };
+
+
+
+ template< typename T >
+ boost::shared_ptr< Cache< T > > makeCacheHandler
+ (
+ const typename Manipulator< T >::Handler& pBody
+ )
+ {
+ return typename Cache< T >::Handler(
+ new Cache< T >( pBody )
+ );
+ }
+
+
+} //namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-#include <vector> \r
-\r
-namespace mof\r
-{\r
- #define DEFAULT_CASCADOR Multiply\r
-//{{{ struct Add\r
- template<typename T>\r
- struct Add\r
- {\r
- inline static T apply(const T& a , const T& b)\r
- {\r
- return a + b;\r
- }\r
- };\r
-//}}}\r
-//{{{ struct Multiply\r
- template<typename T>\r
- struct Multiply\r
- {\r
- inline static T apply(const T& a , const T& b)\r
- {\r
- return a * b;\r
- }\r
- };\r
-//}}}\r
-//{{{ struct Overwrite\r
- template<typename T>\r
- struct Overwrite\r
- {\r
- inline static T apply(const T& , const T& b)\r
- {\r
- return b;\r
- }\r
- };\r
-//}}}\r
-//{{{ class Cascade\r
- template< typename T , class Cascador = DEFAULT_CASCADOR< T > >\r
- class Cascade : public Manipulator< T >{\r
- public:\r
- typedef typename boost::shared_ptr< Cascade > Handler;\r
-\r
- virtual ~Cascade()\r
- {\r
- }\r
-\r
- virtual T value( FrameNumber frame) const\r
- {\r
- T obj = m_list[0]->value(frame);\r
- for(unsigned int i = 1 ; i < m_list.size() ; i++)\r
- {\r
- obj = Cascador::apply(obj , m_list[i]->value(frame));\r
- }\r
- return obj;\r
- }\r
-\r
- void clear()\r
- {\r
- m_list.clear();\r
- }\r
-\r
- void add( const typename Manipulator<T>::Handler& handler )\r
- {\r
- m_list.push_back( handler );\r
- }\r
-\r
- private: \r
- typedef std::vector< typename Manipulator< T >::Handler > List;\r
- List m_list;\r
- \r
- Cascade\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- )\r
- {\r
- int length = &back - &front + 1;\r
- if(length <= 0)throw std::invalid_argument("list size is 0");\r
-\r
- for( int i = 0 ; i < length ; i++)\r
- {\r
- m_list.push_back( (&front)[i] );\r
- }\r
- }\r
- \r
-\r
- Cascade(){}\r
- \r
- template< typename T , class Cascador >\r
- friend typename boost::shared_ptr< Cascade< T , Cascador > >\r
- makeCascadeHandler\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- );\r
-\r
- template< typename T , class Cascador >\r
- friend typename boost::shared_ptr< Cascade< T , Cascador > > makeCascadeHandler();\r
-\r
-\r
- };\r
-//}}}\r
-//{{{ ヘルパ関数 \r
- template< typename T , class Cascador >\r
- boost::shared_ptr< Cascade< T , Cascador > >\r
- makeCascadeHandler\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- )\r
- {\r
- return typename Cascade< T , Cascador >::Handler\r
- (\r
- new Cascade< T , Cascador >( front , back ) \r
- );\r
- }\r
- \r
- template< typename T , class Cascador >\r
- typename boost::shared_ptr< Cascade< T , Cascador > >\r
- makeCascadeHandler( )\r
- {\r
- return typename Cascade< T , Cascador >::Handler\r
- (\r
- new Cascade< T , Cascador >\r
- );\r
- }\r
-\r
- template<typename T >\r
- typename boost::shared_ptr< Cascade< T , DEFAULT_CASCADOR< T > > >\r
- makeCascadeHandler\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- )\r
- {\r
- return makeCascadeHandler< T , DEFAULT_CASCADOR< T > >( front , back );\r
- }\r
- \r
- template<typename T >\r
- typename boost::shared_ptr< Cascade< T , DEFAULT_CASCADOR< T > > >\r
- makeCascadeHandler( )\r
- {\r
- return makeCascadeHandler< T , DEFAULT_CASCADOR< T > >();\r
- }\r
-//}}}\r
-//{{{ ストリーム演算子\r
- template< typename T , class Cascador >\r
- boost::shared_ptr< Cascade< T , Cascador > >& \r
- operator << \r
- (\r
- boost::shared_ptr< Cascade< T , Cascador > >& a ,\r
- const typename Manipulator< T >::Handler& b \r
- )\r
- {\r
- a->add( b );\r
- return a;\r
- }\r
-\r
- template< typename T , class Cascador >\r
- typename boost::shared_ptr< Cascade< T , Cascador > >& \r
- operator << \r
- (\r
- boost::shared_ptr< Cascade< T , Cascador > >& a ,\r
- const T& b \r
- )\r
- {\r
- a->add( mof::makeConstantHandler( b ) );\r
- return a;\r
- }\r
-//}}}\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+#include <vector>
+
+namespace mof
+{
+ #define DEFAULT_CASCADOR Multiply
+//{{{ struct Add
+ template<typename T>
+ struct Add
+ {
+ inline static T apply(const T& a , const T& b)
+ {
+ return a + b;
+ }
+ };
+//}}}
+//{{{ struct Multiply
+ template<typename T>
+ struct Multiply
+ {
+ inline static T apply(const T& a , const T& b)
+ {
+ return a * b;
+ }
+ };
+//}}}
+//{{{ struct Overwrite
+ template<typename T>
+ struct Overwrite
+ {
+ inline static T apply(const T& , const T& b)
+ {
+ return b;
+ }
+ };
+//}}}
+//{{{ class Cascade
+ template< typename T , class Cascador = DEFAULT_CASCADOR< T > >
+ class Cascade : public Manipulator< T >{
+ public:
+ typedef typename boost::shared_ptr< Cascade > Handler;
+
+ virtual ~Cascade()
+ {
+ }
+
+ virtual T value( FrameNumber frame) const
+ {
+ T obj = m_list[0]->value(frame);
+ for(unsigned int i = 1 ; i < m_list.size() ; i++)
+ {
+ obj = Cascador::apply(obj , m_list[i]->value(frame));
+ }
+ return obj;
+ }
+
+ void clear()
+ {
+ m_list.clear();
+ }
+
+ void add( const typename Manipulator<T>::Handler& handler )
+ {
+ m_list.push_back( handler );
+ }
+
+ private:
+ typedef std::vector< typename Manipulator< T >::Handler > List;
+ List m_list;
+
+ Cascade
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ )
+ {
+ int length = &back - &front + 1;
+ if(length <= 0)throw std::invalid_argument("list size is 0");
+
+ for( int i = 0 ; i < length ; i++)
+ {
+ m_list.push_back( (&front)[i] );
+ }
+ }
+
+
+ Cascade(){}
+
+ template< typename T , class Cascador >
+ friend typename boost::shared_ptr< Cascade< T , Cascador > >
+ makeCascadeHandler
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ );
+
+ template< typename T , class Cascador >
+ friend typename boost::shared_ptr< Cascade< T , Cascador > > makeCascadeHandler();
+
+
+ };
+//}}}
+//{{{ ヘルパ関数
+ template< typename T , class Cascador >
+ boost::shared_ptr< Cascade< T , Cascador > >
+ makeCascadeHandler
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ )
+ {
+ return typename Cascade< T , Cascador >::Handler
+ (
+ new Cascade< T , Cascador >( front , back )
+ );
+ }
+
+ template< typename T , class Cascador >
+ typename boost::shared_ptr< Cascade< T , Cascador > >
+ makeCascadeHandler( )
+ {
+ return typename Cascade< T , Cascador >::Handler
+ (
+ new Cascade< T , Cascador >
+ );
+ }
+
+ template<typename T >
+ typename boost::shared_ptr< Cascade< T , DEFAULT_CASCADOR< T > > >
+ makeCascadeHandler
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ )
+ {
+ return makeCascadeHandler< T , DEFAULT_CASCADOR< T > >( front , back );
+ }
+
+ template<typename T >
+ typename boost::shared_ptr< Cascade< T , DEFAULT_CASCADOR< T > > >
+ makeCascadeHandler( )
+ {
+ return makeCascadeHandler< T , DEFAULT_CASCADOR< T > >();
+ }
+//}}}
+//{{{ ストリーム演算子
+ template< typename T , class Cascador >
+ boost::shared_ptr< Cascade< T , Cascador > >&
+ operator <<
+ (
+ boost::shared_ptr< Cascade< T , Cascador > >& a ,
+ const typename Manipulator< T >::Handler& b
+ )
+ {
+ a->add( b );
+ return a;
+ }
+
+ template< typename T , class Cascador >
+ typename boost::shared_ptr< Cascade< T , Cascador > >&
+ operator <<
+ (
+ boost::shared_ptr< Cascade< T , Cascador > >& a ,
+ const T& b
+ )
+ {
+ a->add( mof::makeConstantHandler( b ) );
+ return a;
+ }
+//}}}
+} //namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-#include <vector> \r
-\r
-namespace mof\r
-{\r
- #define DEFAULT_CASCADOR Multiply\r
-//{{{ struct Add\r
- template<typename T>\r
- struct Add\r
- {\r
- inline static T apply(const T& a , const T& b)\r
- {\r
- return a + b;\r
- }\r
- };\r
-//}}}\r
-//{{{ struct Multiply\r
- template<typename T>\r
- struct Multiply\r
- {\r
- inline static T apply(const T& a , const T& b)\r
- {\r
- return a * b;\r
- }\r
- };\r
-//}}}\r
-//{{{ struct Overwrite\r
- template<typename T>\r
- struct Overwrite\r
- {\r
- inline static T apply(const T& , const T& b)\r
- {\r
- return b;\r
- }\r
- };\r
-//}}}\r
-//{{{ class Cascade\r
- template< typename T , class Cascador = DEFAULT_CASCADOR< T > >\r
- class Cascade : public Manipulator< T >{\r
- public:\r
- typedef typename boost::shared_ptr< Cascade > Handler;\r
-\r
- virtual ~Cascade()\r
- {\r
- }\r
-\r
- virtual T value( FrameNumber frame) const\r
- {\r
- T obj = m_list[0]->value(frame);\r
- for(unsigned int i = 1 ; i < m_list.size() ; i++)\r
- {\r
- obj = Cascador::apply(obj , m_list[i]->value(frame));\r
- }\r
- return obj;\r
- }\r
-\r
- void clear()\r
- {\r
- m_list.clear();\r
- }\r
-\r
- void add( const typename Manipulator<T>::Handler& handler )\r
- {\r
- m_list.push_back( handler );\r
- }\r
-\r
- const typename Manipulator<T>::Handler get( int i )\r
- {\r
- return m_cascadeList.at(i);\r
- }\r
-\r
- \r
- private: \r
- typedef std::vector< typename Manipulator< T >::Handler > List;\r
- List m_list;\r
- \r
- Cascade\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- )\r
- {\r
- int length = &back - &front + 1;\r
- if(length <= 0)throw std::invalid_argument("list size is 0");\r
-\r
- for( int i = 0 ; i < length ; i++)\r
- {\r
- m_list.push_back( (&front)[i] );\r
- }\r
- }\r
- \r
-\r
- Cascade(){}\r
- \r
- template< typename T , class Cascador >\r
- friend typename boost::shared_ptr< Cascade< T , Cascador > >\r
- makeCascadeHandler\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- );\r
-\r
- template< typename T , class Cascador >\r
- friend typename boost::shared_ptr< Cascade< T , Cascador > > makeCascadeHandler();\r
-\r
-\r
- };\r
-//}}}\r
-//{{{ ヘルパ関数 \r
- template< typename T , class Cascador >\r
- boost::shared_ptr< Cascade< T , Cascador > >\r
- makeCascadeHandler\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- )\r
- {\r
- return typename Cascade< T , Cascador >::Handler\r
- (\r
- new Cascade< T , Cascador >( front , back ) \r
- );\r
- }\r
- \r
- template< typename T , class Cascador >\r
- typename boost::shared_ptr< Cascade< T , Cascador > >\r
- makeCascadeHandler( )\r
- {\r
- return typename Cascade< T , Cascador >::Handler\r
- (\r
- new Cascade< T , Cascador >\r
- );\r
- }\r
-\r
- template<typename T >\r
- typename boost::shared_ptr< Cascade< T , DEFAULT_CASCADOR< T > > >\r
- makeCascadeHandler\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- )\r
- {\r
- return makeCascadeHandler< T , DEFAULT_CASCADOR< T > >( front , back );\r
- }\r
- \r
- template<typename T >\r
- typename boost::shared_ptr< Cascade< T , DEFAULT_CASCADOR< T > > >\r
- makeCascadeHandler( )\r
- {\r
- return makeCascadeHandler< T , DEFAULT_CASCADOR< T > >();\r
- }\r
-//}}}\r
-//{{{ ストリーム演算子\r
- template< typename T , class Cascador >\r
- boost::shared_ptr< Cascade< T , Cascador > >& \r
- operator << \r
- (\r
- boost::shared_ptr< Cascade< T , Cascador > >& a ,\r
- const typename Manipulator< T >::Handler& b \r
- )\r
- {\r
- a->add( b );\r
- return a;\r
- }\r
-\r
- template< typename T , class Cascador >\r
- typename boost::shared_ptr< Cascade< T , Cascador > >& \r
- operator << \r
- (\r
- boost::shared_ptr< Cascade< T , Cascador > >& a ,\r
- const T& b \r
- )\r
- {\r
- a->add( mof::makeConstantHandler( b ) );\r
- return a;\r
- }\r
-//}}}\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+#include <vector>
+
+namespace mof
+{
+ #define DEFAULT_CASCADOR Multiply
+//{{{ struct Add
+ template<typename T>
+ struct Add
+ {
+ inline static T apply(const T& a , const T& b)
+ {
+ return a + b;
+ }
+ };
+//}}}
+//{{{ struct Multiply
+ template<typename T>
+ struct Multiply
+ {
+ inline static T apply(const T& a , const T& b)
+ {
+ return a * b;
+ }
+ };
+//}}}
+//{{{ struct Overwrite
+ template<typename T>
+ struct Overwrite
+ {
+ inline static T apply(const T& , const T& b)
+ {
+ return b;
+ }
+ };
+//}}}
+//{{{ class Cascade
+ template< typename T , class Cascador = DEFAULT_CASCADOR< T > >
+ class Cascade : public Manipulator< T >{
+ public:
+ typedef typename boost::shared_ptr< Cascade > Handler;
+
+ virtual ~Cascade()
+ {
+ }
+
+ virtual T value( FrameNumber frame) const
+ {
+ T obj = m_list[0]->value(frame);
+ for(unsigned int i = 1 ; i < m_list.size() ; i++)
+ {
+ obj = Cascador::apply(obj , m_list[i]->value(frame));
+ }
+ return obj;
+ }
+
+ void clear()
+ {
+ m_list.clear();
+ }
+
+ void add( const typename Manipulator<T>::Handler& handler )
+ {
+ m_list.push_back( handler );
+ }
+
+ const typename Manipulator<T>::Handler get( int i )
+ {
+ return m_cascadeList.at(i);
+ }
+
+
+ private:
+ typedef std::vector< typename Manipulator< T >::Handler > List;
+ List m_list;
+
+ Cascade
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ )
+ {
+ int length = &back - &front + 1;
+ if(length <= 0)throw std::invalid_argument("list size is 0");
+
+ for( int i = 0 ; i < length ; i++)
+ {
+ m_list.push_back( (&front)[i] );
+ }
+ }
+
+
+ Cascade(){}
+
+ template< typename T , class Cascador >
+ friend typename boost::shared_ptr< Cascade< T , Cascador > >
+ makeCascadeHandler
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ );
+
+ template< typename T , class Cascador >
+ friend typename boost::shared_ptr< Cascade< T , Cascador > > makeCascadeHandler();
+
+
+ };
+//}}}
+//{{{ ヘルパ関数
+ template< typename T , class Cascador >
+ boost::shared_ptr< Cascade< T , Cascador > >
+ makeCascadeHandler
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ )
+ {
+ return typename Cascade< T , Cascador >::Handler
+ (
+ new Cascade< T , Cascador >( front , back )
+ );
+ }
+
+ template< typename T , class Cascador >
+ typename boost::shared_ptr< Cascade< T , Cascador > >
+ makeCascadeHandler( )
+ {
+ return typename Cascade< T , Cascador >::Handler
+ (
+ new Cascade< T , Cascador >
+ );
+ }
+
+ template<typename T >
+ typename boost::shared_ptr< Cascade< T , DEFAULT_CASCADOR< T > > >
+ makeCascadeHandler
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ )
+ {
+ return makeCascadeHandler< T , DEFAULT_CASCADOR< T > >( front , back );
+ }
+
+ template<typename T >
+ typename boost::shared_ptr< Cascade< T , DEFAULT_CASCADOR< T > > >
+ makeCascadeHandler( )
+ {
+ return makeCascadeHandler< T , DEFAULT_CASCADOR< T > >();
+ }
+//}}}
+//{{{ ストリーム演算子
+ template< typename T , class Cascador >
+ boost::shared_ptr< Cascade< T , Cascador > >&
+ operator <<
+ (
+ boost::shared_ptr< Cascade< T , Cascador > >& a ,
+ const typename Manipulator< T >::Handler& b
+ )
+ {
+ a->add( b );
+ return a;
+ }
+
+ template< typename T , class Cascador >
+ typename boost::shared_ptr< Cascade< T , Cascador > >&
+ operator <<
+ (
+ boost::shared_ptr< Cascade< T , Cascador > >& a ,
+ const T& b
+ )
+ {
+ a->add( mof::makeConstantHandler( b ) );
+ return a;
+ }
+//}}}
+} //namespace mof
+
-\r
-#include "mof/CascadeAnimation.h"\r
-\r
-\r
-\r
-mof::CascadeAnimation::CascadeAnimation()\r
-: mof::Animation(false)\r
-{\r
- m_key = 0;\r
- m_maxKey = m_finalKey = 0;\r
-}\r
-\r
-mof::CascadeAnimation::~CascadeAnimation(){\r
-\r
-}\r
-\r
-void mof::CascadeAnimation::setElement(int index , mof::AnimationResource& pAnimation){\r
- if(m_pAnimations.size() <= index)m_pAnimations.resize(index+1);\r
- m_pAnimations.at(index) = pAnimation;\r
- \r
-}\r
-\r
-mof::AnimationResource mof::CascadeAnimation::getElement(int index){\r
- if(m_pAnimations.size() <= index)return mof::AnimationResource();\r
- else return m_pAnimations.at(index);\r
-}\r
-\r
-\r
-\r
-bool mof::CascadeAnimation::update(){\r
- if(!isPlaying())return false;\r
- m_key++;\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() != NULL)m_pAnimations.at(i)->update();\r
- }\r
- return true;\r
-}\r
-\r
-bool mof::CascadeAnimation::isFinalized(){\r
-\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- if(!m_pAnimations.at(i)->isFinalized())return false;\r
- }\r
- return true;\r
-}\r
-\r
-void mof::CascadeAnimation::setFinalKey(mof::AnimationKey key){\r
- if(key > m_maxKey)m_finalKey = m_maxKey;\r
- else m_finalKey = key;\r
-}\r
-\r
-/*\r
-mof::Vector2D mof::CascadeAnimation::getPosition(mof::Vector2D& position){\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- position = m_pAnimations.at(i)->getPosition(position);\r
- }\r
- return position;\r
-\r
-}*/\r
-\r
-mof::Vector2D mof::CascadeAnimation::getPosition(){\r
- mof::Vector2D position;\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- position = position + m_pAnimations.at(i)->getPosition();\r
- }\r
- return position;\r
-\r
-}\r
- \r
-float mof::CascadeAnimation::getWidth(){\r
- float result = 1.0f;\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- result *= m_pAnimations.at(i)->getWidth();\r
- }\r
- return result;\r
-}\r
-\r
-float mof::CascadeAnimation::getHeight(){\r
- float result = 1.0f;\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- result *= m_pAnimations.at(i)->getHeight();\r
- }\r
- return result;\r
-}\r
-\r
-\r
-float mof::CascadeAnimation::getDepth(){\r
- float result = 1.0f;\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- result *= m_pAnimations.at(i)->getDepth();\r
- }\r
- return result;\r
-}\r
-\r
-\r
- \r
-mof::Color mof::CascadeAnimation::getColor(){\r
- float a = 1.0f , r = 1.0f, g = 1.0f, b = 1.0f;\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- mof::Color tmp = m_pAnimations.at(i)->getColor();\r
- a = a * ((float)mof::getAlpha(tmp) / 255);\r
- r = r * ((float)mof::getRed(tmp) / 255);\r
- g = g * ((float)mof::getGreen(tmp) / 255);\r
- b = b * ((float)mof::getBlue(tmp) / 255);\r
- }\r
- return mof::createColor(a * 255 , r * 255 , g * 255 , b * 255);\r
-}\r
-\r
-\r
-mof::Matrix3D mof::CascadeAnimation::getWorldTransform(mof::Matrix3D& matrix){\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- matrix = m_pAnimations.at(i)->getWorldTransform(matrix);\r
- }\r
- return matrix;\r
-}\r
-\r
-\r
-mof::Line2D mof::CascadeAnimation::getTextureRectangle(){\r
- mof::Line2D result;\r
- for(int i = 0 ; i < m_pAnimations.size() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- mof::Line2D tmp = m_pAnimations.at(i)->getTextureRectangle();\r
- if(tmp != mof::Line2D())result = tmp;\r
- }\r
- return result;\r
-}\r
-\r
-\r
-void mof::CascadeAnimation::start(){\r
- for(int i = 0 ; i < getLength() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- if(!m_pAnimations.at(i)->isPlaying())m_pAnimations.at(i)->start();\r
- }\r
-}\r
- \r
-void mof::CascadeAnimation::stop(){\r
- for(int i = 0 ; i < getLength() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- if(m_pAnimations.at(i)->isPlaying())m_pAnimations.at(i)->stop();\r
- }\r
-}\r
-\r
-bool mof::CascadeAnimation::isPlaying(){\r
- if(getLength() == 0)return true;\r
- bool hasAnimation = false;\r
-\r
- for(int i = 0 ; i < getLength() ; i++){\r
- if(m_pAnimations.at(i).get() == NULL)continue;\r
- if(m_pAnimations.at(i)->isPlaying())return true;\r
- else hasAnimation = true;\r
- }\r
- return !hasAnimation;//\91S\97v\91f\82ªNULL\82È\82çtrue\r
+
+#include "mof/CascadeAnimation.h"
+
+
+
+mof::CascadeAnimation::CascadeAnimation()
+: mof::Animation(false)
+{
+ m_key = 0;
+ m_maxKey = m_finalKey = 0;
+}
+
+mof::CascadeAnimation::~CascadeAnimation(){
+
+}
+
+void mof::CascadeAnimation::setElement(int index , mof::AnimationResource& pAnimation){
+ if(m_pAnimations.size() <= index)m_pAnimations.resize(index+1);
+ m_pAnimations.at(index) = pAnimation;
+
+}
+
+mof::AnimationResource mof::CascadeAnimation::getElement(int index){
+ if(m_pAnimations.size() <= index)return mof::AnimationResource();
+ else return m_pAnimations.at(index);
+}
+
+
+
+bool mof::CascadeAnimation::update(){
+ if(!isPlaying())return false;
+ m_key++;
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() != NULL)m_pAnimations.at(i)->update();
+ }
+ return true;
+}
+
+bool mof::CascadeAnimation::isFinalized(){
+
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ if(!m_pAnimations.at(i)->isFinalized())return false;
+ }
+ return true;
+}
+
+void mof::CascadeAnimation::setFinalKey(mof::AnimationKey key){
+ if(key > m_maxKey)m_finalKey = m_maxKey;
+ else m_finalKey = key;
+}
+
+/*
+mof::Vector2D mof::CascadeAnimation::getPosition(mof::Vector2D& position){
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ position = m_pAnimations.at(i)->getPosition(position);
+ }
+ return position;
+
+}*/
+
+mof::Vector2D mof::CascadeAnimation::getPosition(){
+ mof::Vector2D position;
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ position = position + m_pAnimations.at(i)->getPosition();
+ }
+ return position;
+
+}
+
+float mof::CascadeAnimation::getWidth(){
+ float result = 1.0f;
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ result *= m_pAnimations.at(i)->getWidth();
+ }
+ return result;
+}
+
+float mof::CascadeAnimation::getHeight(){
+ float result = 1.0f;
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ result *= m_pAnimations.at(i)->getHeight();
+ }
+ return result;
+}
+
+
+float mof::CascadeAnimation::getDepth(){
+ float result = 1.0f;
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ result *= m_pAnimations.at(i)->getDepth();
+ }
+ return result;
+}
+
+
+
+mof::Color mof::CascadeAnimation::getColor(){
+ float a = 1.0f , r = 1.0f, g = 1.0f, b = 1.0f;
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ mof::Color tmp = m_pAnimations.at(i)->getColor();
+ a = a * ((float)mof::getAlpha(tmp) / 255);
+ r = r * ((float)mof::getRed(tmp) / 255);
+ g = g * ((float)mof::getGreen(tmp) / 255);
+ b = b * ((float)mof::getBlue(tmp) / 255);
+ }
+ return mof::createColor(a * 255 , r * 255 , g * 255 , b * 255);
+}
+
+
+mof::Matrix3D mof::CascadeAnimation::getWorldTransform(mof::Matrix3D& matrix){
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ matrix = m_pAnimations.at(i)->getWorldTransform(matrix);
+ }
+ return matrix;
+}
+
+
+mof::Line2D mof::CascadeAnimation::getTextureRectangle(){
+ mof::Line2D result;
+ for(int i = 0 ; i < m_pAnimations.size() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ mof::Line2D tmp = m_pAnimations.at(i)->getTextureRectangle();
+ if(tmp != mof::Line2D())result = tmp;
+ }
+ return result;
+}
+
+
+void mof::CascadeAnimation::start(){
+ for(int i = 0 ; i < getLength() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ if(!m_pAnimations.at(i)->isPlaying())m_pAnimations.at(i)->start();
+ }
+}
+
+void mof::CascadeAnimation::stop(){
+ for(int i = 0 ; i < getLength() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ if(m_pAnimations.at(i)->isPlaying())m_pAnimations.at(i)->stop();
+ }
+}
+
+bool mof::CascadeAnimation::isPlaying(){
+ if(getLength() == 0)return true;
+ bool hasAnimation = false;
+
+ for(int i = 0 ; i < getLength() ; i++){
+ if(m_pAnimations.at(i).get() == NULL)continue;
+ if(m_pAnimations.at(i)->isPlaying())return true;
+ else hasAnimation = true;
+ }
+ return !hasAnimation;//\91S\97v\91f\82ªNULL\82È\82çtrue
}
\ No newline at end of file
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-#include <boost/function/function2.hpp>\r
-#include <vector> \r
-\r
-namespace mof\r
-{\r
-namespace stream\r
-{\r
-\r
- template<typename T>\r
- struct Add\r
- {\r
- inline static T apply(const T& a , const T& b){\r
- return a + b;\r
- }\r
- };\r
-\r
- template<typename T>\r
- struct Multiply\r
- {\r
- inline static T apply(const T& a , const T& b){\r
- return a * b;\r
- }\r
- };\r
-\r
- template<typename T , class Cascador = mof::Multiply<T> >\r
- class Cascade : public Manipulator<T>{\r
- typedef std::vector< typename Manipulator< T >::Handler > List;\r
- List m_list;\r
- public:\r
-\r
- virtual ~Cascade()\r
- {\r
- }\r
-\r
- virtual T value( mof::FrameNumber frame) const\r
- {\r
- T obj = m_list[0]->getValue(frame);\r
- for(unsigned int i = 1 ; i < m_cascadeList.size() ; i++){\r
- obj = Cascador::apply(obj , m_list[i]->value(frame));\r
- }\r
- return obj;\r
- }\r
-\r
- void clear()\r
- {\r
- m_list.clear();\r
- }\r
-\r
- void add( const typename Manipulator<T>::Handler& handler )\r
- {\r
-\r
- m_list.push_back( handler );\r
- }\r
-\r
- \r
- \r
- void set(int i , const typename Manipulator<T>::Handler& handler )\r
- {\r
-\r
- m_list.at(i) = handler;\r
- }\r
-\r
-\r
- const typename Manipulator<T>::Handler get(int i ){\r
- return m_cascadeList.at(i);\r
- }\r
-\r
- private: \r
- Cascade\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- )\r
- {\r
- int length = &back - &front + 1;\r
- if(length <= 0)throw std::invalid_argument("list size is 0");\r
-\r
- for( int i = 0 ; i < length ; i++){\r
- m_list.push_back( (&front)[i] );\r
- }\r
- }\r
-\r
- Cascade( ){}\r
-\r
- friend template< class T , class Cascador >\r
- mof::stream::Cascade< T , Cascador >::Handler \r
- operator << \r
- (\r
- mof::stream::Cascade< T , Cascador >::Handler a ,\r
- const mof::stream::Manipulator< T >::Handler& b \r
- );\r
-\r
- };\r
-\r
- template<typename T , class Cascador = mof::Multiply<T> >\r
- Cascade< T , Cascador > makeCascadeHandler\r
- (\r
- const typename Manipulator< T >::Handler& front , \r
- const typename Manipulator< T >::Handler& back \r
- )\r
- {\r
- return typename Cascade< T , Cascador >::Handler\r
- (\r
- new Cascade< T , Cascador >( front , back ); \r
- );\r
- }\r
- \r
- template<typename T , class Cascador = mof::Multiply<T> >\r
- Cascade< T , Cascador > makeCascadeHandler( )\r
- {\r
- return typename Cascade< T , Cascador >::Handler\r
- (\r
- new Cascade< T , Cascador >( ); \r
- );\r
- }\r
-\r
-\r
-} //namespace stream\r
-} //namespace mof\r
-\r
-template< class T , class Cascador >\r
-mof::stream::Cascade< T , Cascador >::Handler \r
-operator << \r
-(\r
- mof::stream::Cascade< T , Cascador >::Handler a ,\r
- const mof::stream::Manipulator< T >::Handler& b \r
-)\r
-{\r
- return a->add( b );\r
-}\r
-\r
-template< class T , class Cascador >\r
-mof::stream::Cascade< T , Cascador >::Handler \r
-operator << \r
-(\r
- mof::stream::Cascade< T , Cascador >::Handler a ,\r
- const T& b \r
-)\r
-{\r
- return a->add( mof::stream::makeConstantHandler( b ) );\r
-}\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+#include <boost/function/function2.hpp>
+#include <vector>
+
+namespace mof
+{
+namespace stream
+{
+
+ template<typename T>
+ struct Add
+ {
+ inline static T apply(const T& a , const T& b){
+ return a + b;
+ }
+ };
+
+ template<typename T>
+ struct Multiply
+ {
+ inline static T apply(const T& a , const T& b){
+ return a * b;
+ }
+ };
+
+ template<typename T , class Cascador = mof::Multiply<T> >
+ class Cascade : public Manipulator<T>{
+ typedef std::vector< typename Manipulator< T >::Handler > List;
+ List m_list;
+ public:
+
+ virtual ~Cascade()
+ {
+ }
+
+ virtual T value( mof::FrameNumber frame) const
+ {
+ T obj = m_list[0]->getValue(frame);
+ for(unsigned int i = 1 ; i < m_cascadeList.size() ; i++){
+ obj = Cascador::apply(obj , m_list[i]->value(frame));
+ }
+ return obj;
+ }
+
+ void clear()
+ {
+ m_list.clear();
+ }
+
+ void add( const typename Manipulator<T>::Handler& handler )
+ {
+
+ m_list.push_back( handler );
+ }
+
+
+
+ void set(int i , const typename Manipulator<T>::Handler& handler )
+ {
+
+ m_list.at(i) = handler;
+ }
+
+
+ const typename Manipulator<T>::Handler get(int i ){
+ return m_cascadeList.at(i);
+ }
+
+ private:
+ Cascade
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ )
+ {
+ int length = &back - &front + 1;
+ if(length <= 0)throw std::invalid_argument("list size is 0");
+
+ for( int i = 0 ; i < length ; i++){
+ m_list.push_back( (&front)[i] );
+ }
+ }
+
+ Cascade( ){}
+
+ friend template< class T , class Cascador >
+ mof::stream::Cascade< T , Cascador >::Handler
+ operator <<
+ (
+ mof::stream::Cascade< T , Cascador >::Handler a ,
+ const mof::stream::Manipulator< T >::Handler& b
+ );
+
+ };
+
+ template<typename T , class Cascador = mof::Multiply<T> >
+ Cascade< T , Cascador > makeCascadeHandler
+ (
+ const typename Manipulator< T >::Handler& front ,
+ const typename Manipulator< T >::Handler& back
+ )
+ {
+ return typename Cascade< T , Cascador >::Handler
+ (
+ new Cascade< T , Cascador >( front , back );
+ );
+ }
+
+ template<typename T , class Cascador = mof::Multiply<T> >
+ Cascade< T , Cascador > makeCascadeHandler( )
+ {
+ return typename Cascade< T , Cascador >::Handler
+ (
+ new Cascade< T , Cascador >( );
+ );
+ }
+
+
+} //namespace stream
+} //namespace mof
+
+template< class T , class Cascador >
+mof::stream::Cascade< T , Cascador >::Handler
+operator <<
+(
+ mof::stream::Cascade< T , Cascador >::Handler a ,
+ const mof::stream::Manipulator< T >::Handler& b
+)
+{
+ return a->add( b );
+}
+
+template< class T , class Cascador >
+mof::stream::Cascade< T , Cascador >::Handler
+operator <<
+(
+ mof::stream::Cascade< T , Cascador >::Handler a ,
+ const T& b
+)
+{
+ return a->add( mof::stream::makeConstantHandler( b ) );
+}
-#pragma once\r
-#include <mof/stream/Manipulator.hpp>\r
-\r
-namespace mof\r
-{\r
- template< typename T > class Constant;\r
-\r
- template< typename T >\r
- boost::shared_ptr< Constant<T> > makeConstantHandler(const T&);\r
-\r
-\r
- template< typename T >\r
- class Constant : public Manipulator< T >{\r
- public:\r
- typedef typename boost::shared_ptr< Constant< T > > Handler;\r
-\r
- virtual ~Constant( ){}\r
- \r
- virtual T value( FrameNumber ) const\r
- {\r
- return m_value;\r
- }\r
-\r
- private:\r
- T m_value;\r
- \r
- Constant(const T& value) : m_value(value)\r
- {\r
- }\r
-\r
- template< typename T >\r
- friend boost::shared_ptr< Constant<T> > makeConstantHandler(const T&);\r
- };\r
-\r
-//{{{ ヘルパ関数\r
- template<typename T>\r
- boost::shared_ptr< Constant<T> > makeConstantHandler( const T& value)\r
- {\r
- return typename Constant<T>::Handler(new Constant<T>(value));\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
-\r
-\r
+#pragma once
+#include <mof/stream/Manipulator.hpp>
+
+namespace mof
+{
+ template< typename T > class Constant;
+
+ template< typename T >
+ boost::shared_ptr< Constant<T> > makeConstantHandler(const T&);
+
+
+ template< typename T >
+ class Constant : public Manipulator< T >{
+ public:
+ typedef typename boost::shared_ptr< Constant< T > > Handler;
+
+ virtual ~Constant( ){}
+
+ virtual T value( FrameNumber ) const
+ {
+ return m_value;
+ }
+
+ private:
+ T m_value;
+
+ Constant(const T& value) : m_value(value)
+ {
+ }
+
+ template< typename T >
+ friend boost::shared_ptr< Constant<T> > makeConstantHandler(const T&);
+ };
+
+//{{{ ヘルパ関数
+ template<typename T>
+ boost::shared_ptr< Constant<T> > makeConstantHandler( const T& value)
+ {
+ return typename Constant<T>::Handler(new Constant<T>(value));
+ }
+//}}}
+
+} // namespace mof
+
+
-#pragma once\r
-#include <mof/stream/Manipulator.hpp>\r
-\r
-namespace mof\r
-{\r
- template< typename T > class Constant;\r
-\r
- template< typename T >\r
- boost::shared_ptr< Constant<T> > makeConstantHandler(const T&);\r
-\r
-\r
- template< typename T >\r
- class Constant : public Manipulator< T >{\r
- public:\r
- typedef typename boost::shared_ptr< Constant< T > > Handler;\r
-\r
- virtual ~Constant( ){}\r
- \r
- virtual T value( FrameNumber ) const\r
- {\r
- return m_value;\r
- }\r
-\r
- private:\r
- T m_value;\r
- \r
- Constant(const T& value) : m_value(value)\r
- {\r
- }\r
-\r
- template< typename T >\r
- friend boost::shared_ptr< Constant<T> > makeConstantHandler(const T&);\r
- };\r
-\r
-//{{{ ヘルパ関数\r
- template<typename T>\r
- boost::shared_ptr< Constant<T> > makeConstantHandler( const T& value)\r
- {\r
- return typename Constant<T>::Handler( new Constant<T>( value ) );\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
-\r
-\r
+#pragma once
+#include <mof/stream/Manipulator.hpp>
+
+namespace mof
+{
+ template< typename T > class Constant;
+
+ template< typename T >
+ boost::shared_ptr< Constant<T> > makeConstantHandler(const T&);
+
+
+ template< typename T >
+ class Constant : public Manipulator< T >{
+ public:
+ typedef typename boost::shared_ptr< Constant< T > > Handler;
+
+ virtual ~Constant( ){}
+
+ virtual T value( FrameNumber ) const
+ {
+ return m_value;
+ }
+
+ private:
+ T m_value;
+
+ Constant(const T& value) : m_value(value)
+ {
+ }
+
+ template< typename T >
+ friend boost::shared_ptr< Constant<T> > makeConstantHandler(const T&);
+ };
+
+//{{{ ヘルパ関数
+ template<typename T>
+ boost::shared_ptr< Constant<T> > makeConstantHandler( const T& value)
+ {
+ return typename Constant<T>::Handler( new Constant<T>( value ) );
+ }
+//}}}
+
+} // namespace mof
+
+
-#include "mof/DataBasedAnimation.h"\r
-#include "mof/KeyFrameAnimation.h"\r
-#include "mof/CSVFile.h"\r
-#include <boost/lexical_cast.hpp>\r
-\r
-\r
-mof::DataBasedAnimation::DataBasedAnimation(const TCHAR * const pPath , mof::Vector3D& denormalizeScale , bool isLooping )\r
-: mof::Animation(isLooping) , m_denormalizeScale(denormalizeScale){\r
- m_pBody = new KeyFrameAnimation(isLooping);\r
- m_pFile = new CSVFile(pPath);\r
- m_pFile->setIgnoreNL(false);\r
- m_pFile->nextLine();//1\8ds\96Ú\82Í\97ñ\92è\8b`\82È\82Ì\82Å\8eÌ\82Ä\82é\r
- loadNextKeyFrame();\r
- \r
-}\r
-\r
-mof::DataBasedAnimation::DataBasedAnimation(const TCHAR * const pPath , bool isLooping )\r
-: mof::Animation(isLooping) , m_denormalizeScale(1 , 1 , 1){\r
- m_pBody = new KeyFrameAnimation(isLooping);\r
- m_pFile = new CSVFile(pPath);\r
- m_pFile->setIgnoreNL(false);\r
- m_pFile->nextLine();//1\8ds\96Ú\82Í\97ñ\92è\8b`\82È\82Ì\82Å\8eÌ\82Ä\82é\r
- loadNextKeyFrame();\r
- \r
-}\r
-\r
-void mof::DataBasedAnimation::loadNextKeyFrame(){\r
- if(!m_pFile->hasNextValue())return;\r
- \r
- //KeyFrame\r
- int keyFrame = boost::lexical_cast<int>(m_pFile->getNextValue());\r
-\r
- //Position\r
- {\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring buf1 = m_pFile->getNextValue();\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring buf2 = m_pFile->getNextValue();\r
- if(buf1 != _T("") && buf2 != _T("")){\r
- mof::tstring buf3;\r
- if(m_pFile->hasNextValue())buf3 = m_pFile->getNextValue();\r
- if(buf3 != _T("")){\r
- //z\8dÀ\95W\82à\97L\8cø\82È\8fê\8d\87\82Í\82R\8e\9f\8c³\8dÀ\95W\82Æ\82µ\82Ä\88µ\82¤\r
- mof::Vector3D pos(\r
- boost::lexical_cast<float>(buf1) , boost::lexical_cast<float>(buf2) , boost::lexical_cast<float>(buf3));\r
- pos.x = pos.x * m_denormalizeScale.x;\r
- pos.y = pos.y * m_denormalizeScale.y;\r
- pos.z = pos.z * m_denormalizeScale.z;\r
- m_pBody->setPosition(keyFrame , pos);\r
- }\r
- else m_pBody->setPosition(keyFrame , mof::Vector2D(boost::lexical_cast<int>(buf1) , boost::lexical_cast<int>(buf2)));\r
- }\r
- else if(m_pFile->hasNextValue())m_pFile->getNextValue();//PositionZ\82ð\8eÌ\82Ä\82é\r
- }\r
-\r
- //Color\r
- {\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring buf1 = m_pFile->getNextValue();\r
- if(buf1 != _T("")){\r
- m_pBody->setColor(keyFrame , mof::createColor(buf1));\r
- }\r
- }\r
-\r
- //Texture\r
- {\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring tux = m_pFile->getNextValue();\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring tuy = m_pFile->getNextValue();\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring tvx = m_pFile->getNextValue();\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring tvy = m_pFile->getNextValue();\r
- if(tux != _T("") && tuy != _T("") && tvx != _T("") && tvy != _T("")){\r
- m_pBody->setTextureRectangle(keyFrame , mof::Line2D(\r
- boost::lexical_cast<int>(tux) , boost::lexical_cast<int>(tuy) ,\r
- boost::lexical_cast<int>(tvx) , boost::lexical_cast<int>(tvy)));\r
- }\r
- }\r
-\r
- //Scale\r
- {\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring buf1 = m_pFile->getNextValue();\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring buf2 = m_pFile->getNextValue();\r
- if(buf1 != _T("") && buf2 != _T("")){\r
- mof::tstring buf3;\r
- if(m_pFile->hasNextValue())buf3 = m_pFile->getNextValue();\r
- if(buf3 != _T("")){\r
- //\89\9c\8ds\82«\82à\97L\8cø\82È\8fê\8d\87\82Í\82R\8e\9f\8c³\8dÀ\95W\82Æ\82µ\82Ä\88µ\82¤\r
- m_pBody->setScale(keyFrame , mof::Vector3D(\r
- boost::lexical_cast<float>(buf1) , boost::lexical_cast<float>(buf2) , boost::lexical_cast<float>(buf3)));\r
- }\r
- else {\r
- //ToDo \82Q\8e\9f\8c³\82Ì\83X\83P\81[\83\8b\r
- //m_pBody->set(keyFrame , mof::Vector2D(boost::lexical_cast<int>(buf1) , boost::lexical_cast<int>(buf2)));\r
- }\r
- }\r
- else if(m_pFile->hasNextValue())m_pFile->getNextValue();//Depth\82ð\8eÌ\82Ä\82é\r
- }\r
-\r
- //Rotate\r
- {\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring buf1 = m_pFile->getNextValue();\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring buf2 = m_pFile->getNextValue();\r
- if(buf1 != _T("") && buf2 != _T("")){\r
- mof::tstring buf3;\r
- if(m_pFile->hasNextValue())buf3 = m_pFile->getNextValue();\r
- if(buf3 != _T("")){\r
- //Z\8e²\92\86\90S\82à\97L\8cø\82È\8fê\8d\87\82Í\82R\8e\9f\8c³\8dÀ\95W\82Æ\82µ\82Ä\88µ\82¤\r
- m_pBody->setRotation(keyFrame , mof::Vector3D(\r
- boost::lexical_cast<float>(buf1) , boost::lexical_cast<float>(buf2) , boost::lexical_cast<float>(buf3)));\r
- }\r
- else {\r
- //ToDo \82Q\8e\9f\8c³\82Ì\89ñ\93]\r
- //m_pBody->set(keyFrame , mof::Vector2D(boost::lexical_cast<int>(buf1) , boost::lexical_cast<int>(buf2)));\r
- }\r
- }\r
- else if(m_pFile->hasNextValue())m_pFile->getNextValue();//RotZ\82ð\8eÌ\82Ä\82é\r
- }\r
-\r
-\r
- //finalize\83V\83O\83i\83\8b\r
- {\r
- if(!m_pFile->hasNextValue())goto END;\r
- mof::tstring buf1 = m_pFile->getNextValue();\r
- if(buf1 != _T("")){\r
- m_pBody->setFinalKey(boost::lexical_cast<int>(buf1));\r
- }\r
- }\r
-\r
-\r
-END:\r
- m_pFile->nextLine();\r
-}\r
-\r
-\r
-mof::DataBasedAnimation::~DataBasedAnimation(void){\r
- delete m_pBody;\r
- delete m_pFile;\r
-}\r
-\r
-\r
-bool mof::DataBasedAnimation::update(){\r
- if(!isPlaying())return false;\r
- m_pBody->update();\r
-\r
- loadNextKeyFrame();\r
- return false;\r
-}\r
-\r
-\r
-bool mof::DataBasedAnimation::isFinalized(){\r
- return m_pBody->isFinalized();\r
-}\r
-\r
-\r
-mof::Vector2D mof::DataBasedAnimation::getPosition(){\r
- return m_pBody->getPosition();\r
-}\r
-\r
- \r
-float mof::DataBasedAnimation::getWidth(){\r
- return m_pBody->getWidth();\r
-}\r
-\r
-\r
-float mof::DataBasedAnimation::getHeight(){\r
- return m_pBody->getHeight();\r
-}\r
-\r
-\r
-float mof::DataBasedAnimation::getDepth(){\r
- return m_pBody->getDepth();\r
-}\r
-\r
-mof::Color mof::DataBasedAnimation::getColor(){\r
- return m_pBody->getColor();\r
-}\r
-\r
- \r
-mof::Matrix3D mof::DataBasedAnimation::getWorldTransform(mof::Matrix3D& matrix){\r
- return m_pBody->getWorldTransform(matrix);\r
-}\r
-\r
- \r
-mof::Line2D mof::DataBasedAnimation::getTextureRectangle(){\r
- return m_pBody->getTextureRectangle();\r
-}\r
+#include "mof/DataBasedAnimation.h"
+#include "mof/KeyFrameAnimation.h"
+#include "mof/CSVFile.h"
+#include <boost/lexical_cast.hpp>
+
+
+mof::DataBasedAnimation::DataBasedAnimation(const TCHAR * const pPath , mof::Vector3D& denormalizeScale , bool isLooping )
+: mof::Animation(isLooping) , m_denormalizeScale(denormalizeScale){
+ m_pBody = new KeyFrameAnimation(isLooping);
+ m_pFile = new CSVFile(pPath);
+ m_pFile->setIgnoreNL(false);
+ m_pFile->nextLine();//1\8ds\96Ú\82Í\97ñ\92è\8b`\82È\82Ì\82Å\8eÌ\82Ä\82é
+ loadNextKeyFrame();
+
+}
+
+mof::DataBasedAnimation::DataBasedAnimation(const TCHAR * const pPath , bool isLooping )
+: mof::Animation(isLooping) , m_denormalizeScale(1 , 1 , 1){
+ m_pBody = new KeyFrameAnimation(isLooping);
+ m_pFile = new CSVFile(pPath);
+ m_pFile->setIgnoreNL(false);
+ m_pFile->nextLine();//1\8ds\96Ú\82Í\97ñ\92è\8b`\82È\82Ì\82Å\8eÌ\82Ä\82é
+ loadNextKeyFrame();
+
+}
+
+void mof::DataBasedAnimation::loadNextKeyFrame(){
+ if(!m_pFile->hasNextValue())return;
+
+ //KeyFrame
+ int keyFrame = boost::lexical_cast<int>(m_pFile->getNextValue());
+
+ //Position
+ {
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring buf1 = m_pFile->getNextValue();
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring buf2 = m_pFile->getNextValue();
+ if(buf1 != _T("") && buf2 != _T("")){
+ mof::tstring buf3;
+ if(m_pFile->hasNextValue())buf3 = m_pFile->getNextValue();
+ if(buf3 != _T("")){
+ //z\8dÀ\95W\82à\97L\8cø\82È\8fê\8d\87\82Í\82R\8e\9f\8c³\8dÀ\95W\82Æ\82µ\82Ä\88µ\82¤
+ mof::Vector3D pos(
+ boost::lexical_cast<float>(buf1) , boost::lexical_cast<float>(buf2) , boost::lexical_cast<float>(buf3));
+ pos.x = pos.x * m_denormalizeScale.x;
+ pos.y = pos.y * m_denormalizeScale.y;
+ pos.z = pos.z * m_denormalizeScale.z;
+ m_pBody->setPosition(keyFrame , pos);
+ }
+ else m_pBody->setPosition(keyFrame , mof::Vector2D(boost::lexical_cast<int>(buf1) , boost::lexical_cast<int>(buf2)));
+ }
+ else if(m_pFile->hasNextValue())m_pFile->getNextValue();//PositionZ\82ð\8eÌ\82Ä\82é
+ }
+
+ //Color
+ {
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring buf1 = m_pFile->getNextValue();
+ if(buf1 != _T("")){
+ m_pBody->setColor(keyFrame , mof::createColor(buf1));
+ }
+ }
+
+ //Texture
+ {
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring tux = m_pFile->getNextValue();
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring tuy = m_pFile->getNextValue();
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring tvx = m_pFile->getNextValue();
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring tvy = m_pFile->getNextValue();
+ if(tux != _T("") && tuy != _T("") && tvx != _T("") && tvy != _T("")){
+ m_pBody->setTextureRectangle(keyFrame , mof::Line2D(
+ boost::lexical_cast<int>(tux) , boost::lexical_cast<int>(tuy) ,
+ boost::lexical_cast<int>(tvx) , boost::lexical_cast<int>(tvy)));
+ }
+ }
+
+ //Scale
+ {
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring buf1 = m_pFile->getNextValue();
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring buf2 = m_pFile->getNextValue();
+ if(buf1 != _T("") && buf2 != _T("")){
+ mof::tstring buf3;
+ if(m_pFile->hasNextValue())buf3 = m_pFile->getNextValue();
+ if(buf3 != _T("")){
+ //\89\9c\8ds\82«\82à\97L\8cø\82È\8fê\8d\87\82Í\82R\8e\9f\8c³\8dÀ\95W\82Æ\82µ\82Ä\88µ\82¤
+ m_pBody->setScale(keyFrame , mof::Vector3D(
+ boost::lexical_cast<float>(buf1) , boost::lexical_cast<float>(buf2) , boost::lexical_cast<float>(buf3)));
+ }
+ else {
+ //ToDo \82Q\8e\9f\8c³\82Ì\83X\83P\81[\83\8b
+ //m_pBody->set(keyFrame , mof::Vector2D(boost::lexical_cast<int>(buf1) , boost::lexical_cast<int>(buf2)));
+ }
+ }
+ else if(m_pFile->hasNextValue())m_pFile->getNextValue();//Depth\82ð\8eÌ\82Ä\82é
+ }
+
+ //Rotate
+ {
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring buf1 = m_pFile->getNextValue();
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring buf2 = m_pFile->getNextValue();
+ if(buf1 != _T("") && buf2 != _T("")){
+ mof::tstring buf3;
+ if(m_pFile->hasNextValue())buf3 = m_pFile->getNextValue();
+ if(buf3 != _T("")){
+ //Z\8e²\92\86\90S\82à\97L\8cø\82È\8fê\8d\87\82Í\82R\8e\9f\8c³\8dÀ\95W\82Æ\82µ\82Ä\88µ\82¤
+ m_pBody->setRotation(keyFrame , mof::Vector3D(
+ boost::lexical_cast<float>(buf1) , boost::lexical_cast<float>(buf2) , boost::lexical_cast<float>(buf3)));
+ }
+ else {
+ //ToDo \82Q\8e\9f\8c³\82Ì\89ñ\93]
+ //m_pBody->set(keyFrame , mof::Vector2D(boost::lexical_cast<int>(buf1) , boost::lexical_cast<int>(buf2)));
+ }
+ }
+ else if(m_pFile->hasNextValue())m_pFile->getNextValue();//RotZ\82ð\8eÌ\82Ä\82é
+ }
+
+
+ //finalize\83V\83O\83i\83\8b
+ {
+ if(!m_pFile->hasNextValue())goto END;
+ mof::tstring buf1 = m_pFile->getNextValue();
+ if(buf1 != _T("")){
+ m_pBody->setFinalKey(boost::lexical_cast<int>(buf1));
+ }
+ }
+
+
+END:
+ m_pFile->nextLine();
+}
+
+
+mof::DataBasedAnimation::~DataBasedAnimation(void){
+ delete m_pBody;
+ delete m_pFile;
+}
+
+
+bool mof::DataBasedAnimation::update(){
+ if(!isPlaying())return false;
+ m_pBody->update();
+
+ loadNextKeyFrame();
+ return false;
+}
+
+
+bool mof::DataBasedAnimation::isFinalized(){
+ return m_pBody->isFinalized();
+}
+
+
+mof::Vector2D mof::DataBasedAnimation::getPosition(){
+ return m_pBody->getPosition();
+}
+
+
+float mof::DataBasedAnimation::getWidth(){
+ return m_pBody->getWidth();
+}
+
+
+float mof::DataBasedAnimation::getHeight(){
+ return m_pBody->getHeight();
+}
+
+
+float mof::DataBasedAnimation::getDepth(){
+ return m_pBody->getDepth();
+}
+
+mof::Color mof::DataBasedAnimation::getColor(){
+ return m_pBody->getColor();
+}
+
+
+mof::Matrix3D mof::DataBasedAnimation::getWorldTransform(mof::Matrix3D& matrix){
+ return m_pBody->getWorldTransform(matrix);
+}
+
+
+mof::Line2D mof::DataBasedAnimation::getTextureRectangle(){
+ return m_pBody->getTextureRectangle();
+}
-\r
-#pragma once\r
-#include "mof/Animation.h"\r
-#include "mof/tstring.h"\r
-\r
-namespace mof{\r
- \r
- class KeyFrameAnimation;\r
- class CSVFile;\r
-\r
- class DataBasedAnimation : public Animation\r
- {\r
- KeyFrameAnimation* m_pBody;\r
- CSVFile* m_pFile;\r
- mof::Vector3D m_denormalizeScale;\r
- \r
- void loadNextKeyFrame();\r
- public:\r
- DataBasedAnimation(const TCHAR * const pPath , bool isLooping = false);\r
- DataBasedAnimation(const TCHAR * const pPath , mof::Vector3D& denormalizePositionScale , bool isLooping = false);\r
- virtual ~DataBasedAnimation(void);\r
-\r
- virtual bool update();\r
- virtual bool isFinalized();\r
-\r
- virtual mof::Vector2D getPosition();\r
- virtual float getWidth();\r
- virtual float getHeight();\r
- virtual float getDepth();\r
- virtual mof::Color getColor();\r
- virtual mof::Matrix3D getWorldTransform(mof::Matrix3D& matrix);\r
- virtual mof::Line2D getTextureRectangle();\r
- \r
- \r
- };\r
-\r
+
+#pragma once
+#include "mof/Animation.h"
+#include "mof/tstring.h"
+
+namespace mof{
+
+ class KeyFrameAnimation;
+ class CSVFile;
+
+ class DataBasedAnimation : public Animation
+ {
+ KeyFrameAnimation* m_pBody;
+ CSVFile* m_pFile;
+ mof::Vector3D m_denormalizeScale;
+
+ void loadNextKeyFrame();
+ public:
+ DataBasedAnimation(const TCHAR * const pPath , bool isLooping = false);
+ DataBasedAnimation(const TCHAR * const pPath , mof::Vector3D& denormalizePositionScale , bool isLooping = false);
+ virtual ~DataBasedAnimation(void);
+
+ virtual bool update();
+ virtual bool isFinalized();
+
+ virtual mof::Vector2D getPosition();
+ virtual float getWidth();
+ virtual float getHeight();
+ virtual float getDepth();
+ virtual mof::Color getColor();
+ virtual mof::Matrix3D getWorldTransform(mof::Matrix3D& matrix);
+ virtual mof::Line2D getTextureRectangle();
+
+
+ };
+
};
\ No newline at end of file
-#include "DefaultAnimationPlayer.hpp"\r
-\r
-\r
-\r
-\r
-mof::DefaultAnimationPlayer::DefaultAnimationPlayer()\r
-: m_frame(0)\r
-{\r
-}\r
-\r
-void mof::DefaultAnimationPlayer::setFrameNumber(mof::FrameNumber frame){\r
- m_frame = frame;\r
-}\r
-\r
-void mof::DefaultAnimationPlayer::nextFrame(){\r
- m_frame++;\r
-}\r
-\r
-void mof::DefaultAnimationPlayer::prevFrame(){\r
- if(m_frame > 0)m_frame--;\r
+#include "DefaultAnimationPlayer.hpp"
+
+
+
+
+mof::DefaultAnimationPlayer::DefaultAnimationPlayer()
+: m_frame(0)
+{
+}
+
+void mof::DefaultAnimationPlayer::setFrameNumber(mof::FrameNumber frame){
+ m_frame = frame;
+}
+
+void mof::DefaultAnimationPlayer::nextFrame(){
+ m_frame++;
+}
+
+void mof::DefaultAnimationPlayer::prevFrame(){
+ if(m_frame > 0)m_frame--;
}
\ No newline at end of file
-#ifndef MOF_DEFAULT_ANIMATION_PLAYER_HPP\r
-#define MOF_DEFAULT_ANIMATION_PLAYER_HPP\r
-#include "mof/AnimationPlayer.hpp"\r
-\r
-namespace mof{\r
-\r
-\r
-class DefaultAnimationPlayer : AnimationPlayer{\r
-protected:\r
- mof::FrameNumber m_frame;\r
-public:\r
- DefaultAnimationPlayer();\r
- virtual void setFrameNumber(mof::FrameNumber frame);\r
- virtual void nextFrame();\r
- virtual void prevFrame();\r
- \r
-};\r
-\r
-}\r
-\r
-\r
-#endif\r
+#ifndef MOF_DEFAULT_ANIMATION_PLAYER_HPP
+#define MOF_DEFAULT_ANIMATION_PLAYER_HPP
+#include "mof/AnimationPlayer.hpp"
+
+namespace mof{
+
+
+class DefaultAnimationPlayer : AnimationPlayer{
+protected:
+ mof::FrameNumber m_frame;
+public:
+ DefaultAnimationPlayer();
+ virtual void setFrameNumber(mof::FrameNumber frame);
+ virtual void nextFrame();
+ virtual void prevFrame();
+
+};
+
+}
+
+
+#endif
-#ifndef MOF_DEFAULT_ANIMATION_PLAYER_HPP\r
-#define MOF_DEFAULT_ANIMATION_PLAYER_HPP\r
-#include "mof/AnimationPlayer.hpp"\r
-\r
-namespace mof{\r
-\r
-\r
-class DefaultAnimationPlayer : AnimationPlayer{\r
-protected:\r
- mof::FrameNumber m_frame;\r
-public:\r
- DefaultAnimationPlayer();\r
- virtual void setFrameNumber(mof::FrameNumber frame);\r
- virtual void nextFrame();\r
- virtual void prevFrame();\r
- \r
-};\r
-\r
-}\r
-\r
-\r
+#ifndef MOF_DEFAULT_ANIMATION_PLAYER_HPP
+#define MOF_DEFAULT_ANIMATION_PLAYER_HPP
+#include "mof/AnimationPlayer.hpp"
+
+namespace mof{
+
+
+class DefaultAnimationPlayer : AnimationPlayer{
+protected:
+ mof::FrameNumber m_frame;
+public:
+ DefaultAnimationPlayer();
+ virtual void setFrameNumber(mof::FrameNumber frame);
+ virtual void nextFrame();
+ virtual void prevFrame();
+
+};
+
+}
+
+
#endif
\ No newline at end of file
-#pragma once\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Filter : public Manipulator< Vector2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr<Filter> Handler;\r
- \r
- Filter\r
- (\r
- const Manipulator<Vector2D>::Handler& body ,\r
- const mof::Vector2D& filter\r
- )\r
- : m_body( body ) , m_filter( filter)\r
- {\r
- }\r
-\r
- virtual Vector2D value( FrameNumber frame ) const\r
- {\r
- mof::Vector2D value = m_body->value(frame);\r
- return mof::Vector2D( value.x * m_filter.x , value.y * m_filter.y);\r
- }\r
-\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
- Vector2D m_filter;\r
-\r
-\r
- };\r
-\r
-//{{{ ヘルパ関数\r
- inline Filter::Handler makeFilterHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body ,\r
- const Vector2D& filter\r
- )\r
- {\r
- return Filter::Handler\r
- (\r
- new Filter( body , filter )\r
- );\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
-\r
+#pragma once
+#include "mof/Vector2D.hpp"
+#include "mof/stream/Manipulator.hpp"
+
+
+namespace mof{
+
+ class Filter : public Manipulator< Vector2D >
+ {
+ public:
+ typedef boost::shared_ptr<Filter> Handler;
+
+ Filter
+ (
+ const Manipulator<Vector2D>::Handler& body ,
+ const mof::Vector2D& filter
+ )
+ : m_body( body ) , m_filter( filter)
+ {
+ }
+
+ virtual Vector2D value( FrameNumber frame ) const
+ {
+ mof::Vector2D value = m_body->value(frame);
+ return mof::Vector2D( value.x * m_filter.x , value.y * m_filter.y);
+ }
+
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+ Vector2D m_filter;
+
+
+ };
+
+//{{{ ヘルパ関数
+ inline Filter::Handler makeFilterHandler
+ (
+ const Manipulator< Vector2D >::Handler& body ,
+ const Vector2D& filter
+ )
+ {
+ return Filter::Handler
+ (
+ new Filter( body , filter )
+ );
+ }
+//}}}
+
+} // namespace mof
+
-#pragma once\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Filter : public Manipulator< Vector2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr< Translation2D > Handler;\r
- \r
- Filter\r
- (\r
- const Manipulator<Vector2D>::Handler& body ,\r
- const mof::Vector2D& filter\r
- )\r
- : m_body( body ) , m_filter( filter)\r
- {\r
- }\r
-\r
- virtual Vector2D value( FrameNumber frame ) const\r
- {\r
- mof::Vector2D value = m_body->value(frame);\r
- return mof::Vector2D( value.x * m_filter.x , value.y * m_filter.y);\r
- }\r
-\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
- Vector2D m_filter;\r
-\r
-\r
- };\r
-\r
-//{{{ ヘルパ関数\r
- inline Filter::Handler makeFilterHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body ,\r
- const Vector2D& filter\r
- )\r
- {\r
- return Filter::Handler\r
- (\r
- new Filter( body , filter )\r
- );\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
-\r
+#pragma once
+#include "mof/Vector2D.hpp"
+#include "mof/stream/Manipulator.hpp"
+
+
+namespace mof{
+
+ class Filter : public Manipulator< Vector2D >
+ {
+ public:
+ typedef boost::shared_ptr< Translation2D > Handler;
+
+ Filter
+ (
+ const Manipulator<Vector2D>::Handler& body ,
+ const mof::Vector2D& filter
+ )
+ : m_body( body ) , m_filter( filter)
+ {
+ }
+
+ virtual Vector2D value( FrameNumber frame ) const
+ {
+ mof::Vector2D value = m_body->value(frame);
+ return mof::Vector2D( value.x * m_filter.x , value.y * m_filter.y);
+ }
+
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+ Vector2D m_filter;
+
+
+ };
+
+//{{{ ヘルパ関数
+ inline Filter::Handler makeFilterHandler
+ (
+ const Manipulator< Vector2D >::Handler& body ,
+ const Vector2D& filter
+ )
+ {
+ return Filter::Handler
+ (
+ new Filter( body , filter )
+ );
+ }
+//}}}
+
+} // namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-namespace mof\r
-{\r
- template< typename T , typename K >\r
- class Joint : public Manipulator< T >\r
- {\r
- public:\r
- typedef typename boost::shared_ptr< mof::Joint< T , K > > Handler;\r
-\r
- \r
- virtual ~Joint( )\r
- {\r
- }\r
-\r
- virtual T value( FrameNumber frame ) const\r
- {\r
- return m_converter( m_body->value( frame ) );\r
- }\r
- \r
- typename Manipulator< K >::Handler get( ) const { return m_body; }\r
-\r
- void set( const typename Manipulator< K >::Handler& handler ){ m_body = handler; }\r
-\r
- private:\r
- typename Manipulator<K>::Handler m_body;\r
- T (*m_converter)( const K& );\r
-\r
- Joint( const typename Manipulator< K >::Handler& handler , T (*converter)( const K& ) )\r
- : m_body( handler) , m_converter( converter )\r
- {\r
- }\r
-\r
- template< typename T , typename K > friend\r
- typename Joint< T , K >::Handler makeJointHandler\r
- ( \r
- const typename Manipulator< K >::Handler& handler ,\r
- T (*converter)( const K& )\r
- );\r
-\r
- }; // class Joint\r
-\r
- /** \8c^\95Ï\8a·\82ð\8ds\82í\82È\82¢Joint */\r
- template< typename T >\r
- class Joint< T , T > : public Manipulator< T >\r
- {\r
- public:\r
- typedef typename boost::shared_ptr< mof::Joint< T , T > > Handler;\r
-\r
- \r
- virtual T getValue( mof::FrameNumber frame ) const\r
- {\r
- return m_body->getValue( frame );\r
- }\r
-\r
- typename mof::Manipulator< T >::Handler get( ) const { return m_body; }\r
- void set( const typename mof::Manipulator< T >::Handler& handler ){ m_body = handler; }\r
- \r
- private:\r
- typename mof::Manipulator< T >::Handler m_body;\r
-\r
- Joint( const typename Manipulator< T >::Handler& handler )\r
- : m_body( handler)\r
- {\r
- }\r
-\r
- template< typename T > friend\r
- typename Joint< T , T >::Handler makeJointHandler\r
- ( \r
- const typename Manipulator< T >::Handler& handler \r
- );\r
-\r
- }; // class Joint \r
-\r
- \r
- template< typename T , typename K >\r
- typename Joint< T , K >::Handler makeJointHandler\r
- ( \r
- const typename Manipulator< K >::Handler& handler ,\r
- T (*converter)( const K& )\r
- )\r
- {\r
- return typename Joint< T , K >::Handler( new Joint< T , K >( handler , converter ) );\r
- }\r
-\r
- /** \8c^\95Ï\8a·\82ð\8ds\82í\82È\82¢Joint\82Ì\90¶\90¬ */\r
- // TODO \8c^\90\84\98_\82ª\8cø\82©\82È\82¢\r
- template< typename T >\r
- typename Joint< T , T >::Handler makeJointHandler\r
- ( \r
- const typename Manipulator< T >::Handler& handler \r
- )\r
- {\r
- return typename Joint< T , T >::Handler( new Joint< T , T >( handler ) );\r
- }\r
-\r
- \r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+
+namespace mof
+{
+ template< typename T , typename K >
+ class Joint : public Manipulator< T >
+ {
+ public:
+ typedef typename boost::shared_ptr< mof::Joint< T , K > > Handler;
+
+
+ virtual ~Joint( )
+ {
+ }
+
+ virtual T value( FrameNumber frame ) const
+ {
+ return m_converter( m_body->value( frame ) );
+ }
+
+ typename Manipulator< K >::Handler get( ) const { return m_body; }
+
+ void set( const typename Manipulator< K >::Handler& handler ){ m_body = handler; }
+
+ private:
+ typename Manipulator<K>::Handler m_body;
+ T (*m_converter)( const K& );
+
+ Joint( const typename Manipulator< K >::Handler& handler , T (*converter)( const K& ) )
+ : m_body( handler) , m_converter( converter )
+ {
+ }
+
+ template< typename T , typename K > friend
+ typename Joint< T , K >::Handler makeJointHandler
+ (
+ const typename Manipulator< K >::Handler& handler ,
+ T (*converter)( const K& )
+ );
+
+ }; // class Joint
+
+ /** \8c^\95Ï\8a·\82ð\8ds\82í\82È\82¢Joint */
+ template< typename T >
+ class Joint< T , T > : public Manipulator< T >
+ {
+ public:
+ typedef typename boost::shared_ptr< mof::Joint< T , T > > Handler;
+
+
+ virtual T getValue( mof::FrameNumber frame ) const
+ {
+ return m_body->getValue( frame );
+ }
+
+ typename mof::Manipulator< T >::Handler get( ) const { return m_body; }
+ void set( const typename mof::Manipulator< T >::Handler& handler ){ m_body = handler; }
+
+ private:
+ typename mof::Manipulator< T >::Handler m_body;
+
+ Joint( const typename Manipulator< T >::Handler& handler )
+ : m_body( handler)
+ {
+ }
+
+ template< typename T > friend
+ typename Joint< T , T >::Handler makeJointHandler
+ (
+ const typename Manipulator< T >::Handler& handler
+ );
+
+ }; // class Joint
+
+
+ template< typename T , typename K >
+ typename Joint< T , K >::Handler makeJointHandler
+ (
+ const typename Manipulator< K >::Handler& handler ,
+ T (*converter)( const K& )
+ )
+ {
+ return typename Joint< T , K >::Handler( new Joint< T , K >( handler , converter ) );
+ }
+
+ /** \8c^\95Ï\8a·\82ð\8ds\82í\82È\82¢Joint\82Ì\90¶\90¬ */
+ // TODO \8c^\90\84\98_\82ª\8cø\82©\82È\82¢
+ template< typename T >
+ typename Joint< T , T >::Handler makeJointHandler
+ (
+ const typename Manipulator< T >::Handler& handler
+ )
+ {
+ return typename Joint< T , T >::Handler( new Joint< T , T >( handler ) );
+ }
+
+
+} // namespace mof
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-namespace mof\r
-{\r
- template< typename T , typename K >\r
- class Joint : public Manipulator< T >\r
- {\r
- public:\r
- typedef typename boost::shared_ptr< mof::Joint< T , K > > Handler;\r
-\r
- \r
- virtual ~Joint( )\r
- {\r
- }\r
-\r
- virtual T value( FrameNumber frame ) const\r
- {\r
- return m_converter( m_body->value( frame ) );\r
- }\r
- \r
- typename Manipulator< K >::Handler get( ) const { return m_body; }\r
-\r
- void set( const typename Manipulator< K >::Handler& handler ){ m_body = handler; }\r
-\r
- private:\r
- typename Manipulator<K>::Handler m_body;\r
- T (*m_converter)( const K& );\r
-\r
- Joint( const typename Manipulator< K >::Handler& handler , T (*converter)( const K& ) )\r
- : m_body( handler) , m_converter( converter )\r
- {\r
- }\r
-\r
- template< typename T , typename K > friend\r
- typename Joint< T , K >::Handler makeJointHandler\r
- ( \r
- const typename Manipulator< K >::Handler& handler ,\r
- T (*converter)( const K& )\r
- );\r
-\r
- }; // class Joint\r
-\r
- /** \8c^\95Ï\8a·\82ð\8ds\82í\82È\82¢Joint */\r
- template< typename T >\r
- class Joint< T , T > : public Manipulator< T >\r
- {\r
- public:\r
- typedef typename boost::shared_ptr< mof::Joint< T , T > > Handler;\r
-\r
- \r
- virtual T getValue( mof::FrameNumber frame ) const\r
- {\r
- return m_body->getValue( frame );\r
- }\r
-\r
- typename mof::Manipulator< T >::Handler get( ) const { return m_body; }\r
- void set( const typename mof::Manipulator< T >::Handler& handler ){ m_body = handler; }\r
- \r
- private:\r
- typename mof::Manipulator< T >::Handler m_body;\r
-\r
- Joint( const typename Manipulator< T >::Handler& handler )\r
- : m_body( handler)\r
- {\r
- }\r
-\r
- template< typename T > friend\r
- typename Joint< T , T >::Handler makeJointHandler\r
- ( \r
- const Manipulator< T >::Handler& handler \r
- );\r
-\r
- }; // class Joint \r
-\r
- \r
- template< typename T , typename K >\r
- typename Joint< T , K >::Handler makeJointHandler\r
- ( \r
- const typename Manipulator< K >::Handler& handler ,\r
- T (*converter)( const K& )\r
- )\r
- {\r
- return typename Joint< T , K >::Handler( new Joint< T , K >( handler , converter ) );\r
- }\r
-\r
- /** \8c^\95Ï\8a·\82ð\8ds\82í\82È\82¢Joint\82Ì\90¶\90¬ */\r
- // TODO \8c^\90\84\98_\82ª\8cø\82©\82È\82¢\r
- template< typename T >\r
- typename Joint< T , T >::Handler makeJointHandler\r
- ( \r
- const typename Manipulator< T >::Handler& handler \r
- )\r
- {\r
- return typename Joint< T , T >::Handler( new Joint< T , T >( handler ) );\r
- }\r
-\r
- \r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+
+namespace mof
+{
+ template< typename T , typename K >
+ class Joint : public Manipulator< T >
+ {
+ public:
+ typedef typename boost::shared_ptr< mof::Joint< T , K > > Handler;
+
+
+ virtual ~Joint( )
+ {
+ }
+
+ virtual T value( FrameNumber frame ) const
+ {
+ return m_converter( m_body->value( frame ) );
+ }
+
+ typename Manipulator< K >::Handler get( ) const { return m_body; }
+
+ void set( const typename Manipulator< K >::Handler& handler ){ m_body = handler; }
+
+ private:
+ typename Manipulator<K>::Handler m_body;
+ T (*m_converter)( const K& );
+
+ Joint( const typename Manipulator< K >::Handler& handler , T (*converter)( const K& ) )
+ : m_body( handler) , m_converter( converter )
+ {
+ }
+
+ template< typename T , typename K > friend
+ typename Joint< T , K >::Handler makeJointHandler
+ (
+ const typename Manipulator< K >::Handler& handler ,
+ T (*converter)( const K& )
+ );
+
+ }; // class Joint
+
+ /** \8c^\95Ï\8a·\82ð\8ds\82í\82È\82¢Joint */
+ template< typename T >
+ class Joint< T , T > : public Manipulator< T >
+ {
+ public:
+ typedef typename boost::shared_ptr< mof::Joint< T , T > > Handler;
+
+
+ virtual T getValue( mof::FrameNumber frame ) const
+ {
+ return m_body->getValue( frame );
+ }
+
+ typename mof::Manipulator< T >::Handler get( ) const { return m_body; }
+ void set( const typename mof::Manipulator< T >::Handler& handler ){ m_body = handler; }
+
+ private:
+ typename mof::Manipulator< T >::Handler m_body;
+
+ Joint( const typename Manipulator< T >::Handler& handler )
+ : m_body( handler)
+ {
+ }
+
+ template< typename T > friend
+ typename Joint< T , T >::Handler makeJointHandler
+ (
+ const Manipulator< T >::Handler& handler
+ );
+
+ }; // class Joint
+
+
+ template< typename T , typename K >
+ typename Joint< T , K >::Handler makeJointHandler
+ (
+ const typename Manipulator< K >::Handler& handler ,
+ T (*converter)( const K& )
+ )
+ {
+ return typename Joint< T , K >::Handler( new Joint< T , K >( handler , converter ) );
+ }
+
+ /** \8c^\95Ï\8a·\82ð\8ds\82í\82È\82¢Joint\82Ì\90¶\90¬ */
+ // TODO \8c^\90\84\98_\82ª\8cø\82©\82È\82¢
+ template< typename T >
+ typename Joint< T , T >::Handler makeJointHandler
+ (
+ const typename Manipulator< T >::Handler& handler
+ )
+ {
+ return typename Joint< T , T >::Handler( new Joint< T , T >( handler ) );
+ }
+
+
+} // namespace mof
-#pragma once\r
-#include "mof/Animation.hpp"\r
-#include <boost/function/function1.hpp>\r
-\r
-namespace mof{\r
-\r
-\r
- template< typename T , typename K >\r
- class Joint : boost::noncopyable{\r
- public:\r
- typedef boost::shared_ptr< mof::Joint<T> > Handler;\r
- typedef boost::function1< const T& , const K& > Converter;\r
-\r
- Joint( const mof::Animation<K>::Handler& handler , const Converter& converter )\r
- : m_body( handler) , m_converter( converter )\r
- {\r
- }\r
- \r
- virtual T getValue( mof::FrameNumber frame ) const\r
- {\r
- return m_converter( m_body->getValue( frame ) );\r
- }\r
-\r
- private:\r
- mof::Animation<K>::Handler m_body;\r
- Converter m_converter;\r
- };\r
-\r
- template< typename T , typename K >\r
- Joint< T , K >::Handler makeJointHandler\r
- ( \r
- const Animation<K>::Handler& handler ,\r
- const Joint< T , K >::Converter& converter\r
- )\r
- {\r
- return Joint::Handler( new Joint<T , K>( handler , converter) );\r
- }\r
-\r
-} // namespace mof\r
+#pragma once
+#include "mof/Animation.hpp"
+#include <boost/function/function1.hpp>
+
+namespace mof{
+
+
+ template< typename T , typename K >
+ class Joint : boost::noncopyable{
+ public:
+ typedef boost::shared_ptr< mof::Joint<T> > Handler;
+ typedef boost::function1< const T& , const K& > Converter;
+
+ Joint( const mof::Animation<K>::Handler& handler , const Converter& converter )
+ : m_body( handler) , m_converter( converter )
+ {
+ }
+
+ virtual T getValue( mof::FrameNumber frame ) const
+ {
+ return m_converter( m_body->getValue( frame ) );
+ }
+
+ private:
+ mof::Animation<K>::Handler m_body;
+ Converter m_converter;
+ };
+
+ template< typename T , typename K >
+ Joint< T , K >::Handler makeJointHandler
+ (
+ const Animation<K>::Handler& handler ,
+ const Joint< T , K >::Converter& converter
+ )
+ {
+ return Joint::Handler( new Joint<T , K>( handler , converter) );
+ }
+
+} // namespace mof
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-#include <map>\r
-#include <stdexcept>\r
-#include <boost/function/function2.hpp>\r
-#include "mof/Interpolation.hpp"\r
-\r
-namespace mof{\r
-\r
- template<typename T >\r
- class KeyFrameAnimation : public Manipulator< T >\r
- {\r
- public:\r
- typedef std::pair< FrameNumber , T > KeyFrame;\r
- typedef typename std::map< FrameNumber , T> KeyMap;\r
-\r
- virtual ~KeyFrameAnimation(){}\r
-\r
- virtual T value( mof::FrameNumber frame) const\r
- {\r
- return m_interpolator(m_map , frame);\r
- }\r
-\r
- mof::FrameNumber getFinalKeyFrameNumber()\r
- {\r
- return m_maxKeyFrameNumber;\r
- }\r
-\r
- private:\r
- KeyMap m_map;\r
- FrameNumber m_maxKeyFrameNumber;\r
- boost::function2<T , const KeyMap& , mof::FrameNumber> m_interpolator;\r
-\r
- KeyFrameAnimation\r
- (\r
- const KeyFrame& front ,\r
- const KeyFrame& back , \r
- const boost::function2< T , const KeyMap& , FrameNumber > & interpolator\r
- )\r
- : m_interpolator(interpolator)\r
- {\r
- int length = &back - &front + 1;\r
- if(length < 1)throw std::invalid_argument("length < 1");\r
- m_maxKeyFrameNumber = 0;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- if((&front)[i].first > m_maxKeyFrameNumber)m_maxKeyFrameNumber = (&front)[i].first;\r
- m_map.insert( std::make_pair((&front)[i].first , (&front)[i].second ) );\r
- }\r
- }\r
-\r
- KeyFrameAnimation\r
- (\r
- const KeyFrame& front , const KeyFrame& back \r
- )\r
- : m_interpolator(&mof::linerInterpolate<T>)\r
- {\r
- int length = &back - &front + 1;\r
- if(length < 1)throw std::invalid_argument("length < 1");\r
- m_maxKeyFrameNumber = 0;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- if((&front)[i].first > m_maxKeyFrameNumber)m_maxKeyFrameNumber = (&front)[i].first;\r
- m_map.insert( std::make_pair((&front)[i].first , (&front)[i].second ) );\r
- }\r
- }\r
-\r
- template< typename T > friend\r
- typename KeyFrameAnimation< T >::KeyFrame \r
- makeKeyFrame( mof::FrameNumber frame , const T & obj );\r
-\r
- template< typename T > friend\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back ,\r
- const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator\r
- );\r
-\r
- template< typename T > friend\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back \r
- );\r
-\r
- };\r
-//{{{ ヘルパ関数\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::KeyFrame \r
- makeKeyFrame( mof::FrameNumber frame , const T & obj )\r
- {\r
- return std::make_pair< FrameNumber , T>(frame , obj);\r
- }\r
-\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back ,\r
- const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator\r
- )\r
- {\r
- return KeyFrameAnimation< T >::Handler\r
- (\r
- new KeyFrameAnimation< T >( front , back , interpolator )\r
- );\r
- }\r
-\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back \r
- )\r
- {\r
- return KeyFrameAnimation< T >::Handler\r
- (\r
- new KeyFrameAnimation< T >( front , back ) \r
- );\r
- }\r
-\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- FrameNumber fn1 , const T& v1 ,\r
- FrameNumber fn2 , const T& v2 \r
- )\r
- {\r
- KeyFrameAnimation<T>::KeyFrame keyFrames[] =\r
- {\r
- makeKeyFrame(fn1 , v1) ,\r
- makeKeyFrame(fn2 , v2) \r
- };\r
- return makeKeyFrameAnimationHandler(keyFrames[0] , lastOf(keyFrames));\r
- }\r
- \r
- template< typename T >\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- FrameNumber fn1 , const T& v1 ,\r
- FrameNumber fn2 , const T& v2 ,\r
- const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator\r
- )\r
- {\r
- KeyFrameAnimation<T>::KeyFrame keyFrames[] =\r
- {\r
- makeKeyFrame(fn1 , v1) ,\r
- makeKeyFrame(fn2 , v2) \r
- };\r
- return makeKeyFrameAnimationHandler(keyFrames[0] , lastOf(keyFrames) , interpolator);\r
- }\r
-\r
-\r
-\r
-//}}}\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+#include <map>
+#include <stdexcept>
+#include <boost/function/function2.hpp>
+#include "mof/Interpolation.hpp"
+
+namespace mof{
+
+ template<typename T >
+ class KeyFrameAnimation : public Manipulator< T >
+ {
+ public:
+ typedef std::pair< FrameNumber , T > KeyFrame;
+ typedef typename std::map< FrameNumber , T> KeyMap;
+
+ virtual ~KeyFrameAnimation(){}
+
+ virtual T value( mof::FrameNumber frame) const
+ {
+ return m_interpolator(m_map , frame);
+ }
+
+ mof::FrameNumber getFinalKeyFrameNumber()
+ {
+ return m_maxKeyFrameNumber;
+ }
+
+ private:
+ KeyMap m_map;
+ FrameNumber m_maxKeyFrameNumber;
+ boost::function2<T , const KeyMap& , mof::FrameNumber> m_interpolator;
+
+ KeyFrameAnimation
+ (
+ const KeyFrame& front ,
+ const KeyFrame& back ,
+ const boost::function2< T , const KeyMap& , FrameNumber > & interpolator
+ )
+ : m_interpolator(interpolator)
+ {
+ int length = &back - &front + 1;
+ if(length < 1)throw std::invalid_argument("length < 1");
+ m_maxKeyFrameNumber = 0;
+ for(int i = 0 ; i < length ; i++)
+ {
+ if((&front)[i].first > m_maxKeyFrameNumber)m_maxKeyFrameNumber = (&front)[i].first;
+ m_map.insert( std::make_pair((&front)[i].first , (&front)[i].second ) );
+ }
+ }
+
+ KeyFrameAnimation
+ (
+ const KeyFrame& front , const KeyFrame& back
+ )
+ : m_interpolator(&mof::linerInterpolate<T>)
+ {
+ int length = &back - &front + 1;
+ if(length < 1)throw std::invalid_argument("length < 1");
+ m_maxKeyFrameNumber = 0;
+ for(int i = 0 ; i < length ; i++)
+ {
+ if((&front)[i].first > m_maxKeyFrameNumber)m_maxKeyFrameNumber = (&front)[i].first;
+ m_map.insert( std::make_pair((&front)[i].first , (&front)[i].second ) );
+ }
+ }
+
+ template< typename T > friend
+ typename KeyFrameAnimation< T >::KeyFrame
+ makeKeyFrame( mof::FrameNumber frame , const T & obj );
+
+ template< typename T > friend
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back ,
+ const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator
+ );
+
+ template< typename T > friend
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back
+ );
+
+ };
+//{{{ ヘルパ関数
+ template< typename T >
+ typename KeyFrameAnimation< T >::KeyFrame
+ makeKeyFrame( mof::FrameNumber frame , const T & obj )
+ {
+ return std::make_pair< FrameNumber , T>(frame , obj);
+ }
+
+ template< typename T >
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back ,
+ const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator
+ )
+ {
+ return KeyFrameAnimation< T >::Handler
+ (
+ new KeyFrameAnimation< T >( front , back , interpolator )
+ );
+ }
+
+ template< typename T >
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back
+ )
+ {
+ return KeyFrameAnimation< T >::Handler
+ (
+ new KeyFrameAnimation< T >( front , back )
+ );
+ }
+
+ template< typename T >
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ FrameNumber fn1 , const T& v1 ,
+ FrameNumber fn2 , const T& v2
+ )
+ {
+ KeyFrameAnimation<T>::KeyFrame keyFrames[] =
+ {
+ makeKeyFrame(fn1 , v1) ,
+ makeKeyFrame(fn2 , v2)
+ };
+ return makeKeyFrameAnimationHandler(keyFrames[0] , lastOf(keyFrames));
+ }
+
+ template< typename T >
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ FrameNumber fn1 , const T& v1 ,
+ FrameNumber fn2 , const T& v2 ,
+ const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator
+ )
+ {
+ KeyFrameAnimation<T>::KeyFrame keyFrames[] =
+ {
+ makeKeyFrame(fn1 , v1) ,
+ makeKeyFrame(fn2 , v2)
+ };
+ return makeKeyFrameAnimationHandler(keyFrames[0] , lastOf(keyFrames) , interpolator);
+ }
+
+
+
+//}}}
+} //namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-#include <map>\r
-#include <stdexcept>\r
-#include <boost/function/function2.hpp>\r
-#include "mof/Interpolation.hpp"\r
-\r
-namespace mof{\r
-\r
- template<typename T >\r
- class KeyFrameAnimation : public Manipulator< T >\r
- {\r
- public:\r
- typedef std::pair< FrameNumber , T > KeyFrame;\r
- typedef typename std::map< FrameNumber , T> KeyMap;\r
-\r
- virtual ~KeyFrameAnimation(){}\r
-\r
- virtual T value( mof::FrameNumber frame) const\r
- {\r
- return m_interpolator(m_map , frame);\r
- }\r
-\r
- mof::FrameNumber getFinalKeyFrameNumber()\r
- {\r
- return m_maxKeyFrameNumber;\r
- }\r
-\r
- private:\r
- KeyMap m_map;\r
- FrameNumber m_maxKeyFrameNumber;\r
- boost::function2<T , const KeyMap& , mof::FrameNumber> m_interpolator;\r
-\r
- KeyFrameAnimation\r
- (\r
- const KeyFrame& front ,\r
- const KeyFrame& back , \r
- const boost::function2< T , const KeyMap& , FrameNumber > & interpolator\r
- )\r
- : m_interpolator(interpolator)\r
- {\r
- int length = &back - &front + 1;\r
- if(length < 1)throw std::invalid_argument("length < 1");\r
- m_maxKeyFrameNumber = 0;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- if((&front)[i].first > m_maxKeyFrameNumber)m_maxKeyFrameNumber = (&front)[i].first;\r
- m_map.insert( std::make_pair((&front)[i].first , (&front)[i].second ) );\r
- }\r
- }\r
-\r
- KeyFrameAnimation\r
- (\r
- const KeyFrame& front , const KeyFrame& back \r
- )\r
- : m_interpolator(&mof::linerInterpolate<T>)\r
- {\r
- int length = &back - &front + 1;\r
- if(length < 1)throw std::invalid_argument("length < 1");\r
- m_maxKeyFrameNumber = 0;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- if((&front)[i].first > m_maxKeyFrameNumber)m_maxKeyFrameNumber = (&front)[i].first;\r
- m_map.insert( std::make_pair((&front)[i].first , (&front)[i].second ) );\r
- }\r
- }\r
-\r
- template< typename T > friend\r
- typename KeyFrameAnimation< T >::KeyFrame \r
- makeKeyFrame( mof::FrameNumber frame , const T & obj );\r
-\r
- template< typename T > friend\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back ,\r
- const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator\r
- );\r
-\r
- template< typename T > friend\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back \r
- );\r
-\r
- };\r
-//{{{ ヘルパ関数\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::KeyFrame \r
- makeKeyFrame( mof::FrameNumber frame , const T & obj )\r
- {\r
- return std::make_pair< FrameNumber , T>(frame , obj);\r
- }\r
-\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back ,\r
- const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator\r
- )\r
- {\r
- return KeyFrameAnimation< T >::Handler\r
- (\r
- new KeyFrameAnimation< T >( front , back , interpolator )\r
- );\r
- }\r
-\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back \r
- )\r
- {\r
- return KeyFrameAnimation< T >::Handler\r
- (\r
- new KeyFrameAnimation< T >( front , back ) \r
- );\r
- }\r
-\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- FrameNumber fn1 , const T& v1 ,\r
- FrameNumber fn2 , const T& v2 \r
- )\r
- {\r
- KeyFrameAnimation<T>::KeyFrame keyFrames[] =\r
- {\r
- makeKeyFrame(fn1 , v1) ,\r
- makeKeyFrame(fn2 , v2) \r
- };\r
- return makeKeyFrameAnimationHandler(keyFrames[0] , lastOf(keyFrames));\r
- }\r
-\r
-\r
-//}}}\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+#include <map>
+#include <stdexcept>
+#include <boost/function/function2.hpp>
+#include "mof/Interpolation.hpp"
+
+namespace mof{
+
+ template<typename T >
+ class KeyFrameAnimation : public Manipulator< T >
+ {
+ public:
+ typedef std::pair< FrameNumber , T > KeyFrame;
+ typedef typename std::map< FrameNumber , T> KeyMap;
+
+ virtual ~KeyFrameAnimation(){}
+
+ virtual T value( mof::FrameNumber frame) const
+ {
+ return m_interpolator(m_map , frame);
+ }
+
+ mof::FrameNumber getFinalKeyFrameNumber()
+ {
+ return m_maxKeyFrameNumber;
+ }
+
+ private:
+ KeyMap m_map;
+ FrameNumber m_maxKeyFrameNumber;
+ boost::function2<T , const KeyMap& , mof::FrameNumber> m_interpolator;
+
+ KeyFrameAnimation
+ (
+ const KeyFrame& front ,
+ const KeyFrame& back ,
+ const boost::function2< T , const KeyMap& , FrameNumber > & interpolator
+ )
+ : m_interpolator(interpolator)
+ {
+ int length = &back - &front + 1;
+ if(length < 1)throw std::invalid_argument("length < 1");
+ m_maxKeyFrameNumber = 0;
+ for(int i = 0 ; i < length ; i++)
+ {
+ if((&front)[i].first > m_maxKeyFrameNumber)m_maxKeyFrameNumber = (&front)[i].first;
+ m_map.insert( std::make_pair((&front)[i].first , (&front)[i].second ) );
+ }
+ }
+
+ KeyFrameAnimation
+ (
+ const KeyFrame& front , const KeyFrame& back
+ )
+ : m_interpolator(&mof::linerInterpolate<T>)
+ {
+ int length = &back - &front + 1;
+ if(length < 1)throw std::invalid_argument("length < 1");
+ m_maxKeyFrameNumber = 0;
+ for(int i = 0 ; i < length ; i++)
+ {
+ if((&front)[i].first > m_maxKeyFrameNumber)m_maxKeyFrameNumber = (&front)[i].first;
+ m_map.insert( std::make_pair((&front)[i].first , (&front)[i].second ) );
+ }
+ }
+
+ template< typename T > friend
+ typename KeyFrameAnimation< T >::KeyFrame
+ makeKeyFrame( mof::FrameNumber frame , const T & obj );
+
+ template< typename T > friend
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back ,
+ const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator
+ );
+
+ template< typename T > friend
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back
+ );
+
+ };
+//{{{ ヘルパ関数
+ template< typename T >
+ typename KeyFrameAnimation< T >::KeyFrame
+ makeKeyFrame( mof::FrameNumber frame , const T & obj )
+ {
+ return std::make_pair< FrameNumber , T>(frame , obj);
+ }
+
+ template< typename T >
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back ,
+ const boost::function2< T , const std::map< FrameNumber , T >& , FrameNumber> & interpolator
+ )
+ {
+ return KeyFrameAnimation< T >::Handler
+ (
+ new KeyFrameAnimation< T >( front , back , interpolator )
+ );
+ }
+
+ template< typename T >
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back
+ )
+ {
+ return KeyFrameAnimation< T >::Handler
+ (
+ new KeyFrameAnimation< T >( front , back )
+ );
+ }
+
+ template< typename T >
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ FrameNumber fn1 , const T& v1 ,
+ FrameNumber fn2 , const T& v2
+ )
+ {
+ KeyFrameAnimation<T>::KeyFrame keyFrames[] =
+ {
+ makeKeyFrame(fn1 , v1) ,
+ makeKeyFrame(fn2 , v2)
+ };
+ return makeKeyFrameAnimationHandler(keyFrames[0] , lastOf(keyFrames));
+ }
+
+
+//}}}
+} //namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- template< typename T >\r
- class Loop : public Manipulator< T >\r
- {\r
- \r
- public:\r
-\r
- virtual ~Loop( ){} \r
-\r
- virtual T value( FrameNumber frame) const\r
- {\r
- return m_pBody->value( getInnerFrameNumber( frame ) );\r
- }\r
-\r
- private:\r
-\r
- typename Manipulator<T>::Handler m_pBody;\r
- FrameNumber m_beginLoopFrameNumber;\r
- FrameNumber m_endLoopFrameNumber;\r
-\r
- FrameNumber getInnerFrameNumber(FrameNumber frame) const\r
- {\r
- if(frame < m_beginLoopFrameNumber)return frame;\r
- FrameNumber d = m_endLoopFrameNumber - m_beginLoopFrameNumber;\r
- return (frame - m_beginLoopFrameNumber) % d + m_beginLoopFrameNumber;\r
- }\r
-\r
- Loop(const typename Manipulator<T>::Handler& pBody , FrameNumber endLoopFrameNumber)\r
- : m_pBody(pBody) , m_beginLoopFrameNumber(0) , m_endLoopFrameNumber(endLoopFrameNumber)\r
- {\r
- }\r
-\r
- Loop\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber beginLoopFrameNumber ,\r
- FrameNumber endLoopFrameNumber\r
- ) \r
- : m_pBody(pBody) , m_beginLoopFrameNumber(beginLoopFrameNumber) , m_endLoopFrameNumber(endLoopFrameNumber)\r
- {\r
- if(m_endLoopFrameNumber < m_beginLoopFrameNumber)throw std::invalid_argument("endLoop < beginLoop");\r
- }\r
-\r
- template<typename T > friend\r
- typename boost::shared_ptr< Loop< T> >\r
- makeLoopHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber beginLoopFrameNumber ,\r
- FrameNumber endLoopFrameNumber\r
- );\r
-\r
- template<typename T > friend\r
- typename boost::shared_ptr< Loop< T> >\r
- makeLoopHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber endLoopFrameNumber\r
- );\r
-\r
- };\r
-//{{{ ヘルパ関数\r
- template<typename T >\r
- typename boost::shared_ptr< Loop< T> >\r
- makeLoopHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber beginLoopFrameNumber ,\r
- FrameNumber endLoopFrameNumber\r
- )\r
- {\r
- return typename Manipulator< T >::Handler\r
- (\r
- new Loop< T >(pBody , beginLoopFrameNumber , endLoopFrameNumber)\r
- );\r
- }\r
-\r
- template<typename T >\r
- typename boost::shared_ptr< Loop< T> >\r
- makeLoopHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber endLoopFrameNumber\r
- )\r
- {\r
- return typename Manipulator< T >::Handler\r
- (\r
- new Loop< T >(pBody , endLoopFrameNumber)\r
- );\r
- }\r
-//}}}\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+
+
+namespace mof{
+
+ template< typename T >
+ class Loop : public Manipulator< T >
+ {
+
+ public:
+
+ virtual ~Loop( ){}
+
+ virtual T value( FrameNumber frame) const
+ {
+ return m_pBody->value( getInnerFrameNumber( frame ) );
+ }
+
+ private:
+
+ typename Manipulator<T>::Handler m_pBody;
+ FrameNumber m_beginLoopFrameNumber;
+ FrameNumber m_endLoopFrameNumber;
+
+ FrameNumber getInnerFrameNumber(FrameNumber frame) const
+ {
+ if(frame < m_beginLoopFrameNumber)return frame;
+ FrameNumber d = m_endLoopFrameNumber - m_beginLoopFrameNumber;
+ return (frame - m_beginLoopFrameNumber) % d + m_beginLoopFrameNumber;
+ }
+
+ Loop(const typename Manipulator<T>::Handler& pBody , FrameNumber endLoopFrameNumber)
+ : m_pBody(pBody) , m_beginLoopFrameNumber(0) , m_endLoopFrameNumber(endLoopFrameNumber)
+ {
+ }
+
+ Loop
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber beginLoopFrameNumber ,
+ FrameNumber endLoopFrameNumber
+ )
+ : m_pBody(pBody) , m_beginLoopFrameNumber(beginLoopFrameNumber) , m_endLoopFrameNumber(endLoopFrameNumber)
+ {
+ if(m_endLoopFrameNumber < m_beginLoopFrameNumber)throw std::invalid_argument("endLoop < beginLoop");
+ }
+
+ template<typename T > friend
+ typename boost::shared_ptr< Loop< T> >
+ makeLoopHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber beginLoopFrameNumber ,
+ FrameNumber endLoopFrameNumber
+ );
+
+ template<typename T > friend
+ typename boost::shared_ptr< Loop< T> >
+ makeLoopHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber endLoopFrameNumber
+ );
+
+ };
+//{{{ ヘルパ関数
+ template<typename T >
+ typename boost::shared_ptr< Loop< T> >
+ makeLoopHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber beginLoopFrameNumber ,
+ FrameNumber endLoopFrameNumber
+ )
+ {
+ return typename Manipulator< T >::Handler
+ (
+ new Loop< T >(pBody , beginLoopFrameNumber , endLoopFrameNumber)
+ );
+ }
+
+ template<typename T >
+ typename boost::shared_ptr< Loop< T> >
+ makeLoopHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber endLoopFrameNumber
+ )
+ {
+ return typename Manipulator< T >::Handler
+ (
+ new Loop< T >(pBody , endLoopFrameNumber)
+ );
+ }
+//}}}
+} //namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- template< typename T >\r
- class Loop : public Manipulator< T >\r
- {\r
- \r
- public:\r
-\r
- virtual ~Loop( ){} \r
-\r
- virtual T value( FrameNumber frame) const\r
- {\r
- return m_pBody->value( getInnerFrameNumber( frame ) );\r
- }\r
-\r
- private:\r
-\r
- typename Manipulator<T>::Handler m_pBody;\r
- FrameNumber m_beginLoopFrameNumber;\r
- FrameNumber m_endLoopFrameNumber;\r
-\r
- FrameNumber getInnerFrameNumber(FrameNumber frame) const\r
- {\r
- if(frame < m_beginLoopFrameNumber)return frame;\r
- FrameNumber d = m_endLoopFrameNumber - m_beginLoopFrameNumber;\r
- return (frame - m_beginLoopFrameNumber) % d + m_beginLoopFrameNumber;\r
- }\r
-\r
- Loop(const typename Manipulator<T>::Handler& pBody , FrameNumber endLoopFrameNumber)\r
- : m_pBody(pBody) , m_beginLoopFrameNumber(0) , m_endLoopFrameNumber(endLoopFrameNumber)\r
- {\r
- }\r
-\r
- LoopManipulator\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber beginLoopFrameNumber ,\r
- FrameNumber endLoopFrameNumber\r
- ) \r
- : m_pBody(pBody) , m_beginLoopFrameNumber(beginLoopFrameNumber) , m_endLoopFrameNumber(endLoopFrameNumber)\r
- {\r
- if(m_endLoopFrameNumber < m_beginLoopFrameNumber)throw std::invalid_argument("endLoop < beginLoop");\r
- }\r
-\r
- template<typename T > friend\r
- typename boost::shared_ptr< Loop< T> >\r
- makeLoopHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber beginLoopFrameNumber ,\r
- FrameNumber endLoopFrameNumber\r
- );\r
-\r
- template<typename T > friend\r
- typename boost::shared_ptr< Loop< T> >\r
- makeLoopHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber endLoopFrameNumber\r
- );\r
-\r
- };\r
-//{{{ ヘルパ関数\r
- template<typename T >\r
- typename boost::shared_ptr< Loop< T> >\r
- makeLoopHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber beginLoopFrameNumber ,\r
- FrameNumber endLoopFrameNumber\r
- )\r
- {\r
- return typename Manipulator< T >::Handler\r
- (\r
- new Loop< T >(pBody , beginLoopFrameNumber , endLoopFrameNumber)\r
- );\r
- }\r
-\r
- template<typename T >\r
- typename boost::shared_ptr< Loop< T> >\r
- makeLoopHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- FrameNumber endLoopFrameNumber\r
- )\r
- {\r
- return typename Manipulator< T >::Handler\r
- (\r
- new Loop< T >(pBody , endLoopFrameNumber)\r
- );\r
- }\r
-//}}}\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+
+
+namespace mof{
+
+ template< typename T >
+ class Loop : public Manipulator< T >
+ {
+
+ public:
+
+ virtual ~Loop( ){}
+
+ virtual T value( FrameNumber frame) const
+ {
+ return m_pBody->value( getInnerFrameNumber( frame ) );
+ }
+
+ private:
+
+ typename Manipulator<T>::Handler m_pBody;
+ FrameNumber m_beginLoopFrameNumber;
+ FrameNumber m_endLoopFrameNumber;
+
+ FrameNumber getInnerFrameNumber(FrameNumber frame) const
+ {
+ if(frame < m_beginLoopFrameNumber)return frame;
+ FrameNumber d = m_endLoopFrameNumber - m_beginLoopFrameNumber;
+ return (frame - m_beginLoopFrameNumber) % d + m_beginLoopFrameNumber;
+ }
+
+ Loop(const typename Manipulator<T>::Handler& pBody , FrameNumber endLoopFrameNumber)
+ : m_pBody(pBody) , m_beginLoopFrameNumber(0) , m_endLoopFrameNumber(endLoopFrameNumber)
+ {
+ }
+
+ LoopManipulator
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber beginLoopFrameNumber ,
+ FrameNumber endLoopFrameNumber
+ )
+ : m_pBody(pBody) , m_beginLoopFrameNumber(beginLoopFrameNumber) , m_endLoopFrameNumber(endLoopFrameNumber)
+ {
+ if(m_endLoopFrameNumber < m_beginLoopFrameNumber)throw std::invalid_argument("endLoop < beginLoop");
+ }
+
+ template<typename T > friend
+ typename boost::shared_ptr< Loop< T> >
+ makeLoopHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber beginLoopFrameNumber ,
+ FrameNumber endLoopFrameNumber
+ );
+
+ template<typename T > friend
+ typename boost::shared_ptr< Loop< T> >
+ makeLoopHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber endLoopFrameNumber
+ );
+
+ };
+//{{{ ヘルパ関数
+ template<typename T >
+ typename boost::shared_ptr< Loop< T> >
+ makeLoopHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber beginLoopFrameNumber ,
+ FrameNumber endLoopFrameNumber
+ )
+ {
+ return typename Manipulator< T >::Handler
+ (
+ new Loop< T >(pBody , beginLoopFrameNumber , endLoopFrameNumber)
+ );
+ }
+
+ template<typename T >
+ typename boost::shared_ptr< Loop< T> >
+ makeLoopHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ FrameNumber endLoopFrameNumber
+ )
+ {
+ return typename Manipulator< T >::Handler
+ (
+ new Loop< T >(pBody , endLoopFrameNumber)
+ );
+ }
+//}}}
+} //namespace mof
+
- #pragma once\r
- #include "mof/Animation.hpp"\r
- \r
- \r
- namespace mof{\r
- \r
- template<typename T >\r
- class LoopAnimation : public Animation<T>{\r
- typename Animation<T>::Handler m_pBody;\r
- FrameNumber m_beginLoopFrameNumber;\r
- FrameNumber m_endLoopFrameNumber;\r
- \r
- FrameNumber getInnerFrameNumber(FrameNumber frame) const{\r
- if(frame < m_beginLoopFrameNumber)return frame;\r
- mof::FrameNumber d = m_endLoopFrameNumber - m_beginLoopFrameNumber;\r
- return (frame - m_beginLoopFrameNumber) % d + m_beginLoopFrameNumber;\r
- }\r
- \r
- public:\r
- \r
- LoopAnimation(const typename Animation<T>::Handler& pBody , FrameNumber endLoopFrameNumber)\r
- : m_pBody(pBody) , m_beginLoopFrameNumber(0) , m_endLoopFrameNumber(endLoopFrameNumber)\r
- {\r
- }\r
- \r
- LoopAnimation(\r
- const typename mof::Animation<T>::Handler& pBody ,\r
- mof::FrameNumber beginLoopFrameNumber ,\r
- mof::FrameNumber endLoopFrameNumber\r
- ) : m_pBody(pBody) , m_beginLoopFrameNumber(beginLoopFrameNumber) , m_endLoopFrameNumber(endLoopFrameNumber)\r
- {\r
- if(m_endLoopFrameNumber < m_beginLoopFrameNumber)throw std::invalid_argument("endLoop < beginLoop");\r
- }\r
- \r
- \r
- \r
- virtual T getValue( mof::FrameNumber frame) const{\r
- return m_pBody->getValue(getInnerFrameNumber(frame));\r
- }\r
- \r
- \r
- \r
- };\r
- \r
-\r
- template<typename T >\r
- typename mof::Animation<T>::Handler \r
- makeLoopHandler(\r
- const typename mof::Animation<T>::Handler& pBody ,\r
- mof::FrameNumber beginLoopFrameNumber ,\r
- mof::FrameNumber endLoopFrameNumber){\r
-\r
- return typename mof::Animation<T>::Handler(\r
- new mof::LoopAnimation<T>(pBody , beginLoopFrameNumber , endLoopFrameNumber)\r
- );\r
- }\r
- \r
-\r
- } //namespace mof\r
- \r
+ #pragma once
+ #include "mof/Animation.hpp"
+
+
+ namespace mof{
+
+ template<typename T >
+ class LoopAnimation : public Animation<T>{
+ typename Animation<T>::Handler m_pBody;
+ FrameNumber m_beginLoopFrameNumber;
+ FrameNumber m_endLoopFrameNumber;
+
+ FrameNumber getInnerFrameNumber(FrameNumber frame) const{
+ if(frame < m_beginLoopFrameNumber)return frame;
+ mof::FrameNumber d = m_endLoopFrameNumber - m_beginLoopFrameNumber;
+ return (frame - m_beginLoopFrameNumber) % d + m_beginLoopFrameNumber;
+ }
+
+ public:
+
+ LoopAnimation(const typename Animation<T>::Handler& pBody , FrameNumber endLoopFrameNumber)
+ : m_pBody(pBody) , m_beginLoopFrameNumber(0) , m_endLoopFrameNumber(endLoopFrameNumber)
+ {
+ }
+
+ LoopAnimation(
+ const typename mof::Animation<T>::Handler& pBody ,
+ mof::FrameNumber beginLoopFrameNumber ,
+ mof::FrameNumber endLoopFrameNumber
+ ) : m_pBody(pBody) , m_beginLoopFrameNumber(beginLoopFrameNumber) , m_endLoopFrameNumber(endLoopFrameNumber)
+ {
+ if(m_endLoopFrameNumber < m_beginLoopFrameNumber)throw std::invalid_argument("endLoop < beginLoop");
+ }
+
+
+
+ virtual T getValue( mof::FrameNumber frame) const{
+ return m_pBody->getValue(getInnerFrameNumber(frame));
+ }
+
+
+
+ };
+
+
+ template<typename T >
+ typename mof::Animation<T>::Handler
+ makeLoopHandler(
+ const typename mof::Animation<T>::Handler& pBody ,
+ mof::FrameNumber beginLoopFrameNumber ,
+ mof::FrameNumber endLoopFrameNumber){
+
+ return typename mof::Animation<T>::Handler(
+ new mof::LoopAnimation<T>(pBody , beginLoopFrameNumber , endLoopFrameNumber)
+ );
+ }
+
+
+ } //namespace mof
+
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
- typedef unsigned int FrameNumber;\r
-\r
- template<typename T>\r
- class Manipulator \r
- {\r
- public:\r
- typedef typename boost::shared_ptr< Manipulator > Handler;\r
- virtual ~Manipulator(){} \r
- virtual T value( FrameNumber fn ) const = 0;\r
-\r
- };\r
-\r
-\r
-} // namespace mof\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+ typedef unsigned int FrameNumber;
+
+ template<typename T>
+ class Manipulator
+ {
+ public:
+ typedef typename boost::shared_ptr< Manipulator > Handler;
+ virtual ~Manipulator(){}
+ virtual T value( FrameNumber fn ) const = 0;
+
+ };
+
+
+} // namespace mof
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-\r
- template<typename T>\r
- class Manipulator \r
- {\r
- public:\r
- typedef typename boost::shared_ptr< Manipulator > Handler;\r
- virtual ~Manipulator(){} \r
- virtual T value( FrameNumber fn ) const = 0;\r
-\r
- };\r
-\r
-\r
-} // namespace mof\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+
+ template<typename T>
+ class Manipulator
+ {
+ public:
+ typedef typename boost::shared_ptr< Manipulator > Handler;
+ virtual ~Manipulator(){}
+ virtual T value( FrameNumber fn ) const = 0;
+
+ };
+
+
+} // namespace mof
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-namespace mof{\r
-\r
- template< typename T >\r
- class Offset : public Manipulator< T >\r
- {\r
- \r
- public:\r
- typedef typename boost::shared_ptr< Offset > Handler;\r
- \r
- virtual ~Offset( ){}\r
-\r
- virtual T value( FrameNumber frame ) const\r
- {\r
- if( m_offset + frame < 0)return m_pBody->value( 0 );\r
- else return m_pBody->value( frame + m_offset );\r
- }\r
-\r
- private:\r
- typename Manipulator<T>::Handler m_pBody;\r
- int m_offset;\r
-\r
-\r
- Offset( const typename Manipulator<T>::Handler& pBody , int offset )\r
- : m_pBody(pBody) , m_offset(offset) \r
- {\r
- }\r
-\r
- template<typename T > friend\r
- typename boost::shared_ptr< Offset< T > > makeOffsetHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- int offset\r
- );\r
-\r
- };\r
-\r
-\r
- template< typename T >\r
- boost::shared_ptr< Offset< T > > makeOffsetHandler\r
- (\r
- const typename Manipulator< T >::Handler& pBody ,\r
- int offset\r
- )\r
- {\r
- return typename Offset< T >::Handler(\r
- new Offset< T >( pBody , offset )\r
- );\r
- }\r
-\r
-\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+
+namespace mof{
+
+ template< typename T >
+ class Offset : public Manipulator< T >
+ {
+
+ public:
+ typedef typename boost::shared_ptr< Offset > Handler;
+
+ virtual ~Offset( ){}
+
+ virtual T value( FrameNumber frame ) const
+ {
+ if( m_offset + frame < 0)return m_pBody->value( 0 );
+ else return m_pBody->value( frame + m_offset );
+ }
+
+ private:
+ typename Manipulator<T>::Handler m_pBody;
+ int m_offset;
+
+
+ Offset( const typename Manipulator<T>::Handler& pBody , int offset )
+ : m_pBody(pBody) , m_offset(offset)
+ {
+ }
+
+ template<typename T > friend
+ typename boost::shared_ptr< Offset< T > > makeOffsetHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ int offset
+ );
+
+ };
+
+
+ template< typename T >
+ boost::shared_ptr< Offset< T > > makeOffsetHandler
+ (
+ const typename Manipulator< T >::Handler& pBody ,
+ int offset
+ )
+ {
+ return typename Offset< T >::Handler(
+ new Offset< T >( pBody , offset )
+ );
+ }
+
+
+} //namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-\r
-namespace mof{\r
-\r
- template< typename T >\r
- class Offset : public Manipulator< T >\r
- {\r
- \r
- public:\r
- typedef typename boost::shared_ptr< Cascade > Handler;\r
- \r
- virtual ~Offset( ){}\r
-\r
- virtual T value( FrameNumber frame ) const\r
- {\r
- if( m_offset + frame < 0)return m_pBody->value( 0 );\r
- else return m_pBody->value( frame + m_offset );\r
- }\r
-\r
- private:\r
- typename Manipulator<T>::Handler m_pBody;\r
- int m_offset;\r
-\r
-\r
- Offset( const typename Manipulator<T>::Handler& pBody , int offset )\r
- : m_pBody(pBody) , m_offset(offset) \r
- {\r
- }\r
-\r
- template<typename T > friend\r
- typename boost::shared_ptr< Offset< T > > makeOffsetHandler\r
- (\r
- const typename Manipulator<T>::Handler& pBody ,\r
- int offset\r
- );\r
-\r
- };\r
-\r
-\r
- template< typename T >\r
- boost::shared_ptr< Offset< T > > makeOffsetHandler\r
- (\r
- const typename Manipulator< T >::Handler& pBody ,\r
- int offset\r
- )\r
- {\r
- return typename Offset< T >::Handler(\r
- new Offset< T >( pBody , offset )\r
- );\r
- }\r
-\r
-\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+
+namespace mof{
+
+ template< typename T >
+ class Offset : public Manipulator< T >
+ {
+
+ public:
+ typedef typename boost::shared_ptr< Cascade > Handler;
+
+ virtual ~Offset( ){}
+
+ virtual T value( FrameNumber frame ) const
+ {
+ if( m_offset + frame < 0)return m_pBody->value( 0 );
+ else return m_pBody->value( frame + m_offset );
+ }
+
+ private:
+ typename Manipulator<T>::Handler m_pBody;
+ int m_offset;
+
+
+ Offset( const typename Manipulator<T>::Handler& pBody , int offset )
+ : m_pBody(pBody) , m_offset(offset)
+ {
+ }
+
+ template<typename T > friend
+ typename boost::shared_ptr< Offset< T > > makeOffsetHandler
+ (
+ const typename Manipulator<T>::Handler& pBody ,
+ int offset
+ );
+
+ };
+
+
+ template< typename T >
+ boost::shared_ptr< Offset< T > > makeOffsetHandler
+ (
+ const typename Manipulator< T >::Handler& pBody ,
+ int offset
+ )
+ {
+ return typename Offset< T >::Handler(
+ new Offset< T >( pBody , offset )
+ );
+ }
+
+
+} //namespace mof
+
-#pragma once\r
-#include "mof/Animation.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- template<typename T >\r
- class OffsetAnimation : public Animation<T>{\r
- typename Animation<T>::Handler m_pBody;\r
- int m_offset;\r
-\r
-\r
- public:\r
-\r
- OffsetAnimation(const typename Animation<T>::Handler& pBody , int offset)\r
- : m_pBody(pBody) , m_offset(offset) \r
- {\r
- }\r
-\r
- \r
-\r
- virtual T getValue( mof::FrameNumber frame) const{\r
- if( m_offset + frame < 0)return m_pBody->getValue( 0 );\r
- else return m_pBody->getValue(frame + m_offset );\r
- }\r
-\r
-\r
-\r
- };\r
-\r
-\r
- template<typename T >\r
- typename mof::Animation<T>::Handler \r
- makeOffsetHandler\r
- (\r
- const typename mof::Animation<T>::Handler& pBody ,\r
- int offset\r
- )\r
- {\r
- return typename mof::Animation<T>::Handler\r
- (\r
- new mof::OffsetAnimation<T>(pBody , offset)\r
- );\r
- }\r
-\r
-\r
-} //namespace mof\r
-\r
+#pragma once
+#include "mof/Animation.hpp"
+
+
+namespace mof{
+
+ template<typename T >
+ class OffsetAnimation : public Animation<T>{
+ typename Animation<T>::Handler m_pBody;
+ int m_offset;
+
+
+ public:
+
+ OffsetAnimation(const typename Animation<T>::Handler& pBody , int offset)
+ : m_pBody(pBody) , m_offset(offset)
+ {
+ }
+
+
+
+ virtual T getValue( mof::FrameNumber frame) const{
+ if( m_offset + frame < 0)return m_pBody->getValue( 0 );
+ else return m_pBody->getValue(frame + m_offset );
+ }
+
+
+
+ };
+
+
+ template<typename T >
+ typename mof::Animation<T>::Handler
+ makeOffsetHandler
+ (
+ const typename mof::Animation<T>::Handler& pBody ,
+ int offset
+ )
+ {
+ return typename mof::Animation<T>::Handler
+ (
+ new mof::OffsetAnimation<T>(pBody , offset)
+ );
+ }
+
+
+} //namespace mof
+
- #pragma once\r
- \r
- #include <mof/Animation.hpp>\r
- \r
- namespace mof{\r
- \r
- \r
- \r
- template<typename T>\r
- class ParametricAnimation : public mof::Animation<T>{\r
- const boost::shared_ptr<T>& m_parameter;\r
- public:\r
- \r
- ParametricAnimation(const boost::shared_ptr<T>& parameter) \r
- : m_parameter(parameter){\r
- }\r
- \r
- virtual T getValue(mof::FrameNumber ) const{\r
- return *m_parameter;\r
- }\r
- \r
- };\r
- \r
- template<class T>\r
- typename mof::Animation<T>::Handler makeParametricHandler(const boost::shared_ptr<T>& parameter){\r
- return mof::Animation<T>::Handler(new mof::ParametricAnimation<T>(parameter));\r
- }\r
- \r
- } //namespace mof\r
- \r
+ #pragma once
+
+ #include <mof/Animation.hpp>
+
+ namespace mof{
+
+
+
+ template<typename T>
+ class ParametricAnimation : public mof::Animation<T>{
+ const boost::shared_ptr<T>& m_parameter;
+ public:
+
+ ParametricAnimation(const boost::shared_ptr<T>& parameter)
+ : m_parameter(parameter){
+ }
+
+ virtual T getValue(mof::FrameNumber ) const{
+ return *m_parameter;
+ }
+
+ };
+
+ template<class T>
+ typename mof::Animation<T>::Handler makeParametricHandler(const boost::shared_ptr<T>& parameter){
+ return mof::Animation<T>::Handler(new mof::ParametricAnimation<T>(parameter));
+ }
+
+ } //namespace mof
+
- #pragma once\r
- \r
- #include <mof/Animation.hpp>\r
- \r
- namespace mof{\r
- \r
- \r
- \r
- template<typename T>\r
- class ParametricAnimation : public mof::Animation<T>{\r
- const boost::shared_ptr<T>& m_parameter;\r
- public:\r
- \r
- ParametricAnimation(const boost::shared_ptr<T>& parameter) \r
- : m_parameter(parameter){\r
- }\r
- \r
- virtual T getValue(mof::FrameNumber ) const{\r
- return *m_parameter;\r
- }\r
- \r
- };\r
- \r
- template<class T>\r
- typename mof::Animation<T>::Handler makeParametricHandler(const boost::shared_ptr<T>& parameter){\r
- return mof::Animation<T>::Handler(new mof::ParametricAnimation<T>(parameter));\r
- }\r
- \r
- } //namespace mof\r
- \r
+ #pragma once
+
+ #include <mof/Animation.hpp>
+
+ namespace mof{
+
+
+
+ template<typename T>
+ class ParametricAnimation : public mof::Animation<T>{
+ const boost::shared_ptr<T>& m_parameter;
+ public:
+
+ ParametricAnimation(const boost::shared_ptr<T>& parameter)
+ : m_parameter(parameter){
+ }
+
+ virtual T getValue(mof::FrameNumber ) const{
+ return *m_parameter;
+ }
+
+ };
+
+ template<class T>
+ typename mof::Animation<T>::Handler makeParametricHandler(const boost::shared_ptr<T>& parameter){
+ return mof::Animation<T>::Handler(new mof::ParametricAnimation<T>(parameter));
+ }
+
+ } //namespace mof
+
-#pragma once\r
-#include <mof/stream/Manipulator.hpp>\r
-\r
-namespace mof\r
-{\r
- template< typename T > class Reference;\r
-\r
- template< typename T > \r
- boost::shared_ptr< Reference<T> >\r
- makeReferenceHandler(const typename Manipulator<T>::Handler&);\r
-\r
-//{{{ Reference\r
- template<typename T>\r
- class Reference : public Manipulator<T>\r
- {\r
- public:\r
- typedef typename boost::shared_ptr<Reference> Handler;\r
- \r
- virtual ~Reference(){} \r
- \r
- virtual T value(FrameNumber fn) const\r
- {\r
- return m_body->value(fn);\r
- }\r
-\r
- void replace(const typename Manipulator<T>::Handler& body)\r
- {\r
- m_body = body;\r
- }\r
-\r
- private:\r
- Manipulator<T>::Handler m_body;\r
-\r
- Reference(const Manipulator<T>::Handler& body) : m_body(body)\r
- {}\r
- \r
- template< typename T >\r
- friend typename boost::shared_ptr< Reference<T> > \r
- makeReferenceHandler(const typename Manipulator<T>::Handler&);\r
-\r
- };\r
-//}}}\r
-//{{{ ヘルパ関数\r
- template<typename T>\r
- boost::shared_ptr< Reference<T> >\r
- makeReferenceHandler(const typename Manipulator<T>::Handler& body)\r
- {\r
- return typename Reference<T>::Handler(new Reference<T>(body));\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
+#pragma once
+#include <mof/stream/Manipulator.hpp>
+
+namespace mof
+{
+ template< typename T > class Reference;
+
+ template< typename T >
+ boost::shared_ptr< Reference<T> >
+ makeReferenceHandler(const typename Manipulator<T>::Handler&);
+
+//{{{ Reference
+ template<typename T>
+ class Reference : public Manipulator<T>
+ {
+ public:
+ typedef typename boost::shared_ptr<Reference> Handler;
+
+ virtual ~Reference(){}
+
+ virtual T value(FrameNumber fn) const
+ {
+ return m_body->value(fn);
+ }
+
+ void replace(const typename Manipulator<T>::Handler& body)
+ {
+ m_body = body;
+ }
+
+ private:
+ Manipulator<T>::Handler m_body;
+
+ Reference(const Manipulator<T>::Handler& body) : m_body(body)
+ {}
+
+ template< typename T >
+ friend typename boost::shared_ptr< Reference<T> >
+ makeReferenceHandler(const typename Manipulator<T>::Handler&);
+
+ };
+//}}}
+//{{{ ヘルパ関数
+ template<typename T>
+ boost::shared_ptr< Reference<T> >
+ makeReferenceHandler(const typename Manipulator<T>::Handler& body)
+ {
+ return typename Reference<T>::Handler(new Reference<T>(body));
+ }
+//}}}
+
+} // namespace mof
-#pragma once\r
-#include <mof/stream/Manipulator.hpp>\r
-\r
-namespace mof\r
-{\r
- template< typename T > class Reference;\r
-\r
- template< typename T > \r
- boost::shared_ptr< Reference<T> >\r
- makeReferenceHandler(const typename Manipulator<T>::Handler&);\r
-\r
-//{{{ Reference\r
- template<typename T>\r
- class Reference : public Manipulator<T>\r
- {\r
- public:\r
- typedef typename boost::shared_ptr<Reference> Handler;\r
- \r
- virtual ~Reference(){} \r
- \r
- virtual T value(FrameNumber fn) const\r
- {\r
- return m_body.value(fn);\r
- }\r
-\r
- void replace(const typename Manipulator<T>::Handler& body)\r
- {\r
- m_body = body;\r
- }\r
-\r
- private:\r
- Manipulator<T>::Handler m_body;\r
-\r
- Reference(const Manipulator<T>::Handler& body) : m_body(body)\r
- {}\r
- \r
- template< typename T >\r
- friend typename boost::shared_ptr< Reference<T> > \r
- makeReferenceHandler(const typename Manipulator<T>::Handler&);\r
-\r
- };\r
-//}}}\r
-//{{{ ヘルパ関数\r
- template<typename T>\r
- boost::shared_ptr< Reference<T> >\r
- makeReferenceHandler(const typename Manipulator<T>::Handler& body)\r
- {\r
- return typename Reference<T>::Handler(new Reference<T>(body));\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
+#pragma once
+#include <mof/stream/Manipulator.hpp>
+
+namespace mof
+{
+ template< typename T > class Reference;
+
+ template< typename T >
+ boost::shared_ptr< Reference<T> >
+ makeReferenceHandler(const typename Manipulator<T>::Handler&);
+
+//{{{ Reference
+ template<typename T>
+ class Reference : public Manipulator<T>
+ {
+ public:
+ typedef typename boost::shared_ptr<Reference> Handler;
+
+ virtual ~Reference(){}
+
+ virtual T value(FrameNumber fn) const
+ {
+ return m_body.value(fn);
+ }
+
+ void replace(const typename Manipulator<T>::Handler& body)
+ {
+ m_body = body;
+ }
+
+ private:
+ Manipulator<T>::Handler m_body;
+
+ Reference(const Manipulator<T>::Handler& body) : m_body(body)
+ {}
+
+ template< typename T >
+ friend typename boost::shared_ptr< Reference<T> >
+ makeReferenceHandler(const typename Manipulator<T>::Handler&);
+
+ };
+//}}}
+//{{{ ヘルパ関数
+ template<typename T>
+ boost::shared_ptr< Reference<T> >
+ makeReferenceHandler(const typename Manipulator<T>::Handler& body)
+ {
+ return typename Reference<T>::Handler(new Reference<T>(body));
+ }
+//}}}
+
+} // namespace mof
-#pragma once\r
-#include <mof/stream/Reference.hpp>\r
-#include <mof/stream/Offset.hpp>\r
-#include <mof/stream/TypeStream.hpp>\r
-#include <vector>\r
-\r
-namespace mof\r
-{\r
-//{{{ ReferenceWrapper\r
- template<typename T>\r
- class ReferenceWrapper\r
- {\r
- public:\r
- \r
- typename Reference<T>::Handler makeRef(const typename Manipulator<T>::Handler& body)\r
- {\r
- m_list.push_back(makeReferenceHandler(body));\r
- return m_list.back();\r
- }\r
- \r
- typename Reference<T>::Handler makeRef(const T& body)\r
- {\r
- m_list.push_back(makeReferenceHandler<T>(makeConstantHandler(body)));\r
- return m_list.back();\r
- }\r
-\r
-\r
- void replace(int index , const typename Manipulator<T>::Handler& body)\r
- {\r
- m_list[index]->replace(body);\r
- //m_list[index]->replace(makeOffsetHandler(body , -1 * (int)m_stream.getCurrentFrameNumber()));\r
- }\r
- \r
- void replace(int index , const T& body)\r
- {\r
- m_list[index]->replace(makeConstantHandler(body));\r
- //m_list[index]->replace(makeOffsetHandler(makeConstantHandler(body) , -1 * (int)m_stream.getCurrentFrameNumber()));\r
- }\r
-\r
- void replace(int index , const TypeStream<T>& stream , const typename Manipulator<T>::Handler& body)\r
- {\r
- m_list[index]->replace(makeOffsetHandler<T>(body , -1 * stream.getCurrentFrameNumber()));\r
- }\r
- \r
-\r
- typename Reference<T>::Handler getRef(int index) const\r
- {\r
- return m_list[index];\r
- }\r
-\r
- private:\r
- std::vector<typename Reference<T>::Handler> m_list;\r
- };\r
-//}}}\r
-} // namespace mof\r
-\r
+#pragma once
+#include <mof/stream/Reference.hpp>
+#include <mof/stream/Offset.hpp>
+#include <mof/stream/TypeStream.hpp>
+#include <vector>
+
+namespace mof
+{
+//{{{ ReferenceWrapper
+ template<typename T>
+ class ReferenceWrapper
+ {
+ public:
+
+ typename Reference<T>::Handler makeRef(const typename Manipulator<T>::Handler& body)
+ {
+ m_list.push_back(makeReferenceHandler(body));
+ return m_list.back();
+ }
+
+ typename Reference<T>::Handler makeRef(const T& body)
+ {
+ m_list.push_back(makeReferenceHandler<T>(makeConstantHandler(body)));
+ return m_list.back();
+ }
+
+
+ void replace(int index , const typename Manipulator<T>::Handler& body)
+ {
+ m_list[index]->replace(body);
+ //m_list[index]->replace(makeOffsetHandler(body , -1 * (int)m_stream.getCurrentFrameNumber()));
+ }
+
+ void replace(int index , const T& body)
+ {
+ m_list[index]->replace(makeConstantHandler(body));
+ //m_list[index]->replace(makeOffsetHandler(makeConstantHandler(body) , -1 * (int)m_stream.getCurrentFrameNumber()));
+ }
+
+ void replace(int index , const TypeStream<T>& stream , const typename Manipulator<T>::Handler& body)
+ {
+ m_list[index]->replace(makeOffsetHandler<T>(body , -1 * stream.getCurrentFrameNumber()));
+ }
+
+
+ typename Reference<T>::Handler getRef(int index) const
+ {
+ return m_list[index];
+ }
+
+ private:
+ std::vector<typename Reference<T>::Handler> m_list;
+ };
+//}}}
+} // namespace mof
+
-#pragma once\r
-#include <mof/stream/Reference.hpp>\r
-#include <mof/stream/Offset.hpp>\r
-#include <mof/stream/TypeStream.hpp>\r
-#include <vector>\r
-\r
-namespace mof\r
-{\r
-//{{{ ReferenceWrapper\r
- template<typename T>\r
- class ReferenceWrapper\r
- {\r
- public:\r
- \r
- typename Reference<T>::Handler makeRef(const typename Manipulator<T>::Handler& body)\r
- {\r
- m_list.push_back(makeReferenceHandler(body));\r
- return m_list.back();\r
- }\r
- \r
- typename Reference<T>::Handler makeRef(const T& body)\r
- {\r
- m_list.push_back(makeReferenceHandler<T>(makeConstantHandler(body)));\r
- return m_list.back();\r
- }\r
-\r
-\r
- void replace(int index , const typename Manipulator<T>::Handler& body)\r
- {\r
- m_list[index]->replace(body);\r
- //m_list[index]->replace(makeOffsetHandler(body , -1 * (int)m_stream.getCurrentFrameNumber()));\r
- }\r
- \r
- void replace(int index , const T& body)\r
- {\r
- m_list[index]->replace(makeConstantHandler(body));\r
- //m_list[index]->replace(makeOffsetHandler(makeConstantHandler(body) , -1 * (int)m_stream.getCurrentFrameNumber()));\r
- }\r
-\r
- void replace(int index , const TypeStream<T>& stream , const typename Manipulator<T>::Handler& body)\r
- {\r
- m_list[index]->replace(makeOffsetHandler(body , -1 * stream.getCurrentFrameNumber()));\r
- }\r
- \r
-\r
- typename Reference<T>::Handler getRef(int index) const\r
- {\r
- return m_list[index];\r
- }\r
-\r
- private:\r
- std::vector<typename Reference<T>::Handler> m_list;\r
- };\r
-//}}}\r
-} // namespace mof\r
-\r
+#pragma once
+#include <mof/stream/Reference.hpp>
+#include <mof/stream/Offset.hpp>
+#include <mof/stream/TypeStream.hpp>
+#include <vector>
+
+namespace mof
+{
+//{{{ ReferenceWrapper
+ template<typename T>
+ class ReferenceWrapper
+ {
+ public:
+
+ typename Reference<T>::Handler makeRef(const typename Manipulator<T>::Handler& body)
+ {
+ m_list.push_back(makeReferenceHandler(body));
+ return m_list.back();
+ }
+
+ typename Reference<T>::Handler makeRef(const T& body)
+ {
+ m_list.push_back(makeReferenceHandler<T>(makeConstantHandler(body)));
+ return m_list.back();
+ }
+
+
+ void replace(int index , const typename Manipulator<T>::Handler& body)
+ {
+ m_list[index]->replace(body);
+ //m_list[index]->replace(makeOffsetHandler(body , -1 * (int)m_stream.getCurrentFrameNumber()));
+ }
+
+ void replace(int index , const T& body)
+ {
+ m_list[index]->replace(makeConstantHandler(body));
+ //m_list[index]->replace(makeOffsetHandler(makeConstantHandler(body) , -1 * (int)m_stream.getCurrentFrameNumber()));
+ }
+
+ void replace(int index , const TypeStream<T>& stream , const typename Manipulator<T>::Handler& body)
+ {
+ m_list[index]->replace(makeOffsetHandler(body , -1 * stream.getCurrentFrameNumber()));
+ }
+
+
+ typename Reference<T>::Handler getRef(int index) const
+ {
+ return m_list[index];
+ }
+
+ private:
+ std::vector<typename Reference<T>::Handler> m_list;
+ };
+//}}}
+} // namespace mof
+
-#pragma once\r
-#include "mof/stream/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Rotation2D : public Manipulator< Matrix2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr< Rotation2D > Handler;\r
- \r
- Rotation2D\r
- (\r
- const std::pair< FrameNumber , mof::Vector2D >& front , \r
- const std::pair< FrameNumber , mof::Vector2D >& back \r
- )\r
- {\r
- m_body = makeKeyFrameAnimationHandler< Vector2D >\r
- (\r
- front , back , &linerInterpolate< Vector2D >\r
- );\r
- }\r
- \r
- Rotation2D\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual Matrix2D value( FrameNumber frame ) const\r
- {\r
- return Matrix2D::createRotation( m_body->value(frame) );\r
- }\r
-\r
- Manipulator<mof::Vector2D>::Handler get( ) const\r
- {\r
- return m_body;\r
- }\r
- \r
- void set( const Manipulator< Vector2D >::Handler& handler ) \r
- {\r
- m_body = handler;\r
- }\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
-\r
- };\r
-//{{{ ヘルパ関数\r
- inline Rotation2D::Handler makeRotation2DHandler\r
- (\r
- const std::pair< FrameNumber , Vector2D >& front ,\r
- const std::pair< FrameNumber , Vector2D >& back \r
- )\r
- {\r
- return Rotation2D::Handler\r
- (\r
- new Rotation2D( front , back )\r
- );\r
- }\r
-\r
- inline Rotation2D::Handler makeRotation2DHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- {\r
- return Rotation2D::Handler\r
- (\r
- new Rotation2D( body )\r
- );\r
- }\r
-//}}}\r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+
+
+namespace mof{
+
+ class Rotation2D : public Manipulator< Matrix2D >
+ {
+ public:
+ typedef boost::shared_ptr< Rotation2D > Handler;
+
+ Rotation2D
+ (
+ const std::pair< FrameNumber , mof::Vector2D >& front ,
+ const std::pair< FrameNumber , mof::Vector2D >& back
+ )
+ {
+ m_body = makeKeyFrameAnimationHandler< Vector2D >
+ (
+ front , back , &linerInterpolate< Vector2D >
+ );
+ }
+
+ Rotation2D
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual Matrix2D value( FrameNumber frame ) const
+ {
+ return Matrix2D::createRotation( m_body->value(frame) );
+ }
+
+ Manipulator<mof::Vector2D>::Handler get( ) const
+ {
+ return m_body;
+ }
+
+ void set( const Manipulator< Vector2D >::Handler& handler )
+ {
+ m_body = handler;
+ }
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+
+ };
+//{{{ ヘルパ関数
+ inline Rotation2D::Handler makeRotation2DHandler
+ (
+ const std::pair< FrameNumber , Vector2D >& front ,
+ const std::pair< FrameNumber , Vector2D >& back
+ )
+ {
+ return Rotation2D::Handler
+ (
+ new Rotation2D( front , back )
+ );
+ }
+
+ inline Rotation2D::Handler makeRotation2DHandler
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ {
+ return Rotation2D::Handler
+ (
+ new Rotation2D( body )
+ );
+ }
+//}}}
+} // namespace mof
-#pragma once\r
-#include "mof/stream/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Rotation2D : public Manipulator< Matrix2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr< Rotation2D > Handler;\r
- \r
- Rotation2D\r
- (\r
- const std::pair< FrameNumber , mof::Vector2D >& front , \r
- const std::pair< FrameNumber , mof::Vector2D >& back \r
- )\r
- {\r
- m_body = makeKeyFrameAnimationHandler< Vector2D >\r
- (\r
- front , back , &linerInterpolate< Vector2D >\r
- );\r
- }\r
- \r
- Rotation2D\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual Matrix2D value( FrameNumber frame ) const\r
- {\r
- return Matrix2D::createRotation( m_body->value(frame) );\r
- }\r
-\r
- Manipulator<mof::Vector2D>::Handler get( ) const\r
- {\r
- return m_body;\r
- }\r
- \r
- void set( const Manipulator< Vector2D >::Handler& handler ) \r
- {\r
- m_body = handler;\r
- }\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
-\r
- };\r
-//{{{ ヘルパ関数\r
- Rotation2D::Handler makeRotation2DHandler\r
- (\r
- const std::pair< FrameNumber , Vector2D >& front ,\r
- const std::pair< FrameNumber , Vector2D >& back \r
- )\r
- {\r
- return Rotation2D::Handler\r
- (\r
- new Rotation2D( front , back )\r
- );\r
- }\r
-\r
- Rotation2D::Handler makeRotation2DHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- {\r
- return Rotation2D::Handler\r
- (\r
- new Rotation2D( body )\r
- );\r
- }\r
-//}}}\r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+
+
+namespace mof{
+
+ class Rotation2D : public Manipulator< Matrix2D >
+ {
+ public:
+ typedef boost::shared_ptr< Rotation2D > Handler;
+
+ Rotation2D
+ (
+ const std::pair< FrameNumber , mof::Vector2D >& front ,
+ const std::pair< FrameNumber , mof::Vector2D >& back
+ )
+ {
+ m_body = makeKeyFrameAnimationHandler< Vector2D >
+ (
+ front , back , &linerInterpolate< Vector2D >
+ );
+ }
+
+ Rotation2D
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual Matrix2D value( FrameNumber frame ) const
+ {
+ return Matrix2D::createRotation( m_body->value(frame) );
+ }
+
+ Manipulator<mof::Vector2D>::Handler get( ) const
+ {
+ return m_body;
+ }
+
+ void set( const Manipulator< Vector2D >::Handler& handler )
+ {
+ m_body = handler;
+ }
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+
+ };
+//{{{ ヘルパ関数
+ Rotation2D::Handler makeRotation2DHandler
+ (
+ const std::pair< FrameNumber , Vector2D >& front ,
+ const std::pair< FrameNumber , Vector2D >& back
+ )
+ {
+ return Rotation2D::Handler
+ (
+ new Rotation2D( front , back )
+ );
+ }
+
+ Rotation2D::Handler makeRotation2DHandler
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ {
+ return Rotation2D::Handler
+ (
+ new Rotation2D( body )
+ );
+ }
+//}}}
+} // namespace mof
-#ifndef MOF_ROTATION_ANIMATION_2D_HPP\r
-#define MOF_ROTATION_ANIMATION_2D_HPP\r
-#include "mof/KeyFrameAnimation.hpp"\r
-#include <map>\r
-#include <stdexcept>\r
-#include <boost/function/function2.hpp>\r
-#include "mof/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-#include "mof/utilities.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
-\r
-class RotationAnimation2D : public mof::Animation<mof::Matrix2D>{\r
- boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector2D>> m_pBody;\r
-public:\r
-\r
- RotationAnimation2D(\r
- const std::pair<mof::FrameNumber , mof::Vector2D>& front , \r
- const std::pair<mof::FrameNumber , mof::Vector2D>& back \r
- )\r
- {\r
- m_pBody = boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector2D>>(\r
- new mof::KeyFrameAnimation<mof::Vector2D>(front , back , &mof::linerInterpolate<mof::Vector2D>)\r
- );\r
- }\r
-\r
- virtual mof::Matrix2D getValue( mof::FrameNumber frame) const{\r
- return mof::Matrix2D::createRotation(m_pBody->getValue(frame));\r
- }\r
-\r
- mof::FrameNumber getFinalKeyFrameNumber(){\r
- return m_pBody->getFinalKeyFrameNumber();\r
- }\r
-\r
-\r
-};\r
-\r
-\r
-\r
-\r
-}\r
-\r
+#ifndef MOF_ROTATION_ANIMATION_2D_HPP
+#define MOF_ROTATION_ANIMATION_2D_HPP
+#include "mof/KeyFrameAnimation.hpp"
+#include <map>
+#include <stdexcept>
+#include <boost/function/function2.hpp>
+#include "mof/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+#include "mof/utilities.hpp"
+
+
+namespace mof{
+
+
+class RotationAnimation2D : public mof::Animation<mof::Matrix2D>{
+ boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector2D>> m_pBody;
+public:
+
+ RotationAnimation2D(
+ const std::pair<mof::FrameNumber , mof::Vector2D>& front ,
+ const std::pair<mof::FrameNumber , mof::Vector2D>& back
+ )
+ {
+ m_pBody = boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector2D>>(
+ new mof::KeyFrameAnimation<mof::Vector2D>(front , back , &mof::linerInterpolate<mof::Vector2D>)
+ );
+ }
+
+ virtual mof::Matrix2D getValue( mof::FrameNumber frame) const{
+ return mof::Matrix2D::createRotation(m_pBody->getValue(frame));
+ }
+
+ mof::FrameNumber getFinalKeyFrameNumber(){
+ return m_pBody->getFinalKeyFrameNumber();
+ }
+
+
+};
+
+
+
+
+}
+
#endif
\ No newline at end of file
- #pragma once\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include <map>\r
- #include <stdexcept>\r
- #include <boost/function/function2.hpp>\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include "mof/Matrix3D.hpp"\r
- \r
- \r
- \r
- namespace mof{\r
- \r
- \r
- class RotationAnimation3D : public mof::Animation<mof::Matrix3D>{\r
- mof::Animation<mof::Vector3D>::Handler m_body;\r
- public:\r
- \r
- RotationAnimation3D(\r
- const std::pair<mof::FrameNumber , mof::Vector3D>& front , \r
- const std::pair<mof::FrameNumber , mof::Vector3D>& back \r
- )\r
- {\r
- m_body = mof::Animation<mof::Vector3D>::Handler\r
- (\r
- new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D> )\r
- );\r
- }\r
- \r
- RotationAnimation3D\r
- (\r
- const mof::Animation<mof::Vector3D>::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
- \r
- virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{\r
- return mof::Matrix3D::createRotation(m_body->getValue(frame));\r
- }\r
- \r
- \r
- /*mof::FrameNumber getFinalKeyFrameNumber(){\r
- return m_pBody->getFinalKeyFrameNumber();\r
- }*/\r
- \r
- \r
- };\r
- \r
- \r
- \r
- \r
- } //namespace mof\r
- \r
+ #pragma once
+ #include "mof/KeyFrameAnimation.hpp"
+ #include <map>
+ #include <stdexcept>
+ #include <boost/function/function2.hpp>
+ #include "mof/KeyFrameAnimation.hpp"
+ #include "mof/Matrix3D.hpp"
+
+
+
+ namespace mof{
+
+
+ class RotationAnimation3D : public mof::Animation<mof::Matrix3D>{
+ mof::Animation<mof::Vector3D>::Handler m_body;
+ public:
+
+ RotationAnimation3D(
+ const std::pair<mof::FrameNumber , mof::Vector3D>& front ,
+ const std::pair<mof::FrameNumber , mof::Vector3D>& back
+ )
+ {
+ m_body = mof::Animation<mof::Vector3D>::Handler
+ (
+ new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D> )
+ );
+ }
+
+ RotationAnimation3D
+ (
+ const mof::Animation<mof::Vector3D>::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{
+ return mof::Matrix3D::createRotation(m_body->getValue(frame));
+ }
+
+
+ /*mof::FrameNumber getFinalKeyFrameNumber(){
+ return m_pBody->getFinalKeyFrameNumber();
+ }*/
+
+
+ };
+
+
+
+
+ } //namespace mof
+
- #pragma once\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include <map>\r
- #include <stdexcept>\r
- #include <boost/function/function2.hpp>\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include "mof/Matrix3D.hpp"\r
- \r
- \r
- \r
- namespace mof{\r
- \r
- \r
- class RotationAnimation3D : public mof::Animation<mof::Matrix3D>{\r
- mof::Animation<mof::Vector3D>::Handler m_body;\r
- public:\r
- \r
- RotationAnimation3D(\r
- const std::pair<mof::FrameNumber , mof::Vector3D>& front , \r
- const std::pair<mof::FrameNumber , mof::Vector3D>& back \r
- )\r
- {\r
- m_body = mof::Animation<mof::Vector3D>::Handler\r
- (\r
- new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D> )\r
- );\r
- }\r
- \r
- RotationAnimation3D\r
- (\r
- const mof::Animation<mof::Vector3D>::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
- \r
- virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{\r
- return mof::Matrix3D::createRotation(m_body->getValue(frame));\r
- }\r
- \r
- \r
- /*mof::FrameNumber getFinalKeyFrameNumber(){\r
- return m_pBody->getFinalKeyFrameNumber();\r
- }*/\r
- \r
- \r
- };\r
- \r
- \r
- \r
- \r
- } //namespace mof\r
- \r
+ #pragma once
+ #include "mof/KeyFrameAnimation.hpp"
+ #include <map>
+ #include <stdexcept>
+ #include <boost/function/function2.hpp>
+ #include "mof/KeyFrameAnimation.hpp"
+ #include "mof/Matrix3D.hpp"
+
+
+
+ namespace mof{
+
+
+ class RotationAnimation3D : public mof::Animation<mof::Matrix3D>{
+ mof::Animation<mof::Vector3D>::Handler m_body;
+ public:
+
+ RotationAnimation3D(
+ const std::pair<mof::FrameNumber , mof::Vector3D>& front ,
+ const std::pair<mof::FrameNumber , mof::Vector3D>& back
+ )
+ {
+ m_body = mof::Animation<mof::Vector3D>::Handler
+ (
+ new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D> )
+ );
+ }
+
+ RotationAnimation3D
+ (
+ const mof::Animation<mof::Vector3D>::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{
+ return mof::Matrix3D::createRotation(m_body->getValue(frame));
+ }
+
+
+ /*mof::FrameNumber getFinalKeyFrameNumber(){
+ return m_pBody->getFinalKeyFrameNumber();
+ }*/
+
+
+ };
+
+
+
+
+ } //namespace mof
+
-#pragma once\r
-#include "mof/stream/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Scaling2D : public Manipulator< Matrix2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr< Scaling2D > Handler;\r
- \r
- Scaling2D\r
- (\r
- const std::pair< FrameNumber , mof::Vector2D >& front , \r
- const std::pair< FrameNumber , mof::Vector2D >& back \r
- )\r
- {\r
- m_body = makeKeyFrameAnimationHandler< Vector2D >\r
- (\r
- front , back , &linerInterpolate< Vector2D >\r
- );\r
- }\r
- \r
- Scaling2D\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual Matrix2D value( FrameNumber frame ) const\r
- {\r
- return Matrix2D::createScaling( m_body->value(frame) );\r
- }\r
-\r
- Manipulator<mof::Vector2D>::Handler get( ) const\r
- {\r
- return m_body;\r
- }\r
- \r
- void set( const Manipulator< Vector2D >::Handler& handler ) \r
- {\r
- m_body = handler;\r
- }\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
-\r
-\r
- };\r
-//{{{ ヘルパ関数\r
- inline Scaling2D::Handler makeScaling2DHandler\r
- (\r
- const std::pair< FrameNumber , Vector2D >& front ,\r
- const std::pair< FrameNumber , Vector2D >& back \r
- )\r
- {\r
- return Scaling2D::Handler\r
- (\r
- new Scaling2D( front , back )\r
- );\r
- }\r
-\r
- inline Scaling2D::Handler makeScaling2DHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- {\r
- return Scaling2D::Handler\r
- (\r
- new Scaling2D( body )\r
- );\r
- }\r
-//}}}\r
-} // namespace mof\r
-\r
+#pragma once
+#include "mof/stream/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+
+
+namespace mof{
+
+ class Scaling2D : public Manipulator< Matrix2D >
+ {
+ public:
+ typedef boost::shared_ptr< Scaling2D > Handler;
+
+ Scaling2D
+ (
+ const std::pair< FrameNumber , mof::Vector2D >& front ,
+ const std::pair< FrameNumber , mof::Vector2D >& back
+ )
+ {
+ m_body = makeKeyFrameAnimationHandler< Vector2D >
+ (
+ front , back , &linerInterpolate< Vector2D >
+ );
+ }
+
+ Scaling2D
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual Matrix2D value( FrameNumber frame ) const
+ {
+ return Matrix2D::createScaling( m_body->value(frame) );
+ }
+
+ Manipulator<mof::Vector2D>::Handler get( ) const
+ {
+ return m_body;
+ }
+
+ void set( const Manipulator< Vector2D >::Handler& handler )
+ {
+ m_body = handler;
+ }
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+
+
+ };
+//{{{ ヘルパ関数
+ inline Scaling2D::Handler makeScaling2DHandler
+ (
+ const std::pair< FrameNumber , Vector2D >& front ,
+ const std::pair< FrameNumber , Vector2D >& back
+ )
+ {
+ return Scaling2D::Handler
+ (
+ new Scaling2D( front , back )
+ );
+ }
+
+ inline Scaling2D::Handler makeScaling2DHandler
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ {
+ return Scaling2D::Handler
+ (
+ new Scaling2D( body )
+ );
+ }
+//}}}
+} // namespace mof
+
-#pragma once\r
-#include "mof/stream/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Scaling2D : public Manipulator< Matrix2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr< Scaling2D > Handler;\r
- \r
- Scaling2D\r
- (\r
- const std::pair< FrameNumber , mof::Vector2D >& front , \r
- const std::pair< FrameNumber , mof::Vector2D >& back \r
- )\r
- {\r
- m_body = makeKeyFrameAnimationHandler< Vector2D >\r
- (\r
- front , back , &linerInterpolate< Vector2D >\r
- );\r
- }\r
- \r
- Scaling2D\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual Matrix2D value( FrameNumber frame ) const\r
- {\r
- return Matrix2D::createScaling( m_body->value(frame) );\r
- }\r
-\r
- Manipulator<mof::Vector2D>::Handler get( ) const\r
- {\r
- return m_body;\r
- }\r
- \r
- void set( const Manipulator< Vector2D >::Handler& handler ) \r
- {\r
- m_body = handler;\r
- }\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
-\r
-\r
- };\r
-//{{{ ヘルパ関数\r
- Scaling2D::Handler makeScaling2DHandler\r
- (\r
- const std::pair< FrameNumber , Vector2D >& front ,\r
- const std::pair< FrameNumber , Vector2D >& back \r
- )\r
- {\r
- return Scaling2D::Handler\r
- (\r
- new Scaling2D( front , back )\r
- );\r
- }\r
-\r
- Scaling2D::Handler makeScaling2DHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- {\r
- return Scaling2D::Handler\r
- (\r
- new Scaling2D( body )\r
- );\r
- }\r
-//}}}\r
-} // namespace mof\r
-\r
+#pragma once
+#include "mof/stream/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+
+
+namespace mof{
+
+ class Scaling2D : public Manipulator< Matrix2D >
+ {
+ public:
+ typedef boost::shared_ptr< Scaling2D > Handler;
+
+ Scaling2D
+ (
+ const std::pair< FrameNumber , mof::Vector2D >& front ,
+ const std::pair< FrameNumber , mof::Vector2D >& back
+ )
+ {
+ m_body = makeKeyFrameAnimationHandler< Vector2D >
+ (
+ front , back , &linerInterpolate< Vector2D >
+ );
+ }
+
+ Scaling2D
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual Matrix2D value( FrameNumber frame ) const
+ {
+ return Matrix2D::createScaling( m_body->value(frame) );
+ }
+
+ Manipulator<mof::Vector2D>::Handler get( ) const
+ {
+ return m_body;
+ }
+
+ void set( const Manipulator< Vector2D >::Handler& handler )
+ {
+ m_body = handler;
+ }
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+
+
+ };
+//{{{ ヘルパ関数
+ Scaling2D::Handler makeScaling2DHandler
+ (
+ const std::pair< FrameNumber , Vector2D >& front ,
+ const std::pair< FrameNumber , Vector2D >& back
+ )
+ {
+ return Scaling2D::Handler
+ (
+ new Scaling2D( front , back )
+ );
+ }
+
+ Scaling2D::Handler makeScaling2DHandler
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ {
+ return Scaling2D::Handler
+ (
+ new Scaling2D( body )
+ );
+ }
+//}}}
+} // namespace mof
+
-#pragma once\r
-#include <boost/function/function2.hpp>\r
-#include "mof/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
-\r
-class ScalingAnimation2D : public mof::Animation<mof::Matrix2D>{\r
- mof::Animation<mof::Vector2D>::Handler m_body;\r
-public:\r
- typedef boost::shared_ptr< mof::ScalingAnimation2D > Handler;\r
-\r
- ScalingAnimation2D(\r
- const std::pair<mof::FrameNumber , mof::Vector2D>& front , \r
- const std::pair<mof::FrameNumber , mof::Vector2D>& back \r
- )\r
- {\r
- m_body = mof::Animation<mof::Vector2D>::Handler\r
- (\r
- new mof::KeyFrameAnimation<mof::Vector2D>(front , back , &mof::linerInterpolate<mof::Vector2D> )\r
- );\r
-\r
- }\r
- \r
- ScalingAnimation2D\r
- (\r
- const mof::Animation<mof::Vector2D>::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
-\r
- virtual mof::Matrix2D getValue( mof::FrameNumber frame) const{\r
- return mof::Matrix2D::createScaling(m_body->getValue(frame));\r
- }\r
-\r
- mof::Animation<mof::Vector2D>::Handler get( ) const\r
- {\r
- return m_body;\r
- }\r
- \r
- void set( const mof::Animation<mof::Vector2D>::Handler& handler ) \r
- {\r
- m_body = handler;\r
- }\r
-\r
-\r
-};\r
-\r
-\r
-}\r
-\r
+#pragma once
+#include <boost/function/function2.hpp>
+#include "mof/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+
+
+namespace mof{
+
+
+class ScalingAnimation2D : public mof::Animation<mof::Matrix2D>{
+ mof::Animation<mof::Vector2D>::Handler m_body;
+public:
+ typedef boost::shared_ptr< mof::ScalingAnimation2D > Handler;
+
+ ScalingAnimation2D(
+ const std::pair<mof::FrameNumber , mof::Vector2D>& front ,
+ const std::pair<mof::FrameNumber , mof::Vector2D>& back
+ )
+ {
+ m_body = mof::Animation<mof::Vector2D>::Handler
+ (
+ new mof::KeyFrameAnimation<mof::Vector2D>(front , back , &mof::linerInterpolate<mof::Vector2D> )
+ );
+
+ }
+
+ ScalingAnimation2D
+ (
+ const mof::Animation<mof::Vector2D>::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+
+ virtual mof::Matrix2D getValue( mof::FrameNumber frame) const{
+ return mof::Matrix2D::createScaling(m_body->getValue(frame));
+ }
+
+ mof::Animation<mof::Vector2D>::Handler get( ) const
+ {
+ return m_body;
+ }
+
+ void set( const mof::Animation<mof::Vector2D>::Handler& handler )
+ {
+ m_body = handler;
+ }
+
+
+};
+
+
+}
+
- #pragma once\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include <map>\r
- #include <stdexcept>\r
- #include <boost/function/function2.hpp>\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include "mof/Matrix3D.hpp"\r
- \r
- \r
- namespace mof{\r
- \r
- \r
- class ScalingAnimation3D : public mof::Animation<mof::Matrix3D>{\r
- boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector3D> > m_pBody;\r
- public:\r
- \r
- ScalingAnimation3D(\r
- const std::pair<mof::FrameNumber , mof::Vector3D>& front , \r
- const std::pair<mof::FrameNumber , mof::Vector3D>& back \r
- )\r
- {\r
- m_pBody = boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector3D> >(\r
- new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D>)\r
- );\r
- }\r
- \r
- virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{\r
- return mof::Matrix3D::createScaling(m_pBody->getValue(frame));\r
- }\r
- \r
- mof::FrameNumber getFinalKeyFrameNumber(){\r
- return m_pBody->getFinalKeyFrameNumber();\r
- }\r
- \r
- \r
- };\r
- \r
- } //namespace mof\r
- \r
+ #pragma once
+ #include "mof/KeyFrameAnimation.hpp"
+ #include <map>
+ #include <stdexcept>
+ #include <boost/function/function2.hpp>
+ #include "mof/KeyFrameAnimation.hpp"
+ #include "mof/Matrix3D.hpp"
+
+
+ namespace mof{
+
+
+ class ScalingAnimation3D : public mof::Animation<mof::Matrix3D>{
+ boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector3D> > m_pBody;
+ public:
+
+ ScalingAnimation3D(
+ const std::pair<mof::FrameNumber , mof::Vector3D>& front ,
+ const std::pair<mof::FrameNumber , mof::Vector3D>& back
+ )
+ {
+ m_pBody = boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector3D> >(
+ new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D>)
+ );
+ }
+
+ virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{
+ return mof::Matrix3D::createScaling(m_pBody->getValue(frame));
+ }
+
+ mof::FrameNumber getFinalKeyFrameNumber(){
+ return m_pBody->getFinalKeyFrameNumber();
+ }
+
+
+ };
+
+ } //namespace mof
+
- #pragma once\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include <map>\r
- #include <stdexcept>\r
- #include <boost/function/function2.hpp>\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include "mof/Matrix3D.hpp"\r
- \r
- \r
- namespace mof{\r
- \r
- \r
- class ScalingAnimation3D : public mof::Animation<mof::Matrix3D>{\r
- boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector3D> > m_pBody;\r
- public:\r
- \r
- ScalingAnimation3D(\r
- const std::pair<mof::FrameNumber , mof::Vector3D>& front , \r
- const std::pair<mof::FrameNumber , mof::Vector3D>& back \r
- )\r
- {\r
- m_pBody = boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector3D> >(\r
- new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D>)\r
- );\r
- }\r
- \r
- virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{\r
- return mof::Matrix3D::createScaling(m_pBody->getValue(frame));\r
- }\r
- \r
- mof::FrameNumber getFinalKeyFrameNumber(){\r
- return m_pBody->getFinalKeyFrameNumber();\r
- }\r
- \r
- \r
- };\r
- \r
- } //namespace mof\r
- \r
+ #pragma once
+ #include "mof/KeyFrameAnimation.hpp"
+ #include <map>
+ #include <stdexcept>
+ #include <boost/function/function2.hpp>
+ #include "mof/KeyFrameAnimation.hpp"
+ #include "mof/Matrix3D.hpp"
+
+
+ namespace mof{
+
+
+ class ScalingAnimation3D : public mof::Animation<mof::Matrix3D>{
+ boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector3D> > m_pBody;
+ public:
+
+ ScalingAnimation3D(
+ const std::pair<mof::FrameNumber , mof::Vector3D>& front ,
+ const std::pair<mof::FrameNumber , mof::Vector3D>& back
+ )
+ {
+ m_pBody = boost::shared_ptr<mof::KeyFrameAnimation<mof::Vector3D> >(
+ new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D>)
+ );
+ }
+
+ virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{
+ return mof::Matrix3D::createScaling(m_pBody->getValue(frame));
+ }
+
+ mof::FrameNumber getFinalKeyFrameNumber(){
+ return m_pBody->getFinalKeyFrameNumber();
+ }
+
+
+ };
+
+ } //namespace mof
+
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/stream/Cascade.hpp"\r
-#include "mof/stream/Constant.hpp"\r
-\r
-namespace mof\r
-{\r
- \r
- template< typename T , class Cascador = DEFAULT_CASCADOR< T > >\r
- struct TypeStream\r
- {\r
- public:\r
- TypeStream( )\r
- : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T >() )\r
- {\r
- }\r
- \r
- TypeStream( const typename Cascade< T , Cascador >::Handler& handler )\r
- : m_frameNumber( 0 ) , m_cascade( handler )\r
- {\r
- }\r
-\r
-\r
- ~TypeStream( )\r
- {\r
- }\r
-\r
- typename Cascade< T , Cascador >::Handler& \r
- get()\r
- {\r
- return m_cascador;\r
- }\r
- \r
- typename const Cascade< T , Cascador >::Handler& \r
- get() const\r
- {\r
- return m_cascador;\r
- }\r
-\r
-\r
- TypeStream< T , Cascador >&\r
- operator << \r
- (\r
- const typename Manipulator< T >::Handler& b \r
- )\r
- {\r
- m_cascade->add( b );\r
- return *this;\r
- }\r
-\r
- TypeStream< T , Cascador >&\r
- operator << \r
- (\r
- const T& b \r
- )\r
- {\r
- m_cascade->add( mof::makeConstantHandler( b ) );\r
- return *this;\r
- }\r
-\r
- T value( ) const\r
- {\r
- return m_cascade->value( m_frameNumber );\r
- }\r
- \r
- void update( )\r
- {\r
- m_frameNumber++;\r
- }\r
-\r
- private:\r
- FrameNumber m_frameNumber;\r
- typename Cascade< T , Cascador >::Handler m_cascade;\r
- };\r
-\r
-} // namespace mof\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+#include "mof/stream/Cascade.hpp"
+#include "mof/stream/Constant.hpp"
+
+namespace mof
+{
+
+ template< typename T , class Cascador = DEFAULT_CASCADOR< T > >
+ struct TypeStream
+ {
+ public:
+ TypeStream( )
+ : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T >() )
+ {
+ }
+
+ TypeStream( const typename Cascade< T , Cascador >::Handler& handler )
+ : m_frameNumber( 0 ) , m_cascade( handler )
+ {
+ }
+
+
+ ~TypeStream( )
+ {
+ }
+
+ typename Cascade< T , Cascador >::Handler&
+ get()
+ {
+ return m_cascador;
+ }
+
+ typename const Cascade< T , Cascador >::Handler&
+ get() const
+ {
+ return m_cascador;
+ }
+
+
+ TypeStream< T , Cascador >&
+ operator <<
+ (
+ const typename Manipulator< T >::Handler& b
+ )
+ {
+ m_cascade->add( b );
+ return *this;
+ }
+
+ TypeStream< T , Cascador >&
+ operator <<
+ (
+ const T& b
+ )
+ {
+ m_cascade->add( mof::makeConstantHandler( b ) );
+ return *this;
+ }
+
+ T value( ) const
+ {
+ return m_cascade->value( m_frameNumber );
+ }
+
+ void update( )
+ {
+ m_frameNumber++;
+ }
+
+ private:
+ FrameNumber m_frameNumber;
+ typename Cascade< T , Cascador >::Handler m_cascade;
+ };
+
+} // namespace mof
-#pragma once\r
-#include "mof/stream/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Translation2D : public Manipulator< Matrix2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr< Translation2D > Handler;\r
- \r
- Translation2D\r
- (\r
- const std::pair< FrameNumber , mof::Vector2D >& front , \r
- const std::pair< FrameNumber , mof::Vector2D >& back \r
- )\r
- {\r
- m_body = makeKeyFrameAnimationHandler< Vector2D >\r
- (\r
- front , back , &linerInterpolate< Vector2D >\r
- );\r
- }\r
- \r
- Translation2D\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual Matrix2D value( FrameNumber frame ) const\r
- {\r
- return Matrix2D::createTranslation( m_body->value(frame) );\r
- }\r
-\r
- Manipulator<mof::Vector2D>::Handler get( ) const\r
- {\r
- return m_body;\r
- }\r
- \r
- void set( const Manipulator< Vector2D >::Handler& handler ) \r
- {\r
- m_body = handler;\r
- }\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
-\r
-\r
- };\r
-\r
-//{{{ ヘルパ関数\r
- inline Translation2D::Handler makeTranslation2DHandler\r
- (\r
- const std::pair< FrameNumber , Vector2D >& front ,\r
- const std::pair< FrameNumber , Vector2D >& back \r
- )\r
- {\r
- return Translation2D::Handler\r
- (\r
- new Translation2D( front , back )\r
- );\r
- }\r
-\r
- inline Translation2D::Handler makeTranslation2DHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- {\r
- return Translation2D::Handler\r
- (\r
- new Translation2D( body )\r
- );\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
-\r
+#pragma once
+#include "mof/stream/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+
+
+namespace mof{
+
+ class Translation2D : public Manipulator< Matrix2D >
+ {
+ public:
+ typedef boost::shared_ptr< Translation2D > Handler;
+
+ Translation2D
+ (
+ const std::pair< FrameNumber , mof::Vector2D >& front ,
+ const std::pair< FrameNumber , mof::Vector2D >& back
+ )
+ {
+ m_body = makeKeyFrameAnimationHandler< Vector2D >
+ (
+ front , back , &linerInterpolate< Vector2D >
+ );
+ }
+
+ Translation2D
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual Matrix2D value( FrameNumber frame ) const
+ {
+ return Matrix2D::createTranslation( m_body->value(frame) );
+ }
+
+ Manipulator<mof::Vector2D>::Handler get( ) const
+ {
+ return m_body;
+ }
+
+ void set( const Manipulator< Vector2D >::Handler& handler )
+ {
+ m_body = handler;
+ }
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+
+
+ };
+
+//{{{ ヘルパ関数
+ inline Translation2D::Handler makeTranslation2DHandler
+ (
+ const std::pair< FrameNumber , Vector2D >& front ,
+ const std::pair< FrameNumber , Vector2D >& back
+ )
+ {
+ return Translation2D::Handler
+ (
+ new Translation2D( front , back )
+ );
+ }
+
+ inline Translation2D::Handler makeTranslation2DHandler
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ {
+ return Translation2D::Handler
+ (
+ new Translation2D( body )
+ );
+ }
+//}}}
+
+} // namespace mof
+
-#pragma once\r
-#include "mof/stream/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Translation2D : public Manipulator< Matrix2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr< Translation2D > Handler;\r
- \r
- Translation2D\r
- (\r
- const std::pair< FrameNumber , mof::Vector2D >& front , \r
- const std::pair< FrameNumber , mof::Vector2D >& back \r
- )\r
- {\r
- m_body = makeKeyFrameAnimationHandler< Vector2D >\r
- (\r
- front , back , &linerInterpolate< Vector2D >\r
- );\r
- }\r
- \r
- Translation2D\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual Matrix2D value( FrameNumber frame ) const\r
- {\r
- return Matrix2D::createTranslation( m_body->value(frame) );\r
- }\r
-\r
- Manipulator<mof::Vector2D>::Handler get( ) const\r
- {\r
- return m_body;\r
- }\r
- \r
- void set( const Manipulator< Vector2D >::Handler& handler ) \r
- {\r
- m_body = handler;\r
- }\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
-\r
-\r
- };\r
-\r
-//{{{ ヘルパ関数\r
- Translation2D::Handler makeTranslation2DHandler\r
- (\r
- const std::pair< FrameNumber , Vector2D >& front ,\r
- const std::pair< FrameNumber , Vector2D >& back \r
- )\r
- {\r
- return Translation2D::Handler\r
- (\r
- new Translation2D( front , back )\r
- );\r
- }\r
-\r
- Translation2D::Handler makeTranslation2DHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- {\r
- return Translation2D::Handler\r
- (\r
- new Translation2D( body )\r
- );\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
-\r
+#pragma once
+#include "mof/stream/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+
+
+namespace mof{
+
+ class Translation2D : public Manipulator< Matrix2D >
+ {
+ public:
+ typedef boost::shared_ptr< Translation2D > Handler;
+
+ Translation2D
+ (
+ const std::pair< FrameNumber , mof::Vector2D >& front ,
+ const std::pair< FrameNumber , mof::Vector2D >& back
+ )
+ {
+ m_body = makeKeyFrameAnimationHandler< Vector2D >
+ (
+ front , back , &linerInterpolate< Vector2D >
+ );
+ }
+
+ Translation2D
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual Matrix2D value( FrameNumber frame ) const
+ {
+ return Matrix2D::createTranslation( m_body->value(frame) );
+ }
+
+ Manipulator<mof::Vector2D>::Handler get( ) const
+ {
+ return m_body;
+ }
+
+ void set( const Manipulator< Vector2D >::Handler& handler )
+ {
+ m_body = handler;
+ }
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+
+
+ };
+
+//{{{ ヘルパ関数
+ Translation2D::Handler makeTranslation2DHandler
+ (
+ const std::pair< FrameNumber , Vector2D >& front ,
+ const std::pair< FrameNumber , Vector2D >& back
+ )
+ {
+ return Translation2D::Handler
+ (
+ new Translation2D( front , back )
+ );
+ }
+
+ Translation2D::Handler makeTranslation2DHandler
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ {
+ return Translation2D::Handler
+ (
+ new Translation2D( body )
+ );
+ }
+//}}}
+
+} // namespace mof
+
-#pragma once\r
-#include "mof/stream/KeyFrameAnimation.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-\r
-\r
-namespace mof{\r
-\r
- class Translation2D : public Manipulator< Matrix2D >\r
- {\r
- public:\r
- typedef boost::shared_ptr< Translation2D > Handler;\r
- \r
- Translation2D\r
- (\r
- const std::pair< FrameNumber , mof::Vector2D >& front , \r
- const std::pair< FrameNumber , mof::Vector2D >& back \r
- )\r
- {\r
- m_body = makeKeyFrameAnimationHandler\r
- (\r
- front , back , &linerInterpolate< Vector2D >\r
- );\r
- }\r
- \r
- Translation2D\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual Matrix2D value( FrameNumber frame ) const\r
- {\r
- return Matrix2D::createTranslation( m_body->value(frame) );\r
- }\r
-\r
- Manipulator<mof::Vector2D>::Handler get( ) const\r
- {\r
- return m_body;\r
- }\r
- \r
- void set( const Manipulator< Vector2D >::Handler& handler ) \r
- {\r
- m_body = handler;\r
- }\r
-\r
- private:\r
- Manipulator< Vector2D >::Handler m_body;\r
-\r
-\r
- };\r
-\r
-//{{{ ヘルパ関数\r
- template< typename T >\r
- typename Translation2D< T >::Handler \r
- makeTranslation2DHandler\r
- (\r
- const std::pair< FrameNumber , T >& front ,\r
- const std::pair< FrameNumber , T >& back ,\r
- )\r
- {\r
- return Translation2D< T >::Handler\r
- (\r
- new Translation2D< T >( front , back )\r
- );\r
- }\r
-\r
- template< typename T >\r
- typename Translation2D< T >::Handler \r
- makeTranslation2DHandler\r
- (\r
- const Manipulator< Vector2D >::Handler& body\r
- )\r
- {\r
- return Translation2D< T >::Handler\r
- (\r
- new Translation2D< T >( body )\r
- );\r
- }\r
-\r
- template< typename T >\r
- typename KeyFrameAnimation< T >::Handler \r
- makeKeyFrameAnimationHandler\r
- (\r
- )\r
- {\r
- return KeyFrameAnimation< T >::Handler\r
- (\r
- new KeyFrameAnimation< T >( front , back ) \r
- );\r
- }\r
-//}}}\r
-\r
-}\r
-\r
+#pragma once
+#include "mof/stream/KeyFrameAnimation.hpp"
+#include "mof/Matrix2D.hpp"
+
+
+namespace mof{
+
+ class Translation2D : public Manipulator< Matrix2D >
+ {
+ public:
+ typedef boost::shared_ptr< Translation2D > Handler;
+
+ Translation2D
+ (
+ const std::pair< FrameNumber , mof::Vector2D >& front ,
+ const std::pair< FrameNumber , mof::Vector2D >& back
+ )
+ {
+ m_body = makeKeyFrameAnimationHandler
+ (
+ front , back , &linerInterpolate< Vector2D >
+ );
+ }
+
+ Translation2D
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual Matrix2D value( FrameNumber frame ) const
+ {
+ return Matrix2D::createTranslation( m_body->value(frame) );
+ }
+
+ Manipulator<mof::Vector2D>::Handler get( ) const
+ {
+ return m_body;
+ }
+
+ void set( const Manipulator< Vector2D >::Handler& handler )
+ {
+ m_body = handler;
+ }
+
+ private:
+ Manipulator< Vector2D >::Handler m_body;
+
+
+ };
+
+//{{{ ヘルパ関数
+ template< typename T >
+ typename Translation2D< T >::Handler
+ makeTranslation2DHandler
+ (
+ const std::pair< FrameNumber , T >& front ,
+ const std::pair< FrameNumber , T >& back ,
+ )
+ {
+ return Translation2D< T >::Handler
+ (
+ new Translation2D< T >( front , back )
+ );
+ }
+
+ template< typename T >
+ typename Translation2D< T >::Handler
+ makeTranslation2DHandler
+ (
+ const Manipulator< Vector2D >::Handler& body
+ )
+ {
+ return Translation2D< T >::Handler
+ (
+ new Translation2D< T >( body )
+ );
+ }
+
+ template< typename T >
+ typename KeyFrameAnimation< T >::Handler
+ makeKeyFrameAnimationHandler
+ (
+ )
+ {
+ return KeyFrameAnimation< T >::Handler
+ (
+ new KeyFrameAnimation< T >( front , back )
+ );
+ }
+//}}}
+
+}
+
- #pragma once\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include <map>\r
- #include <stdexcept>\r
- #include <boost/function/function2.hpp>\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include "mof/Matrix3D.hpp"\r
- \r
- \r
- \r
- namespace mof{\r
- \r
- \r
- class TranslationAnimation3D : public mof::Animation<mof::Matrix3D>{\r
- mof::Animation<mof::Vector3D>::Handler m_body;\r
- public:\r
- \r
- TranslationAnimation3D\r
- (\r
- const std::pair<mof::FrameNumber , mof::Vector3D>& front , \r
- const std::pair<mof::FrameNumber , mof::Vector3D>& back \r
- )\r
- {\r
- m_body = mof::Animation<mof::Vector3D>::Handler\r
- (\r
- new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D>)\r
- );\r
- }\r
- \r
- TranslationAnimation3D\r
- (\r
- const mof::Animation<mof::Vector3D>::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{\r
- return mof::Matrix3D::createTranslation(m_body->getValue(frame));\r
- }\r
- \r
- /*mof::FrameNumber getFinalKeyFrameNumber(){\r
- return m_pBody->getFinalKeyFrameNumber();\r
- }*/\r
- \r
- \r
- };\r
- \r
- \r
- \r
- \r
- } //namespace mof\r
- \r
+ #pragma once
+ #include "mof/KeyFrameAnimation.hpp"
+ #include <map>
+ #include <stdexcept>
+ #include <boost/function/function2.hpp>
+ #include "mof/KeyFrameAnimation.hpp"
+ #include "mof/Matrix3D.hpp"
+
+
+
+ namespace mof{
+
+
+ class TranslationAnimation3D : public mof::Animation<mof::Matrix3D>{
+ mof::Animation<mof::Vector3D>::Handler m_body;
+ public:
+
+ TranslationAnimation3D
+ (
+ const std::pair<mof::FrameNumber , mof::Vector3D>& front ,
+ const std::pair<mof::FrameNumber , mof::Vector3D>& back
+ )
+ {
+ m_body = mof::Animation<mof::Vector3D>::Handler
+ (
+ new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D>)
+ );
+ }
+
+ TranslationAnimation3D
+ (
+ const mof::Animation<mof::Vector3D>::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{
+ return mof::Matrix3D::createTranslation(m_body->getValue(frame));
+ }
+
+ /*mof::FrameNumber getFinalKeyFrameNumber(){
+ return m_pBody->getFinalKeyFrameNumber();
+ }*/
+
+
+ };
+
+
+
+
+ } //namespace mof
+
- #pragma once\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include <map>\r
- #include <stdexcept>\r
- #include <boost/function/function2.hpp>\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include "mof/Matrix3D.hpp"\r
- \r
- \r
- \r
- namespace mof{\r
- \r
- \r
- class TranslationAnimation3D : public mof::Animation<mof::Matrix3D>{\r
- mof::Animation<mof::Vector3D>::Handler m_body;\r
- public:\r
- \r
- TranslationAnimation3D\r
- (\r
- const std::pair<mof::FrameNumber , mof::Vector3D>& front , \r
- const std::pair<mof::FrameNumber , mof::Vector3D>& back \r
- )\r
- {\r
- m_body = mof::Animation<mof::Vector3D>::Handler\r
- (\r
- new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D>)\r
- );\r
- }\r
- \r
- TranslationAnimation3D\r
- (\r
- const mof::Animation<mof::Vector3D>::Handler& body\r
- )\r
- : m_body( body )\r
- {\r
- }\r
-\r
- virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{\r
- return mof::Matrix3D::createTranslation(m_body->getValue(frame));\r
- }\r
- \r
- /*mof::FrameNumber getFinalKeyFrameNumber(){\r
- return m_pBody->getFinalKeyFrameNumber();\r
- }*/\r
- \r
- \r
- };\r
- \r
- \r
- \r
- \r
- } //namespace mof\r
- \r
+ #pragma once
+ #include "mof/KeyFrameAnimation.hpp"
+ #include <map>
+ #include <stdexcept>
+ #include <boost/function/function2.hpp>
+ #include "mof/KeyFrameAnimation.hpp"
+ #include "mof/Matrix3D.hpp"
+
+
+
+ namespace mof{
+
+
+ class TranslationAnimation3D : public mof::Animation<mof::Matrix3D>{
+ mof::Animation<mof::Vector3D>::Handler m_body;
+ public:
+
+ TranslationAnimation3D
+ (
+ const std::pair<mof::FrameNumber , mof::Vector3D>& front ,
+ const std::pair<mof::FrameNumber , mof::Vector3D>& back
+ )
+ {
+ m_body = mof::Animation<mof::Vector3D>::Handler
+ (
+ new mof::KeyFrameAnimation<mof::Vector3D>(front , back , &mof::linerInterpolate<mof::Vector3D>)
+ );
+ }
+
+ TranslationAnimation3D
+ (
+ const mof::Animation<mof::Vector3D>::Handler& body
+ )
+ : m_body( body )
+ {
+ }
+
+ virtual mof::Matrix3D getValue( mof::FrameNumber frame) const{
+ return mof::Matrix3D::createTranslation(m_body->getValue(frame));
+ }
+
+ /*mof::FrameNumber getFinalKeyFrameNumber(){
+ return m_pBody->getFinalKeyFrameNumber();
+ }*/
+
+
+ };
+
+
+
+
+ } //namespace mof
+
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/stream/Cascade.hpp"\r
-#include "mof/stream/Constant.hpp"\r
-#include "mof/stream/Offset.hpp"\r
-\r
-namespace mof\r
-{\r
- \r
- template< typename T , class Cascador = DEFAULT_CASCADOR< T > >\r
- class TypeStream\r
- {\r
- public:\r
- TypeStream( )\r
- : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )\r
- {}\r
- \r
-\r
- TypeStream( const typename Manipulator< T >::Handler& handler )\r
- : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )\r
- {\r
- m_cascade << handler;\r
- }\r
- \r
- TypeStream( const T& value )\r
- : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )\r
- {\r
- m_cascade << value;\r
- }\r
-\r
- ~TypeStream( )\r
- {}\r
- \r
- TypeStream< T , Cascador >&\r
- operator << \r
- (\r
- const typename Manipulator< T >::Handler& b \r
- )\r
- {\r
- m_cascade->add\r
- (\r
- makeOffsetHandler< T >( b , -1 * (int)m_frameNumber)\r
- );\r
- return *this;\r
- }\r
- \r
- TypeStream< T , Cascador >&\r
- operator << \r
- (\r
- const TypeStream< T , Cascador >& obj \r
- )\r
- {\r
- //m_cascade->add( obj.m_cascade );\r
- m_cascade->add( makeCacheHandler<T>(makeOffsetHandler< T >( obj.m_cascade , obj.m_frameNumber - m_frameNumber) ) );\r
- return *this;\r
- }\r
-\r
-\r
- TypeStream< T , Cascador >&\r
- operator << \r
- (\r
- const T& b \r
- )\r
- {\r
- m_cascade->add( mof::makeConstantHandler( b ) );\r
- return *this;\r
- }\r
-\r
- T value( ) const\r
- {\r
- return m_cascade->value( m_frameNumber );\r
- }\r
-\r
- typename Manipulator<T>::Handler toManipulator()\r
- {\r
- return m_cascade;\r
- }\r
- \r
- void update( )\r
- {\r
- m_frameNumber++;\r
- }\r
-\r
- FrameNumber getCurrentFrameNumber() const\r
- {\r
- return m_frameNumber;\r
- }\r
-\r
- private:\r
- FrameNumber m_frameNumber;\r
- typename Cascade< T , Cascador >::Handler m_cascade;\r
- };\r
-\r
-} // namespace mof\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+#include "mof/stream/Cascade.hpp"
+#include "mof/stream/Constant.hpp"
+#include "mof/stream/Offset.hpp"
+
+namespace mof
+{
+
+ template< typename T , class Cascador = DEFAULT_CASCADOR< T > >
+ class TypeStream
+ {
+ public:
+ TypeStream( )
+ : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )
+ {}
+
+
+ TypeStream( const typename Manipulator< T >::Handler& handler )
+ : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )
+ {
+ m_cascade << handler;
+ }
+
+ TypeStream( const T& value )
+ : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )
+ {
+ m_cascade << value;
+ }
+
+ ~TypeStream( )
+ {}
+
+ TypeStream< T , Cascador >&
+ operator <<
+ (
+ const typename Manipulator< T >::Handler& b
+ )
+ {
+ m_cascade->add
+ (
+ makeOffsetHandler< T >( b , -1 * (int)m_frameNumber)
+ );
+ return *this;
+ }
+
+ TypeStream< T , Cascador >&
+ operator <<
+ (
+ const TypeStream< T , Cascador >& obj
+ )
+ {
+ //m_cascade->add( obj.m_cascade );
+ m_cascade->add( makeCacheHandler<T>(makeOffsetHandler< T >( obj.m_cascade , obj.m_frameNumber - m_frameNumber) ) );
+ return *this;
+ }
+
+
+ TypeStream< T , Cascador >&
+ operator <<
+ (
+ const T& b
+ )
+ {
+ m_cascade->add( mof::makeConstantHandler( b ) );
+ return *this;
+ }
+
+ T value( ) const
+ {
+ return m_cascade->value( m_frameNumber );
+ }
+
+ typename Manipulator<T>::Handler toManipulator()
+ {
+ return m_cascade;
+ }
+
+ void update( )
+ {
+ m_frameNumber++;
+ }
+
+ FrameNumber getCurrentFrameNumber() const
+ {
+ return m_frameNumber;
+ }
+
+ private:
+ FrameNumber m_frameNumber;
+ typename Cascade< T , Cascador >::Handler m_cascade;
+ };
+
+} // namespace mof
-#pragma once\r
-#include <boost/shared_ptr.hpp>\r
-#include "mof/stream/Cascade.hpp"\r
-#include "mof/stream/Constant.hpp"\r
-#include "mof/stream/Offset.hpp"\r
-\r
-namespace mof\r
-{\r
- \r
- template< typename T , class Cascador = DEFAULT_CASCADOR< T > >\r
- class TypeStream\r
- {\r
- public:\r
- TypeStream( )\r
- : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )\r
- {}\r
- \r
-\r
- TypeStream( const typename Manipulator< T >::Handler& handler )\r
- : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )\r
- {\r
- m_cascade << handler;\r
- }\r
- \r
- TypeStream( const T& value )\r
- : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )\r
- {\r
- m_cascade << value;\r
- }\r
-\r
- ~TypeStream( )\r
- {}\r
- \r
- TypeStream< T , Cascador >&\r
- operator << \r
- (\r
- const typename Manipulator< T >::Handler& b \r
- )\r
- {\r
- m_cascade->add\r
- (\r
- makeOffsetHandler< T >( b , -1 * (int)m_frameNumber)\r
- );\r
- return *this;\r
- }\r
- \r
- TypeStream< T , Cascador >&\r
- operator << \r
- (\r
- const TypeStream< T , Cascador >& obj \r
- )\r
- {\r
- //m_cascade->add( obj.m_cascade );\r
- m_cascade->add( makeCacheHandler<T>(makeOffsetHandler< T >( obj.m_cascade , obj.m_frameNumber - m_frameNumber) ) );\r
- return *this;\r
- }\r
-\r
-\r
- TypeStream< T , Cascador >&\r
- operator << \r
- (\r
- const T& b \r
- )\r
- {\r
- m_cascade->add( mof::makeConstantHandler( b ) );\r
- return *this;\r
- }\r
-\r
- T value( ) const\r
- {\r
- return m_cascade->value( m_frameNumber );\r
- }\r
-\r
- Manipulator<T>::Handler toManipulator()\r
- {\r
- return m_cascade;\r
- }\r
- \r
- void update( )\r
- {\r
- m_frameNumber++;\r
- }\r
-\r
- FrameNumber getCurrentFrameNumber() const\r
- {\r
- return m_frameNumber;\r
- }\r
-\r
- private:\r
- FrameNumber m_frameNumber;\r
- typename Cascade< T , Cascador >::Handler m_cascade;\r
- };\r
-\r
-} // namespace mof\r
+#pragma once
+#include <boost/shared_ptr.hpp>
+#include "mof/stream/Cascade.hpp"
+#include "mof/stream/Constant.hpp"
+#include "mof/stream/Offset.hpp"
+
+namespace mof
+{
+
+ template< typename T , class Cascador = DEFAULT_CASCADOR< T > >
+ class TypeStream
+ {
+ public:
+ TypeStream( )
+ : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )
+ {}
+
+
+ TypeStream( const typename Manipulator< T >::Handler& handler )
+ : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )
+ {
+ m_cascade << handler;
+ }
+
+ TypeStream( const T& value )
+ : m_frameNumber( 0 ) , m_cascade( mof::makeCascadeHandler< T , Cascador >() )
+ {
+ m_cascade << value;
+ }
+
+ ~TypeStream( )
+ {}
+
+ TypeStream< T , Cascador >&
+ operator <<
+ (
+ const typename Manipulator< T >::Handler& b
+ )
+ {
+ m_cascade->add
+ (
+ makeOffsetHandler< T >( b , -1 * (int)m_frameNumber)
+ );
+ return *this;
+ }
+
+ TypeStream< T , Cascador >&
+ operator <<
+ (
+ const TypeStream< T , Cascador >& obj
+ )
+ {
+ //m_cascade->add( obj.m_cascade );
+ m_cascade->add( makeCacheHandler<T>(makeOffsetHandler< T >( obj.m_cascade , obj.m_frameNumber - m_frameNumber) ) );
+ return *this;
+ }
+
+
+ TypeStream< T , Cascador >&
+ operator <<
+ (
+ const T& b
+ )
+ {
+ m_cascade->add( mof::makeConstantHandler( b ) );
+ return *this;
+ }
+
+ T value( ) const
+ {
+ return m_cascade->value( m_frameNumber );
+ }
+
+ Manipulator<T>::Handler toManipulator()
+ {
+ return m_cascade;
+ }
+
+ void update( )
+ {
+ m_frameNumber++;
+ }
+
+ FrameNumber getCurrentFrameNumber() const
+ {
+ return m_frameNumber;
+ }
+
+ private:
+ FrameNumber m_frameNumber;
+ typename Cascade< T , Cascador >::Handler m_cascade;
+ };
+
+} // namespace mof
-#pragma once\r
-#include "mof/Animation.hpp"\r
-#include "mof/Vector3D.hpp"\r
- \r
-namespace mof{\r
-\r
- class UniformAnimation : public mof::Animation<mof::Vector3D>\r
- {\r
- \r
- mof::Vector3D m_initialValue;\r
- mof::Vector3D m_targetValue; \r
- double m_speed; \r
- public:\r
- \r
- UniformAnimation\r
- (\r
- const mof::Vector3D& initialValue ,\r
- const mof::Vector3D& targetValue ,\r
- double speed \r
- ) \r
- : m_initialValue(initialValue) , m_targetValue(targetValue) , m_speed(speed)\r
- {\r
- }\r
- \r
- \r
- virtual mof::Vector3D getValue( mof::FrameNumber frame) const\r
- {\r
- \r
- mof::Vector3D direction = ( m_targetValue - m_initialValue );\r
- direction.normalize();\r
- mof::Vector3D result = m_initialValue + direction * m_speed * frame;//\91\9d\95ª \r
- if( direction.x > 0 && result.x > m_targetValue.x )result.x = m_targetValue.x; \r
- else if( direction.x < 0 && result.x < m_targetValue.x )result.x = m_targetValue.x; \r
- if( direction.y > 0 && result.y > m_targetValue.y )result.y = m_targetValue.y; \r
- else if( direction.y < 0 && result.y < m_targetValue.y )result.y = m_targetValue.y; \r
- if( direction.z > 0 && result.z > m_targetValue.z )result.z = m_targetValue.z; \r
- else if( direction.z < 0 && result.z < m_targetValue.z )result.z = m_targetValue.z; \r
- \r
- return result;\r
- }\r
-\r
- \r
- };\r
- \r
- \r
- \r
-} //namespace mof\r
- \r
+#pragma once
+#include "mof/Animation.hpp"
+#include "mof/Vector3D.hpp"
+
+namespace mof{
+
+ class UniformAnimation : public mof::Animation<mof::Vector3D>
+ {
+
+ mof::Vector3D m_initialValue;
+ mof::Vector3D m_targetValue;
+ double m_speed;
+ public:
+
+ UniformAnimation
+ (
+ const mof::Vector3D& initialValue ,
+ const mof::Vector3D& targetValue ,
+ double speed
+ )
+ : m_initialValue(initialValue) , m_targetValue(targetValue) , m_speed(speed)
+ {
+ }
+
+
+ virtual mof::Vector3D getValue( mof::FrameNumber frame) const
+ {
+
+ mof::Vector3D direction = ( m_targetValue - m_initialValue );
+ direction.normalize();
+ mof::Vector3D result = m_initialValue + direction * m_speed * frame;//\91\9d\95ª
+ if( direction.x > 0 && result.x > m_targetValue.x )result.x = m_targetValue.x;
+ else if( direction.x < 0 && result.x < m_targetValue.x )result.x = m_targetValue.x;
+ if( direction.y > 0 && result.y > m_targetValue.y )result.y = m_targetValue.y;
+ else if( direction.y < 0 && result.y < m_targetValue.y )result.y = m_targetValue.y;
+ if( direction.z > 0 && result.z > m_targetValue.z )result.z = m_targetValue.z;
+ else if( direction.z < 0 && result.z < m_targetValue.z )result.z = m_targetValue.z;
+
+ return result;
+ }
+
+
+ };
+
+
+
+} //namespace mof
+
-#pragma once\r
-#include "mof/Animation.hpp"\r
-#include "mof/Vector3D.hpp"\r
- \r
-namespace mof{\r
-\r
- class UniformAnimation : public mof::Animation<mof::Vector3D>\r
- {\r
- \r
- mof::Vector3D m_initialValue;\r
- mof::Vector3D m_targetValue; \r
- double m_speed; \r
- public:\r
- \r
- UniformAnimation\r
- (\r
- const mof::Vector3D& initialValue ,\r
- const mof::Vector3D& targetValue ,\r
- double speed \r
- ) \r
- : m_initialValue(initialValue) , m_targetValue(targetValue) , m_speed(speed)\r
- {\r
- }\r
- \r
- \r
- virtual mof::Vector3D getValue( mof::FrameNumber frame) const\r
- {\r
- \r
- mof::Vector3D direction = ( m_targetValue - m_initialValue );\r
- direction.normalize();\r
- mof::Vector3D result = m_initialValue + direction * m_speed * frame;//増分 \r
- if( direction.x > 0 && result.x > m_targetValue.x )result.x = m_targetValue.x; \r
- else if( direction.x < 0 && result.x < m_targetValue.x )result.x = m_targetValue.x; \r
- if( direction.y > 0 && result.y > m_targetValue.y )result.y = m_targetValue.y; \r
- else if( direction.y < 0 && result.y < m_targetValue.y )result.y = m_targetValue.y; \r
- if( direction.z > 0 && result.z > m_targetValue.z )result.z = m_targetValue.z; \r
- else if( direction.z < 0 && result.z < m_targetValue.z )result.z = m_targetValue.z; \r
- \r
- return result;\r
- }\r
-\r
- \r
- };\r
- \r
- \r
- \r
-} //namespace mof\r
- \r
+#pragma once
+#include "mof/Animation.hpp"
+#include "mof/Vector3D.hpp"
+
+namespace mof{
+
+ class UniformAnimation : public mof::Animation<mof::Vector3D>
+ {
+
+ mof::Vector3D m_initialValue;
+ mof::Vector3D m_targetValue;
+ double m_speed;
+ public:
+
+ UniformAnimation
+ (
+ const mof::Vector3D& initialValue ,
+ const mof::Vector3D& targetValue ,
+ double speed
+ )
+ : m_initialValue(initialValue) , m_targetValue(targetValue) , m_speed(speed)
+ {
+ }
+
+
+ virtual mof::Vector3D getValue( mof::FrameNumber frame) const
+ {
+
+ mof::Vector3D direction = ( m_targetValue - m_initialValue );
+ direction.normalize();
+ mof::Vector3D result = m_initialValue + direction * m_speed * frame;//増分
+ if( direction.x > 0 && result.x > m_targetValue.x )result.x = m_targetValue.x;
+ else if( direction.x < 0 && result.x < m_targetValue.x )result.x = m_targetValue.x;
+ if( direction.y > 0 && result.y > m_targetValue.y )result.y = m_targetValue.y;
+ else if( direction.y < 0 && result.y < m_targetValue.y )result.y = m_targetValue.y;
+ if( direction.z > 0 && result.z > m_targetValue.z )result.z = m_targetValue.z;
+ else if( direction.z < 0 && result.z < m_targetValue.z )result.z = m_targetValue.z;
+
+ return result;
+ }
+
+
+ };
+
+
+
+} //namespace mof
+
- #pragma once\r
- \r
- #include "mof/ParametricAnimation.hpp"\r
- #include "mof/KeyFrameAnimation.hpp"\r
- #include "mof/RotationAnimation3D.hpp"\r
- #include "mof/TranslationAnimation3D.hpp"\r
- #include "mof/ScalingAnimation3D.hpp"\r
- #include "mof/RotationAnimation2D.hpp"\r
- #include "mof/TranslationAnimation2D.hpp"\r
- #include "mof/ScalingAnimation2D.hpp"\r
- #include "mof/Constant.hpp"\r
- #include "mof/CascadingAnimation.hpp"\r
- #include "mof/LoopAnimation.hpp"\r
- #include "mof/Joint.hpp"\r
- #include "mof/dynamic/utilities.hpp"\r
- #include "mof/BoundsAnimation.hpp"\r
- #include "mof/OffsetAnimation.hpp"\r
- #include "mof/Interpolation.hpp"\r
+ #pragma once
+
+ #include "mof/ParametricAnimation.hpp"
+ #include "mof/KeyFrameAnimation.hpp"
+ #include "mof/RotationAnimation3D.hpp"
+ #include "mof/TranslationAnimation3D.hpp"
+ #include "mof/ScalingAnimation3D.hpp"
+ #include "mof/RotationAnimation2D.hpp"
+ #include "mof/TranslationAnimation2D.hpp"
+ #include "mof/ScalingAnimation2D.hpp"
+ #include "mof/Constant.hpp"
+ #include "mof/CascadingAnimation.hpp"
+ #include "mof/LoopAnimation.hpp"
+ #include "mof/Joint.hpp"
+ #include "mof/dynamic/utilities.hpp"
+ #include "mof/BoundsAnimation.hpp"
+ #include "mof/OffsetAnimation.hpp"
+ #include "mof/Interpolation.hpp"
-#include "mof/stream/utilities.hpp"\r
-#include "mof/stream/Joint.hpp"\r
-#include <boost/bind.hpp>\r
-\r
-namespace\r
-{\r
- mof::Vector2D matrix2translation( const mof::Matrix2D& matrix )\r
- {\r
- return mof::Matrix2D::getTranslation( matrix );\r
- }\r
- \r
- mof::Vector2D matrix2scaling( const mof::Matrix2D& matrix )\r
- {\r
- return matrix.getDiagonal( );\r
- }\r
-\r
- mof::Vector2D matrix2rotation( const mof::Matrix2D& matrix )\r
- {\r
- //TODO implementation\r
- return matrix.getDiagonal( );\r
- }\r
-\r
-}\r
-\r
-\r
-namespace mof\r
-{\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeTranslation2DHandler( const Manipulator< Matrix2D >::Handler& handler )\r
- {\r
- return makeJointHandler( handler , &matrix2translation );\r
- //return makeJointHandler( handler , boost::bind( &matrix2translation ) );\r
- }\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeScaling2DHandler( const Manipulator< Matrix2D >::Handler& handler )\r
- {\r
- return makeJointHandler( handler , &matrix2scaling );\r
- //return makeJointHandler( handler , boost::bind( &matrix2scaling ) );\r
- }\r
-\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeRotation2DHandler( const Manipulator< Matrix2D >::Handler& handler )\r
- {\r
- return makeJointHandler( handler , &matrix2rotation );\r
- //return makeJointHandler( handler , boost::bind( &matrix2rotation ) );\r
- }\r
-\r
-\r
-\r
-} // namespace mof\r
-\r
+#include "mof/stream/utilities.hpp"
+#include "mof/stream/Joint.hpp"
+#include <boost/bind.hpp>
+
+namespace
+{
+ mof::Vector2D matrix2translation( const mof::Matrix2D& matrix )
+ {
+ return mof::Matrix2D::getTranslation( matrix );
+ }
+
+ mof::Vector2D matrix2scaling( const mof::Matrix2D& matrix )
+ {
+ return matrix.getDiagonal( );
+ }
+
+ mof::Vector2D matrix2rotation( const mof::Matrix2D& matrix )
+ {
+ //TODO implementation
+ return matrix.getDiagonal( );
+ }
+
+}
+
+
+namespace mof
+{
+
+ Manipulator< Vector2D >::Handler
+ makeTranslation2DHandler( const Manipulator< Matrix2D >::Handler& handler )
+ {
+ return makeJointHandler( handler , &matrix2translation );
+ //return makeJointHandler( handler , boost::bind( &matrix2translation ) );
+ }
+
+ Manipulator< Vector2D >::Handler
+ makeScaling2DHandler( const Manipulator< Matrix2D >::Handler& handler )
+ {
+ return makeJointHandler( handler , &matrix2scaling );
+ //return makeJointHandler( handler , boost::bind( &matrix2scaling ) );
+ }
+
+
+ Manipulator< Vector2D >::Handler
+ makeRotation2DHandler( const Manipulator< Matrix2D >::Handler& handler )
+ {
+ return makeJointHandler( handler , &matrix2rotation );
+ //return makeJointHandler( handler , boost::bind( &matrix2rotation ) );
+ }
+
+
+
+} // namespace mof
+
-#include "mof/stream/utilities.hpp"\r
-#include "mof/stream/Joint.hpp"\r
-#include <boost/bind.hpp>\r
-\r
-namespace\r
-{\r
- mof::Vector2D matrix2translation( const mof::Matrix2D& matrix )\r
- {\r
- return mof::Matrix2D::getTranslation( matrix );\r
- }\r
- \r
- mof::Vector2D matrix2scaling( const mof::Matrix2D& matrix )\r
- {\r
- return matrix.getDiagonal( );\r
- }\r
-\r
- mof::Vector2D matrix2rotation( const mof::Matrix2D& matrix )\r
- {\r
- //TODO implementation\r
- return matrix.getDiagonal( );\r
- }\r
-\r
-}\r
-\r
-\r
-namespace mof\r
-{\r
-\r
- Animation< Vector2D >::Handler \r
- makeTranslation2DHandler( const Animation< Matrix2D >::Handler& handler )\r
- {\r
- return makeJointHandler( handler , &matrix2translation );\r
- //return makeJointHandler( handler , boost::bind( &matrix2translation ) );\r
- }\r
-\r
- Animation< Vector2D >::Handler \r
- makeScaling2DHandler( const Animation< Matrix2D >::Handler& handler )\r
- {\r
- return makeJointHandler( handler , &matrix2scaling );\r
- //return makeJointHandler( handler , boost::bind( &matrix2scaling ) );\r
- }\r
-\r
-\r
- Animation< Vector2D >::Handler \r
- makeRotation2DHandler( const Animation< Matrix2D >::Handler& handler )\r
- {\r
- return makeJointHandler( handler , &matrix2rotation );\r
- //return makeJointHandler( handler , boost::bind( &matrix2rotation ) );\r
- }\r
-\r
-\r
-\r
-} // namespace mof\r
-\r
+#include "mof/stream/utilities.hpp"
+#include "mof/stream/Joint.hpp"
+#include <boost/bind.hpp>
+
+namespace
+{
+ mof::Vector2D matrix2translation( const mof::Matrix2D& matrix )
+ {
+ return mof::Matrix2D::getTranslation( matrix );
+ }
+
+ mof::Vector2D matrix2scaling( const mof::Matrix2D& matrix )
+ {
+ return matrix.getDiagonal( );
+ }
+
+ mof::Vector2D matrix2rotation( const mof::Matrix2D& matrix )
+ {
+ //TODO implementation
+ return matrix.getDiagonal( );
+ }
+
+}
+
+
+namespace mof
+{
+
+ Animation< Vector2D >::Handler
+ makeTranslation2DHandler( const Animation< Matrix2D >::Handler& handler )
+ {
+ return makeJointHandler( handler , &matrix2translation );
+ //return makeJointHandler( handler , boost::bind( &matrix2translation ) );
+ }
+
+ Animation< Vector2D >::Handler
+ makeScaling2DHandler( const Animation< Matrix2D >::Handler& handler )
+ {
+ return makeJointHandler( handler , &matrix2scaling );
+ //return makeJointHandler( handler , boost::bind( &matrix2scaling ) );
+ }
+
+
+ Animation< Vector2D >::Handler
+ makeRotation2DHandler( const Animation< Matrix2D >::Handler& handler )
+ {
+ return makeJointHandler( handler , &matrix2rotation );
+ //return makeJointHandler( handler , boost::bind( &matrix2rotation ) );
+ }
+
+
+
+} // namespace mof
+
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-#include "mof/stream/TypeStream.hpp"\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-#include "mof/Color.hpp"\r
-#include "mof/Rectangle.hpp"\r
-\r
-namespace mof\r
-{\r
- typedef TypeStream< Vector2D , Add< Vector2D > > Vector2DStream;\r
- typedef TypeStream< Color4f , Multiply< Color4f > > ColorStream;\r
- typedef TypeStream< Rectangle< float > , Overwrite< Rectangle< float > > > RectangleStream;\r
-\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeTranslation2DHandler( const Manipulator< Matrix2D >::Handler& handler );\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeScaling2DHandler( const Manipulator< Matrix2D >::Handler& handler );\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeRotation2DHandler( const Manipulator< Matrix2D >::Handler& handler );\r
-\r
-\r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+#include "mof/stream/TypeStream.hpp"
+#include "mof/Vector2D.hpp"
+#include "mof/Matrix2D.hpp"
+#include "mof/Color.hpp"
+#include "mof/Rectangle.hpp"
+
+namespace mof
+{
+ typedef TypeStream< Vector2D , Add< Vector2D > > Vector2DStream;
+ typedef TypeStream< Color4f , Multiply< Color4f > > ColorStream;
+ typedef TypeStream< Rectangle< float > , Overwrite< Rectangle< float > > > RectangleStream;
+
+
+ Manipulator< Vector2D >::Handler
+ makeTranslation2DHandler( const Manipulator< Matrix2D >::Handler& handler );
+
+ Manipulator< Vector2D >::Handler
+ makeScaling2DHandler( const Manipulator< Matrix2D >::Handler& handler );
+
+ Manipulator< Vector2D >::Handler
+ makeRotation2DHandler( const Manipulator< Matrix2D >::Handler& handler );
+
+
+} // namespace mof
-#pragma once\r
-#include "mof/stream/Manipulator.hpp"\r
-#include "mof/stream/TypeStream.hpp"\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/Matrix2D.hpp"\r
-#include "mof/Color.hpp"\r
-#include "mof/Rectangle.hpp"\r
-\r
-namespace mof\r
-{\r
- typedef TypeStream< Vector2D , Add< Vector2D > > Vector2DStream;\r
- typedef TypeStream< Color4f , Multiply< Color4f > > ColorStream;\r
- typedef TypeStream< Rectangle< float > , Add< Rectangle< float > > > RectangleStream;\r
-\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeTranslation2DHandler( const Manipulator< Matrix2D >::Handler& handler );\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeScaling2DHandler( const Manipulator< Matrix2D >::Handler& handler );\r
-\r
- Manipulator< Vector2D >::Handler \r
- makeRotation2DHandler( const Manipulator< Matrix2D >::Handler& handler );\r
-\r
-\r
-} // namespace mof\r
+#pragma once
+#include "mof/stream/Manipulator.hpp"
+#include "mof/stream/TypeStream.hpp"
+#include "mof/Vector2D.hpp"
+#include "mof/Matrix2D.hpp"
+#include "mof/Color.hpp"
+#include "mof/Rectangle.hpp"
+
+namespace mof
+{
+ typedef TypeStream< Vector2D , Add< Vector2D > > Vector2DStream;
+ typedef TypeStream< Color4f , Multiply< Color4f > > ColorStream;
+ typedef TypeStream< Rectangle< float > , Add< Rectangle< float > > > RectangleStream;
+
+
+ Manipulator< Vector2D >::Handler
+ makeTranslation2DHandler( const Manipulator< Matrix2D >::Handler& handler );
+
+ Manipulator< Vector2D >::Handler
+ makeScaling2DHandler( const Manipulator< Matrix2D >::Handler& handler );
+
+ Manipulator< Vector2D >::Handler
+ makeRotation2DHandler( const Manipulator< Matrix2D >::Handler& handler );
+
+
+} // namespace mof
-#pragma once\r
-\r
-\r
-#include "mof/stream/TypeStream.hpp"\r
-#include "mof/stream/Manipulator.hpp"\r
-#include "mof/stream/Cascade.hpp"\r
-#include "mof/stream/Constant.hpp"\r
-#include "mof/stream/KeyFrameAnimation.hpp"\r
-#include "mof/stream/Translation2D.hpp"\r
-#include "mof/stream/Rotation2D.hpp"\r
-#include "mof/stream/Scaling2D.hpp"\r
-#include "mof/stream/Loop.hpp"\r
-#include "mof/stream/Joint.hpp"\r
-#include "mof/stream/Offset.hpp"\r
-#include "mof/stream/Reference.hpp"\r
-#include "mof/stream/Filter.hpp"\r
-#include "mof/stream/ReferenceWrapper.hpp"\r
-#include "mof/stream/Cache.hpp"\r
-#include "mof/stream/utilities.hpp"\r
-\r
-/*\r
-#include "mof/ParametricAnimation.hpp"\r
-#include "mof/RotationAnimation3D.hpp"\r
-#include "mof/TranslationAnimation3D.hpp"\r
-#include "mof/ScalingAnimation3D.hpp"\r
-#include "mof/BoundsAnimation.hpp"\r
-*/\r
+#pragma once
+
+
+#include "mof/stream/TypeStream.hpp"
+#include "mof/stream/Manipulator.hpp"
+#include "mof/stream/Cascade.hpp"
+#include "mof/stream/Constant.hpp"
+#include "mof/stream/KeyFrameAnimation.hpp"
+#include "mof/stream/Translation2D.hpp"
+#include "mof/stream/Rotation2D.hpp"
+#include "mof/stream/Scaling2D.hpp"
+#include "mof/stream/Loop.hpp"
+#include "mof/stream/Joint.hpp"
+#include "mof/stream/Offset.hpp"
+#include "mof/stream/Reference.hpp"
+#include "mof/stream/Filter.hpp"
+#include "mof/stream/ReferenceWrapper.hpp"
+#include "mof/stream/Cache.hpp"
+#include "mof/stream/utilities.hpp"
+
+/*
+#include "mof/ParametricAnimation.hpp"
+#include "mof/RotationAnimation3D.hpp"
+#include "mof/TranslationAnimation3D.hpp"
+#include "mof/ScalingAnimation3D.hpp"
+#include "mof/BoundsAnimation.hpp"
+*/
-#include <cppunit/BriefTestProgressListener.h>\r
-#include <cppunit/CompilerOutputter.h>\r
-#include <cppunit/extensions/TestFactoryRegistry.h>\r
-#include <cppunit/TestResult.h>\r
-#include <cppunit/TestResultCollector.h>\r
-#include <cppunit/TestRunner.h>\r
-#include <conio.h>\r
-\r
-int main( int argc, char* argv[] ) {\r
- // \83C\83x\83\93\83g\81E\83}\83l\81[\83W\83\83\82Æ\83e\83X\83g\81E\83R\83\93\83g\83\8d\81[\83\89\82ð\90¶\90¬\82·\82é\r
- CPPUNIT_NS::TestResult controller;\r
-\r
- // \83e\83X\83g\8c\8b\89Ê\8eû\8fW\83\8a\83X\83i\82ð\83R\83\93\83g\83\8d\81[\83\89\82É\83A\83^\83b\83`\82·\82é\r
- CPPUNIT_NS::TestResultCollector result;\r
- controller.addListener( &result );\r
-\r
- // \81u.\81v\82Å\90i\8ds\8fó\8bµ\82ð\8fo\97Í\82·\82é\83\8a\83X\83i\82ð\83A\83^\83b\83`\82·\82é\r
- CPPUNIT_NS::BriefTestProgressListener progress;\r
- controller.addListener( &progress );\r
-\r
- // \83e\83X\83g\81E\83\89\83\93\83i\81[\82É\83e\83X\83g\8cQ\82ð\97^\82¦\81A\83e\83X\83g\82·\82é\r
- CPPUNIT_NS::TestRunner runner;\r
- runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );\r
- runner.run( controller );\r
-\r
- // \83e\83X\83g\8c\8b\89Ê\82ð\95W\8f\80\8fo\97Í\82É\93f\82«\8fo\82·\r
- CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );\r
- outputter.write();\r
-\r
- \r
- return result.wasSuccessful() ? 0 : 1;\r
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TestRunner.h>
+#include <conio.h>
+
+int main( int argc, char* argv[] ) {
+ // \83C\83x\83\93\83g\81E\83}\83l\81[\83W\83\83\82Æ\83e\83X\83g\81E\83R\83\93\83g\83\8d\81[\83\89\82ð\90¶\90¬\82·\82é
+ CPPUNIT_NS::TestResult controller;
+
+ // \83e\83X\83g\8c\8b\89Ê\8eû\8fW\83\8a\83X\83i\82ð\83R\83\93\83g\83\8d\81[\83\89\82É\83A\83^\83b\83`\82·\82é
+ CPPUNIT_NS::TestResultCollector result;
+ controller.addListener( &result );
+
+ // \81u.\81v\82Å\90i\8ds\8fó\8bµ\82ð\8fo\97Í\82·\82é\83\8a\83X\83i\82ð\83A\83^\83b\83`\82·\82é
+ CPPUNIT_NS::BriefTestProgressListener progress;
+ controller.addListener( &progress );
+
+ // \83e\83X\83g\81E\83\89\83\93\83i\81[\82É\83e\83X\83g\8cQ\82ð\97^\82¦\81A\83e\83X\83g\82·\82é
+ CPPUNIT_NS::TestRunner runner;
+ runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() );
+ runner.run( controller );
+
+ // \83e\83X\83g\8c\8b\89Ê\82ð\95W\8f\80\8fo\97Í\82É\93f\82«\8fo\82·
+ CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() );
+ outputter.write();
+
+
+ return result.wasSuccessful() ? 0 : 1;
}
\ No newline at end of file
-#include <cppunit/extensions/HelperMacros.h> \r
-#include "mof/SceneGraph.hpp"\r
-#include "mof/tstring.hpp"\r
-\r
-class SceneGraphTest : public CPPUNIT_NS::TestFixture { \r
- CPPUNIT_TEST_SUITE( SceneGraphTest );\r
- CPPUNIT_TEST( test_run ); \r
- CPPUNIT_TEST_SUITE_END(); \r
-\r
-protected:\r
- mof::SceneGraph* c_;\r
-\r
-public:\r
- void setUp(); //\r
- void tearDown(); //\r
-\r
-protected:\r
- void test_run(); //\r
- \r
-};\r
-\r
-\r
-CPPUNIT_TEST_SUITE_REGISTRATION( SceneGraphTest ); //\r
-\r
-// \8ae\83e\83X\83g\81E\83P\81[\83X\82Ì\8eÀ\8ds\92¼\91O\82É\8cÄ\82Î\82ê\82é\r
-void SceneGraphTest::setUp() {\r
- c_ = new mof::SceneGraph();\r
-}\r
-\r
-// \8ae\83e\83X\83g\81E\83P\81[\83X\82Ì\8eÀ\8ds\92¼\8cã\82É\8cÄ\82Î\82ê\82é\r
-void SceneGraphTest::tearDown() {\r
- delete c_;\r
-}\r
-\r
-// \82±\82ê\88È\8d~\82Í\83e\83X\83g\81E\83P\81[\83X\82Ì\8eÀ\91\95\93à\97e\r
-\r
-void SceneGraphTest::test_run() {\r
- //CPPUNIT_ASSERT_EQUAL(0, c_->run(NULL)); //\r
-}\r
+#include <cppunit/extensions/HelperMacros.h>
+#include "mof/SceneGraph.hpp"
+#include "mof/tstring.hpp"
+
+class SceneGraphTest : public CPPUNIT_NS::TestFixture {
+ CPPUNIT_TEST_SUITE( SceneGraphTest );
+ CPPUNIT_TEST( test_run );
+ CPPUNIT_TEST_SUITE_END();
+
+protected:
+ mof::SceneGraph* c_;
+
+public:
+ void setUp(); //
+ void tearDown(); //
+
+protected:
+ void test_run(); //
+
+};
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION( SceneGraphTest ); //
+
+// \8ae\83e\83X\83g\81E\83P\81[\83X\82Ì\8eÀ\8ds\92¼\91O\82É\8cÄ\82Î\82ê\82é
+void SceneGraphTest::setUp() {
+ c_ = new mof::SceneGraph();
+}
+
+// \8ae\83e\83X\83g\81E\83P\81[\83X\82Ì\8eÀ\8ds\92¼\8cã\82É\8cÄ\82Î\82ê\82é
+void SceneGraphTest::tearDown() {
+ delete c_;
+}
+
+// \82±\82ê\88È\8d~\82Í\83e\83X\83g\81E\83P\81[\83X\82Ì\8eÀ\91\95\93à\97e
+
+void SceneGraphTest::test_run() {
+ //CPPUNIT_ASSERT_EQUAL(0, c_->run(NULL)); //
+}
-#include <cppunit/extensions/HelperMacros.h> \r
-#include "mof/Timer.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <memory>\r
-\r
-class TimerTest : public CPPUNIT_NS::TestFixture { \r
- CPPUNIT_TEST_SUITE( TimerTest ); \r
- CPPUNIT_TEST( test_run ); \r
- CPPUNIT_TEST_SUITE_END(); \r
-\r
-protected:\r
- std::auto_ptr<mof::Timer> m_pTarget;\r
-\r
-public:\r
- void setUp(); \r
-\r
-protected:\r
- void test_run();\r
- \r
-};\r
-\r
-\r
-CPPUNIT_TEST_SUITE_REGISTRATION( TimerTest ); \r
-\r
-void TimerTest::setUp() {\r
- m_pTarget = std::auto_ptr<mof::Timer>(new mof::Timer());\r
-}\r
-\r
-\r
-void TimerTest::test_run(){\r
-\r
+#include <cppunit/extensions/HelperMacros.h>
+#include "mof/Timer.hpp"
+#include "mof/tstring.hpp"
+#include <memory>
+
+class TimerTest : public CPPUNIT_NS::TestFixture {
+ CPPUNIT_TEST_SUITE( TimerTest );
+ CPPUNIT_TEST( test_run );
+ CPPUNIT_TEST_SUITE_END();
+
+protected:
+ std::auto_ptr<mof::Timer> m_pTarget;
+
+public:
+ void setUp();
+
+protected:
+ void test_run();
+
+};
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION( TimerTest );
+
+void TimerTest::setUp() {
+ m_pTarget = std::auto_ptr<mof::Timer>(new mof::Timer());
+}
+
+
+void TimerTest::test_run(){
+
}
\ No newline at end of file
-#ifndef TSTRING_HPP\r
-#define TSTRING_HPP\r
-\r
-#include <string>\r
-#include <tchar.h>\r
-#include <sstream>\r
-\r
-namespace mof {\r
- typedef std::basic_string<TCHAR> tstring;\r
- typedef std::basic_ostringstream<TCHAR> otstringstream;\r
-};\r
-\r
-#endif\r
+#ifndef TSTRING_HPP
+#define TSTRING_HPP
+
+#include <string>
+#include <tchar.h>
+#include <sstream>
+
+namespace mof {
+ typedef std::basic_string<TCHAR> tstring;
+ typedef std::basic_ostringstream<TCHAR> otstringstream;
+};
+
+#endif
-#pragma once\r
-#define _USE_MATH_DEFINES\r
-#include <math.h>\r
-#include <boost/foreach.hpp>\r
-#define foreach BOOST_FOREACH \r
-\r
-namespace mof{\r
- \r
- inline float deg2rad( float deg )\r
- {\r
- return deg / 180.0f * static_cast<float>(M_PI);\r
- }\r
-\r
- inline float rad2deg( float rad )\r
- {\r
- return rad / static_cast<float>(M_PI) * 180.0f;\r
- }\r
-\r
- template< typename T , int N >\r
- int lengthOf( T (&)[N] )\r
- {\r
- return N;\r
- }\r
- \r
- template< typename T , int N >\r
- T& lastOf( T(&arr)[N] )\r
- {\r
- return arr[N-1];\r
- }\r
-\r
- template< typename T >\r
- void safe_delete( T* (&p) )\r
- {\r
- delete p;\r
- p = NULL;\r
- }\r
-\r
- template< typename T >\r
- void safe_delete_array( T* (&p) )\r
- {\r
- delete[] p;\r
- p = NULL;\r
- }\r
-\r
- inline int rotation_mod(int a , unsigned int b)\r
- {\r
- return a >= 0 ? a % b : b - (-a % b);\r
- }\r
-\r
-\r
-\r
-} // namespace mof\r
-\r
+#pragma once
+#define _USE_MATH_DEFINES
+#include <math.h>
+#include <boost/foreach.hpp>
+#define foreach BOOST_FOREACH
+
+namespace mof{
+
+ inline float deg2rad( float deg )
+ {
+ return deg / 180.0f * static_cast<float>(M_PI);
+ }
+
+ inline float rad2deg( float rad )
+ {
+ return rad / static_cast<float>(M_PI) * 180.0f;
+ }
+
+ template< typename T , int N >
+ int lengthOf( T (&)[N] )
+ {
+ return N;
+ }
+
+ template< typename T , int N >
+ T& lastOf( T(&arr)[N] )
+ {
+ return arr[N-1];
+ }
+
+ template< typename T >
+ void safe_delete( T* (&p) )
+ {
+ delete p;
+ p = NULL;
+ }
+
+ template< typename T >
+ void safe_delete_array( T* (&p) )
+ {
+ delete[] p;
+ p = NULL;
+ }
+
+ inline int rotation_mod(int a , unsigned int b)
+ {
+ return a >= 0 ? a % b : b - (-a % b);
+ }
+
+
+
+} // namespace mof
+
-#pragma once\r
-#include "mof/widget/WdigetView.hpp"\r
-\r
-namespace mof\r
-{\r
- \r
-\r
- class ButtonWidgetView \r
- :\r
- public WidgetView ,\r
- {\r
- public:\r
-\r
- virtual FrameNumber blur( bool imidiately = false ) = 0;\r
-\r
- };\r
-\r
-}\r
+#pragma once
+#include "mof/widget/WdigetView.hpp"
+
+namespace mof
+{
+
+
+ class ButtonWidgetView
+ :
+ public WidgetView ,
+ {
+ public:
+
+ virtual FrameNumber blur( bool imidiately = false ) = 0;
+
+ };
+
+}
-#include <mof/widget/Container.hpp>\r
-#include "mof/mofGraphics.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/widgets.hpp"\r
-#include "mof/streams.hpp"\r
-#include <vector>\r
-#include <algorithm>\r
-#include <memory>\r
-#include <boost/shared_ptr.hpp>\r
- \r
-using std::auto_ptr;\r
-using boost::shared_ptr;\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-//{{{ struct Impl\r
- struct Container::Impl\r
- {\r
- std::vector< shared_ptr<WidgetView> > children;\r
- auto_ptr<Layout> pLayout;\r
- \r
- \r
- Impl() : pLayout(NULL){}\r
- ~Impl(){}\r
- \r
- };\r
-//}}}\r
-//{{{ constructor\r
- Container::Container\r
- (\r
- const shared_ptr<WidgetView>& front ,\r
- const shared_ptr<WidgetView>& back ,\r
- const FactoryMethod<Layout>& layout\r
- )\r
- : \r
- m_pImpl( new Impl( ) ) \r
- {\r
- \r
- int length = (&back - &front) +1;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- m_pImpl->children.push_back( (&front)[i] );\r
- }\r
-\r
- m_pImpl->pLayout = auto_ptr<Layout>( layout() );\r
- foreach(shared_ptr<WidgetView> pView , m_pImpl->children)\r
- {\r
- m_pImpl->pLayout->add(pView);\r
- }\r
- m_sizeStream << m_pImpl->pLayout->getPreferredSize();\r
- m_pImpl->pLayout->connect(this);\r
-\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- m_pImpl->children[i]->getColorStream() << getColorStream(); \r
- }\r
- }\r
-//}}}\r
-//{{{ destructor\r
- Container::~Container()\r
- {\r
- }\r
-//}}}\r
-//{{{ update\r
- void Container::update( )\r
- {\r
- m_positionStream.update( );\r
- m_sizeStream.update( );\r
- m_colorStream.update( );\r
- foreach(shared_ptr<WidgetView> value , m_pImpl->children)\r
- {\r
- value->update();\r
- }\r
- }\r
-//}}}\r
-//{{{ draw\r
- void Container::draw( ) const\r
- {\r
- foreach(shared_ptr<WidgetView> value , m_pImpl->children)\r
- {\r
- value->draw();\r
- }\r
-\r
- }\r
-//}}}\r
-//{{{ show\r
- FrameNumber Container::show(bool imidiately) \r
- {\r
- unsigned int maxFrame = 0;\r
- foreach(shared_ptr<WidgetView> value , m_pImpl->children)\r
- {\r
- maxFrame = max(value->show(imidiately) , maxFrame);\r
- }\r
- return maxFrame;\r
- }\r
-//}}}\r
-//{{{ hide\r
- FrameNumber Container::hide(bool imidiately)\r
- {\r
- unsigned int maxFrame = 0;\r
- foreach(shared_ptr<WidgetView> value , m_pImpl->children)\r
- {\r
- maxFrame = max(value->hide(imidiately) , maxFrame);\r
- }\r
- return maxFrame;\r
-\r
- }\r
-//}}}\r
-//{{{ focus\r
- FrameNumber Container::focus(bool) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ blur\r
- FrameNumber Container::blur(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ click\r
- FrameNumber Container::click(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ getAt\r
- shared_ptr<WidgetView> Container::getAt(int index) const\r
- {\r
- return m_pImpl->children[index];\r
- }\r
-//}}}\r
-//{{{ getLength\r
- int Container::getLength() const\r
- {\r
- return m_pImpl->children.size();\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsUp\r
- int Container::getAdjacencyAsUp(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsUp(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsDown\r
- int Container::getAdjacencyAsDown(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsDown(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsLeft\r
- int Container::getAdjacencyAsLeft(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsLeft(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsRight\r
- int Container::getAdjacencyAsRight(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsRight(index);\r
- }\r
-//}}}\r
-//{{{ add\r
- void Container::add(shared_ptr<WidgetView> pView)\r
- {\r
- //children.push_back( pView ); \r
- //m_pImpl->pLayout = adaptWidgetViewAndLayout( m_pImpl->children.begin( ) , m_pImpl->children.end( ) , layout);\r
- }\r
-//}}}\r
-\r
-}\r
-} // namespace mof\r
+#include <mof/widget/Container.hpp>
+#include "mof/mofGraphics.hpp"
+#include "mof/utilities.hpp"
+#include "mof/widgets.hpp"
+#include "mof/streams.hpp"
+#include <vector>
+#include <algorithm>
+#include <memory>
+#include <boost/shared_ptr.hpp>
+
+using std::auto_ptr;
+using boost::shared_ptr;
+
+namespace mof
+{
+namespace widget
+{
+//{{{ struct Impl
+ struct Container::Impl
+ {
+ std::vector< shared_ptr<WidgetView> > children;
+ auto_ptr<Layout> pLayout;
+
+
+ Impl() : pLayout(NULL){}
+ ~Impl(){}
+
+ };
+//}}}
+//{{{ constructor
+ Container::Container
+ (
+ const shared_ptr<WidgetView>& front ,
+ const shared_ptr<WidgetView>& back ,
+ const FactoryMethod<Layout>& layout
+ )
+ :
+ m_pImpl( new Impl( ) )
+ {
+
+ int length = (&back - &front) +1;
+ for(int i = 0 ; i < length ; i++)
+ {
+ m_pImpl->children.push_back( (&front)[i] );
+ }
+
+ m_pImpl->pLayout = auto_ptr<Layout>( layout() );
+ foreach(shared_ptr<WidgetView> pView , m_pImpl->children)
+ {
+ m_pImpl->pLayout->add(pView);
+ }
+ m_sizeStream << m_pImpl->pLayout->getPreferredSize();
+ m_pImpl->pLayout->connect(this);
+
+ for(int i = 0 ; i < length ; i++)
+ {
+ m_pImpl->children[i]->getColorStream() << getColorStream();
+ }
+ }
+//}}}
+//{{{ destructor
+ Container::~Container()
+ {
+ }
+//}}}
+//{{{ update
+ void Container::update( )
+ {
+ m_positionStream.update( );
+ m_sizeStream.update( );
+ m_colorStream.update( );
+ foreach(shared_ptr<WidgetView> value , m_pImpl->children)
+ {
+ value->update();
+ }
+ }
+//}}}
+//{{{ draw
+ void Container::draw( ) const
+ {
+ foreach(shared_ptr<WidgetView> value , m_pImpl->children)
+ {
+ value->draw();
+ }
+
+ }
+//}}}
+//{{{ show
+ FrameNumber Container::show(bool imidiately)
+ {
+ unsigned int maxFrame = 0;
+ foreach(shared_ptr<WidgetView> value , m_pImpl->children)
+ {
+ maxFrame = max(value->show(imidiately) , maxFrame);
+ }
+ return maxFrame;
+ }
+//}}}
+//{{{ hide
+ FrameNumber Container::hide(bool imidiately)
+ {
+ unsigned int maxFrame = 0;
+ foreach(shared_ptr<WidgetView> value , m_pImpl->children)
+ {
+ maxFrame = max(value->hide(imidiately) , maxFrame);
+ }
+ return maxFrame;
+
+ }
+//}}}
+//{{{ focus
+ FrameNumber Container::focus(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ blur
+ FrameNumber Container::blur(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ click
+ FrameNumber Container::click(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ getAt
+ shared_ptr<WidgetView> Container::getAt(int index) const
+ {
+ return m_pImpl->children[index];
+ }
+//}}}
+//{{{ getLength
+ int Container::getLength() const
+ {
+ return m_pImpl->children.size();
+ }
+//}}}
+//{{{ getAdjacentAsUp
+ int Container::getAdjacencyAsUp(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsUp(index);
+ }
+//}}}
+//{{{ getAdjacentAsDown
+ int Container::getAdjacencyAsDown(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsDown(index);
+ }
+//}}}
+//{{{ getAdjacentAsLeft
+ int Container::getAdjacencyAsLeft(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsLeft(index);
+ }
+//}}}
+//{{{ getAdjacentAsRight
+ int Container::getAdjacencyAsRight(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsRight(index);
+ }
+//}}}
+//{{{ add
+ void Container::add(shared_ptr<WidgetView> pView)
+ {
+ //children.push_back( pView );
+ //m_pImpl->pLayout = adaptWidgetViewAndLayout( m_pImpl->children.begin( ) , m_pImpl->children.end( ) , layout);
+ }
+//}}}
+
+}
+} // namespace mof
-#include <mof/widget/Container.hpp>\r
-#include "mof/mofGraphics.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/widgets.hpp"\r
-#include "mof/streams.hpp"\r
-#include <vector>\r
-#include <algorithm>\r
-#include <memory>\r
-#include <boost/shared_ptr.hpp>\r
- \r
-using std::auto_ptr;\r
-using boost::shared_ptr;\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-//{{{ struct Impl\r
- struct Container::Impl\r
- {\r
- std::vector< shared_ptr<WidgetView> > children;\r
- auto_ptr<Layout> pLayout;\r
- \r
- \r
- Impl() : pLayout(NULL){}\r
- ~Impl(){}\r
- \r
- };\r
-//}}}\r
-//{{{ constructor\r
- Container::Container\r
- (\r
- const shared_ptr<WidgetView>& front ,\r
- const shared_ptr<WidgetView>& back ,\r
- const FactoryMethod<Layout>& layout\r
- )\r
- : \r
- m_pImpl( new Impl( ) ) \r
- {\r
- \r
- int length = (&back - &front) +1;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- m_pImpl->children.push_back( (&front)[i] );\r
- }\r
-\r
- m_pImpl->pLayout = auto_ptr<Layout>( layout() );\r
- foreach(shared_ptr<WidgetView> pView , m_pImpl->children)\r
- {\r
- m_pImpl->pLayout->add(pView);\r
- }\r
- DEBUG_PRINT( m_pImpl->pLayout->getPreferredSize());\r
- m_sizeStream << m_pImpl->pLayout->getPreferredSize();\r
- m_pImpl->pLayout->connect(this);\r
-\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- m_pImpl->children[i]->getColorStream() << getColorStream(); \r
- }\r
- }\r
-//}}}\r
-//{{{ destructor\r
- Container::~Container()\r
- {\r
- }\r
-//}}}\r
-//{{{ update\r
- void Container::update( )\r
- {\r
- m_positionStream.update( );\r
- m_sizeStream.update( );\r
- m_colorStream.update( );\r
- foreach(shared_ptr<WidgetView> value , m_pImpl->children)\r
- {\r
- value->update();\r
- }\r
- }\r
-//}}}\r
-//{{{ draw\r
- void Container::draw( ) const\r
- {\r
- foreach(shared_ptr<WidgetView> value , m_pImpl->children)\r
- {\r
- value->draw();\r
- }\r
-\r
- }\r
-//}}}\r
-//{{{ show\r
- FrameNumber Container::show(bool imidiately) \r
- {\r
- unsigned int maxFrame = 0;\r
- foreach(shared_ptr<WidgetView> value , m_pImpl->children)\r
- {\r
- maxFrame = max(value->show(imidiately) , maxFrame);\r
- }\r
- return maxFrame;\r
- }\r
-//}}}\r
-//{{{ hide\r
- FrameNumber Container::hide(bool imidiately)\r
- {\r
- unsigned int maxFrame = 0;\r
- foreach(shared_ptr<WidgetView> value , m_pImpl->children)\r
- {\r
- maxFrame = max(value->hide(imidiately) , maxFrame);\r
- }\r
- return maxFrame;\r
-\r
- }\r
-//}}}\r
-//{{{ focus\r
- FrameNumber Container::focus(bool) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ blur\r
- FrameNumber Container::blur(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ click\r
- FrameNumber Container::click(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ getAt\r
- shared_ptr<WidgetView> Container::getAt(int index) const\r
- {\r
- return m_pImpl->children[index];\r
- }\r
-//}}}\r
-//{{{ getLength\r
- int Container::getLength() const\r
- {\r
- return m_pImpl->children.size();\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsUp\r
- int Container::getAdjacencyAsUp(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsUp(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsDown\r
- int Container::getAdjacencyAsDown(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsDown(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsLeft\r
- int Container::getAdjacencyAsLeft(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsLeft(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsRight\r
- int Container::getAdjacencyAsRight(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsRight(index);\r
- }\r
-//}}}\r
-//{{{ add\r
- void Container::add(shared_ptr<WidgetView> pView)\r
- {\r
- //children.push_back( pView ); \r
- //m_pImpl->pLayout = adaptWidgetViewAndLayout( m_pImpl->children.begin( ) , m_pImpl->children.end( ) , layout);\r
- }\r
-//}}}\r
-\r
-}\r
-} // namespace mof\r
+#include <mof/widget/Container.hpp>
+#include "mof/mofGraphics.hpp"
+#include "mof/utilities.hpp"
+#include "mof/widgets.hpp"
+#include "mof/streams.hpp"
+#include <vector>
+#include <algorithm>
+#include <memory>
+#include <boost/shared_ptr.hpp>
+
+using std::auto_ptr;
+using boost::shared_ptr;
+
+namespace mof
+{
+namespace widget
+{
+//{{{ struct Impl
+ struct Container::Impl
+ {
+ std::vector< shared_ptr<WidgetView> > children;
+ auto_ptr<Layout> pLayout;
+
+
+ Impl() : pLayout(NULL){}
+ ~Impl(){}
+
+ };
+//}}}
+//{{{ constructor
+ Container::Container
+ (
+ const shared_ptr<WidgetView>& front ,
+ const shared_ptr<WidgetView>& back ,
+ const FactoryMethod<Layout>& layout
+ )
+ :
+ m_pImpl( new Impl( ) )
+ {
+
+ int length = (&back - &front) +1;
+ for(int i = 0 ; i < length ; i++)
+ {
+ m_pImpl->children.push_back( (&front)[i] );
+ }
+
+ m_pImpl->pLayout = auto_ptr<Layout>( layout() );
+ foreach(shared_ptr<WidgetView> pView , m_pImpl->children)
+ {
+ m_pImpl->pLayout->add(pView);
+ }
+ DEBUG_PRINT( m_pImpl->pLayout->getPreferredSize());
+ m_sizeStream << m_pImpl->pLayout->getPreferredSize();
+ m_pImpl->pLayout->connect(this);
+
+ for(int i = 0 ; i < length ; i++)
+ {
+ m_pImpl->children[i]->getColorStream() << getColorStream();
+ }
+ }
+//}}}
+//{{{ destructor
+ Container::~Container()
+ {
+ }
+//}}}
+//{{{ update
+ void Container::update( )
+ {
+ m_positionStream.update( );
+ m_sizeStream.update( );
+ m_colorStream.update( );
+ foreach(shared_ptr<WidgetView> value , m_pImpl->children)
+ {
+ value->update();
+ }
+ }
+//}}}
+//{{{ draw
+ void Container::draw( ) const
+ {
+ foreach(shared_ptr<WidgetView> value , m_pImpl->children)
+ {
+ value->draw();
+ }
+
+ }
+//}}}
+//{{{ show
+ FrameNumber Container::show(bool imidiately)
+ {
+ unsigned int maxFrame = 0;
+ foreach(shared_ptr<WidgetView> value , m_pImpl->children)
+ {
+ maxFrame = max(value->show(imidiately) , maxFrame);
+ }
+ return maxFrame;
+ }
+//}}}
+//{{{ hide
+ FrameNumber Container::hide(bool imidiately)
+ {
+ unsigned int maxFrame = 0;
+ foreach(shared_ptr<WidgetView> value , m_pImpl->children)
+ {
+ maxFrame = max(value->hide(imidiately) , maxFrame);
+ }
+ return maxFrame;
+
+ }
+//}}}
+//{{{ focus
+ FrameNumber Container::focus(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ blur
+ FrameNumber Container::blur(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ click
+ FrameNumber Container::click(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ getAt
+ shared_ptr<WidgetView> Container::getAt(int index) const
+ {
+ return m_pImpl->children[index];
+ }
+//}}}
+//{{{ getLength
+ int Container::getLength() const
+ {
+ return m_pImpl->children.size();
+ }
+//}}}
+//{{{ getAdjacentAsUp
+ int Container::getAdjacencyAsUp(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsUp(index);
+ }
+//}}}
+//{{{ getAdjacentAsDown
+ int Container::getAdjacencyAsDown(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsDown(index);
+ }
+//}}}
+//{{{ getAdjacentAsLeft
+ int Container::getAdjacencyAsLeft(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsLeft(index);
+ }
+//}}}
+//{{{ getAdjacentAsRight
+ int Container::getAdjacencyAsRight(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsRight(index);
+ }
+//}}}
+//{{{ add
+ void Container::add(shared_ptr<WidgetView> pView)
+ {
+ //children.push_back( pView );
+ //m_pImpl->pLayout = adaptWidgetViewAndLayout( m_pImpl->children.begin( ) , m_pImpl->children.end( ) , layout);
+ }
+//}}}
+
+}
+} // namespace mof
-#pragma once\r
-#include "mof/widget/WidgetView.hpp"\r
-#include <mof/widget/Layout.hpp>\r
-#include "mof/FactoryMethod.hpp"\r
-#include "mof/graphics/utilities.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-\r
-namespace widget\r
-{\r
-\r
- class Container\r
- : \r
- public WidgetView\r
- {\r
- public:\r
- \r
- Container\r
- (\r
- const boost::shared_ptr<WidgetView>& front ,\r
- const boost::shared_ptr<WidgetView>& back ,\r
- const FactoryMethod<Layout>& layout\r
- );\r
- virtual ~Container( );\r
-\r
- virtual FrameNumber show( bool imidiately = false );\r
- virtual FrameNumber hide( bool imidiately = false );\r
- virtual FrameNumber focus( bool imidiately = false );\r
- virtual FrameNumber blur( bool imidiately = false );\r
- virtual FrameNumber click( bool imidiately = false );\r
- virtual void update( );\r
- virtual void draw( ) const;\r
- boost::shared_ptr<WidgetView> getAt(int index) const;\r
- int getLength() const;\r
- int getAdjacencyAsUp(int index) const;\r
- int getAdjacencyAsDown(int index) const;\r
- int getAdjacencyAsLeft(int index) const;\r
- int getAdjacencyAsRight(int index) const;\r
- void add(boost::shared_ptr<WidgetView> pView);\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- };\r
-\r
-}\r
-}\r
+#pragma once
+#include "mof/widget/WidgetView.hpp"
+#include <mof/widget/Layout.hpp>
+#include "mof/FactoryMethod.hpp"
+#include "mof/graphics/utilities.hpp"
+#include "mof/tstring.hpp"
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+
+
+
+namespace mof
+{
+ class Font;
+
+namespace widget
+{
+
+ class Container
+ :
+ public WidgetView
+ {
+ public:
+
+ Container
+ (
+ const boost::shared_ptr<WidgetView>& front ,
+ const boost::shared_ptr<WidgetView>& back ,
+ const FactoryMethod<Layout>& layout
+ );
+ virtual ~Container( );
+
+ virtual FrameNumber show( bool imidiately = false );
+ virtual FrameNumber hide( bool imidiately = false );
+ virtual FrameNumber focus( bool imidiately = false );
+ virtual FrameNumber blur( bool imidiately = false );
+ virtual FrameNumber click( bool imidiately = false );
+ virtual void update( );
+ virtual void draw( ) const;
+ boost::shared_ptr<WidgetView> getAt(int index) const;
+ int getLength() const;
+ int getAdjacencyAsUp(int index) const;
+ int getAdjacencyAsDown(int index) const;
+ int getAdjacencyAsLeft(int index) const;
+ int getAdjacencyAsRight(int index) const;
+ void add(boost::shared_ptr<WidgetView> pView);
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+}
+}
-#pragma once\r
-#include "mof/widget/WidgetView.hpp"\r
-#include <mof/widget/Layout.hpp>\r
-#include "mof/FactoryMethod.hpp"\r
-#include "mof/graphics/utilities.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-\r
-namespace widget\r
-{\r
-\r
- class Container\r
- : \r
- public WidgetView\r
- {\r
- public:\r
- \r
- Container\r
- (\r
- boost::shared_ptr<WidgetView> pTop ,\r
- const FactoryMethod<WidgetView>& last ,\r
- const FactoryMethod<Layout>& layout\r
- );\r
- virtual ~Container( );\r
-\r
- virtual FrameNumber show( bool imidiately = false );\r
- virtual FrameNumber hide( bool imidiately = false );\r
- virtual FrameNumber focus( bool imidiately = false );\r
- virtual FrameNumber blur( bool imidiately = false );\r
- virtual FrameNumber click( bool imidiately = false );\r
- virtual void update( );\r
- virtual void draw( ) const;\r
- boost::shared_ptr<WidgetView> getAt(int index) const;\r
- int getLength() const;\r
- int getAdjacencyAsUp(int index) const;\r
- int getAdjacencyAsDown(int index) const;\r
- int getAdjacencyAsLeft(int index) const;\r
- int getAdjacencyAsRight(int index) const;\r
- void add(boost::shared_ptr<WidgetView> pView);\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- };\r
-\r
-}\r
-}\r
+#pragma once
+#include "mof/widget/WidgetView.hpp"
+#include <mof/widget/Layout.hpp>
+#include "mof/FactoryMethod.hpp"
+#include "mof/graphics/utilities.hpp"
+#include "mof/tstring.hpp"
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+
+
+
+namespace mof
+{
+ class Font;
+
+namespace widget
+{
+
+ class Container
+ :
+ public WidgetView
+ {
+ public:
+
+ Container
+ (
+ boost::shared_ptr<WidgetView> pTop ,
+ const FactoryMethod<WidgetView>& last ,
+ const FactoryMethod<Layout>& layout
+ );
+ virtual ~Container( );
+
+ virtual FrameNumber show( bool imidiately = false );
+ virtual FrameNumber hide( bool imidiately = false );
+ virtual FrameNumber focus( bool imidiately = false );
+ virtual FrameNumber blur( bool imidiately = false );
+ virtual FrameNumber click( bool imidiately = false );
+ virtual void update( );
+ virtual void draw( ) const;
+ boost::shared_ptr<WidgetView> getAt(int index) const;
+ int getLength() const;
+ int getAdjacencyAsUp(int index) const;
+ int getAdjacencyAsDown(int index) const;
+ int getAdjacencyAsLeft(int index) const;
+ int getAdjacencyAsRight(int index) const;
+ void add(boost::shared_ptr<WidgetView> pView);
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+}
+}
-#include <mof/widget/ContainerWidgetView.hpp>\r
-#include "mof/mofGraphics.hpp"\r
-#include <mof/adaptWidgetViewAndLayout.hpp>\r
-#include "mof/utilities.hpp"\r
-#include "mof/widgets.hpp"\r
-#include "mof/streams.hpp"\r
-#include <vector>\r
-#include <algorithm>\r
- \r
-namespace mof\r
-{\r
-//{{{ struct Impl\r
- struct ContainerWidgetView::Impl\r
- {\r
- std::vector<WidgetView*> children;\r
- mof::Layout* pLayout;\r
- \r
- Impl() : pLayout(NULL){}\r
- ~Impl(){}\r
- \r
- };\r
-//}}}\r
-//{{{ constructor\r
- ContainerWidgetView::ContainerWidgetView\r
- (\r
- const FactoryMethod<WidgetView>& front ,\r
- const FactoryMethod<WidgetView>& last ,\r
- const FactoryMethod<Layout>& layout\r
- )\r
- : \r
- m_pImpl( new Impl( ) ) \r
- {\r
- \r
- int length = (&last - &front) +1;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- m_pImpl->children.push_back((&front)[i]());\r
- }\r
-\r
- m_pImpl->pLayout = adaptWidgetViewAndLayout(m_pImpl->children , layout);\r
- m_sizeStream << m_pImpl->pLayout->getBounds();\r
-\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- m_pImpl->children[i]->getPositionStream() << getPositionStream(); \r
- m_pImpl->children[i]->getColorStream() << getColorStream(); \r
- }\r
- }\r
-//}}}\r
-//{{{ destructor\r
- ContainerWidgetView::~ContainerWidgetView()\r
- {\r
- foreach(WidgetView* value , m_pImpl->children)\r
- {\r
- delete value;\r
- }\r
- }\r
-//}}}\r
-//{{{ update\r
- void ContainerWidgetView::update( )\r
- {\r
- m_positionStream.update( );\r
- m_sizeStream.update( );\r
- m_colorStream.update( );\r
- foreach(WidgetView* value , m_pImpl->children)\r
- {\r
- value->update();\r
- }\r
- }\r
-//}}}\r
-//{{{ draw\r
- void ContainerWidgetView::draw( ) const\r
- {\r
- foreach(WidgetView* value , m_pImpl->children)\r
- {\r
- value->draw();\r
- }\r
-\r
- }\r
-//}}}\r
-//{{{ show\r
- FrameNumber ContainerWidgetView::show(bool imidiately) \r
- {\r
- unsigned int maxFrame = 0;\r
- foreach(WidgetView* value , m_pImpl->children)\r
- {\r
- maxFrame = max(value->show(imidiately) , maxFrame);\r
- }\r
- return maxFrame;\r
- }\r
-//}}}\r
-//{{{ hide\r
- FrameNumber ContainerWidgetView::hide(bool imidiately)\r
- {\r
- int maxFrame = 0;\r
- foreach(WidgetView* value , m_pImpl->children)\r
- {\r
- maxFrame = max(value->hide(imidiately) , maxFrame);\r
- }\r
- return maxFrame;\r
-\r
- }\r
-//}}}\r
-//{{{ focus\r
- FrameNumber ContainerWidgetView::focus(bool) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ blur\r
- FrameNumber ContainerWidgetView::blur(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ click\r
- FrameNumber ContainerWidgetView::click(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ getAt\r
- WidgetView* ContainerWidgetView::getAt(int index) const\r
- {\r
- return m_pImpl->children[index];\r
- }\r
-//}}}\r
-//{{{ getLength\r
- int ContainerWidgetView::getLength() const\r
- {\r
- return m_pImpl->children.size();\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsUp\r
- int ContainerWidgetView::getAdjacencyAsUp(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsUp(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsDown\r
- int ContainerWidgetView::getAdjacencyAsDown(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsDown(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsLeft\r
- int ContainerWidgetView::getAdjacencyAsLeft(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsLeft(index);\r
- }\r
-//}}}\r
-//{{{ getAdjacentAsRight\r
- int ContainerWidgetView::getAdjacencyAsRight(int index) const\r
- {\r
- return m_pImpl->pLayout->getAdjacencyAsRight(index);\r
- }\r
-//}}}\r
-\r
-\r
-} // namespace mof\r
+#include <mof/widget/ContainerWidgetView.hpp>
+#include "mof/mofGraphics.hpp"
+#include <mof/adaptWidgetViewAndLayout.hpp>
+#include "mof/utilities.hpp"
+#include "mof/widgets.hpp"
+#include "mof/streams.hpp"
+#include <vector>
+#include <algorithm>
+
+namespace mof
+{
+//{{{ struct Impl
+ struct ContainerWidgetView::Impl
+ {
+ std::vector<WidgetView*> children;
+ mof::Layout* pLayout;
+
+ Impl() : pLayout(NULL){}
+ ~Impl(){}
+
+ };
+//}}}
+//{{{ constructor
+ ContainerWidgetView::ContainerWidgetView
+ (
+ const FactoryMethod<WidgetView>& front ,
+ const FactoryMethod<WidgetView>& last ,
+ const FactoryMethod<Layout>& layout
+ )
+ :
+ m_pImpl( new Impl( ) )
+ {
+
+ int length = (&last - &front) +1;
+ for(int i = 0 ; i < length ; i++)
+ {
+ m_pImpl->children.push_back((&front)[i]());
+ }
+
+ m_pImpl->pLayout = adaptWidgetViewAndLayout(m_pImpl->children , layout);
+ m_sizeStream << m_pImpl->pLayout->getBounds();
+
+ for(int i = 0 ; i < length ; i++)
+ {
+ m_pImpl->children[i]->getPositionStream() << getPositionStream();
+ m_pImpl->children[i]->getColorStream() << getColorStream();
+ }
+ }
+//}}}
+//{{{ destructor
+ ContainerWidgetView::~ContainerWidgetView()
+ {
+ foreach(WidgetView* value , m_pImpl->children)
+ {
+ delete value;
+ }
+ }
+//}}}
+//{{{ update
+ void ContainerWidgetView::update( )
+ {
+ m_positionStream.update( );
+ m_sizeStream.update( );
+ m_colorStream.update( );
+ foreach(WidgetView* value , m_pImpl->children)
+ {
+ value->update();
+ }
+ }
+//}}}
+//{{{ draw
+ void ContainerWidgetView::draw( ) const
+ {
+ foreach(WidgetView* value , m_pImpl->children)
+ {
+ value->draw();
+ }
+
+ }
+//}}}
+//{{{ show
+ FrameNumber ContainerWidgetView::show(bool imidiately)
+ {
+ unsigned int maxFrame = 0;
+ foreach(WidgetView* value , m_pImpl->children)
+ {
+ maxFrame = max(value->show(imidiately) , maxFrame);
+ }
+ return maxFrame;
+ }
+//}}}
+//{{{ hide
+ FrameNumber ContainerWidgetView::hide(bool imidiately)
+ {
+ int maxFrame = 0;
+ foreach(WidgetView* value , m_pImpl->children)
+ {
+ maxFrame = max(value->hide(imidiately) , maxFrame);
+ }
+ return maxFrame;
+
+ }
+//}}}
+//{{{ focus
+ FrameNumber ContainerWidgetView::focus(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ blur
+ FrameNumber ContainerWidgetView::blur(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ click
+ FrameNumber ContainerWidgetView::click(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ getAt
+ WidgetView* ContainerWidgetView::getAt(int index) const
+ {
+ return m_pImpl->children[index];
+ }
+//}}}
+//{{{ getLength
+ int ContainerWidgetView::getLength() const
+ {
+ return m_pImpl->children.size();
+ }
+//}}}
+//{{{ getAdjacentAsUp
+ int ContainerWidgetView::getAdjacencyAsUp(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsUp(index);
+ }
+//}}}
+//{{{ getAdjacentAsDown
+ int ContainerWidgetView::getAdjacencyAsDown(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsDown(index);
+ }
+//}}}
+//{{{ getAdjacentAsLeft
+ int ContainerWidgetView::getAdjacencyAsLeft(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsLeft(index);
+ }
+//}}}
+//{{{ getAdjacentAsRight
+ int ContainerWidgetView::getAdjacencyAsRight(int index) const
+ {
+ return m_pImpl->pLayout->getAdjacencyAsRight(index);
+ }
+//}}}
+
+
+} // namespace mof
-#pragma once\r
-#include "mof/widget/WidgetView.hpp"\r
-#include <mof/widget/Layout.hpp>\r
-#include "mof/FactoryMethod.hpp"\r
-#include "mof/graphics/utilities.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-\r
- class ContainerWidgetView \r
- : \r
- public WidgetView\r
- {\r
- public:\r
- ContainerWidgetView\r
- (\r
- const FactoryMethod<WidgetView>& front ,\r
- const FactoryMethod<WidgetView>& last ,\r
- const FactoryMethod<Layout>& layout\r
- );\r
- virtual ~ContainerWidgetView( );\r
-\r
- virtual FrameNumber show( bool imidiately = false );\r
- virtual FrameNumber hide( bool imidiately = false );\r
- virtual FrameNumber focus( bool imidiately = false );\r
- virtual FrameNumber blur( bool imidiately = false );\r
- virtual void update( );\r
- virtual void draw( ) const;\r
- WidgetView* getAt(int index) const;\r
- int getLength() const;\r
- int getAdjacencyAsUp(int index) const;\r
- int getAdjacencyAsDown(int index) const;\r
- int getAdjacencyAsLeft(int index) const;\r
- int getAdjacencyAsRight(int index) const;\r
-\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- };\r
-\r
-}\r
+#pragma once
+#include "mof/widget/WidgetView.hpp"
+#include <mof/widget/Layout.hpp>
+#include "mof/FactoryMethod.hpp"
+#include "mof/graphics/utilities.hpp"
+#include "mof/tstring.hpp"
+#include <boost/scoped_ptr.hpp>
+
+namespace mof
+{
+ class Font;
+
+ class ContainerWidgetView
+ :
+ public WidgetView
+ {
+ public:
+ ContainerWidgetView
+ (
+ const FactoryMethod<WidgetView>& front ,
+ const FactoryMethod<WidgetView>& last ,
+ const FactoryMethod<Layout>& layout
+ );
+ virtual ~ContainerWidgetView( );
+
+ virtual FrameNumber show( bool imidiately = false );
+ virtual FrameNumber hide( bool imidiately = false );
+ virtual FrameNumber focus( bool imidiately = false );
+ virtual FrameNumber blur( bool imidiately = false );
+ virtual void update( );
+ virtual void draw( ) const;
+ WidgetView* getAt(int index) const;
+ int getLength() const;
+ int getAdjacencyAsUp(int index) const;
+ int getAdjacencyAsDown(int index) const;
+ int getAdjacencyAsLeft(int index) const;
+ int getAdjacencyAsRight(int index) const;
+
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+}
-#include "mof/widget/Effect.hpp"\r
-#include <map>\r
-#include "mof/Sprite.hpp"\r
-#include "mof/Drawable.hpp"\r
-#include "mof/utilities.hpp"\r
-#include <stdexcept>\r
-\r
-typedef std::map<mof::tstring , mof::Sprite*> SpriteMap;\r
-typedef std::pair<mof::tstring , mof::Sprite*> SpriteMapPair;\r
-typedef std::map<mof::tstring , mof::Drawable*> DrawableMap;\r
-typedef std::pair<mof::tstring , mof::Drawable*> DrawableMapPair;\r
-\r
-\r
-struct mof::Effect::Impl\r
-{\r
- SpriteMap spriteMap;\r
- DrawableMap drawableMap;\r
-\r
- Impl(){\r
-\r
- }\r
-\r
- ~Impl(){\r
- deleteAll();\r
- }\r
-\r
- void deleteAll(){\r
- foreach(DrawableMapPair pair , drawableMap){\r
- delete pair.second;\r
- }\r
- drawableMap.clear();\r
-\r
- foreach(SpriteMapPair pair , spriteMap){\r
- delete pair.second;\r
- }\r
- spriteMap.clear();\r
- }\r
-};\r
-\r
-\r
-mof::Effect::Effect()\r
-: m_pImpl(new Impl())\r
-{\r
-}\r
-\r
-mof::Effect::~Effect(){\r
-}\r
-\r
-mof::Sprite* mof::Effect::getSpriteByName(const mof::tstring &name) {\r
- SpriteMap::iterator result = m_pImpl->spriteMap.find(name);\r
- if(result == m_pImpl->spriteMap.end())throw std::invalid_argument(name + "is not exists");\r
- return result->second;\r
-}\r
-\r
-void mof::Effect::addSprite(const mof::tstring& name , mof::Sprite* pSprite){\r
- SpriteMap::iterator result = m_pImpl->spriteMap.find(name);\r
- if(result != m_pImpl->spriteMap.end())throw std::invalid_argument(name + "is already exists");\r
- m_pImpl->spriteMap.insert(SpriteMapPair(name , pSprite));\r
-}\r
- \r
-void mof::Effect::addDrawable( const mof::tstring& name , mof::Drawable* pDrawable )\r
-{\r
- DrawableMap::iterator result = m_pImpl->drawableMap.find(name);\r
- if(result != m_pImpl->drawableMap.end())throw std::invalid_argument(name + "is already exists");\r
- m_pImpl->drawableMap.insert(DrawableMapPair(name , pDrawable));\r
-}\r
-\r
-void mof::Effect::remove(const mof::tstring& name ){\r
- {\r
- SpriteMap::iterator result = m_pImpl->spriteMap.find(name);\r
- if(result != m_pImpl->spriteMap.end())\r
- {\r
- m_pImpl->spriteMap.erase(name);\r
- return;\r
- }\r
- }\r
- {\r
- DrawableMap::iterator result = m_pImpl->drawableMap.find(name);\r
- if(result != m_pImpl->drawableMap.end())\r
- {\r
- m_pImpl->drawableMap.erase(name);\r
- return;\r
- }\r
- }\r
- throw std::invalid_argument(name + "is not exists");\r
-}\r
-\r
-void mof::Effect::deleteAll(){\r
- m_pImpl->deleteAll();\r
-}\r
-\r
-void mof::Effect::draw() const\r
-{\r
- foreach(DrawableMapPair pair , m_pImpl->drawableMap){\r
- pair.second->draw();\r
- }\r
- foreach(SpriteMapPair pair , m_pImpl->spriteMap){\r
- pair.second->draw();\r
- }\r
-}\r
-\r
-\r
-void mof::Effect::update(){\r
- foreach(SpriteMapPair pair , m_pImpl->spriteMap){\r
- pair.second->update();\r
- }\r
-}\r
-\r
-\r
+#include "mof/widget/Effect.hpp"
+#include <map>
+#include "mof/Sprite.hpp"
+#include "mof/Drawable.hpp"
+#include "mof/utilities.hpp"
+#include <stdexcept>
+
+typedef std::map<mof::tstring , mof::Sprite*> SpriteMap;
+typedef std::pair<mof::tstring , mof::Sprite*> SpriteMapPair;
+typedef std::map<mof::tstring , mof::Drawable*> DrawableMap;
+typedef std::pair<mof::tstring , mof::Drawable*> DrawableMapPair;
+
+
+struct mof::Effect::Impl
+{
+ SpriteMap spriteMap;
+ DrawableMap drawableMap;
+
+ Impl(){
+
+ }
+
+ ~Impl(){
+ deleteAll();
+ }
+
+ void deleteAll(){
+ foreach(DrawableMapPair pair , drawableMap){
+ delete pair.second;
+ }
+ drawableMap.clear();
+
+ foreach(SpriteMapPair pair , spriteMap){
+ delete pair.second;
+ }
+ spriteMap.clear();
+ }
+};
+
+
+mof::Effect::Effect()
+: m_pImpl(new Impl())
+{
+}
+
+mof::Effect::~Effect(){
+}
+
+mof::Sprite* mof::Effect::getSpriteByName(const mof::tstring &name) {
+ SpriteMap::iterator result = m_pImpl->spriteMap.find(name);
+ if(result == m_pImpl->spriteMap.end())throw std::invalid_argument(name + "is not exists");
+ return result->second;
+}
+
+void mof::Effect::addSprite(const mof::tstring& name , mof::Sprite* pSprite){
+ SpriteMap::iterator result = m_pImpl->spriteMap.find(name);
+ if(result != m_pImpl->spriteMap.end())throw std::invalid_argument(name + "is already exists");
+ m_pImpl->spriteMap.insert(SpriteMapPair(name , pSprite));
+}
+
+void mof::Effect::addDrawable( const mof::tstring& name , mof::Drawable* pDrawable )
+{
+ DrawableMap::iterator result = m_pImpl->drawableMap.find(name);
+ if(result != m_pImpl->drawableMap.end())throw std::invalid_argument(name + "is already exists");
+ m_pImpl->drawableMap.insert(DrawableMapPair(name , pDrawable));
+}
+
+void mof::Effect::remove(const mof::tstring& name ){
+ {
+ SpriteMap::iterator result = m_pImpl->spriteMap.find(name);
+ if(result != m_pImpl->spriteMap.end())
+ {
+ m_pImpl->spriteMap.erase(name);
+ return;
+ }
+ }
+ {
+ DrawableMap::iterator result = m_pImpl->drawableMap.find(name);
+ if(result != m_pImpl->drawableMap.end())
+ {
+ m_pImpl->drawableMap.erase(name);
+ return;
+ }
+ }
+ throw std::invalid_argument(name + "is not exists");
+}
+
+void mof::Effect::deleteAll(){
+ m_pImpl->deleteAll();
+}
+
+void mof::Effect::draw() const
+{
+ foreach(DrawableMapPair pair , m_pImpl->drawableMap){
+ pair.second->draw();
+ }
+ foreach(SpriteMapPair pair , m_pImpl->spriteMap){
+ pair.second->draw();
+ }
+}
+
+
+void mof::Effect::update(){
+ foreach(SpriteMapPair pair , m_pImpl->spriteMap){
+ pair.second->update();
+ }
+}
+
+
-#include "mof/widget/Effect.hpp"\r
-#include <map>\r
-#include "mof/Sprite.hpp"\r
-#include "mof/Drawable.hpp"\r
-#include "mof/utilities.hpp"\r
-#include <stdexcept>\r
-\r
-typedef std::map<mof::tstring , mof::Sprite*> SpriteMap;\r
-typedef std::pair<mof::tstring , mof::Sprite*> SpriteMapPair;\r
-typedef std::map<mof::tstring , mof::Drawable*> DrawableMap;\r
-typedef std::pair<mof::tstring , mof::Drawable*> DrawableMapPair;\r
-\r
-\r
-struct mof::Effect::Impl\r
-{\r
- SpriteMap spriteMap;\r
- DrawableMap drawableMap;\r
-\r
- Impl(){\r
-\r
- }\r
-\r
- ~Impl(){\r
- deleteAll();\r
- }\r
-\r
- void deleteAll(){\r
- foreach(DrawableMapPair pair , drawableMap){\r
- delete pair.second;\r
- }\r
- drawableMap.clear();\r
-\r
- foreach(SpriteMapPair pair , spriteMap){\r
- delete pair.second;\r
- }\r
- spriteMap.clear();\r
- }\r
-};\r
-\r
-\r
-mof::Effect::Effect()\r
-: m_pImpl(new Impl())\r
-{\r
-}\r
-\r
-mof::Effect::~Effect(){\r
-}\r
-\r
-mof::Sprite* mof::Effect::getSpriteByName(const mof::tstring &name) {\r
- SpriteMap::iterator result = m_pImpl->spriteMap.find(name);\r
- if(result == m_pImpl->spriteMap.end())throw std::invalid_argument(name + "is not exists");\r
- return result->second;\r
-}\r
-\r
-void mof::Effect::addSprite(const mof::tstring& name , mof::Sprite* pSprite){\r
- SpriteMap::iterator result = m_pImpl->spriteMap.find(name);\r
- if(result != m_pImpl->spriteMap.end())throw std::invalid_argument(name + "is already exists");\r
- m_pImpl->spriteMap.insert(SpriteMapPair(name , pSprite));\r
-}\r
- \r
-void mof::Effect::addDrawable( const mof::tstring& name , mof::Drawable* pDrawable )\r
-{\r
- DrawableMap::iterator result = m_pImpl->drawableMap.find(name);\r
- if(result != m_pImpl->drawableMap.end())throw std::invalid_argument(name + "is already exists");\r
- m_pImpl->drawableMap.insert(DrawableMapPair(name , pDrawable));\r
-}\r
-\r
-void mof::Effect::remove(const mof::tstring& name ){\r
- {\r
- SpriteMap::iterator result = m_pImpl->spriteMap.find(name);\r
- if(result != m_pImpl->spriteMap.end())\r
- {\r
- m_pImpl->spriteMap.erase(name);\r
- return;\r
- }\r
- }\r
- {\r
- DrawableMap::iterator result = m_pImpl->drawableMap.find(name);\r
- if(result != m_pImpl->drawableMap.end())\r
- {\r
- m_pImpl->drawableMap.erase(name);\r
- return;\r
- }\r
- }\r
- throw std::invalid_argument(name + "is not exists");\r
-}\r
-\r
-void mof::Effect::deleteAll(){\r
- m_pImpl->deleteAll();\r
-}\r
-\r
-void mof::Effect::draw() const{\r
- foreach(DrawableMapPair pair , m_pImpl->drawableMap){\r
- pair.second->draw();\r
- }\r
- foreach(SpriteMapPair pair , m_pImpl->spriteMap){\r
- pair.second->draw();\r
- }\r
-}\r
-\r
-\r
-void mof::Effect::update(){\r
- foreach(SpriteMapPair pair , m_pImpl->spriteMap){\r
- pair.second->update();\r
- }\r
-}\r
-\r
-\r
+#include "mof/widget/Effect.hpp"
+#include <map>
+#include "mof/Sprite.hpp"
+#include "mof/Drawable.hpp"
+#include "mof/utilities.hpp"
+#include <stdexcept>
+
+typedef std::map<mof::tstring , mof::Sprite*> SpriteMap;
+typedef std::pair<mof::tstring , mof::Sprite*> SpriteMapPair;
+typedef std::map<mof::tstring , mof::Drawable*> DrawableMap;
+typedef std::pair<mof::tstring , mof::Drawable*> DrawableMapPair;
+
+
+struct mof::Effect::Impl
+{
+ SpriteMap spriteMap;
+ DrawableMap drawableMap;
+
+ Impl(){
+
+ }
+
+ ~Impl(){
+ deleteAll();
+ }
+
+ void deleteAll(){
+ foreach(DrawableMapPair pair , drawableMap){
+ delete pair.second;
+ }
+ drawableMap.clear();
+
+ foreach(SpriteMapPair pair , spriteMap){
+ delete pair.second;
+ }
+ spriteMap.clear();
+ }
+};
+
+
+mof::Effect::Effect()
+: m_pImpl(new Impl())
+{
+}
+
+mof::Effect::~Effect(){
+}
+
+mof::Sprite* mof::Effect::getSpriteByName(const mof::tstring &name) {
+ SpriteMap::iterator result = m_pImpl->spriteMap.find(name);
+ if(result == m_pImpl->spriteMap.end())throw std::invalid_argument(name + "is not exists");
+ return result->second;
+}
+
+void mof::Effect::addSprite(const mof::tstring& name , mof::Sprite* pSprite){
+ SpriteMap::iterator result = m_pImpl->spriteMap.find(name);
+ if(result != m_pImpl->spriteMap.end())throw std::invalid_argument(name + "is already exists");
+ m_pImpl->spriteMap.insert(SpriteMapPair(name , pSprite));
+}
+
+void mof::Effect::addDrawable( const mof::tstring& name , mof::Drawable* pDrawable )
+{
+ DrawableMap::iterator result = m_pImpl->drawableMap.find(name);
+ if(result != m_pImpl->drawableMap.end())throw std::invalid_argument(name + "is already exists");
+ m_pImpl->drawableMap.insert(DrawableMapPair(name , pDrawable));
+}
+
+void mof::Effect::remove(const mof::tstring& name ){
+ {
+ SpriteMap::iterator result = m_pImpl->spriteMap.find(name);
+ if(result != m_pImpl->spriteMap.end())
+ {
+ m_pImpl->spriteMap.erase(name);
+ return;
+ }
+ }
+ {
+ DrawableMap::iterator result = m_pImpl->drawableMap.find(name);
+ if(result != m_pImpl->drawableMap.end())
+ {
+ m_pImpl->drawableMap.erase(name);
+ return;
+ }
+ }
+ throw std::invalid_argument(name + "is not exists");
+}
+
+void mof::Effect::deleteAll(){
+ m_pImpl->deleteAll();
+}
+
+void mof::Effect::draw() const{
+ foreach(DrawableMapPair pair , m_pImpl->drawableMap){
+ pair.second->draw();
+ }
+ foreach(SpriteMapPair pair , m_pImpl->spriteMap){
+ pair.second->draw();
+ }
+}
+
+
+void mof::Effect::update(){
+ foreach(SpriteMapPair pair , m_pImpl->spriteMap){
+ pair.second->update();
+ }
+}
+
+
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/utility.hpp>\r
-#include "mof/tstring.hpp"\r
-\r
-namespace mof{\r
- class Sprite;\r
- class Drawable;\r
-\r
- class Effect : boost::noncopyable{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- public:\r
- Effect();\r
- ~Effect();\r
- mof::Sprite* getSpriteByName(const mof::tstring& name);\r
- void addSprite(const mof::tstring& name , mof::Sprite* pSprite);\r
- void addDrawable( const mof::tstring& name , mof::Drawable* pDrawable );\r
- void remove(const mof::tstring& name);\r
- void deleteAll();\r
-\r
- void draw() const;\r
- void update();\r
- };\r
-\r
- \r
-}\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <boost/utility.hpp>
+#include "mof/tstring.hpp"
+
+namespace mof{
+ class Sprite;
+ class Drawable;
+
+ class Effect : boost::noncopyable{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ public:
+ Effect();
+ ~Effect();
+ mof::Sprite* getSpriteByName(const mof::tstring& name);
+ void addSprite(const mof::tstring& name , mof::Sprite* pSprite);
+ void addDrawable( const mof::tstring& name , mof::Drawable* pDrawable );
+ void remove(const mof::tstring& name);
+ void deleteAll();
+
+ void draw() const;
+ void update();
+ };
+
+
+}
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/utility.hpp>\r
-#include "mof/tstring.hpp"\r
-\r
-namespace mof{\r
- class Sprite;\r
- class Drawable;\r
-\r
- class Effect : boost::noncopyable{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- public:\r
- Effect();\r
- ~Effect();\r
- mof::Sprite* getSpriteByName(const mof::tstring& name);\r
- void addSprite(const mof::tstring& name , mof::Sprite* pSprite);\r
- void addDrawable( const mof::tstring& name , mof::Drawable* pDrawable );\r
- void remove(const mof::tstring& name);\r
- void deleteAll();\r
-\r
- void draw() const;\r
- void update();\r
- };\r
-\r
- \r
-}\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <boost/utility.hpp>
+#include "mof/tstring.hpp"
+
+namespace mof{
+ class Sprite;
+ class Drawable;
+
+ class Effect : boost::noncopyable{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ public:
+ Effect();
+ ~Effect();
+ mof::Sprite* getSpriteByName(const mof::tstring& name);
+ void addSprite(const mof::tstring& name , mof::Sprite* pSprite);
+ void addDrawable( const mof::tstring& name , mof::Drawable* pDrawable );
+ void remove(const mof::tstring& name);
+ void deleteAll();
+
+ void draw() const;
+ void update();
+ };
+
+
+}
-#pragma once\r
-#include <mof/widget/Frame.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-#include <mof/widget/Container.hpp>\r
-#include <mof/widget/ImageView.hpp>\r
-#include <mof/widget/GridLayout.hpp>\r
-#include <mof/widget/OverlapLayout.hpp>\r
-#include <mof/utilities.hpp>\r
-#include <boost/make_shared.hpp>\r
-\r
-using namespace mof::widget;\r
-using boost::shared_ptr;\r
-using boost::make_shared;\r
-using mof::lastOf;\r
-using std::vector;\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-//{{{ Impl\r
- struct Frame::Impl\r
- {\r
- shared_ptr<WidgetView> pCaptionView; \r
- shared_ptr<WidgetView> pContentBackgroundView; \r
- shared_ptr<WidgetView> pTitleBackgroundView; \r
- shared_ptr<Container> pContainer; \r
-\r
- Impl()\r
- : \r
- pCaptionView( ) ,\r
- pContentBackgroundView( ) ,\r
- pContainer( )\r
- {}\r
- };\r
-//}}}\r
-//{{{ constructor\r
- Frame::Frame\r
- (\r
- const mof::tstring& caption , const mof::Font& font ,\r
- shared_ptr<WidgetView> pContentView ,\r
- const FactoryMethod<WidgetView>& contentBackground , \r
- const FactoryMethod<WidgetView>& titleBackground \r
- )\r
- : m_pImpl(new Impl)\r
- {\r
- m_pImpl->pCaptionView = make_shared<ImageView>( caption , font );\r
- m_pImpl->pContentBackgroundView = shared_ptr<WidgetView>( contentBackground( ) );\r
- m_pImpl->pTitleBackgroundView = shared_ptr<WidgetView>( titleBackground( ) );\r
- \r
- {\r
- shared_ptr<WidgetView> children[] = {\r
- m_pImpl->pTitleBackgroundView ,\r
- m_pImpl->pCaptionView ,\r
- };\r
- m_pImpl->pContainer = make_shared<Container>( \r
- children[0] ,\r
- lastOf( children ) ,\r
- makeFactoryMethod<OverlapLayout>( m_pImpl->pCaptionView->getSizeStream().value() )\r
- );\r
- }\r
-\r
- {\r
- shared_ptr<WidgetView> children[] = {\r
- m_pImpl->pContainer ,\r
- pContentView ,\r
- };\r
- m_pImpl->pContainer = make_shared<Container>( \r
- children[0] ,\r
- lastOf( children ) ,\r
- makeFactoryMethod<GridLayout>( GridLayout::VERTICAL , 0 , 10)\r
- );\r
- }\r
- \r
- {\r
- shared_ptr<WidgetView> children[] = {\r
- m_pImpl->pContentBackgroundView ,\r
- m_pImpl->pContainer ,\r
- };\r
- m_pImpl->pContainer = make_shared<Container>( \r
- children[0] ,\r
- lastOf( children ) ,\r
- makeFactoryMethod<OverlapLayout>( m_pImpl->pContainer->getSizeStream().value() )\r
- );\r
- }\r
-\r
- }\r
-//}}}\r
-//{{{ destructor\r
- Frame::~Frame()\r
- {\r
- }\r
-//}}}\r
-//{{{ show\r
- mof::FrameNumber Frame::show(bool imidiately)\r
- {\r
- return m_pImpl->pContainer->show(imidiately);\r
- }\r
-//}}}\r
-//{{{ hide\r
- mof::FrameNumber Frame::hide(bool imidiately)\r
- {\r
- return m_pImpl->pContainer->hide(imidiately);\r
- }\r
-//}}}\r
-//{{{ getView\r
- const boost::shared_ptr<WidgetView> Frame::getView( ) const\r
- {\r
- return m_pImpl->pContainer;\r
- }\r
-//}}}\r
-//{{{ getView\r
- boost::shared_ptr<WidgetView> Frame::getView( ) \r
- {\r
- return m_pImpl->pContainer;\r
- }\r
-//}}}\r
-//{{{ update\r
- void Frame::update()\r
- {\r
- m_pImpl->pContainer->update();\r
- }\r
-//}}}\r
-\r
-}\r
-}\r
+#pragma once
+#include <mof/widget/Frame.hpp>
+#include <mof/widget/Layout.hpp>
+#include <mof/widget/Container.hpp>
+#include <mof/widget/ImageView.hpp>
+#include <mof/widget/GridLayout.hpp>
+#include <mof/widget/OverlapLayout.hpp>
+#include <mof/utilities.hpp>
+#include <boost/make_shared.hpp>
+
+using namespace mof::widget;
+using boost::shared_ptr;
+using boost::make_shared;
+using mof::lastOf;
+using std::vector;
+
+namespace mof
+{
+namespace widget
+{
+//{{{ Impl
+ struct Frame::Impl
+ {
+ shared_ptr<WidgetView> pCaptionView;
+ shared_ptr<WidgetView> pContentBackgroundView;
+ shared_ptr<WidgetView> pTitleBackgroundView;
+ shared_ptr<Container> pContainer;
+
+ Impl()
+ :
+ pCaptionView( ) ,
+ pContentBackgroundView( ) ,
+ pContainer( )
+ {}
+ };
+//}}}
+//{{{ constructor
+ Frame::Frame
+ (
+ const mof::tstring& caption , const mof::Font& font ,
+ shared_ptr<WidgetView> pContentView ,
+ const FactoryMethod<WidgetView>& contentBackground ,
+ const FactoryMethod<WidgetView>& titleBackground
+ )
+ : m_pImpl(new Impl)
+ {
+ m_pImpl->pCaptionView = make_shared<ImageView>( caption , font );
+ m_pImpl->pContentBackgroundView = shared_ptr<WidgetView>( contentBackground( ) );
+ m_pImpl->pTitleBackgroundView = shared_ptr<WidgetView>( titleBackground( ) );
+
+ {
+ shared_ptr<WidgetView> children[] = {
+ m_pImpl->pTitleBackgroundView ,
+ m_pImpl->pCaptionView ,
+ };
+ m_pImpl->pContainer = make_shared<Container>(
+ children[0] ,
+ lastOf( children ) ,
+ makeFactoryMethod<OverlapLayout>( m_pImpl->pCaptionView->getSizeStream().value() )
+ );
+ }
+
+ {
+ shared_ptr<WidgetView> children[] = {
+ m_pImpl->pContainer ,
+ pContentView ,
+ };
+ m_pImpl->pContainer = make_shared<Container>(
+ children[0] ,
+ lastOf( children ) ,
+ makeFactoryMethod<GridLayout>( GridLayout::VERTICAL , 0 , 10)
+ );
+ }
+
+ {
+ shared_ptr<WidgetView> children[] = {
+ m_pImpl->pContentBackgroundView ,
+ m_pImpl->pContainer ,
+ };
+ m_pImpl->pContainer = make_shared<Container>(
+ children[0] ,
+ lastOf( children ) ,
+ makeFactoryMethod<OverlapLayout>( m_pImpl->pContainer->getSizeStream().value() )
+ );
+ }
+
+ }
+//}}}
+//{{{ destructor
+ Frame::~Frame()
+ {
+ }
+//}}}
+//{{{ show
+ mof::FrameNumber Frame::show(bool imidiately)
+ {
+ return m_pImpl->pContainer->show(imidiately);
+ }
+//}}}
+//{{{ hide
+ mof::FrameNumber Frame::hide(bool imidiately)
+ {
+ return m_pImpl->pContainer->hide(imidiately);
+ }
+//}}}
+//{{{ getView
+ const boost::shared_ptr<WidgetView> Frame::getView( ) const
+ {
+ return m_pImpl->pContainer;
+ }
+//}}}
+//{{{ getView
+ boost::shared_ptr<WidgetView> Frame::getView( )
+ {
+ return m_pImpl->pContainer;
+ }
+//}}}
+//{{{ update
+ void Frame::update()
+ {
+ m_pImpl->pContainer->update();
+ }
+//}}}
+
+}
+}
-#pragma once\r
-#include <mof/widget/Frame.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-#include <mof/widget/Container.hpp>\r
-#include <mof/widget/ImageView.hpp>\r
-#include <mof/widget/GridLayout.hpp>\r
-#include <mof/widget/OverlapLayout.hpp>\r
-#include <mof/utilities.hpp>\r
-#include <boost/make_shared.hpp>\r
-\r
-using namespace mof::widget;\r
-using boost::shared_ptr;\r
-using boost::make_shared;\r
-using mof::lastOf;\r
-using std::vector;\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-//{{{ Impl\r
- struct Frame::Impl\r
- {\r
- shared_ptr<WidgetView> pCaptionView; \r
- shared_ptr<WidgetView> pContentBackgroundView; \r
- shared_ptr<WidgetView> pTitleBackgroundView; \r
- shared_ptr<Container> pContainer; \r
-\r
- Impl()\r
- : \r
- pCaptionView( ) ,\r
- pContentBackgroundView( ) ,\r
- pContainer( )\r
- {}\r
- };\r
-//}}}\r
-//{{{ constructor\r
- Frame::Frame\r
- (\r
- const mof::tstring& caption , const mof::Font& font ,\r
- shared_ptr<WidgetView> pContentView ,\r
- const FactoryMethod<WidgetView>& contentBackground , \r
- const FactoryMethod<WidgetView>& titleBackground \r
- )\r
- : m_pImpl(new Impl)\r
- {\r
- m_pImpl->pCaptionView = make_shared<ImageView>( caption , font );\r
- m_pImpl->pContentBackgroundView = shared_ptr<WidgetView>( contentBackground( ) );\r
- m_pImpl->pTitleBackgroundView = shared_ptr<WidgetView>( titleBackground( ) );\r
- \r
- {\r
- shared_ptr<WidgetView> children[] = {\r
- m_pImpl->pTitleBackgroundView ,\r
- m_pImpl->pCaptionView ,\r
- };\r
- m_pImpl->pContainer = make_shared<Container>( \r
- children[0] ,\r
- lastOf( children ) ,\r
- makeFactoryMethod<OverlapLayout>( m_pImpl->pCaptionView->getSizeStream().value() )\r
- );\r
- }\r
-\r
- {\r
- shared_ptr<WidgetView> children[] = {\r
- m_pImpl->pContainer ,\r
- pContentView ,\r
- };\r
- m_pImpl->pContainer = make_shared<Container>( \r
- children[0] ,\r
- lastOf( children ) ,\r
- makeFactoryMethod<GridLayout>( GridLayout::VERTICAL , 0 , 20)\r
- );\r
- }\r
- \r
- {\r
- shared_ptr<WidgetView> children[] = {\r
- m_pImpl->pContentBackgroundView ,\r
- m_pImpl->pContainer ,\r
- };\r
- m_pImpl->pContainer = make_shared<Container>( \r
- children[0] ,\r
- lastOf( children ) ,\r
- makeFactoryMethod<OverlapLayout>( m_pImpl->pContainer->getSizeStream().value() )\r
- );\r
- }\r
-\r
- }\r
-//}}}\r
-//{{{ destructor\r
- Frame::~Frame()\r
- {\r
- }\r
-//}}}\r
-//{{{ show\r
- mof::FrameNumber Frame::show(bool imidiately)\r
- {\r
- return m_pImpl->pContainer->show(imidiately);\r
- }\r
-//}}}\r
-//{{{ hide\r
- mof::FrameNumber Frame::hide(bool imidiately)\r
- {\r
- return m_pImpl->pContainer->hide(imidiately);\r
- }\r
-//}}}\r
-//{{{ getView\r
- const boost::shared_ptr<WidgetView> Frame::getView( ) const\r
- {\r
- return m_pImpl->pContainer;\r
- }\r
-//}}}\r
-//{{{ getView\r
- boost::shared_ptr<WidgetView> Frame::getView( ) \r
- {\r
- return m_pImpl->pContainer;\r
- }\r
-//}}}\r
-//{{{ update\r
- void Frame::update()\r
- {\r
- m_pImpl->pContainer->update();\r
- }\r
-//}}}\r
-\r
-}\r
-}\r
+#pragma once
+#include <mof/widget/Frame.hpp>
+#include <mof/widget/Layout.hpp>
+#include <mof/widget/Container.hpp>
+#include <mof/widget/ImageView.hpp>
+#include <mof/widget/GridLayout.hpp>
+#include <mof/widget/OverlapLayout.hpp>
+#include <mof/utilities.hpp>
+#include <boost/make_shared.hpp>
+
+using namespace mof::widget;
+using boost::shared_ptr;
+using boost::make_shared;
+using mof::lastOf;
+using std::vector;
+
+namespace mof
+{
+namespace widget
+{
+//{{{ Impl
+ struct Frame::Impl
+ {
+ shared_ptr<WidgetView> pCaptionView;
+ shared_ptr<WidgetView> pContentBackgroundView;
+ shared_ptr<WidgetView> pTitleBackgroundView;
+ shared_ptr<Container> pContainer;
+
+ Impl()
+ :
+ pCaptionView( ) ,
+ pContentBackgroundView( ) ,
+ pContainer( )
+ {}
+ };
+//}}}
+//{{{ constructor
+ Frame::Frame
+ (
+ const mof::tstring& caption , const mof::Font& font ,
+ shared_ptr<WidgetView> pContentView ,
+ const FactoryMethod<WidgetView>& contentBackground ,
+ const FactoryMethod<WidgetView>& titleBackground
+ )
+ : m_pImpl(new Impl)
+ {
+ m_pImpl->pCaptionView = make_shared<ImageView>( caption , font );
+ m_pImpl->pContentBackgroundView = shared_ptr<WidgetView>( contentBackground( ) );
+ m_pImpl->pTitleBackgroundView = shared_ptr<WidgetView>( titleBackground( ) );
+
+ {
+ shared_ptr<WidgetView> children[] = {
+ m_pImpl->pTitleBackgroundView ,
+ m_pImpl->pCaptionView ,
+ };
+ m_pImpl->pContainer = make_shared<Container>(
+ children[0] ,
+ lastOf( children ) ,
+ makeFactoryMethod<OverlapLayout>( m_pImpl->pCaptionView->getSizeStream().value() )
+ );
+ }
+
+ {
+ shared_ptr<WidgetView> children[] = {
+ m_pImpl->pContainer ,
+ pContentView ,
+ };
+ m_pImpl->pContainer = make_shared<Container>(
+ children[0] ,
+ lastOf( children ) ,
+ makeFactoryMethod<GridLayout>( GridLayout::VERTICAL , 0 , 20)
+ );
+ }
+
+ {
+ shared_ptr<WidgetView> children[] = {
+ m_pImpl->pContentBackgroundView ,
+ m_pImpl->pContainer ,
+ };
+ m_pImpl->pContainer = make_shared<Container>(
+ children[0] ,
+ lastOf( children ) ,
+ makeFactoryMethod<OverlapLayout>( m_pImpl->pContainer->getSizeStream().value() )
+ );
+ }
+
+ }
+//}}}
+//{{{ destructor
+ Frame::~Frame()
+ {
+ }
+//}}}
+//{{{ show
+ mof::FrameNumber Frame::show(bool imidiately)
+ {
+ return m_pImpl->pContainer->show(imidiately);
+ }
+//}}}
+//{{{ hide
+ mof::FrameNumber Frame::hide(bool imidiately)
+ {
+ return m_pImpl->pContainer->hide(imidiately);
+ }
+//}}}
+//{{{ getView
+ const boost::shared_ptr<WidgetView> Frame::getView( ) const
+ {
+ return m_pImpl->pContainer;
+ }
+//}}}
+//{{{ getView
+ boost::shared_ptr<WidgetView> Frame::getView( )
+ {
+ return m_pImpl->pContainer;
+ }
+//}}}
+//{{{ update
+ void Frame::update()
+ {
+ m_pImpl->pContainer->update();
+ }
+//}}}
+
+}
+}
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-#include <mof/widget/Widget.hpp>\r
-#include <mof/FactoryMethod.hpp>\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-\r
-namespace widget\r
-{\r
-\r
- class Frame : public Widget\r
- {\r
- public:\r
- Frame\r
- (\r
- const tstring& title ,\r
- const Font& font ,\r
- boost::shared_ptr<WidgetView> content ,\r
- const FactoryMethod<WidgetView>& contentBackground ,\r
- const FactoryMethod<WidgetView>& titleBackground \r
- );\r
-\r
- virtual ~Frame();\r
- virtual FrameNumber show(bool imidiately = false);\r
- virtual FrameNumber hide(bool imidiately = false);\r
- virtual const boost::shared_ptr<WidgetView> getView( ) const;\r
- virtual boost::shared_ptr<WidgetView> getView( );\r
- virtual void update();\r
-\r
-\r
- \r
- protected:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
- };\r
-\r
-\r
-} // namespace widget\r
-} // namespace mof\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+#include <mof/widget/Widget.hpp>
+#include <mof/FactoryMethod.hpp>
+
+namespace mof
+{
+ class Font;
+
+namespace widget
+{
+
+ class Frame : public Widget
+ {
+ public:
+ Frame
+ (
+ const tstring& title ,
+ const Font& font ,
+ boost::shared_ptr<WidgetView> content ,
+ const FactoryMethod<WidgetView>& contentBackground ,
+ const FactoryMethod<WidgetView>& titleBackground
+ );
+
+ virtual ~Frame();
+ virtual FrameNumber show(bool imidiately = false);
+ virtual FrameNumber hide(bool imidiately = false);
+ virtual const boost::shared_ptr<WidgetView> getView( ) const;
+ virtual boost::shared_ptr<WidgetView> getView( );
+ virtual void update();
+
+
+
+ protected:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+
+} // namespace widget
+} // namespace mof
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-#include <mof/widget/Widget.hpp>\r
-#include <mof/FactoryMethod.hpp>\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-\r
-namespace widget\r
-{\r
-\r
- class Frame : public Widget\r
- {\r
- public:\r
- Frame\r
- (\r
- const tstring& title ,\r
- const Font& font ,\r
- boost::shared_ptr<Widget> content ,\r
- const FactoryMethod<WidgetView>& contentBackground ,\r
- const FactoryMethod<WidgetView>& titleBackground \r
- );\r
-\r
- virtual ~Frame();\r
- virtual FrameNumber show(bool imidiately = false);\r
- virtual FrameNumber hide(bool imidiately = false);\r
- virtual const boost::shared_ptr<WidgetView> getView( ) const;\r
- virtual boost::shared_ptr<WidgetView> getView( );\r
- virtual void update();\r
-\r
-\r
- \r
- protected:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
- };\r
-\r
-\r
-} // namespace widget\r
-} // namespace mof\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <boost/shared_ptr.hpp>
+#include <mof/widget/Widget.hpp>
+#include <mof/FactoryMethod.hpp>
+
+namespace mof
+{
+ class Font;
+
+namespace widget
+{
+
+ class Frame : public Widget
+ {
+ public:
+ Frame
+ (
+ const tstring& title ,
+ const Font& font ,
+ boost::shared_ptr<Widget> content ,
+ const FactoryMethod<WidgetView>& contentBackground ,
+ const FactoryMethod<WidgetView>& titleBackground
+ );
+
+ virtual ~Frame();
+ virtual FrameNumber show(bool imidiately = false);
+ virtual FrameNumber hide(bool imidiately = false);
+ virtual const boost::shared_ptr<WidgetView> getView( ) const;
+ virtual boost::shared_ptr<WidgetView> getView( );
+ virtual void update();
+
+
+
+ protected:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+
+} // namespace widget
+} // namespace mof
-#pragma once\r
-#include <boost/utility.hpp>\r
-#include <boost/scoped_ptr.hpp>\r
-#include <mof/tstring.hpp>\r
-#include <memory>\r
-#include <mof/widget/Frame.hpp>\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/FactoryMethod.hpp>\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-namespace widget\r
-{\r
-\r
- class FrameBuilder : boost::noncopyable\r
- {\r
- public:\r
- FrameBuilder();\r
- ~FrameBuilder();\r
-\r
- void setTitle( const mof::tstring& title , const mof::Font& font );\r
- void setContentBackgroundView( const mof::FactoryMethod<WidgetView>& contentBackground );\r
- void setTitleBackgroundView( const mof::FactoryMethod<WidgetView>& titleBackground );\r
- std::auto_ptr<Frame> create( );\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
- }; // class FrameBuilder\r
-} // namespace widget\r
-} // namespace mof\r
+#pragma once
+#include <boost/utility.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <mof/tstring.hpp>
+#include <memory>
+#include <mof/widget/Frame.hpp>
+#include <mof/widget/WidgetView.hpp>
+#include <mof/FactoryMethod.hpp>
+
+namespace mof
+{
+ class Font;
+namespace widget
+{
+
+ class FrameBuilder : boost::noncopyable
+ {
+ public:
+ FrameBuilder();
+ ~FrameBuilder();
+
+ void setTitle( const mof::tstring& title , const mof::Font& font );
+ void setContentBackgroundView( const mof::FactoryMethod<WidgetView>& contentBackground );
+ void setTitleBackgroundView( const mof::FactoryMethod<WidgetView>& titleBackground );
+ std::auto_ptr<Frame> create( );
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ }; // class FrameBuilder
+} // namespace widget
+} // namespace mof
-#pragma once\r
-#include <boost/utility.hpp>\r
-#include <boost/scoped_ptr.hpp>\r
-#include <mof/tstring.hpp>\r
-#include <memory>\r
-#include <mof/widget/Frame.hpp>\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/FactoryMethod.hpp>\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-namespace widget\r
-{\r
-\r
- class FrameBuilder : boost::noncopyable\r
- {\r
- public:\r
- FrameBuilder();\r
- ~FrameBuilder();\r
-\r
- void setTitle( const mof::tstring& title , const mof::Font& font );\r
- void setContentBackgroundView( const FactoryMethod<WidgetView>& contentBackground );\r
- void setTitleBackgroundView( const FactoryMethod<WidgetView>& titleBackground );\r
- std::auto_ptr<Frame> create( );\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
- }; // class FrameBuilder\r
-} // namespace widget\r
-} // namespace mof\r
+#pragma once
+#include <boost/utility.hpp>
+#include <boost/scoped_ptr.hpp>
+#include <mof/tstring.hpp>
+#include <memory>
+#include <mof/widget/Frame.hpp>
+#include <mof/widget/WidgetView.hpp>
+#include <mof/FactoryMethod.hpp>
+
+namespace mof
+{
+ class Font;
+namespace widget
+{
+
+ class FrameBuilder : boost::noncopyable
+ {
+ public:
+ FrameBuilder();
+ ~FrameBuilder();
+
+ void setTitle( const mof::tstring& title , const mof::Font& font );
+ void setContentBackgroundView( const FactoryMethod<WidgetView>& contentBackground );
+ void setTitleBackgroundView( const FactoryMethod<WidgetView>& titleBackground );
+ std::auto_ptr<Frame> create( );
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ }; // class FrameBuilder
+} // namespace widget
+} // namespace mof
-#include <mof/widget/GridLayout.hpp>\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/streams.hpp>\r
-#include <mof/utilities.hpp>\r
-#include "mof/ConsoleIO.hpp"\r
-#include <algorithm>\r
-#include <vector>\r
-\r
-using boost::shared_ptr;\r
-\r
-//{{{ Impl\r
-struct mof::widget::GridLayout::Impl\r
-{\r
- \r
- mof::widget::GridLayout::Direction direction;\r
- int span , margin;\r
- int width , height;// preferredSize\r
- std::vector< shared_ptr<WidgetView> > views;\r
- std::vector<Vector2D> positions;\r
-\r
- Impl(Direction _direction , int span_ , int margin_ )\r
- : \r
- direction(_direction) , span(span_) , margin(margin_) ,\r
- width(0) , height(0)\r
- {}\r
- \r
-\r
- ~Impl()\r
- {\r
- }\r
-};\r
-//}}}\r
-//{{{ GridLayout\r
-mof::widget::GridLayout::GridLayout\r
-(\r
- Direction direction , int span , int margin\r
-)\r
-: m_pImpl( new Impl( direction , span , margin ) )\r
-{\r
-}\r
-//}}}\r
-//{{{ ~GridLayout\r
-mof::widget::GridLayout::~GridLayout( )\r
-{\r
-}\r
-//}}}\r
-//{{{ add\r
-void mof::widget::GridLayout::add(shared_ptr<WidgetView> pView)\r
-{\r
- mof::Vector2D size = pView->getSizeStream().value();\r
- m_pImpl->views.push_back(pView);\r
- \r
- if(m_pImpl->direction == VERTICAL)\r
- {\r
- m_pImpl->positions.push_back( mof::Vector2D(0 , m_pImpl->height));\r
- if( !m_pImpl->views.empty( ) )m_pImpl->height += m_pImpl->margin;\r
- m_pImpl->width = m_pImpl->width < size.x \r
- ? mof::real2int(size.x) \r
- : m_pImpl->width;\r
- m_pImpl->height += mof::real2int(size.y);\r
- }\r
- else if(m_pImpl->direction == HORIZONTAL)\r
- {\r
- m_pImpl->positions.push_back( mof::Vector2D(m_pImpl->width , 0));\r
- if( !m_pImpl->views.empty( ) )m_pImpl->width += m_pImpl->margin;\r
- m_pImpl->width += mof::real2int(size.x);\r
- m_pImpl->height = m_pImpl->height < size.y \r
- ? mof::real2int(size.y) \r
- : m_pImpl->height;\r
- }\r
-}\r
-//}}}\r
-//{{{ getLength\r
-size_t mof::widget::GridLayout::getLength() const\r
-{\r
- return m_pImpl->positions.size();\r
-}\r
-//}}}\r
-//{{{ getPreferredSize\r
-mof::Vector2D mof::widget::GridLayout::getPreferredSize() const\r
-{\r
- return mof::Vector2D(m_pImpl->width , m_pImpl->height);\r
-}\r
-//}}}\r
-//{{{ getSizeDependencyType\r
-mof::widget::Layout::DependencyType mof::widget::GridLayout::getSizeDependencyType() const\r
-{\r
- return mof::widget::Layout::PARENT_LEADING;\r
-}\r
-//}}}\r
-//{{{ connect\r
-void mof::widget::GridLayout::connect(WidgetView* pParentView) \r
-{\r
- size_t i = 0;\r
- if(m_pImpl->direction == VERTICAL)\r
- {\r
- foreach(shared_ptr<WidgetView> pView , m_pImpl->views) \r
- {\r
- pView->getPositionStream() << m_pImpl->positions[i++] << pParentView->getPositionStream();\r
- mof::Vector2D filter(1 , 0);\r
- mof::Vector2D offset(-1.0f * pView->getSizeStream().value().x , 0.0f);\r
- pView->getSizeStream() \r
- << offset\r
- << mof::makeFilterHandler(pParentView->getSizeStream().toManipulator() , filter);\r
- }\r
- }\r
- else\r
- {\r
- foreach(shared_ptr<WidgetView> pView , m_pImpl->views) \r
- {\r
- pView->getPositionStream() << m_pImpl->positions[i++] << pParentView->getPositionStream();\r
- pView->getSizeStream() << -pView->getSizeStream().value() << pParentView->getSizeStream();\r
- }\r
- }\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsUp\r
-int mof::widget::GridLayout::getAdjacencyAsUp(int index) const\r
-{\r
- if(m_pImpl->direction == VERTICAL)return mof::rotation_mod(index-1 , m_pImpl->positions.size());\r
- else return index;\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsDown\r
-int mof::widget::GridLayout::getAdjacencyAsDown(int index) const\r
-{\r
- if(m_pImpl->direction == VERTICAL)return mof::rotation_mod(index+1 , m_pImpl->positions.size());\r
- else return index;\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsLeft\r
-int mof::widget::GridLayout::getAdjacencyAsLeft(int index) const\r
-{\r
- if(m_pImpl->direction == HORIZONTAL)return mof::rotation_mod(index-1 , m_pImpl->positions.size());\r
- else return index;\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsRight\r
-int mof::widget::GridLayout::getAdjacencyAsRight(int index) const\r
-{\r
- if(m_pImpl->direction == HORIZONTAL)return mof::rotation_mod(index+1 , m_pImpl->positions.size());\r
- else return index;\r
-}\r
-//}}}\r
+#include <mof/widget/GridLayout.hpp>
+#include <mof/widget/WidgetView.hpp>
+#include <mof/streams.hpp>
+#include <mof/utilities.hpp>
+#include "mof/ConsoleIO.hpp"
+#include <algorithm>
+#include <vector>
+
+using boost::shared_ptr;
+
+//{{{ Impl
+struct mof::widget::GridLayout::Impl
+{
+
+ mof::widget::GridLayout::Direction direction;
+ int span , margin;
+ int width , height;// preferredSize
+ std::vector< shared_ptr<WidgetView> > views;
+ std::vector<Vector2D> positions;
+
+ Impl(Direction _direction , int span_ , int margin_ )
+ :
+ direction(_direction) , span(span_) , margin(margin_) ,
+ width(0) , height(0)
+ {}
+
+
+ ~Impl()
+ {
+ }
+};
+//}}}
+//{{{ GridLayout
+mof::widget::GridLayout::GridLayout
+(
+ Direction direction , int span , int margin
+)
+: m_pImpl( new Impl( direction , span , margin ) )
+{
+}
+//}}}
+//{{{ ~GridLayout
+mof::widget::GridLayout::~GridLayout( )
+{
+}
+//}}}
+//{{{ add
+void mof::widget::GridLayout::add(shared_ptr<WidgetView> pView)
+{
+ mof::Vector2D size = pView->getSizeStream().value();
+ m_pImpl->views.push_back(pView);
+
+ if(m_pImpl->direction == VERTICAL)
+ {
+ m_pImpl->positions.push_back( mof::Vector2D(0 , m_pImpl->height));
+ if( !m_pImpl->views.empty( ) )m_pImpl->height += m_pImpl->margin;
+ m_pImpl->width = m_pImpl->width < size.x
+ ? mof::real2int(size.x)
+ : m_pImpl->width;
+ m_pImpl->height += mof::real2int(size.y);
+ }
+ else if(m_pImpl->direction == HORIZONTAL)
+ {
+ m_pImpl->positions.push_back( mof::Vector2D(m_pImpl->width , 0));
+ if( !m_pImpl->views.empty( ) )m_pImpl->width += m_pImpl->margin;
+ m_pImpl->width += mof::real2int(size.x);
+ m_pImpl->height = m_pImpl->height < size.y
+ ? mof::real2int(size.y)
+ : m_pImpl->height;
+ }
+}
+//}}}
+//{{{ getLength
+size_t mof::widget::GridLayout::getLength() const
+{
+ return m_pImpl->positions.size();
+}
+//}}}
+//{{{ getPreferredSize
+mof::Vector2D mof::widget::GridLayout::getPreferredSize() const
+{
+ return mof::Vector2D(m_pImpl->width , m_pImpl->height);
+}
+//}}}
+//{{{ getSizeDependencyType
+mof::widget::Layout::DependencyType mof::widget::GridLayout::getSizeDependencyType() const
+{
+ return mof::widget::Layout::PARENT_LEADING;
+}
+//}}}
+//{{{ connect
+void mof::widget::GridLayout::connect(WidgetView* pParentView)
+{
+ size_t i = 0;
+ if(m_pImpl->direction == VERTICAL)
+ {
+ foreach(shared_ptr<WidgetView> pView , m_pImpl->views)
+ {
+ pView->getPositionStream() << m_pImpl->positions[i++] << pParentView->getPositionStream();
+ mof::Vector2D filter(1 , 0);
+ mof::Vector2D offset(-1.0f * pView->getSizeStream().value().x , 0.0f);
+ pView->getSizeStream()
+ << offset
+ << mof::makeFilterHandler(pParentView->getSizeStream().toManipulator() , filter);
+ }
+ }
+ else
+ {
+ foreach(shared_ptr<WidgetView> pView , m_pImpl->views)
+ {
+ pView->getPositionStream() << m_pImpl->positions[i++] << pParentView->getPositionStream();
+ pView->getSizeStream() << -pView->getSizeStream().value() << pParentView->getSizeStream();
+ }
+ }
+}
+//}}}
+//{{{ getAdjacencyAsUp
+int mof::widget::GridLayout::getAdjacencyAsUp(int index) const
+{
+ if(m_pImpl->direction == VERTICAL)return mof::rotation_mod(index-1 , m_pImpl->positions.size());
+ else return index;
+}
+//}}}
+//{{{ getAdjacencyAsDown
+int mof::widget::GridLayout::getAdjacencyAsDown(int index) const
+{
+ if(m_pImpl->direction == VERTICAL)return mof::rotation_mod(index+1 , m_pImpl->positions.size());
+ else return index;
+}
+//}}}
+//{{{ getAdjacencyAsLeft
+int mof::widget::GridLayout::getAdjacencyAsLeft(int index) const
+{
+ if(m_pImpl->direction == HORIZONTAL)return mof::rotation_mod(index-1 , m_pImpl->positions.size());
+ else return index;
+}
+//}}}
+//{{{ getAdjacencyAsRight
+int mof::widget::GridLayout::getAdjacencyAsRight(int index) const
+{
+ if(m_pImpl->direction == HORIZONTAL)return mof::rotation_mod(index+1 , m_pImpl->positions.size());
+ else return index;
+}
+//}}}
-#include <mof/widget/GridLayout.hpp>\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/streams.hpp>\r
-#include <mof/utilities.hpp>\r
-#include "mof/ConsoleIO.hpp"\r
-#include <algorithm>\r
-#include <vector>\r
-\r
-using boost::shared_ptr;\r
-\r
-//{{{ Impl\r
-struct mof::widget::GridLayout::Impl\r
-{\r
- \r
- mof::widget::GridLayout::Direction direction;\r
- int span , margin;\r
- int width , height;// preferredSize\r
- std::vector< shared_ptr<WidgetView> > views;\r
- std::vector<Vector2D> positions;\r
-\r
- Impl(Direction _direction , int span_ , int margin_ )\r
- : \r
- direction(_direction) , span(span_) , margin(margin_) ,\r
- width(0) , height(0)\r
- {}\r
- \r
-\r
- ~Impl()\r
- {\r
- }\r
-};\r
-//}}}\r
-//{{{ GridLayout\r
-mof::widget::GridLayout::GridLayout\r
-(\r
- Direction direction , int span , int margin\r
-)\r
-: m_pImpl( new Impl( direction , span , margin ) )\r
-{\r
-}\r
-//}}}\r
-//{{{ ~GridLayout\r
-mof::widget::GridLayout::~GridLayout( )\r
-{\r
-}\r
-//}}}\r
-//{{{ add\r
-void mof::widget::GridLayout::add(shared_ptr<WidgetView> pView)\r
-{\r
- mof::Vector2D size = pView->getSizeStream().value();\r
- m_pImpl->views.push_back(pView);\r
- \r
- if(m_pImpl->direction == VERTICAL)\r
- {\r
- //if( !m_pImpl->views.empty( ) )m_pImpl->height += m_pImpl->margin;\r
- m_pImpl->positions.push_back( mof::Vector2D(0 , m_pImpl->height));\r
- m_pImpl->width = m_pImpl->width < size.x \r
- ? mof::real2int(size.x) \r
- : m_pImpl->width;\r
- m_pImpl->height += mof::real2int(size.y);\r
- }\r
- else if(m_pImpl->direction == HORIZONTAL)\r
- {\r
- if( !m_pImpl->views.empty( ) )m_pImpl->width += m_pImpl->margin;\r
- m_pImpl->positions.push_back( mof::Vector2D(m_pImpl->width , 0));\r
- m_pImpl->width += mof::real2int(size.x);\r
- m_pImpl->height = m_pImpl->height < size.y \r
- ? mof::real2int(size.y) \r
- : m_pImpl->height;\r
- }\r
-}\r
-//}}}\r
-//{{{ getLength\r
-size_t mof::widget::GridLayout::getLength() const\r
-{\r
- return m_pImpl->positions.size();\r
-}\r
-//}}}\r
-//{{{ getPreferredSize\r
-mof::Vector2D mof::widget::GridLayout::getPreferredSize() const\r
-{\r
- return mof::Vector2D(m_pImpl->width , m_pImpl->height);\r
-}\r
-//}}}\r
-//{{{ getSizeDependencyType\r
-mof::widget::Layout::DependencyType mof::widget::GridLayout::getSizeDependencyType() const\r
-{\r
- return mof::widget::Layout::PARENT_LEADING;\r
-}\r
-//}}}\r
-//{{{ connect\r
-void mof::widget::GridLayout::connect(WidgetView* pParentView) \r
-{\r
- size_t i = 0;\r
- if(m_pImpl->direction == VERTICAL)\r
- {\r
- foreach(shared_ptr<WidgetView> pView , m_pImpl->views) \r
- {\r
- pView->getPositionStream() << m_pImpl->positions[i++] << pParentView->getPositionStream();\r
- mof::Vector2D filter(1 , 0);\r
- mof::Vector2D offset(-1.0f * pView->getSizeStream().value().x , 0.0f);\r
- pView->getSizeStream() \r
- << offset\r
- << mof::makeFilterHandler(pParentView->getSizeStream().toManipulator() , filter);\r
- }\r
- }\r
- else\r
- {\r
- foreach(shared_ptr<WidgetView> pView , m_pImpl->views) \r
- {\r
- pView->getPositionStream() << m_pImpl->positions[i++] << pParentView->getPositionStream();\r
- pView->getSizeStream() << -pView->getSizeStream().value() << pParentView->getSizeStream();\r
- }\r
- }\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsUp\r
-int mof::widget::GridLayout::getAdjacencyAsUp(int index) const\r
-{\r
- if(m_pImpl->direction == VERTICAL)return mof::rotation_mod(index-1 , m_pImpl->positions.size());\r
- else return index;\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsDown\r
-int mof::widget::GridLayout::getAdjacencyAsDown(int index) const\r
-{\r
- if(m_pImpl->direction == VERTICAL)return mof::rotation_mod(index+1 , m_pImpl->positions.size());\r
- else return index;\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsLeft\r
-int mof::widget::GridLayout::getAdjacencyAsLeft(int index) const\r
-{\r
- if(m_pImpl->direction == HORIZONTAL)return mof::rotation_mod(index-1 , m_pImpl->positions.size());\r
- else return index;\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsRight\r
-int mof::widget::GridLayout::getAdjacencyAsRight(int index) const\r
-{\r
- if(m_pImpl->direction == HORIZONTAL)return mof::rotation_mod(index+1 , m_pImpl->positions.size());\r
- else return index;\r
-}\r
-//}}}\r
+#include <mof/widget/GridLayout.hpp>
+#include <mof/widget/WidgetView.hpp>
+#include <mof/streams.hpp>
+#include <mof/utilities.hpp>
+#include "mof/ConsoleIO.hpp"
+#include <algorithm>
+#include <vector>
+
+using boost::shared_ptr;
+
+//{{{ Impl
+struct mof::widget::GridLayout::Impl
+{
+
+ mof::widget::GridLayout::Direction direction;
+ int span , margin;
+ int width , height;// preferredSize
+ std::vector< shared_ptr<WidgetView> > views;
+ std::vector<Vector2D> positions;
+
+ Impl(Direction _direction , int span_ , int margin_ )
+ :
+ direction(_direction) , span(span_) , margin(margin_) ,
+ width(0) , height(0)
+ {}
+
+
+ ~Impl()
+ {
+ }
+};
+//}}}
+//{{{ GridLayout
+mof::widget::GridLayout::GridLayout
+(
+ Direction direction , int span , int margin
+)
+: m_pImpl( new Impl( direction , span , margin ) )
+{
+}
+//}}}
+//{{{ ~GridLayout
+mof::widget::GridLayout::~GridLayout( )
+{
+}
+//}}}
+//{{{ add
+void mof::widget::GridLayout::add(shared_ptr<WidgetView> pView)
+{
+ mof::Vector2D size = pView->getSizeStream().value();
+ m_pImpl->views.push_back(pView);
+
+ if(m_pImpl->direction == VERTICAL)
+ {
+ //if( !m_pImpl->views.empty( ) )m_pImpl->height += m_pImpl->margin;
+ m_pImpl->positions.push_back( mof::Vector2D(0 , m_pImpl->height));
+ m_pImpl->width = m_pImpl->width < size.x
+ ? mof::real2int(size.x)
+ : m_pImpl->width;
+ m_pImpl->height += mof::real2int(size.y);
+ }
+ else if(m_pImpl->direction == HORIZONTAL)
+ {
+ if( !m_pImpl->views.empty( ) )m_pImpl->width += m_pImpl->margin;
+ m_pImpl->positions.push_back( mof::Vector2D(m_pImpl->width , 0));
+ m_pImpl->width += mof::real2int(size.x);
+ m_pImpl->height = m_pImpl->height < size.y
+ ? mof::real2int(size.y)
+ : m_pImpl->height;
+ }
+}
+//}}}
+//{{{ getLength
+size_t mof::widget::GridLayout::getLength() const
+{
+ return m_pImpl->positions.size();
+}
+//}}}
+//{{{ getPreferredSize
+mof::Vector2D mof::widget::GridLayout::getPreferredSize() const
+{
+ return mof::Vector2D(m_pImpl->width , m_pImpl->height);
+}
+//}}}
+//{{{ getSizeDependencyType
+mof::widget::Layout::DependencyType mof::widget::GridLayout::getSizeDependencyType() const
+{
+ return mof::widget::Layout::PARENT_LEADING;
+}
+//}}}
+//{{{ connect
+void mof::widget::GridLayout::connect(WidgetView* pParentView)
+{
+ size_t i = 0;
+ if(m_pImpl->direction == VERTICAL)
+ {
+ foreach(shared_ptr<WidgetView> pView , m_pImpl->views)
+ {
+ pView->getPositionStream() << m_pImpl->positions[i++] << pParentView->getPositionStream();
+ mof::Vector2D filter(1 , 0);
+ mof::Vector2D offset(-1.0f * pView->getSizeStream().value().x , 0.0f);
+ pView->getSizeStream()
+ << offset
+ << mof::makeFilterHandler(pParentView->getSizeStream().toManipulator() , filter);
+ }
+ }
+ else
+ {
+ foreach(shared_ptr<WidgetView> pView , m_pImpl->views)
+ {
+ pView->getPositionStream() << m_pImpl->positions[i++] << pParentView->getPositionStream();
+ pView->getSizeStream() << -pView->getSizeStream().value() << pParentView->getSizeStream();
+ }
+ }
+}
+//}}}
+//{{{ getAdjacencyAsUp
+int mof::widget::GridLayout::getAdjacencyAsUp(int index) const
+{
+ if(m_pImpl->direction == VERTICAL)return mof::rotation_mod(index-1 , m_pImpl->positions.size());
+ else return index;
+}
+//}}}
+//{{{ getAdjacencyAsDown
+int mof::widget::GridLayout::getAdjacencyAsDown(int index) const
+{
+ if(m_pImpl->direction == VERTICAL)return mof::rotation_mod(index+1 , m_pImpl->positions.size());
+ else return index;
+}
+//}}}
+//{{{ getAdjacencyAsLeft
+int mof::widget::GridLayout::getAdjacencyAsLeft(int index) const
+{
+ if(m_pImpl->direction == HORIZONTAL)return mof::rotation_mod(index-1 , m_pImpl->positions.size());
+ else return index;
+}
+//}}}
+//{{{ getAdjacencyAsRight
+int mof::widget::GridLayout::getAdjacencyAsRight(int index) const
+{
+ if(m_pImpl->direction == HORIZONTAL)return mof::rotation_mod(index+1 , m_pImpl->positions.size());
+ else return index;
+}
+//}}}
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class GridLayout : public Layout\r
- {\r
-\r
- public:\r
- enum Direction\r
- {\r
- HORIZONTAL , VERTICAL\r
- };\r
-\r
- GridLayout(Direction direction , int span , int margin = 0 );\r
- virtual ~GridLayout();\r
- virtual void add(boost::shared_ptr<WidgetView> pView);\r
- virtual Vector2D getPreferredSize() const;\r
- virtual DependencyType getSizeDependencyType() const;\r
- virtual void connect(WidgetView* pParentView);\r
- virtual size_t getLength( ) const;\r
- virtual int getAdjacencyAsUp(int index) const;\r
- virtual int getAdjacencyAsDown(int index) const;\r
- virtual int getAdjacencyAsLeft(int index) const;\r
- virtual int getAdjacencyAsRight(int index) const;\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
-} // namepsace mof\r
-\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <mof/widget/Layout.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class GridLayout : public Layout
+ {
+
+ public:
+ enum Direction
+ {
+ HORIZONTAL , VERTICAL
+ };
+
+ GridLayout(Direction direction , int span , int margin = 0 );
+ virtual ~GridLayout();
+ virtual void add(boost::shared_ptr<WidgetView> pView);
+ virtual Vector2D getPreferredSize() const;
+ virtual DependencyType getSizeDependencyType() const;
+ virtual void connect(WidgetView* pParentView);
+ virtual size_t getLength( ) const;
+ virtual int getAdjacencyAsUp(int index) const;
+ virtual int getAdjacencyAsDown(int index) const;
+ virtual int getAdjacencyAsLeft(int index) const;
+ virtual int getAdjacencyAsRight(int index) const;
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
+} // namepsace mof
+
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class GridLayout : public Layout\r
- {\r
-\r
- public:\r
- enum Direction\r
- {\r
- HORIZONTAL , VERTICAL\r
- };\r
-\r
- GridLayout(Direction direction , int span , int margin = 0 );\r
- virtual ~GridLayout();\r
- virtual void add(boost::shared_ptr<WidgetView> pView);\r
- virtual Vector2D getPreferredSize() const;\r
- virtual DependencyType getSizeDependencyType() const;\r
- virtual void connect( boost::shared_ptr<WidgetView> pParentView);\r
- virtual size_t getLength( ) const;\r
- virtual int getAdjacencyAsUp(int index) const;\r
- virtual int getAdjacencyAsDown(int index) const;\r
- virtual int getAdjacencyAsLeft(int index) const;\r
- virtual int getAdjacencyAsRight(int index) const;\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
-} // namepsace mof\r
-\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <mof/widget/Layout.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class GridLayout : public Layout
+ {
+
+ public:
+ enum Direction
+ {
+ HORIZONTAL , VERTICAL
+ };
+
+ GridLayout(Direction direction , int span , int margin = 0 );
+ virtual ~GridLayout();
+ virtual void add(boost::shared_ptr<WidgetView> pView);
+ virtual Vector2D getPreferredSize() const;
+ virtual DependencyType getSizeDependencyType() const;
+ virtual void connect( boost::shared_ptr<WidgetView> pParentView);
+ virtual size_t getLength( ) const;
+ virtual int getAdjacencyAsUp(int index) const;
+ virtual int getAdjacencyAsDown(int index) const;
+ virtual int getAdjacencyAsLeft(int index) const;
+ virtual int getAdjacencyAsRight(int index) const;
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
+} // namepsace mof
+
-#include <mof/widget/ImageView.hpp>\r
-#include "mof/mofGraphics.hpp"\r
-#include "mof/Font.hpp"\r
-#include "mof/Sprite.hpp"\r
-#include "mof/widget/Effect.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/widgets.hpp"\r
-#include "mof/streams.hpp"\r
- \r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-//{{{ struct Impl\r
- struct ImageView::Impl\r
- {\r
- Sprite* pSprite;\r
- \r
- Impl( )\r
- : pSprite( NULL )\r
- {\r
- }\r
- \r
- ~Impl()\r
- {\r
- delete pSprite;\r
- }\r
- \r
- };\r
-//}}}\r
-//{{{ constructor\r
- ImageView::ImageView\r
- (\r
- const tstring& caption ,\r
- const Font& font\r
- )\r
- : \r
- m_pImpl( new Impl ) \r
- {\r
- { // 画像の生成\r
- m_pImpl->pSprite = Sprite::createTextSprite( font , caption );\r
- m_pImpl->pSprite->getPositionStream( ) << getPositionStream( ); \r
- m_pImpl->pSprite->getColorStream( ) << getColorStream( ); \r
- m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定\r
- }\r
- }\r
-//}}}\r
-//{{{ constructor\r
- ImageView::ImageView\r
- (\r
- const TextureHandler& texture ,\r
- const Rectangle<float>& tRect\r
- )\r
- : \r
- m_pImpl( new Impl( ) ) \r
- {\r
- { // 画像の生成\r
- m_pImpl->pSprite = new Sprite( texture , tRect );\r
- m_pImpl->pSprite->getPositionStream( ) << getPositionStream( ); \r
- m_pImpl->pSprite->getColorStream( ) << getColorStream( ); \r
- m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定\r
- }\r
- \r
- }\r
-//}}}\r
-//{{{ destructor\r
- ImageView::~ImageView()\r
- {\r
- }\r
-//}}}\r
-//{{{ update\r
- void ImageView::update( )\r
- {\r
- m_positionStream.update( );\r
- m_sizeStream.update( );\r
- m_colorStream.update( );\r
- m_pImpl->pSprite->update();\r
- }\r
-//}}}\r
-//{{{ draw\r
- void ImageView::draw( ) const\r
- {\r
- m_pImpl->pSprite->draw( );\r
- }\r
-//}}}\r
-//{{{ show\r
- FrameNumber ImageView::show(bool) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ hide\r
- FrameNumber ImageView::hide(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ focus\r
- FrameNumber ImageView::focus(bool) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ blur\r
- FrameNumber ImageView::blur(bool imidiately)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ click\r
- FrameNumber ImageView::click(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-}\r
-} // namespace mof\r
+#include <mof/widget/ImageView.hpp>
+#include "mof/mofGraphics.hpp"
+#include "mof/Font.hpp"
+#include "mof/Sprite.hpp"
+#include "mof/widget/Effect.hpp"
+#include "mof/utilities.hpp"
+#include "mof/widgets.hpp"
+#include "mof/streams.hpp"
+
+namespace mof
+{
+namespace widget
+{
+//{{{ struct Impl
+ struct ImageView::Impl
+ {
+ Sprite* pSprite;
+
+ Impl( )
+ : pSprite( NULL )
+ {
+ }
+
+ ~Impl()
+ {
+ delete pSprite;
+ }
+
+ };
+//}}}
+//{{{ constructor
+ ImageView::ImageView
+ (
+ const tstring& caption ,
+ const Font& font
+ )
+ :
+ m_pImpl( new Impl )
+ {
+ { // 画像の生成
+ m_pImpl->pSprite = Sprite::createTextSprite( font , caption );
+ m_pImpl->pSprite->getPositionStream( ) << getPositionStream( );
+ m_pImpl->pSprite->getColorStream( ) << getColorStream( );
+ m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定
+ }
+ }
+//}}}
+//{{{ constructor
+ ImageView::ImageView
+ (
+ const TextureHandler& texture ,
+ const Rectangle<float>& tRect
+ )
+ :
+ m_pImpl( new Impl( ) )
+ {
+ { // 画像の生成
+ m_pImpl->pSprite = new Sprite( texture , tRect );
+ m_pImpl->pSprite->getPositionStream( ) << getPositionStream( );
+ m_pImpl->pSprite->getColorStream( ) << getColorStream( );
+ m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定
+ }
+
+ }
+//}}}
+//{{{ destructor
+ ImageView::~ImageView()
+ {
+ }
+//}}}
+//{{{ update
+ void ImageView::update( )
+ {
+ m_positionStream.update( );
+ m_sizeStream.update( );
+ m_colorStream.update( );
+ m_pImpl->pSprite->update();
+ }
+//}}}
+//{{{ draw
+ void ImageView::draw( ) const
+ {
+ m_pImpl->pSprite->draw( );
+ }
+//}}}
+//{{{ show
+ FrameNumber ImageView::show(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ hide
+ FrameNumber ImageView::hide(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ focus
+ FrameNumber ImageView::focus(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ blur
+ FrameNumber ImageView::blur(bool imidiately)
+ {
+ return 0;
+ }
+//}}}
+//{{{ click
+ FrameNumber ImageView::click(bool)
+ {
+ return 0;
+ }
+//}}}
+}
+} // namespace mof
-#include <mof/widget/ImageView.hpp>\r
-#include "mof/mofGraphics.hpp"\r
-#include "mof/Font.hpp"\r
-#include "mof/Sprite.hpp"\r
-#include "mof/widget/Effect.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/widgets.hpp"\r
-#include "mof/streams.hpp"\r
- \r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-//{{{ struct Impl\r
- struct ImageView::Impl\r
- {\r
- Sprite* pSprite;\r
- \r
- Impl( )\r
- : pSprite( NULL )\r
- {\r
- }\r
- \r
- ~Impl()\r
- {\r
- delete pSprite;\r
- }\r
- \r
- };\r
-//}}}\r
-//{{{ constructor\r
- ImageView::ImageView\r
- (\r
- const tstring& caption ,\r
- const Font& font\r
- )\r
- : \r
- m_pImpl( new Impl ) \r
- {\r
- { // 画像の生成\r
- m_pImpl->pSprite = Sprite::createTextSprite( font , caption );\r
- m_pImpl->pSprite->getPositionStream( ) << getPositionStream( ); \r
- m_pImpl->pSprite->getColorStream( ) << getColorStream( ); \r
- m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定\r
- }\r
- }\r
-//}}}\r
-//{{{ constructor\r
- ImageView::ImageView\r
- (\r
- const TextureHandler& texture ,\r
- const Rectangle<float>& tRect\r
- )\r
- : \r
- m_pImpl( new Impl( ) ) \r
- {\r
- { // 画像の生成\r
- m_pImpl->pSprite = new Sprite( texture , tRect );\r
- m_pImpl->pSprite->getPositionStream( ) << getPositionStream( ); \r
- m_pImpl->pSprite->getColorStream( ) << getColorStream( ); \r
- m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定\r
- }\r
- \r
- }\r
-//}}}\r
-//{{{ destructor\r
- ImageView::~ImageView()\r
- {\r
- }\r
-//}}}\r
-//{{{ update\r
- void ImageView::update( )\r
- {\r
- m_positionStream.update( );\r
- m_sizeStream.update( );\r
- m_colorStream.update( );\r
- m_pImpl->pSprite->update();\r
- }\r
-//}}}\r
-//{{{ draw\r
- void ImageView::draw( ) const\r
- {\r
- m_pImpl->pSprite->draw( );\r
- }\r
-//}}}\r
-//{{{ show\r
- FrameNumber ImageView::show(bool) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ hide\r
- FrameNumber ImageView::hide(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ focus\r
- FrameNumber ImageView::focus(bool) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ blur\r
- FrameNumber ImageView::blur(bool imidiately)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ click\r
- FrameNumber ImageView::click(bool)\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-\r
-}\r
-} // namespace mof\r
+#include <mof/widget/ImageView.hpp>
+#include "mof/mofGraphics.hpp"
+#include "mof/Font.hpp"
+#include "mof/Sprite.hpp"
+#include "mof/widget/Effect.hpp"
+#include "mof/utilities.hpp"
+#include "mof/widgets.hpp"
+#include "mof/streams.hpp"
+
+namespace mof
+{
+namespace widget
+{
+//{{{ struct Impl
+ struct ImageView::Impl
+ {
+ Sprite* pSprite;
+
+ Impl( )
+ : pSprite( NULL )
+ {
+ }
+
+ ~Impl()
+ {
+ delete pSprite;
+ }
+
+ };
+//}}}
+//{{{ constructor
+ ImageView::ImageView
+ (
+ const tstring& caption ,
+ const Font& font
+ )
+ :
+ m_pImpl( new Impl )
+ {
+ { // 画像の生成
+ m_pImpl->pSprite = Sprite::createTextSprite( font , caption );
+ m_pImpl->pSprite->getPositionStream( ) << getPositionStream( );
+ m_pImpl->pSprite->getColorStream( ) << getColorStream( );
+ m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定
+ }
+ }
+//}}}
+//{{{ constructor
+ ImageView::ImageView
+ (
+ const TextureHandler& texture ,
+ const Rectangle<float>& tRect
+ )
+ :
+ m_pImpl( new Impl( ) )
+ {
+ { // 画像の生成
+ m_pImpl->pSprite = new Sprite( texture , tRect );
+ m_pImpl->pSprite->getPositionStream( ) << getPositionStream( );
+ m_pImpl->pSprite->getColorStream( ) << getColorStream( );
+ m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定
+ }
+
+ }
+//}}}
+//{{{ destructor
+ ImageView::~ImageView()
+ {
+ }
+//}}}
+//{{{ update
+ void ImageView::update( )
+ {
+ m_positionStream.update( );
+ m_sizeStream.update( );
+ m_colorStream.update( );
+ m_pImpl->pSprite->update();
+ }
+//}}}
+//{{{ draw
+ void ImageView::draw( ) const
+ {
+ m_pImpl->pSprite->draw( );
+ }
+//}}}
+//{{{ show
+ FrameNumber ImageView::show(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ hide
+ FrameNumber ImageView::hide(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ focus
+ FrameNumber ImageView::focus(bool)
+ {
+ return 0;
+ }
+//}}}
+//{{{ blur
+ FrameNumber ImageView::blur(bool imidiately)
+ {
+ return 0;
+ }
+//}}}
+//{{{ click
+ FrameNumber ImageView::click(bool)
+ {
+ return 0;
+ }
+//}}}
+
+}
+} // namespace mof
-#pragma once\r
-#include "mof/widget/WidgetView.hpp"\r
-#include "mof/graphics/utilities.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-\r
-namespace widget\r
-{\r
-\r
- class ImageView \r
- : \r
- public WidgetView\r
- {\r
- public:\r
- ImageView( const tstring& caption , const Font& font );\r
- ImageView( const TextureHandler& texture , const Rectangle<float>& tRect );\r
- virtual ~ImageView( );\r
-\r
- virtual FrameNumber show( bool imidiately = false );\r
- virtual FrameNumber hide( bool imidiately = false );\r
- virtual FrameNumber focus( bool imidiately = false );\r
- virtual FrameNumber blur( bool imidiately = false );\r
- virtual FrameNumber click( bool imidiately = false );\r
- virtual void update( );\r
- virtual void draw( ) const;\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- };\r
-\r
-}\r
-}\r
+#pragma once
+#include "mof/widget/WidgetView.hpp"
+#include "mof/graphics/utilities.hpp"
+#include "mof/tstring.hpp"
+#include <boost/scoped_ptr.hpp>
+
+namespace mof
+{
+ class Font;
+
+namespace widget
+{
+
+ class ImageView
+ :
+ public WidgetView
+ {
+ public:
+ ImageView( const tstring& caption , const Font& font );
+ ImageView( const TextureHandler& texture , const Rectangle<float>& tRect );
+ virtual ~ImageView( );
+
+ virtual FrameNumber show( bool imidiately = false );
+ virtual FrameNumber hide( bool imidiately = false );
+ virtual FrameNumber focus( bool imidiately = false );
+ virtual FrameNumber blur( bool imidiately = false );
+ virtual FrameNumber click( bool imidiately = false );
+ virtual void update( );
+ virtual void draw( ) const;
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+}
+}
-#pragma once\r
-#include "mof/widget/WidgetView.hpp"\r
-#include "mof/graphics/utilities.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class Font;\r
-\r
- class ImageView \r
- : \r
- public WidgetView\r
- {\r
- public:\r
- ImageView( const tstring& caption , const Font& font );\r
- ImageView( const TextureHandler& texture , const Rectangle<float>& tRect );\r
- virtual ~ImageView( );\r
-\r
- virtual FrameNumber show( bool imidiately = false );\r
- virtual FrameNumber hide( bool imidiately = false );\r
- virtual FrameNumber focus( bool imidiately = false );\r
- virtual FrameNumber blur( bool imidiately = false );\r
- virtual FrameNumber click( bool imidiately = false );\r
- virtual void update( );\r
- virtual void draw( ) const;\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- };\r
-\r
-}\r
-}\r
+#pragma once
+#include "mof/widget/WidgetView.hpp"
+#include "mof/graphics/utilities.hpp"
+#include "mof/tstring.hpp"
+#include <boost/scoped_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class Font;
+
+ class ImageView
+ :
+ public WidgetView
+ {
+ public:
+ ImageView( const tstring& caption , const Font& font );
+ ImageView( const TextureHandler& texture , const Rectangle<float>& tRect );
+ virtual ~ImageView( );
+
+ virtual FrameNumber show( bool imidiately = false );
+ virtual FrameNumber hide( bool imidiately = false );
+ virtual FrameNumber focus( bool imidiately = false );
+ virtual FrameNumber blur( bool imidiately = false );
+ virtual FrameNumber click( bool imidiately = false );
+ virtual void update( );
+ virtual void draw( ) const;
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+}
+}
-#include <mof/widget/ImageWidgetView.hpp>\r
-#include "mof/mofGraphics.hpp"\r
-#include "mof/Font.hpp"\r
-#include "mof/Sprite.hpp"\r
-#include "mof/widget/Effect.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/widgets.hpp"\r
-#include "mof/streams.hpp"\r
- \r
-namespace mof\r
-{\r
-//{{{ struct Impl\r
- struct ImageWidgetView::Impl\r
- {\r
- Sprite* pSprite;\r
- \r
- Impl( )\r
- : pSprite( NULL )\r
- {\r
- }\r
- \r
- ~Impl()\r
- {\r
- delete pSprite;\r
- }\r
- \r
- };\r
-//}}}\r
-//{{{ constructor\r
- ImageWidgetView::ImageWidgetView\r
- (\r
- const tstring& caption ,\r
- const Font& font\r
- )\r
- : \r
- m_pImpl( new Impl( ) ) \r
- {\r
- { // 画像の生成\r
- m_pImpl->pSprite = Sprite::createTextSprite( font , caption );\r
- m_pImpl->pSprite->getPositionStream( ) << getPositionStream( ); \r
- m_pImpl->pSprite->getColorStream( ) << getColorStream( ); \r
- m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定\r
- }\r
- }\r
-//}}}\r
-//{{{ constructor\r
- ImageWidgetView::ImageWidgetView\r
- (\r
- const TextureHandler& texture ,\r
- const Rectangle<float>& tRect\r
- )\r
- : \r
- m_pImpl( new Impl( ) ) \r
- {\r
- { // 画像の生成\r
- m_pImpl->pSprite = new Sprite( texture , tRect );\r
- m_pImpl->pSprite->getPositionStream( ) << getPositionStream( ); \r
- m_pImpl->pSprite->getColorStream( ) << getColorStream( ); \r
- m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定\r
- }\r
- \r
- }\r
-//}}}\r
-//{{{ destructor\r
- ImageWidgetView::~ImageWidgetView()\r
- {\r
- }\r
-//}}}\r
-//{{{ update\r
- void ImageWidgetView::update( )\r
- {\r
- m_positionStream.update( );\r
- m_sizeStream.update( );\r
- m_colorStream.update( );\r
- m_pImpl->pSprite->update();\r
- }\r
-//}}}\r
-//{{{ draw\r
- void ImageWidgetView::draw( ) const\r
- {\r
- m_pImpl->pSprite->draw( );\r
- }\r
-//}}}\r
-//{{{ show\r
- FrameNumber ImageWidgetView::show( bool imidiately ) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ hide\r
- FrameNumber ImageWidgetView::hide( bool imidiately )\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ focus\r
- FrameNumber ImageWidgetView::focus( bool imidiately ) \r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ blur\r
- FrameNumber ImageWidgetView::blur( bool imidiately )\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-//{{{ click\r
- FrameNumber ImageWidgetView::click( bool imidiately )\r
- {\r
- return 0;\r
- }\r
-//}}}\r
-\r
-} // namespace mof\r
+#include <mof/widget/ImageWidgetView.hpp>
+#include "mof/mofGraphics.hpp"
+#include "mof/Font.hpp"
+#include "mof/Sprite.hpp"
+#include "mof/widget/Effect.hpp"
+#include "mof/utilities.hpp"
+#include "mof/widgets.hpp"
+#include "mof/streams.hpp"
+
+namespace mof
+{
+//{{{ struct Impl
+ struct ImageWidgetView::Impl
+ {
+ Sprite* pSprite;
+
+ Impl( )
+ : pSprite( NULL )
+ {
+ }
+
+ ~Impl()
+ {
+ delete pSprite;
+ }
+
+ };
+//}}}
+//{{{ constructor
+ ImageWidgetView::ImageWidgetView
+ (
+ const tstring& caption ,
+ const Font& font
+ )
+ :
+ m_pImpl( new Impl( ) )
+ {
+ { // 画像の生成
+ m_pImpl->pSprite = Sprite::createTextSprite( font , caption );
+ m_pImpl->pSprite->getPositionStream( ) << getPositionStream( );
+ m_pImpl->pSprite->getColorStream( ) << getColorStream( );
+ m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定
+ }
+ }
+//}}}
+//{{{ constructor
+ ImageWidgetView::ImageWidgetView
+ (
+ const TextureHandler& texture ,
+ const Rectangle<float>& tRect
+ )
+ :
+ m_pImpl( new Impl( ) )
+ {
+ { // 画像の生成
+ m_pImpl->pSprite = new Sprite( texture , tRect );
+ m_pImpl->pSprite->getPositionStream( ) << getPositionStream( );
+ m_pImpl->pSprite->getColorStream( ) << getColorStream( );
+ m_sizeStream << m_pImpl->pSprite->getSizeStream( ); //ビューのサイズを設定
+ }
+
+ }
+//}}}
+//{{{ destructor
+ ImageWidgetView::~ImageWidgetView()
+ {
+ }
+//}}}
+//{{{ update
+ void ImageWidgetView::update( )
+ {
+ m_positionStream.update( );
+ m_sizeStream.update( );
+ m_colorStream.update( );
+ m_pImpl->pSprite->update();
+ }
+//}}}
+//{{{ draw
+ void ImageWidgetView::draw( ) const
+ {
+ m_pImpl->pSprite->draw( );
+ }
+//}}}
+//{{{ show
+ FrameNumber ImageWidgetView::show( bool imidiately )
+ {
+ return 0;
+ }
+//}}}
+//{{{ hide
+ FrameNumber ImageWidgetView::hide( bool imidiately )
+ {
+ return 0;
+ }
+//}}}
+//{{{ focus
+ FrameNumber ImageWidgetView::focus( bool imidiately )
+ {
+ return 0;
+ }
+//}}}
+//{{{ blur
+ FrameNumber ImageWidgetView::blur( bool imidiately )
+ {
+ return 0;
+ }
+//}}}
+//{{{ click
+ FrameNumber ImageWidgetView::click( bool imidiately )
+ {
+ return 0;
+ }
+//}}}
+
+} // namespace mof
-#pragma once\r
-#include "mof/widget/WidgetView.hpp"\r
-#include "mof/graphics/utilities.hpp"\r
-#include "mof/tstring.hpp"\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
- class Font;\r
-\r
- class ImageWidgetView \r
- : \r
- public WidgetView\r
- {\r
- public:\r
- ImageWidgetView( const tstring& caption , const Font& font );\r
- ImageWidgetView( const TextureHandler& texture , const Rectangle<float>& tRect );\r
- virtual ~ImageWidgetView( );\r
-\r
- virtual FrameNumber show( bool imidiately = false );\r
- virtual FrameNumber hide( bool imidiately = false );\r
- virtual FrameNumber focus( bool imidiately = false );\r
- virtual FrameNumber blur( bool imidiately = false );\r
- virtual void update( );\r
- virtual void draw( ) const;\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- \r
- };\r
-\r
-}\r
+#pragma once
+#include "mof/widget/WidgetView.hpp"
+#include "mof/graphics/utilities.hpp"
+#include "mof/tstring.hpp"
+#include <boost/scoped_ptr.hpp>
+
+namespace mof
+{
+ class Font;
+
+ class ImageWidgetView
+ :
+ public WidgetView
+ {
+ public:
+ ImageWidgetView( const tstring& caption , const Font& font );
+ ImageWidgetView( const TextureHandler& texture , const Rectangle<float>& tRect );
+ virtual ~ImageWidgetView( );
+
+ virtual FrameNumber show( bool imidiately = false );
+ virtual FrameNumber hide( bool imidiately = false );
+ virtual FrameNumber focus( bool imidiately = false );
+ virtual FrameNumber blur( bool imidiately = false );
+ virtual void update( );
+ virtual void draw( ) const;
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ };
+
+}
-#pragma once\r
-\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
- class WidgetView;\r
-\r
- class Layout\r
- {\r
-\r
- public:\r
- enum DependencyType\r
- {\r
- PARENT_LEADING ,\r
- CHILD_LEADING\r
- };\r
-\r
- virtual ~Layout(){}\r
- virtual void add(boost::shared_ptr<WidgetView> pView) = 0;\r
- virtual Vector2D getPreferredSize() const = 0;\r
- virtual DependencyType getSizeDependencyType() const = 0;\r
- virtual void connect( WidgetView* pParentView) = 0;\r
- virtual size_t getLength() const = 0;\r
- virtual int getAdjacencyAsUp(int index) const = 0;\r
- virtual int getAdjacencyAsDown(int index) const = 0;\r
- virtual int getAdjacencyAsLeft(int index) const = 0;\r
- virtual int getAdjacencyAsRight(int index) const = 0;\r
- };\r
-}\r
-}\r
+#pragma once
+
+#include "mof/Vector2D.hpp"
+#include "mof/Rectangle.hpp"
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+ class WidgetView;
+
+ class Layout
+ {
+
+ public:
+ enum DependencyType
+ {
+ PARENT_LEADING ,
+ CHILD_LEADING
+ };
+
+ virtual ~Layout(){}
+ virtual void add(boost::shared_ptr<WidgetView> pView) = 0;
+ virtual Vector2D getPreferredSize() const = 0;
+ virtual DependencyType getSizeDependencyType() const = 0;
+ virtual void connect( WidgetView* pParentView) = 0;
+ virtual size_t getLength() const = 0;
+ virtual int getAdjacencyAsUp(int index) const = 0;
+ virtual int getAdjacencyAsDown(int index) const = 0;
+ virtual int getAdjacencyAsLeft(int index) const = 0;
+ virtual int getAdjacencyAsRight(int index) const = 0;
+ };
+}
+}
-#pragma once\r
-\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
- class WidgetView;\r
-\r
- class Layout\r
- {\r
-\r
- public:\r
- enum DependencyType\r
- {\r
- PARENT_LEADING ,\r
- CHILD_LEADING\r
- };\r
-\r
- virtual ~Layout(){}\r
- virtual void add(boost::shared_ptr<WidgetView> pView) = 0;\r
- virtual Vector2D getPreferredSize() const = 0;\r
- virtual DependencyType getSizeDependencyType() const = 0;\r
- virtual void connect( WidgetView* pParentView) = 0;\r
- virtual size_t getLength() const = 0;\r
- virtual int getAdjacencyAsUp(int index) const = 0;\r
- virtual int getAdjacencyAsDown(int index) const = 0;\r
- virtual int getAdjacencyAsLeft(int index) const = 0;\r
- virtual int getAdjacencyAsRight(int index) const = 0;\r
- };\r
-}\r
-}\r
+#pragma once
+
+#include "mof/Vector2D.hpp"
+#include "mof/Rectangle.hpp"
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+ class WidgetView;
+
+ class Layout
+ {
+
+ public:
+ enum DependencyType
+ {
+ PARENT_LEADING ,
+ CHILD_LEADING
+ };
+
+ virtual ~Layout(){}
+ virtual void add(boost::shared_ptr<WidgetView> pView) = 0;
+ virtual Vector2D getPreferredSize() const = 0;
+ virtual DependencyType getSizeDependencyType() const = 0;
+ virtual void connect( WidgetView* pParentView) = 0;
+ virtual size_t getLength() const = 0;
+ virtual int getAdjacencyAsUp(int index) const = 0;
+ virtual int getAdjacencyAsDown(int index) const = 0;
+ virtual int getAdjacencyAsLeft(int index) const = 0;
+ virtual int getAdjacencyAsRight(int index) const = 0;
+ };
+}
+}
-#include "mof/LayoutManager.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-\r
-\r
-\r
-struct mof::LayoutManager::Impl{\r
- \r
- mof::LayoutManager::Direction direction;\r
- int span;\r
- int length;\r
- unsigned int width;\r
- unsigned int height;\r
- mof::Vector2D* positions;\r
-\r
-\r
- Impl( Direction _direction , int _n )\r
- : direction(_direction) , span(_n) , \r
- width(0) , height(0) , length(0) , positions(NULL)\r
- {\r
- }\r
-\r
- ~Impl(){\r
- delete[] positions;\r
- }\r
-};\r
-\r
-\r
-mof::LayoutManager::LayoutManager\r
-(\r
- Direction direction , int n\r
-)\r
-: m_pImpl( new Impl( direction , n ) )\r
-{\r
-}\r
-\r
-\r
-mof::LayoutManager::~LayoutManager( )\r
-{\r
-}\r
-\r
-void mof::LayoutManager::replace\r
-(\r
- unsigned int width , \r
- unsigned int height, \r
- const mof::Rectangle<int> &front ,\r
- const mof::Rectangle<int> &back\r
-)\r
-{\r
- m_pImpl->width = width;\r
- m_pImpl->height = height;\r
- m_pImpl->length = &back - &front + 1;\r
- if(m_pImpl->length <= 0)throw std::invalid_argument("the length of front-back is less than zero");\r
-\r
- delete[] m_pImpl->positions;\r
- m_pImpl->positions = new mof::Vector2D[m_pImpl->length];\r
-\r
- //TODO X Layout\r
- int sumOfY = 0;\r
- for(int i = 0 ; i < m_pImpl->length ; ++i){\r
- m_pImpl->positions[i] = mof::Vector2D( 0 , sumOfY );\r
- sumOfY += (&front)[i].endY - (&front)[i].beginY;\r
- }\r
- \r
-}\r
-\r
-mof::Vector2D mof::LayoutManager::getPosition(int index) const{\r
- if(m_pImpl->positions == NULL)throw std::runtime_error("layout has not initialized yet");\r
- return m_pImpl->positions[index];\r
-}\r
-\r
- \r
- \r
+#include "mof/LayoutManager.hpp"
+#include "mof/ConsoleIO.hpp"
+
+
+
+
+struct mof::LayoutManager::Impl{
+
+ mof::LayoutManager::Direction direction;
+ int span;
+ int length;
+ unsigned int width;
+ unsigned int height;
+ mof::Vector2D* positions;
+
+
+ Impl( Direction _direction , int _n )
+ : direction(_direction) , span(_n) ,
+ width(0) , height(0) , length(0) , positions(NULL)
+ {
+ }
+
+ ~Impl(){
+ delete[] positions;
+ }
+};
+
+
+mof::LayoutManager::LayoutManager
+(
+ Direction direction , int n
+)
+: m_pImpl( new Impl( direction , n ) )
+{
+}
+
+
+mof::LayoutManager::~LayoutManager( )
+{
+}
+
+void mof::LayoutManager::replace
+(
+ unsigned int width ,
+ unsigned int height,
+ const mof::Rectangle<int> &front ,
+ const mof::Rectangle<int> &back
+)
+{
+ m_pImpl->width = width;
+ m_pImpl->height = height;
+ m_pImpl->length = &back - &front + 1;
+ if(m_pImpl->length <= 0)throw std::invalid_argument("the length of front-back is less than zero");
+
+ delete[] m_pImpl->positions;
+ m_pImpl->positions = new mof::Vector2D[m_pImpl->length];
+
+ //TODO X Layout
+ int sumOfY = 0;
+ for(int i = 0 ; i < m_pImpl->length ; ++i){
+ m_pImpl->positions[i] = mof::Vector2D( 0 , sumOfY );
+ sumOfY += (&front)[i].endY - (&front)[i].beginY;
+ }
+
+}
+
+mof::Vector2D mof::LayoutManager::getPosition(int index) const{
+ if(m_pImpl->positions == NULL)throw std::runtime_error("layout has not initialized yet");
+ return m_pImpl->positions[index];
+}
+
+
+
-#pragma once\r
-\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/Rectangle.hpp"\r
-\r
-namespace mof{\r
-\r
- class LayoutManager{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
-\r
- public:\r
- enum Direction{\r
- HORIZONTAL , VERTICAL\r
- };\r
- LayoutManager( Direction direction , int n);\r
- virtual ~LayoutManager();\r
- void replace(unsigned int width , unsigned int height , const mof::Rectangle<int>& front , const mof::Rectangle<int>& back);\r
- \r
- mof::Vector2D getPosition(int index) const ;\r
- int getLength( ) const ;\r
- };\r
-}\r
+#pragma once
+
+#include <boost/scoped_ptr.hpp>
+#include "mof/Vector2D.hpp"
+#include "mof/Rectangle.hpp"
+
+namespace mof{
+
+ class LayoutManager{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+
+ public:
+ enum Direction{
+ HORIZONTAL , VERTICAL
+ };
+ LayoutManager( Direction direction , int n);
+ virtual ~LayoutManager();
+ void replace(unsigned int width , unsigned int height , const mof::Rectangle<int>& front , const mof::Rectangle<int>& back);
+
+ mof::Vector2D getPosition(int index) const ;
+ int getLength( ) const ;
+ };
+}
-#pragma once\r
-#include <mof/widget/Menu.hpp>\r
-#include <mof/widget/GridLayout.hpp>\r
-#include <mof/widget/Container.hpp>\r
-#include <boost/make_shared.hpp>\r
-\r
-using mof::widget::Container;\r
-using mof::widget::WidgetView;\r
-using mof::widget::GridLayout;\r
-using mof::widget::MenuItem;\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-//{{{ Impl\r
- struct Menu::Impl\r
- {\r
- std::vector< boost::function0<void> > actions;\r
- boost::shared_ptr<Container> pView; \r
- int currentIndex;\r
- \r
- Impl()\r
- : pView() , currentIndex(0)\r
- {}\r
- };\r
-//}}}\r
-//{{{ constructor\r
- Menu::Menu\r
- (\r
- const MenuItem& front ,\r
- const MenuItem& back\r
- )\r
- : m_pImpl(new Impl)\r
- {\r
- int length = &back - &front + 1;\r
- std::vector< boost::shared_ptr<mof::widget::WidgetView> > views;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- views.push_back( boost::shared_ptr<WidgetView>( (&front + i)->view( ) ) );\r
- }\r
- \r
- m_pImpl->pView = boost::make_shared<Container>\r
- (\r
- views.front() , views.back() , \r
- makeFactoryMethod<GridLayout>(GridLayout::VERTICAL , 0)\r
- );\r
- \r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ constructor\r
- Menu::Menu\r
- (\r
- const MenuItem& front ,\r
- const MenuItem& back ,\r
- const FactoryMethod<Layout>& layout\r
- )\r
- : m_pImpl(new Impl)\r
- {\r
- int length = &back - &front + 1;\r
- std::vector< boost::shared_ptr<mof::widget::WidgetView> > views;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- views.push_back( boost::shared_ptr<WidgetView>( (&front + i)->view( ) ) );\r
- }\r
- \r
- m_pImpl->pView = boost::make_shared<Container>\r
- (\r
- views.front() , views.back() , layout\r
- );\r
- \r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ destructor\r
- Menu::~Menu()\r
- {\r
- }\r
-//}}}\r
-//{{{ show\r
- mof::FrameNumber Menu::show(bool imidiately)\r
- {\r
- return m_pImpl->pView->show(imidiately);\r
- }\r
-//}}}\r
-//{{{ hide\r
- mof::FrameNumber Menu::hide(bool imidiately)\r
- {\r
- return m_pImpl->pView->hide(imidiately);\r
- }\r
-//}}}\r
-//{{{ getView\r
- const boost::shared_ptr<WidgetView> Menu::getView( ) const\r
- {\r
- return m_pImpl->pView;\r
- }\r
-//}}}\r
-//{{{ getView\r
- boost::shared_ptr<WidgetView> Menu::getView( ) \r
- {\r
- return m_pImpl->pView;\r
- }\r
-//}}}\r
-//{{{ update\r
- void Menu::update()\r
- {\r
- m_pImpl->pView->update();\r
- }\r
-//}}}\r
-//{{{ up\r
- void Menu::up()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsUp(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ down\r
- void Menu::down()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsDown(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ left \r
- void Menu::left()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsLeft(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ right \r
- void Menu::right()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsRight(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ performAction\r
- void Menu::performAction() const\r
- {\r
- m_pImpl->actions[m_pImpl->currentIndex]();\r
- }\r
-//}}}\r
-}\r
-}\r
+#pragma once
+#include <mof/widget/Menu.hpp>
+#include <mof/widget/GridLayout.hpp>
+#include <mof/widget/Container.hpp>
+#include <boost/make_shared.hpp>
+
+using mof::widget::Container;
+using mof::widget::WidgetView;
+using mof::widget::GridLayout;
+using mof::widget::MenuItem;
+
+namespace mof
+{
+namespace widget
+{
+//{{{ Impl
+ struct Menu::Impl
+ {
+ std::vector< boost::function0<void> > actions;
+ boost::shared_ptr<Container> pView;
+ int currentIndex;
+
+ Impl()
+ : pView() , currentIndex(0)
+ {}
+ };
+//}}}
+//{{{ constructor
+ Menu::Menu
+ (
+ const MenuItem& front ,
+ const MenuItem& back
+ )
+ : m_pImpl(new Impl)
+ {
+ int length = &back - &front + 1;
+ std::vector< boost::shared_ptr<mof::widget::WidgetView> > views;
+ for(int i = 0 ; i < length ; i++)
+ {
+ views.push_back( boost::shared_ptr<WidgetView>( (&front + i)->view( ) ) );
+ }
+
+ m_pImpl->pView = boost::make_shared<Container>
+ (
+ views.front() , views.back() ,
+ makeFactoryMethod<GridLayout>(GridLayout::VERTICAL , 0)
+ );
+
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ constructor
+ Menu::Menu
+ (
+ const MenuItem& front ,
+ const MenuItem& back ,
+ const FactoryMethod<Layout>& layout
+ )
+ : m_pImpl(new Impl)
+ {
+ int length = &back - &front + 1;
+ std::vector< boost::shared_ptr<mof::widget::WidgetView> > views;
+ for(int i = 0 ; i < length ; i++)
+ {
+ views.push_back( boost::shared_ptr<WidgetView>( (&front + i)->view( ) ) );
+ }
+
+ m_pImpl->pView = boost::make_shared<Container>
+ (
+ views.front() , views.back() , layout
+ );
+
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ destructor
+ Menu::~Menu()
+ {
+ }
+//}}}
+//{{{ show
+ mof::FrameNumber Menu::show(bool imidiately)
+ {
+ return m_pImpl->pView->show(imidiately);
+ }
+//}}}
+//{{{ hide
+ mof::FrameNumber Menu::hide(bool imidiately)
+ {
+ return m_pImpl->pView->hide(imidiately);
+ }
+//}}}
+//{{{ getView
+ const boost::shared_ptr<WidgetView> Menu::getView( ) const
+ {
+ return m_pImpl->pView;
+ }
+//}}}
+//{{{ getView
+ boost::shared_ptr<WidgetView> Menu::getView( )
+ {
+ return m_pImpl->pView;
+ }
+//}}}
+//{{{ update
+ void Menu::update()
+ {
+ m_pImpl->pView->update();
+ }
+//}}}
+//{{{ up
+ void Menu::up()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsUp(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ down
+ void Menu::down()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsDown(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ left
+ void Menu::left()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsLeft(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ right
+ void Menu::right()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsRight(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ performAction
+ void Menu::performAction() const
+ {
+ m_pImpl->actions[m_pImpl->currentIndex]();
+ }
+//}}}
+}
+}
-#pragma once\r
-#include <mof/widget/Menu.hpp>\r
-#include <mof/widget/GridLayout.hpp>\r
-#include <mof/widget/Container.hpp>\r
-\r
-using mof::widget::Container;\r
-using mof::widget::WidgetView;\r
-using mof::widget::GridLayout;\r
-using mof::widget::MenuItem;\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-//{{{ Impl\r
- struct Menu::Impl\r
- {\r
- std::vector< boost::function0<void> > actions;\r
- boost::shared_ptr<Container> pView; \r
- int currentIndex;\r
- \r
- Impl()\r
- : pView() , currentIndex(0)\r
- {}\r
- };\r
-//}}}\r
-//{{{ constructor\r
- Menu::Menu\r
- (\r
- const MenuItem& front ,\r
- const MenuItem& back\r
- )\r
- : m_pImpl(new Impl)\r
- {\r
- int length = &back - &front + 1;\r
- std::vector< boost::shared_ptr<mof::widget::WidgetView> > views;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- views.push_back( boost::shared_ptr<WidgetView>( (&front + i)->view( ) ) );\r
- }\r
- \r
- m_pImpl->pView = boost::make_shared<Container>\r
- (\r
- views.front() , views.back() , \r
- makeFactoryMethod<GridLayout>(GridLayout::VERTICAL , 0)\r
- );\r
- \r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ constructor\r
- Menu::Menu\r
- (\r
- const MenuItem& front ,\r
- const MenuItem& back ,\r
- const FactoryMethod<Layout>& layout\r
- )\r
- : m_pImpl(new Impl)\r
- {\r
- int length = &back - &front + 1;\r
- std::vector< boost::shared_ptr<mof::widget::WidgetView> > views;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- views.push_back( boost::shared_ptr<WidgetView>( (&front + i)->view( ) ) );\r
- }\r
- \r
- m_pImpl->pView = boost::make_shared<Container>\r
- (\r
- views.front() , views.back() , layout\r
- );\r
- \r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ destructor\r
- Menu::~Menu()\r
- {\r
- }\r
-//}}}\r
-//{{{ show\r
- mof::FrameNumber Menu::show(bool imidiately)\r
- {\r
- return m_pImpl->pView->show(imidiately);\r
- }\r
-//}}}\r
-//{{{ hide\r
- mof::FrameNumber Menu::hide(bool imidiately)\r
- {\r
- return m_pImpl->pView->hide(imidiately);\r
- }\r
-//}}}\r
-//{{{ getView\r
- const boost::shared_ptr<WidgetView> Menu::getView( ) const\r
- {\r
- return m_pImpl->pView;\r
- }\r
-//}}}\r
-//{{{ getView\r
- boost::shared_ptr<WidgetView> Menu::getView( ) \r
- {\r
- return m_pImpl->pView;\r
- }\r
-//}}}\r
-//{{{ update\r
- void Menu::update()\r
- {\r
- m_pImpl->pView->update();\r
- }\r
-//}}}\r
-//{{{ up\r
- void Menu::up()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsUp(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ down\r
- void Menu::down()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsDown(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ left \r
- void Menu::left()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsLeft(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ right \r
- void Menu::right()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsRight(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ performAction\r
- void Menu::performAction() const\r
- {\r
- m_pImpl->actions[m_pImpl->currentIndex]();\r
- }\r
-//}}}\r
-}\r
-}\r
+#pragma once
+#include <mof/widget/Menu.hpp>
+#include <mof/widget/GridLayout.hpp>
+#include <mof/widget/Container.hpp>
+
+using mof::widget::Container;
+using mof::widget::WidgetView;
+using mof::widget::GridLayout;
+using mof::widget::MenuItem;
+
+namespace mof
+{
+namespace widget
+{
+//{{{ Impl
+ struct Menu::Impl
+ {
+ std::vector< boost::function0<void> > actions;
+ boost::shared_ptr<Container> pView;
+ int currentIndex;
+
+ Impl()
+ : pView() , currentIndex(0)
+ {}
+ };
+//}}}
+//{{{ constructor
+ Menu::Menu
+ (
+ const MenuItem& front ,
+ const MenuItem& back
+ )
+ : m_pImpl(new Impl)
+ {
+ int length = &back - &front + 1;
+ std::vector< boost::shared_ptr<mof::widget::WidgetView> > views;
+ for(int i = 0 ; i < length ; i++)
+ {
+ views.push_back( boost::shared_ptr<WidgetView>( (&front + i)->view( ) ) );
+ }
+
+ m_pImpl->pView = boost::make_shared<Container>
+ (
+ views.front() , views.back() ,
+ makeFactoryMethod<GridLayout>(GridLayout::VERTICAL , 0)
+ );
+
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ constructor
+ Menu::Menu
+ (
+ const MenuItem& front ,
+ const MenuItem& back ,
+ const FactoryMethod<Layout>& layout
+ )
+ : m_pImpl(new Impl)
+ {
+ int length = &back - &front + 1;
+ std::vector< boost::shared_ptr<mof::widget::WidgetView> > views;
+ for(int i = 0 ; i < length ; i++)
+ {
+ views.push_back( boost::shared_ptr<WidgetView>( (&front + i)->view( ) ) );
+ }
+
+ m_pImpl->pView = boost::make_shared<Container>
+ (
+ views.front() , views.back() , layout
+ );
+
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ destructor
+ Menu::~Menu()
+ {
+ }
+//}}}
+//{{{ show
+ mof::FrameNumber Menu::show(bool imidiately)
+ {
+ return m_pImpl->pView->show(imidiately);
+ }
+//}}}
+//{{{ hide
+ mof::FrameNumber Menu::hide(bool imidiately)
+ {
+ return m_pImpl->pView->hide(imidiately);
+ }
+//}}}
+//{{{ getView
+ const boost::shared_ptr<WidgetView> Menu::getView( ) const
+ {
+ return m_pImpl->pView;
+ }
+//}}}
+//{{{ getView
+ boost::shared_ptr<WidgetView> Menu::getView( )
+ {
+ return m_pImpl->pView;
+ }
+//}}}
+//{{{ update
+ void Menu::update()
+ {
+ m_pImpl->pView->update();
+ }
+//}}}
+//{{{ up
+ void Menu::up()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsUp(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ down
+ void Menu::down()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsDown(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ left
+ void Menu::left()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsLeft(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ right
+ void Menu::right()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsRight(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ performAction
+ void Menu::performAction() const
+ {
+ m_pImpl->actions[m_pImpl->currentIndex]();
+ }
+//}}}
+}
+}
-#pragma once\r
-#include <mof/widget/Widget.hpp>\r
-#include <mof/FactoryMethod.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-#include <boost/function/function0.hpp>\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- inline void emptyFunc(){}\r
-\r
- struct MenuItem\r
- {\r
- mof::FactoryMethod<WidgetView> view;\r
- boost::function0<void> action;\r
- \r
- MenuItem\r
- (\r
- const mof::FactoryMethod<WidgetView>& view_ ,\r
- const boost::function0<void>& action_\r
- )\r
- : view(view_) , action(action_)\r
- {\r
- }\r
- \r
- MenuItem\r
- (\r
- const mof::FactoryMethod<WidgetView>& view_ \r
- )\r
- : view(view_) , action(emptyFunc)\r
- {\r
- }\r
-\r
- };\r
-\r
- class Menu : public Widget\r
- {\r
- public:\r
- Menu(const MenuItem& front , const MenuItem& back );\r
- Menu\r
- (\r
- const MenuItem& front ,\r
- const MenuItem& back ,\r
- const FactoryMethod<Layout>& layout\r
- );\r
-\r
- virtual ~Menu();\r
- virtual FrameNumber show(bool imidiately = false);\r
- virtual FrameNumber hide(bool imidiately = false);\r
- virtual const boost::shared_ptr<WidgetView> getView( ) const;\r
- virtual boost::shared_ptr<WidgetView> getView( );\r
- virtual void update();\r
- \r
- virtual void up();\r
- virtual void down();\r
- virtual void left();\r
- virtual void right();\r
- virtual void performAction() const;\r
- protected:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
-} // namespace mof\r
+#pragma once
+#include <mof/widget/Widget.hpp>
+#include <mof/FactoryMethod.hpp>
+#include <mof/widget/Layout.hpp>
+#include <boost/function/function0.hpp>
+#include <boost/scoped_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ inline void emptyFunc(){}
+
+ struct MenuItem
+ {
+ mof::FactoryMethod<WidgetView> view;
+ boost::function0<void> action;
+
+ MenuItem
+ (
+ const mof::FactoryMethod<WidgetView>& view_ ,
+ const boost::function0<void>& action_
+ )
+ : view(view_) , action(action_)
+ {
+ }
+
+ MenuItem
+ (
+ const mof::FactoryMethod<WidgetView>& view_
+ )
+ : view(view_) , action(emptyFunc)
+ {
+ }
+
+ };
+
+ class Menu : public Widget
+ {
+ public:
+ Menu(const MenuItem& front , const MenuItem& back );
+ Menu
+ (
+ const MenuItem& front ,
+ const MenuItem& back ,
+ const FactoryMethod<Layout>& layout
+ );
+
+ virtual ~Menu();
+ virtual FrameNumber show(bool imidiately = false);
+ virtual FrameNumber hide(bool imidiately = false);
+ virtual const boost::shared_ptr<WidgetView> getView( ) const;
+ virtual boost::shared_ptr<WidgetView> getView( );
+ virtual void update();
+
+ virtual void up();
+ virtual void down();
+ virtual void left();
+ virtual void right();
+ virtual void performAction() const;
+ protected:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
+} // namespace mof
-#pragma once\r
-#include <mof/widget/Widget.hpp>\r
-#include <mof/FactoryMethod.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-#include <boost/function/function0.hpp>\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- inline void emptyFunc(){}\r
-\r
- struct MenuItem\r
- {\r
- mof::FactoryMethod<WidgetView> view;\r
- boost::function0<void> action;\r
- \r
- MenuItem\r
- (\r
- const mof::FactoryMethod<WidgetView>& view_ ,\r
- const boost::function0<void>& action_\r
- )\r
- : view(view_) , action(action_)\r
- {\r
- }\r
- \r
- MenuItem\r
- (\r
- const mof::FactoryMethod<WidgetView>& view_ \r
- )\r
- : view(view_) , action(emptyFunc)\r
- {\r
- }\r
-\r
- };\r
-\r
- class Menu : public Widget\r
- {\r
- public:\r
- Menu(const MenuItem& front , const MenuItem& back );\r
- Menu\r
- (\r
- const MenuItem& front ,\r
- const MenuItem& back ,\r
- const FactoryMethod<Layout>& layout\r
- );\r
-\r
- virtual ~Menu();\r
- virtual FrameNumber show(bool imidiately = false);\r
- virtual FrameNumber hide(bool imidiately = false);\r
- virtual const boost::shared_ptr<WidgetView> getView() const = 0;\r
- virtual boost::shared_ptr<WidgetView> getView() = 0;\r
- virtual void update();\r
- \r
- virtual void up();\r
- virtual void down();\r
- virtual void left();\r
- virtual void right();\r
- virtual void performAction() const;\r
- protected:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
-} // namespace mof\r
+#pragma once
+#include <mof/widget/Widget.hpp>
+#include <mof/FactoryMethod.hpp>
+#include <mof/widget/Layout.hpp>
+#include <boost/function/function0.hpp>
+#include <boost/scoped_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ inline void emptyFunc(){}
+
+ struct MenuItem
+ {
+ mof::FactoryMethod<WidgetView> view;
+ boost::function0<void> action;
+
+ MenuItem
+ (
+ const mof::FactoryMethod<WidgetView>& view_ ,
+ const boost::function0<void>& action_
+ )
+ : view(view_) , action(action_)
+ {
+ }
+
+ MenuItem
+ (
+ const mof::FactoryMethod<WidgetView>& view_
+ )
+ : view(view_) , action(emptyFunc)
+ {
+ }
+
+ };
+
+ class Menu : public Widget
+ {
+ public:
+ Menu(const MenuItem& front , const MenuItem& back );
+ Menu
+ (
+ const MenuItem& front ,
+ const MenuItem& back ,
+ const FactoryMethod<Layout>& layout
+ );
+
+ virtual ~Menu();
+ virtual FrameNumber show(bool imidiately = false);
+ virtual FrameNumber hide(bool imidiately = false);
+ virtual const boost::shared_ptr<WidgetView> getView() const = 0;
+ virtual boost::shared_ptr<WidgetView> getView() = 0;
+ virtual void update();
+
+ virtual void up();
+ virtual void down();
+ virtual void left();
+ virtual void right();
+ virtual void performAction() const;
+ protected:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
+} // namespace mof
-#pragma once\r
-#include "widget/MenuWidget.hpp"\r
-#include <mof/widget/GridLayout.hpp>\r
-#include <mof/widget/ContainerWidgetView.hpp>\r
-\r
-namespace mof\r
-{\r
-//{{{ Impl\r
- struct MenuWidget::Impl\r
- {\r
- std::vector< boost::function0<void> > actions;\r
- mof::ContainerWidgetView* pView; \r
- int currentIndex;\r
- \r
- Impl()\r
- : pView(NULL) , currentIndex(0)\r
- {}\r
- };\r
-//}}}\r
-//{{{ constructor\r
- MenuWidget::MenuWidget\r
- (\r
- const mof::MenuItem& front ,\r
- const mof::MenuItem& back\r
- )\r
- : m_pImpl(new Impl)\r
- {\r
- int length = &back - &front + 1;\r
- std::vector< mof::FactoryMethod<mof::WidgetView> > views;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- views.push_back((&front + i)->view);\r
- }\r
- \r
- m_pImpl->pView = new mof::ContainerWidgetView\r
- (\r
- views.front() , views.back() , \r
- makeFactoryMethod<GridLayout>(mof::GridLayout::VERTICAL , 0)\r
- );\r
- \r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ constructor\r
- MenuWidget::MenuWidget\r
- (\r
- const mof::MenuItem& front ,\r
- const mof::MenuItem& back ,\r
- const FactoryMethod<Layout>& layout\r
- )\r
- : m_pImpl(new Impl)\r
- {\r
- int length = &back - &front + 1;\r
- std::vector< mof::FactoryMethod<mof::WidgetView> > views;\r
- for(int i = 0 ; i < length ; i++)\r
- {\r
- views.push_back((&front + i)->view);\r
- }\r
- \r
- m_pImpl->pView = new mof::ContainerWidgetView\r
- (\r
- views.front() , views.back() , layout\r
- );\r
- \r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ destructor\r
- MenuWidget::~MenuWidget()\r
- {\r
- delete m_pImpl->pView;\r
- }\r
-//}}}\r
-//{{{ show\r
- mof::FrameNumber MenuWidget::show(bool imidiately)\r
- {\r
- return m_pImpl->pView->show(imidiately);\r
- }\r
-//}}}\r
-//{{{ hide\r
- mof::FrameNumber MenuWidget::hide(bool imidiately)\r
- {\r
- return m_pImpl->pView->hide(imidiately);\r
- }\r
-//}}}\r
-//{{{ getView\r
- const mof::WidgetView& MenuWidget::getView() const\r
- {\r
- return *m_pImpl->pView;\r
- }\r
-//}}}\r
-//{{{ getView\r
- mof::WidgetView& MenuWidget::getView()\r
- {\r
- return *m_pImpl->pView;\r
- }\r
-//}}}\r
-//{{{ update\r
- void MenuWidget::update()\r
- {\r
- m_pImpl->pView->update();\r
- }\r
-//}}}\r
-//{{{ up\r
- void MenuWidget::up()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsUp(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ down\r
- void MenuWidget::down()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsDown(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ left \r
- void MenuWidget::left()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsLeft(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ right \r
- void MenuWidget::right()\r
- {\r
- int index = m_pImpl->pView->getAdjacencyAsRight(m_pImpl->currentIndex);\r
- if(index == m_pImpl->currentIndex)return;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();\r
- m_pImpl->currentIndex = index;\r
- m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();\r
- }\r
-//}}}\r
-//{{{ performAction\r
- void MenuWidget::performAction() const\r
- {\r
- m_pImpl->actions[m_pImpl->currentIndex]();\r
- }\r
-//}}}\r
-} \r
+#pragma once
+#include "widget/MenuWidget.hpp"
+#include <mof/widget/GridLayout.hpp>
+#include <mof/widget/ContainerWidgetView.hpp>
+
+namespace mof
+{
+//{{{ Impl
+ struct MenuWidget::Impl
+ {
+ std::vector< boost::function0<void> > actions;
+ mof::ContainerWidgetView* pView;
+ int currentIndex;
+
+ Impl()
+ : pView(NULL) , currentIndex(0)
+ {}
+ };
+//}}}
+//{{{ constructor
+ MenuWidget::MenuWidget
+ (
+ const mof::MenuItem& front ,
+ const mof::MenuItem& back
+ )
+ : m_pImpl(new Impl)
+ {
+ int length = &back - &front + 1;
+ std::vector< mof::FactoryMethod<mof::WidgetView> > views;
+ for(int i = 0 ; i < length ; i++)
+ {
+ views.push_back((&front + i)->view);
+ }
+
+ m_pImpl->pView = new mof::ContainerWidgetView
+ (
+ views.front() , views.back() ,
+ makeFactoryMethod<GridLayout>(mof::GridLayout::VERTICAL , 0)
+ );
+
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ constructor
+ MenuWidget::MenuWidget
+ (
+ const mof::MenuItem& front ,
+ const mof::MenuItem& back ,
+ const FactoryMethod<Layout>& layout
+ )
+ : m_pImpl(new Impl)
+ {
+ int length = &back - &front + 1;
+ std::vector< mof::FactoryMethod<mof::WidgetView> > views;
+ for(int i = 0 ; i < length ; i++)
+ {
+ views.push_back((&front + i)->view);
+ }
+
+ m_pImpl->pView = new mof::ContainerWidgetView
+ (
+ views.front() , views.back() , layout
+ );
+
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ destructor
+ MenuWidget::~MenuWidget()
+ {
+ delete m_pImpl->pView;
+ }
+//}}}
+//{{{ show
+ mof::FrameNumber MenuWidget::show(bool imidiately)
+ {
+ return m_pImpl->pView->show(imidiately);
+ }
+//}}}
+//{{{ hide
+ mof::FrameNumber MenuWidget::hide(bool imidiately)
+ {
+ return m_pImpl->pView->hide(imidiately);
+ }
+//}}}
+//{{{ getView
+ const mof::WidgetView& MenuWidget::getView() const
+ {
+ return *m_pImpl->pView;
+ }
+//}}}
+//{{{ getView
+ mof::WidgetView& MenuWidget::getView()
+ {
+ return *m_pImpl->pView;
+ }
+//}}}
+//{{{ update
+ void MenuWidget::update()
+ {
+ m_pImpl->pView->update();
+ }
+//}}}
+//{{{ up
+ void MenuWidget::up()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsUp(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ down
+ void MenuWidget::down()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsDown(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ left
+ void MenuWidget::left()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsLeft(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ right
+ void MenuWidget::right()
+ {
+ int index = m_pImpl->pView->getAdjacencyAsRight(m_pImpl->currentIndex);
+ if(index == m_pImpl->currentIndex)return;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->blur();
+ m_pImpl->currentIndex = index;
+ m_pImpl->pView->getAt(m_pImpl->currentIndex)->focus();
+ }
+//}}}
+//{{{ performAction
+ void MenuWidget::performAction() const
+ {
+ m_pImpl->actions[m_pImpl->currentIndex]();
+ }
+//}}}
+}
-#pragma once\r
-#include <mof/widget/Widget.hpp>\r
-#include <mof/FactoryMethod.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-#include <boost/function/function0.hpp>\r
-#include <boost/scoped_ptr.hpp>\r
-\r
-namespace mof{\r
-\r
- inline void emptyFunc(){}\r
-\r
- struct MenuItem\r
- {\r
- mof::FactoryMethod<WidgetView> view;\r
- boost::function0<void> action;\r
- \r
- MenuItem\r
- (\r
- const mof::FactoryMethod<WidgetView>& view_ ,\r
- const boost::function0<void>& action_\r
- )\r
- : view(view_) , action(action_)\r
- {\r
- }\r
- \r
- MenuItem\r
- (\r
- const mof::FactoryMethod<WidgetView>& view_ \r
- )\r
- : view(view_) , action(emptyFunc)\r
- {\r
- }\r
-\r
- };\r
-\r
- class MenuWidget \r
- {\r
- public:\r
- MenuWidget(const MenuItem& front , const MenuItem& back );\r
- MenuWidget\r
- (\r
- const MenuItem& front ,\r
- const MenuItem& back ,\r
- const FactoryMethod<Layout>& layout\r
- );\r
-\r
- virtual ~MenuWidget();\r
- virtual FrameNumber show(bool imidiately = false);\r
- virtual FrameNumber hide(bool imidiately = false);\r
- virtual const WidgetView& getView() const;\r
- virtual WidgetView& getView();\r
- virtual void update();\r
- \r
- virtual void up();\r
- virtual void down();\r
- virtual void left();\r
- virtual void right();\r
- virtual void performAction() const;\r
- protected:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-} // namespace mof\r
+#pragma once
+#include <mof/widget/Widget.hpp>
+#include <mof/FactoryMethod.hpp>
+#include <mof/widget/Layout.hpp>
+#include <boost/function/function0.hpp>
+#include <boost/scoped_ptr.hpp>
+
+namespace mof{
+
+ inline void emptyFunc(){}
+
+ struct MenuItem
+ {
+ mof::FactoryMethod<WidgetView> view;
+ boost::function0<void> action;
+
+ MenuItem
+ (
+ const mof::FactoryMethod<WidgetView>& view_ ,
+ const boost::function0<void>& action_
+ )
+ : view(view_) , action(action_)
+ {
+ }
+
+ MenuItem
+ (
+ const mof::FactoryMethod<WidgetView>& view_
+ )
+ : view(view_) , action(emptyFunc)
+ {
+ }
+
+ };
+
+ class MenuWidget
+ {
+ public:
+ MenuWidget(const MenuItem& front , const MenuItem& back );
+ MenuWidget
+ (
+ const MenuItem& front ,
+ const MenuItem& back ,
+ const FactoryMethod<Layout>& layout
+ );
+
+ virtual ~MenuWidget();
+ virtual FrameNumber show(bool imidiately = false);
+ virtual FrameNumber hide(bool imidiately = false);
+ virtual const WidgetView& getView() const;
+ virtual WidgetView& getView();
+ virtual void update();
+
+ virtual void up();
+ virtual void down();
+ virtual void left();
+ virtual void right();
+ virtual void performAction() const;
+ protected:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+} // namespace mof
-#pragma once\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/widget/Widget.hpp>\r
-#include <mof/stream/Manipulator.hpp>\r
-#include <boost/utility.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class Message : public Widget\r
- {\r
- public:\r
- Message(mof::tstring& message);\r
- virtual ~Message();\r
- virtual FrameNumber show(bool imidiately = false);\r
- virtual FrameNumber hide(bool imidiately = false);\r
- virtual const boost::shared_ptr<WidgetView> getView() const;\r
- virtual boost::shared_ptr<WidgetView> getView();\r
- virtual void update();\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- }; \r
-\r
-}\r
-}\r
+#pragma once
+#include <mof/widget/WidgetView.hpp>
+#include <mof/widget/Widget.hpp>
+#include <mof/stream/Manipulator.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class Message : public Widget
+ {
+ public:
+ Message(mof::tstring& message);
+ virtual ~Message();
+ virtual FrameNumber show(bool imidiately = false);
+ virtual FrameNumber hide(bool imidiately = false);
+ virtual const boost::shared_ptr<WidgetView> getView() const;
+ virtual boost::shared_ptr<WidgetView> getView();
+ virtual void update();
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
+}
-#pragma once\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/widget/Widget.hpp>\r
-#include <mof/stream/Manipulator.hpp>\r
-#include <boost/utility.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class Message : public Widget\r
- {\r
- public:\r
- Message();\r
- virtual ~Message();\r
- virtual FrameNumber show(bool imidiately = false);\r
- virtual FrameNumber hide(bool imidiately = false);\r
- virtual const boost::shared_ptr<WidgetView> getView() const;\r
- virtual boost::shared_ptr<WidgetView> getView();\r
- virtual void update();\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- }; \r
-\r
-}\r
-}\r
+#pragma once
+#include <mof/widget/WidgetView.hpp>
+#include <mof/widget/Widget.hpp>
+#include <mof/stream/Manipulator.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class Message : public Widget
+ {
+ public:
+ Message();
+ virtual ~Message();
+ virtual FrameNumber show(bool imidiately = false);
+ virtual FrameNumber hide(bool imidiately = false);
+ virtual const boost::shared_ptr<WidgetView> getView() const;
+ virtual boost::shared_ptr<WidgetView> getView();
+ virtual void update();
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
+}
-#include "mof/MessageWidget.hpp"\r
-#include "mof/Effect.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/LayoutManager.hpp"\r
-#include <boost/scoped_array.hpp>\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/WidgetView.hpp"\r
-#include "mof/TextView.hpp"\r
-#include "mof/GraphicsDevice.hpp"\r
-#include "mof/mofAnimations.hpp"\r
-#include "mof/TextCompiler.hpp"\r
-#include "mof/widgets.hpp"\r
- \r
-namespace mof\r
-{\r
- \r
- struct MessageWidget::Impl\r
- {\r
- mof::WidgetView* pBackgroundView;\r
- mof::TextView* pTitleView;\r
- mof::LayoutManager* pLayout;\r
- //boost::shared_ptr<mof::Matrix2D> pTranslation;\r
- mof::TranslationAnimation2D::Handler translation;\r
- mof::ScalingAnimation2D::Handler scaling;\r
- mof::Pager* pPager;\r
- mof::FrameNumber frame;\r
- //int width;\r
- //int height;\r
- \r
-//{{{ Impl \r
- Impl()\r
- : \r
- pBackgroundView(NULL) , \r
- pTitleView(NULL) , \r
- pLayout(NULL) ,\r
- pPager( NULL ) ,\r
- frame( 0 )\r
- {\r
- translation = mof::TranslationAnimation2D::Handler\r
- (\r
- new mof::TranslationAnimation2D\r
- (\r
- mof::makeConstantHandler\r
- (\r
- mof::Vector2D( 0 , 0 )\r
- )\r
- )\r
- );\r
-\r
- scaling = mof::ScalingAnimation2D::Handler\r
- (\r
- new mof::ScalingAnimation2D\r
- (\r
- mof::makeConstantHandler\r
- (\r
- mof::Vector2D( 0 , 0 )\r
- )\r
- )\r
- );\r
-\r
- }\r
-//}}}\r
-//{{{ ~Impl\r
- ~Impl()\r
- {\r
- delete pLayout;\r
- delete pBackgroundView;\r
- delete pTitleView;\r
- delete pPager;\r
- }\r
- \r
-//}}} \r
- };\r
-//{{{ MessageWidget\r
- MessageWidget::MessageWidget\r
- (\r
- mof::WidgetView* pBackgroundView ,\r
- const mof::Rectangle<int>& bounds ,\r
- mof::LayoutManager* pLayout\r
- )\r
- : m_pImpl( new Impl( ) )\r
- {\r
- m_pImpl->pLayout = pLayout;\r
- m_pImpl->pBackgroundView = pBackgroundView;\r
- m_pImpl->pBackgroundView->setBounds( bounds );\r
- m_pImpl->translation->set( m_pImpl->pBackgroundView->getPosition( ) );\r
- m_pImpl->scaling->set( m_pImpl->pBackgroundView->getSize( ) );\r
- \r
- { // \83^\83C\83g\83\8b\82Ì\8f\89\8aú\89»\r
- if( true )\r
- {\r
- m_pImpl->pTitleView = new mof::TextView\r
- (\r
- _T("Title") , mof::Font( mof::Font::MS_P_GOTHIC , 25 )\r
- );\r
- m_pImpl->pTitleView->initialize();\r
- mof::Rectangle<int> tmp( bounds.beginX , bounds.beginY , bounds.endX , bounds.beginY + 32 );\r
- m_pImpl->pTitleView->setBounds( tmp );\r
- \r
- }\r
- }\r
- { // \83y\81[\83W\83\83\82Ì\90¶\90¬\r
- mof::LayoutManager* pLayout = new mof::LayoutManager( mof::LayoutManager::HORIZONTAL , 1);\r
- m_pImpl->pPager = new mof::Pager( bounds , pLayout );\r
- }\r
- }\r
-//}}}\r
-//{{{ ~MessageWidget\r
- MessageWidget::~MessageWidget(){\r
- \r
- }\r
-//}}}\r
-//{{{ show\r
- void MessageWidget::show(){\r
- m_pImpl->pPager->show();\r
- m_pImpl->pBackgroundView->show();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->show();\r
- }\r
-//}}}\r
-//{{{ close\r
- void MessageWidget::close()\r
- {\r
- m_pImpl->pPager->close();\r
- m_pImpl->pBackgroundView->close();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->close();\r
- }\r
-//}}}\r
-//{{{ nextPage\r
- void MessageWidget::nextPage(){\r
- if( !m_pImpl->pPager->hasNextPage( ) )close();\r
- else if( !m_pImpl->pPager->hasPreviousPage() )show();\r
- else m_pImpl->pPager->nextPage();\r
- }\r
-//}}}\r
-//{{{ addPage\r
- void MessageWidget::addPage( const PageRequest& page ){\r
- \r
- m_pImpl->pPager->addPage( page );\r
- \r
- std::vector<mof::Rectangle<int> > boundList;\r
- if( m_pImpl->pTitleView )boundList.push_back( mof::Rectangle<int>( 0 , 0 , 1 , 32) );\r
- boundList.push_back( m_pImpl->pPager->getBounds( ) );\r
- \r
- mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );\r
- m_pImpl->pLayout->replace\r
- (\r
- scaling.x , scaling.y ,\r
- boundList.front() , boundList.back()\r
- );\r
-\r
- int i = 0;\r
- if( m_pImpl->pTitleView )\r
- {\r
- mof::Animation<mof::Matrix2D>::Handler children[] =\r
- {\r
- mof::makeConstantHandler\r
- ( \r
- mof::Matrix2D::createScaling\r
- (\r
- mof::Vector2D(boundList.at(i).getWidth( ) , boundList.at(i).getHeight( ) )\r
- )\r
- ) ,\r
- m_pImpl->translation ,\r
- mof::makeConstantHandler\r
- (\r
- mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(i) )\r
- )\r
- }; // array children\r
- \r
- mof::Animation<mof::Matrix2D>::Handler handler\r
- (\r
- new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )\r
- );\r
- i++;\r
- //m_pImpl->pTitleView->setWorldTransform( handler );\r
- //m_pImpl->pTitleView->setColor(mof::Color4f(0 , 1 , 1 , 1));\r
- \r
- } // if\r
- {\r
- const mof::Animation<mof::Vector2D>::Handler children[] =\r
- {\r
- //mof::makeConstantHandler( mof::Vector2D( 300 , 300) ) ,\r
- m_pImpl->translation->get( ) ,\r
- mof::makeConstantHandler\r
- (\r
- m_pImpl->pLayout->getPosition(i) \r
- )\r
- }; // array children\r
- \r
- mof::Animation<mof::Vector2D>::Handler handler\r
- (\r
- new mof::CascadingAnimation<mof::Vector2D , mof::Add<mof::Vector2D> >( children[0] , mof::lastOf( children ) )\r
- );\r
- m_pImpl->pPager->setPosition( handler );\r
- //m_pImpl->pTitleView->setWorldTransform( handler );\r
- //m_pImpl->pTitleView->setColor(mof::Color4f(0 , 1 , 1 , 1));\r
- \r
- } // for \r
- \r
- \r
- }\r
-//}}}\r
-//{{{ draw\r
- void MessageWidget::draw() const{\r
- m_pImpl->pBackgroundView->draw();\r
- \r
- { // \95`\89æ\97Ì\88æ\82ð\90§\8cÀ\r
- mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );\r
- mof::Vector2D translation = m_pImpl->translation->get( )->getValue( m_pImpl->frame );\r
- mof::GraphicsDevice::setViewport \r
- ( \r
- mof::Rectangle<int>( translation.x , translation.y , translation.x + scaling.x , translation.y + scaling.y )\r
- );\r
- }\r
-\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->getEffect()->draw();\r
- m_pImpl->pPager->draw(); \r
- mof::GraphicsDevice::setViewport(mof::Rectangle<int>(0 , 0 , 640 , 480));//TODO\r
- \r
- }\r
-//}}}\r
-//{{{ update\r
- void MessageWidget::update() {\r
- \r
- m_pImpl->pBackgroundView->update();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->update();\r
- m_pImpl->pPager->update(); \r
- m_pImpl->frame++;\r
- }\r
-//}}}\r
-//{{{ hasNextPage\r
- bool MessageWidget::hasNextPage( ){\r
- return m_pImpl->pPager->hasNextPage( );\r
- \r
- }\r
-//}}}\r
-} //namespace mof\r
-\r
+#include "mof/MessageWidget.hpp"
+#include "mof/Effect.hpp"
+#include "mof/utilities.hpp"
+#include "mof/LayoutManager.hpp"
+#include <boost/scoped_array.hpp>
+#include "mof/ConsoleIO.hpp"
+#include "mof/WidgetView.hpp"
+#include "mof/TextView.hpp"
+#include "mof/GraphicsDevice.hpp"
+#include "mof/mofAnimations.hpp"
+#include "mof/TextCompiler.hpp"
+#include "mof/widgets.hpp"
+
+namespace mof
+{
+
+ struct MessageWidget::Impl
+ {
+ mof::WidgetView* pBackgroundView;
+ mof::TextView* pTitleView;
+ mof::LayoutManager* pLayout;
+ //boost::shared_ptr<mof::Matrix2D> pTranslation;
+ mof::TranslationAnimation2D::Handler translation;
+ mof::ScalingAnimation2D::Handler scaling;
+ mof::Pager* pPager;
+ mof::FrameNumber frame;
+ //int width;
+ //int height;
+
+//{{{ Impl
+ Impl()
+ :
+ pBackgroundView(NULL) ,
+ pTitleView(NULL) ,
+ pLayout(NULL) ,
+ pPager( NULL ) ,
+ frame( 0 )
+ {
+ translation = mof::TranslationAnimation2D::Handler
+ (
+ new mof::TranslationAnimation2D
+ (
+ mof::makeConstantHandler
+ (
+ mof::Vector2D( 0 , 0 )
+ )
+ )
+ );
+
+ scaling = mof::ScalingAnimation2D::Handler
+ (
+ new mof::ScalingAnimation2D
+ (
+ mof::makeConstantHandler
+ (
+ mof::Vector2D( 0 , 0 )
+ )
+ )
+ );
+
+ }
+//}}}
+//{{{ ~Impl
+ ~Impl()
+ {
+ delete pLayout;
+ delete pBackgroundView;
+ delete pTitleView;
+ delete pPager;
+ }
+
+//}}}
+ };
+//{{{ MessageWidget
+ MessageWidget::MessageWidget
+ (
+ mof::WidgetView* pBackgroundView ,
+ const mof::Rectangle<int>& bounds ,
+ mof::LayoutManager* pLayout
+ )
+ : m_pImpl( new Impl( ) )
+ {
+ m_pImpl->pLayout = pLayout;
+ m_pImpl->pBackgroundView = pBackgroundView;
+ m_pImpl->pBackgroundView->setBounds( bounds );
+ m_pImpl->translation->set( m_pImpl->pBackgroundView->getPosition( ) );
+ m_pImpl->scaling->set( m_pImpl->pBackgroundView->getSize( ) );
+
+ { // \83^\83C\83g\83\8b\82Ì\8f\89\8aú\89»
+ if( true )
+ {
+ m_pImpl->pTitleView = new mof::TextView
+ (
+ _T("Title") , mof::Font( mof::Font::MS_P_GOTHIC , 25 )
+ );
+ m_pImpl->pTitleView->initialize();
+ mof::Rectangle<int> tmp( bounds.beginX , bounds.beginY , bounds.endX , bounds.beginY + 32 );
+ m_pImpl->pTitleView->setBounds( tmp );
+
+ }
+ }
+ { // \83y\81[\83W\83\83\82Ì\90¶\90¬
+ mof::LayoutManager* pLayout = new mof::LayoutManager( mof::LayoutManager::HORIZONTAL , 1);
+ m_pImpl->pPager = new mof::Pager( bounds , pLayout );
+ }
+ }
+//}}}
+//{{{ ~MessageWidget
+ MessageWidget::~MessageWidget(){
+
+ }
+//}}}
+//{{{ show
+ void MessageWidget::show(){
+ m_pImpl->pPager->show();
+ m_pImpl->pBackgroundView->show();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->show();
+ }
+//}}}
+//{{{ close
+ void MessageWidget::close()
+ {
+ m_pImpl->pPager->close();
+ m_pImpl->pBackgroundView->close();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->close();
+ }
+//}}}
+//{{{ nextPage
+ void MessageWidget::nextPage(){
+ if( !m_pImpl->pPager->hasNextPage( ) )close();
+ else if( !m_pImpl->pPager->hasPreviousPage() )show();
+ else m_pImpl->pPager->nextPage();
+ }
+//}}}
+//{{{ addPage
+ void MessageWidget::addPage( const PageRequest& page ){
+
+ m_pImpl->pPager->addPage( page );
+
+ std::vector<mof::Rectangle<int> > boundList;
+ if( m_pImpl->pTitleView )boundList.push_back( mof::Rectangle<int>( 0 , 0 , 1 , 32) );
+ boundList.push_back( m_pImpl->pPager->getBounds( ) );
+
+ mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );
+ m_pImpl->pLayout->replace
+ (
+ scaling.x , scaling.y ,
+ boundList.front() , boundList.back()
+ );
+
+ int i = 0;
+ if( m_pImpl->pTitleView )
+ {
+ mof::Animation<mof::Matrix2D>::Handler children[] =
+ {
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createScaling
+ (
+ mof::Vector2D(boundList.at(i).getWidth( ) , boundList.at(i).getHeight( ) )
+ )
+ ) ,
+ m_pImpl->translation ,
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(i) )
+ )
+ }; // array children
+
+ mof::Animation<mof::Matrix2D>::Handler handler
+ (
+ new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )
+ );
+ i++;
+ //m_pImpl->pTitleView->setWorldTransform( handler );
+ //m_pImpl->pTitleView->setColor(mof::Color4f(0 , 1 , 1 , 1));
+
+ } // if
+ {
+ const mof::Animation<mof::Vector2D>::Handler children[] =
+ {
+ //mof::makeConstantHandler( mof::Vector2D( 300 , 300) ) ,
+ m_pImpl->translation->get( ) ,
+ mof::makeConstantHandler
+ (
+ m_pImpl->pLayout->getPosition(i)
+ )
+ }; // array children
+
+ mof::Animation<mof::Vector2D>::Handler handler
+ (
+ new mof::CascadingAnimation<mof::Vector2D , mof::Add<mof::Vector2D> >( children[0] , mof::lastOf( children ) )
+ );
+ m_pImpl->pPager->setPosition( handler );
+ //m_pImpl->pTitleView->setWorldTransform( handler );
+ //m_pImpl->pTitleView->setColor(mof::Color4f(0 , 1 , 1 , 1));
+
+ } // for
+
+
+ }
+//}}}
+//{{{ draw
+ void MessageWidget::draw() const{
+ m_pImpl->pBackgroundView->draw();
+
+ { // \95`\89æ\97Ì\88æ\82ð\90§\8cÀ
+ mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );
+ mof::Vector2D translation = m_pImpl->translation->get( )->getValue( m_pImpl->frame );
+ mof::GraphicsDevice::setViewport
+ (
+ mof::Rectangle<int>( translation.x , translation.y , translation.x + scaling.x , translation.y + scaling.y )
+ );
+ }
+
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->getEffect()->draw();
+ m_pImpl->pPager->draw();
+ mof::GraphicsDevice::setViewport(mof::Rectangle<int>(0 , 0 , 640 , 480));//TODO
+
+ }
+//}}}
+//{{{ update
+ void MessageWidget::update() {
+
+ m_pImpl->pBackgroundView->update();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->update();
+ m_pImpl->pPager->update();
+ m_pImpl->frame++;
+ }
+//}}}
+//{{{ hasNextPage
+ bool MessageWidget::hasNextPage( ){
+ return m_pImpl->pPager->hasNextPage( );
+
+ }
+//}}}
+} //namespace mof
+
-#include "mof/MessageWidget.hpp"\r
-#include "mof/Effect.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/LayoutManager.hpp"\r
-#include <boost/scoped_array.hpp>\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/WidgetView.hpp"\r
-#include "mof/TextView.hpp"\r
-#include "mof/GraphicsDevice.hpp"\r
-#include "mof/mofAnimations.hpp"\r
-#include "mof/TextCompiler.hpp"\r
-#include "mof/widgets.hpp"\r
-\r
-struct mof::MessageWidget::Impl{\r
- mof::WidgetView* pBackgroundView;\r
- mof::TextView* pTitleView;\r
- mof::LayoutManager* pLayout;\r
- boost::shared_ptr<mof::Matrix2D> pTranslation;\r
- int width;\r
- int height;\r
- \r
- std::vector<std::vector<mof::Sprite*> > pages;\r
- int currentPage;\r
-\r
- Impl(const mof::Rectangle<int>& _bounds)\r
- : \r
- pBackgroundView(NULL) , \r
- pTitleView(NULL) , \r
- width(_bounds.endX - _bounds.beginX) ,\r
- height(_bounds.endY - _bounds.beginY) ,\r
- currentPage(-1) ,\r
- pLayout(NULL) \r
- {\r
- pTranslation = boost::shared_ptr<mof::Matrix2D>\r
- (\r
- new mof::Matrix2D\r
- (\r
- mof::Matrix2D::createTranslation\r
- (\r
- mof::Vector2D(_bounds.beginX , _bounds.beginY )\r
- )\r
- )\r
- );\r
- }\r
-\r
- ~Impl(){\r
- delete pLayout;\r
- delete pBackgroundView;\r
- delete pTitleView;\r
- foreach(std::vector<mof::Sprite*>& page , pages ){\r
- foreach(mof::Sprite*& pSprite , page ){\r
- delete pSprite;\r
- }\r
- }\r
- }\r
-\r
- void showPage(bool first){\r
- mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {\r
- mof::makeKeyFrame(first ? 0 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) ,\r
- mof::makeKeyFrame(first ? 30*2 : 90 , mof::Color4f(1 , 1 , 1 , 1) ) \r
- };\r
- mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));\r
- foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){\r
- pSprite->setColor(handler);\r
- pSprite->setFrameNumber(0);\r
- }\r
- }\r
-\r
- void closePage(bool last){\r
- mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {\r
- mof::makeKeyFrame(0 , mof::Color4f(1 , 1 , 1 , 1) ) ,\r
- mof::makeKeyFrame(last ? 10*2 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) \r
- };\r
- mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));\r
- foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){\r
- pSprite->setColor(handler);\r
- pSprite->setFrameNumber(0);\r
- }\r
- }\r
-\r
-\r
- \r
-};\r
-\r
-//{{{ MessageWidget\r
-mof::MessageWidget::MessageWidget\r
-(\r
- mof::WidgetView* pBackgroundView ,\r
- const mof::Rectangle<int>& bounds ,\r
- mof::LayoutManager* pLayout\r
-)\r
-: m_pImpl( new Impl( bounds) )\r
-{\r
- m_pImpl->pLayout = pLayout;\r
- m_pImpl->pBackgroundView = pBackgroundView;\r
-\r
- { // \83^\83C\83g\83\8b\82Ì\8f\89\8aú\89»\r
- if( true )\r
- {\r
- m_pImpl->pTitleView = new mof::TextView\r
- (\r
- _T("Title") , mof::Font( mof::Font::MS_P_GOTHIC , 25 )\r
- );\r
- m_pImpl->pTitleView->initialize();\r
- mof::Rectangle<int> tmp( bounds.beginX , bounds.beginY , bounds.endX , bounds.beginY + 32 );\r
- m_pImpl->pTitleView->setBounds( tmp );\r
-\r
- }\r
- }\r
-\r
- m_pImpl->pBackgroundView->setBounds(bounds);\r
-}\r
-//}}}\r
-//{{{ ~MessageWidget\r
-mof::MessageWidget::~MessageWidget(){\r
-\r
-}\r
-//}}}\r
-//{{{ show\r
-void mof::MessageWidget::show(){\r
- m_pImpl->currentPage = -1;\r
- m_pImpl->pBackgroundView->show();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->show();\r
- m_pImpl->currentPage++;\r
- m_pImpl->showPage(true);\r
-}\r
-//}}}\r
-//{{{ close\r
-void mof::MessageWidget::close(){\r
-\r
- m_pImpl->pBackgroundView->close();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->close();\r
- if(m_pImpl->currentPage < 0)return;\r
- m_pImpl->closePage(true);\r
-}\r
-//}}}\r
-//{{{ nextPage\r
-void mof::MessageWidget::nextPage(){\r
- if(m_pImpl->currentPage < 0){\r
- show();\r
- return;\r
- }\r
- m_pImpl->closePage(false);\r
- if(m_pImpl->currentPage >= static_cast<signed int>(m_pImpl->pages.size()) -1 ){\r
- close();\r
- return;\r
- }\r
- m_pImpl->currentPage++;\r
- m_pImpl->showPage(false);\r
-}\r
-//}}}\r
-//{{{ addPage\r
-void mof::MessageWidget::addPage( const Page& page ){\r
-\r
- m_pImpl->pages.push_back(std::vector<mof::Sprite*>());\r
- mof::compileText( page.message , page.font , m_pImpl->pages.back() );\r
- \r
- std::vector<mof::Rectangle<int> > boundList;\r
- if( m_pImpl->pTitleView )boundList.push_back( mof::Rectangle<int>( 0 , 0 , 1 , 32) );\r
- //if( m_pImpl->pTitleView )boundList.push_back( m_pImpl->pTitle->getBounds() );\r
- \r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.back() ){\r
- mof::Rectangle<int> bounds = pSprite->getWorldTransform().toBoundingBox(); \r
- boundList.push_back(bounds);\r
- }\r
- m_pImpl->pLayout->replace(m_pImpl->width , m_pImpl->height , boundList.front() , boundList.back() );\r
- \r
- //TODO: LayoutAnimation\82ð\82Â\82\82é\r
- for(unsigned int j = 0 ; j < m_pImpl->pLayout->getLength( ) ; ++j)\r
- {\r
- const mof::Animation<mof::Matrix2D>::Handler children[] =\r
- {\r
- mof::makeConstantHandler\r
- ( \r
- mof::Matrix2D::createScaling\r
- (\r
- mof::Vector2D(boundList.at(j).endX - boundList.at(j).beginX , boundList.at(j).endY - boundList.at(j).beginY)\r
- )\r
- ) ,\r
- mof::makeParametricHandler(m_pImpl->pTranslation) ,\r
- mof::makeConstantHandler\r
- (\r
- mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(j) )\r
- )\r
- }; // array children\r
-\r
- mof::Animation<mof::Matrix2D>::Handler handler\r
- (\r
- new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )\r
- );\r
-\r
- //if( m_pImpl->pTitleView && j == 0 )m_pImpl->pTitleView->setPosition( handler );\r
- if( m_pImpl->pTitleView && j != 0 )\r
- {\r
- m_pImpl->pages.back().at(j-1)->setWorldTransform( handler );\r
- m_pImpl->pages.back().at(j-1)->setColor(mof::Color4f(0 , 1 , 1 , 1));\r
- }\r
- else if( NULL != m_pImpl->pTitleView )\r
- {\r
- m_pImpl->pages.back().at(j)->setWorldTransform( handler );\r
- m_pImpl->pages.back().at(j)->setColor(mof::Color4f(0 , 1 , 1 , 1));\r
- }\r
-\r
- } // for \r
-\r
-\r
-}\r
-//}}}\r
-//{{{ draw\r
-void mof::MessageWidget::draw() const{\r
- m_pImpl->pBackgroundView->draw();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->getEffect()->draw();\r
- if(m_pImpl->currentPage < 0)return;\r
- \r
- if(m_pImpl->currentPage > 0){\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){\r
- pSprite->draw();\r
- }\r
- }\r
- mof::GraphicsDevice::setViewport(m_pImpl->pBackgroundView->getBounds());\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){\r
- pSprite->draw();\r
- }\r
- mof::GraphicsDevice::setViewport(mof::Rectangle<int>(0 , 0 , 640 , 480));//TODO\r
- \r
-}\r
-//}}}\r
-//{{{ update\r
-void mof::MessageWidget::update() {\r
-\r
- m_pImpl->pBackgroundView->update();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->update();\r
- if(m_pImpl->currentPage < 0)return;\r
- if(m_pImpl->currentPage > 0){\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){\r
- pSprite->update();\r
- }\r
- }\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){\r
- pSprite->update();\r
- }\r
-}\r
-//}}}\r
-//{{{ hasNextPage\r
-bool mof::MessageWidget::hasNextPage(){\r
- return m_pImpl->currentPage < static_cast<signed int>(m_pImpl->pages.size()) -1;\r
-\r
-}\r
-//}}}\r
-\r
+#include "mof/MessageWidget.hpp"
+#include "mof/Effect.hpp"
+#include "mof/utilities.hpp"
+#include "mof/LayoutManager.hpp"
+#include <boost/scoped_array.hpp>
+#include "mof/ConsoleIO.hpp"
+#include "mof/WidgetView.hpp"
+#include "mof/TextView.hpp"
+#include "mof/GraphicsDevice.hpp"
+#include "mof/mofAnimations.hpp"
+#include "mof/TextCompiler.hpp"
+#include "mof/widgets.hpp"
+
+struct mof::MessageWidget::Impl{
+ mof::WidgetView* pBackgroundView;
+ mof::TextView* pTitleView;
+ mof::LayoutManager* pLayout;
+ boost::shared_ptr<mof::Matrix2D> pTranslation;
+ int width;
+ int height;
+
+ std::vector<std::vector<mof::Sprite*> > pages;
+ int currentPage;
+
+ Impl(const mof::Rectangle<int>& _bounds)
+ :
+ pBackgroundView(NULL) ,
+ pTitleView(NULL) ,
+ width(_bounds.endX - _bounds.beginX) ,
+ height(_bounds.endY - _bounds.beginY) ,
+ currentPage(-1) ,
+ pLayout(NULL)
+ {
+ pTranslation = boost::shared_ptr<mof::Matrix2D>
+ (
+ new mof::Matrix2D
+ (
+ mof::Matrix2D::createTranslation
+ (
+ mof::Vector2D(_bounds.beginX , _bounds.beginY )
+ )
+ )
+ );
+ }
+
+ ~Impl(){
+ delete pLayout;
+ delete pBackgroundView;
+ delete pTitleView;
+ foreach(std::vector<mof::Sprite*>& page , pages ){
+ foreach(mof::Sprite*& pSprite , page ){
+ delete pSprite;
+ }
+ }
+ }
+
+ void showPage(bool first){
+ mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {
+ mof::makeKeyFrame(first ? 0 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) ,
+ mof::makeKeyFrame(first ? 30*2 : 90 , mof::Color4f(1 , 1 , 1 , 1) )
+ };
+ mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));
+ foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){
+ pSprite->setColor(handler);
+ pSprite->setFrameNumber(0);
+ }
+ }
+
+ void closePage(bool last){
+ mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {
+ mof::makeKeyFrame(0 , mof::Color4f(1 , 1 , 1 , 1) ) ,
+ mof::makeKeyFrame(last ? 10*2 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) )
+ };
+ mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));
+ foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){
+ pSprite->setColor(handler);
+ pSprite->setFrameNumber(0);
+ }
+ }
+
+
+
+};
+
+//{{{ MessageWidget
+mof::MessageWidget::MessageWidget
+(
+ mof::WidgetView* pBackgroundView ,
+ const mof::Rectangle<int>& bounds ,
+ mof::LayoutManager* pLayout
+)
+: m_pImpl( new Impl( bounds) )
+{
+ m_pImpl->pLayout = pLayout;
+ m_pImpl->pBackgroundView = pBackgroundView;
+
+ { // \83^\83C\83g\83\8b\82Ì\8f\89\8aú\89»
+ if( true )
+ {
+ m_pImpl->pTitleView = new mof::TextView
+ (
+ _T("Title") , mof::Font( mof::Font::MS_P_GOTHIC , 25 )
+ );
+ m_pImpl->pTitleView->initialize();
+ mof::Rectangle<int> tmp( bounds.beginX , bounds.beginY , bounds.endX , bounds.beginY + 32 );
+ m_pImpl->pTitleView->setBounds( tmp );
+
+ }
+ }
+
+ m_pImpl->pBackgroundView->setBounds(bounds);
+}
+//}}}
+//{{{ ~MessageWidget
+mof::MessageWidget::~MessageWidget(){
+
+}
+//}}}
+//{{{ show
+void mof::MessageWidget::show(){
+ m_pImpl->currentPage = -1;
+ m_pImpl->pBackgroundView->show();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->show();
+ m_pImpl->currentPage++;
+ m_pImpl->showPage(true);
+}
+//}}}
+//{{{ close
+void mof::MessageWidget::close(){
+
+ m_pImpl->pBackgroundView->close();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->close();
+ if(m_pImpl->currentPage < 0)return;
+ m_pImpl->closePage(true);
+}
+//}}}
+//{{{ nextPage
+void mof::MessageWidget::nextPage(){
+ if(m_pImpl->currentPage < 0){
+ show();
+ return;
+ }
+ m_pImpl->closePage(false);
+ if(m_pImpl->currentPage >= static_cast<signed int>(m_pImpl->pages.size()) -1 ){
+ close();
+ return;
+ }
+ m_pImpl->currentPage++;
+ m_pImpl->showPage(false);
+}
+//}}}
+//{{{ addPage
+void mof::MessageWidget::addPage( const Page& page ){
+
+ m_pImpl->pages.push_back(std::vector<mof::Sprite*>());
+ mof::compileText( page.message , page.font , m_pImpl->pages.back() );
+
+ std::vector<mof::Rectangle<int> > boundList;
+ if( m_pImpl->pTitleView )boundList.push_back( mof::Rectangle<int>( 0 , 0 , 1 , 32) );
+ //if( m_pImpl->pTitleView )boundList.push_back( m_pImpl->pTitle->getBounds() );
+
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.back() ){
+ mof::Rectangle<int> bounds = pSprite->getWorldTransform().toBoundingBox();
+ boundList.push_back(bounds);
+ }
+ m_pImpl->pLayout->replace(m_pImpl->width , m_pImpl->height , boundList.front() , boundList.back() );
+
+ //TODO: LayoutAnimation\82ð\82Â\82\82é
+ for(unsigned int j = 0 ; j < m_pImpl->pLayout->getLength( ) ; ++j)
+ {
+ const mof::Animation<mof::Matrix2D>::Handler children[] =
+ {
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createScaling
+ (
+ mof::Vector2D(boundList.at(j).endX - boundList.at(j).beginX , boundList.at(j).endY - boundList.at(j).beginY)
+ )
+ ) ,
+ mof::makeParametricHandler(m_pImpl->pTranslation) ,
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(j) )
+ )
+ }; // array children
+
+ mof::Animation<mof::Matrix2D>::Handler handler
+ (
+ new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )
+ );
+
+ //if( m_pImpl->pTitleView && j == 0 )m_pImpl->pTitleView->setPosition( handler );
+ if( m_pImpl->pTitleView && j != 0 )
+ {
+ m_pImpl->pages.back().at(j-1)->setWorldTransform( handler );
+ m_pImpl->pages.back().at(j-1)->setColor(mof::Color4f(0 , 1 , 1 , 1));
+ }
+ else if( NULL != m_pImpl->pTitleView )
+ {
+ m_pImpl->pages.back().at(j)->setWorldTransform( handler );
+ m_pImpl->pages.back().at(j)->setColor(mof::Color4f(0 , 1 , 1 , 1));
+ }
+
+ } // for
+
+
+}
+//}}}
+//{{{ draw
+void mof::MessageWidget::draw() const{
+ m_pImpl->pBackgroundView->draw();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->getEffect()->draw();
+ if(m_pImpl->currentPage < 0)return;
+
+ if(m_pImpl->currentPage > 0){
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){
+ pSprite->draw();
+ }
+ }
+ mof::GraphicsDevice::setViewport(m_pImpl->pBackgroundView->getBounds());
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){
+ pSprite->draw();
+ }
+ mof::GraphicsDevice::setViewport(mof::Rectangle<int>(0 , 0 , 640 , 480));//TODO
+
+}
+//}}}
+//{{{ update
+void mof::MessageWidget::update() {
+
+ m_pImpl->pBackgroundView->update();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->update();
+ if(m_pImpl->currentPage < 0)return;
+ if(m_pImpl->currentPage > 0){
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){
+ pSprite->update();
+ }
+ }
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){
+ pSprite->update();
+ }
+}
+//}}}
+//{{{ hasNextPage
+bool mof::MessageWidget::hasNextPage(){
+ return m_pImpl->currentPage < static_cast<signed int>(m_pImpl->pages.size()) -1;
+
+}
+//}}}
+
-#include "mof/MessageWidget.hpp"\r
-#include "mof/Effect.hpp"\r
-#include "mof/utilities.hpp"\r
-#include "mof/LayoutManager.hpp"\r
-#include <boost/scoped_array.hpp>\r
-#include "mof/ConsoleIO.hpp"\r
-#include "mof/WidgetView.hpp"\r
-#include "mof/TextView.hpp"\r
-#include "mof/GraphicsDevice.hpp"\r
-#include "mof/mofAnimations.hpp"\r
-#include "mof/TextCompiler.hpp"\r
-#include "mof/widgets.hpp"\r
- \r
-namespace mof\r
-{\r
- \r
- struct MessageWidget::Impl\r
- {\r
- mof::WidgetView* pBackgroundView;\r
- mof::TextView* pTitleView;\r
- mof::LayoutManager* pLayout;\r
- //boost::shared_ptr<mof::Matrix2D> pTranslation;\r
- mof::TranslationAnimation2D::Handler translation;\r
- mof::ScalingAnimation2D::Handler scaling;\r
- mof::Pager* pPager;\r
- mof::FrameNumber frame;\r
- //int width;\r
- //int height;\r
- \r
-//{{{ Impl \r
- Impl()\r
- : \r
- pBackgroundView(NULL) , \r
- pTitleView(NULL) , \r
- pLayout(NULL) ,\r
- pPager( NULL ) ,\r
- frame( 0 )\r
- {\r
- translation = mof::TranslationAnimation2D::Handler\r
- (\r
- new mof::TranslationAnimation2D\r
- (\r
- mof::makeConstantHandler\r
- (\r
- mof::Vector2D( 0 , 0 )\r
- )\r
- )\r
- );\r
-\r
- scaling = mof::ScalingAnimation2D::Handler\r
- (\r
- new mof::ScalingAnimation2D\r
- (\r
- mof::makeConstantHandler\r
- (\r
- mof::Vector2D( 0 , 0 )\r
- )\r
- )\r
- );\r
-\r
- }\r
-//}}}\r
-//{{{ ~Impl\r
- ~Impl()\r
- {\r
- delete pLayout;\r
- delete pBackgroundView;\r
- delete pTitleView;\r
- delete pPager;\r
- }\r
- \r
-//}}} \r
- };\r
-//{{{ MessageWidget\r
- MessageWidget::MessageWidget\r
- (\r
- mof::WidgetView* pBackgroundView ,\r
- const mof::Rectangle<int>& bounds ,\r
- mof::LayoutManager* pLayout\r
- )\r
- : m_pImpl( new Impl( ) )\r
- {\r
- m_pImpl->pLayout = pLayout;\r
- m_pImpl->pBackgroundView = pBackgroundView;\r
- m_pImpl->pBackgroundView->setBounds( bounds );\r
- m_pImpl->translation->set( m_pImpl->pBackgroundView->getPosition( ) );\r
- m_pImpl->scaling->set( m_pImpl->pBackgroundView->getSize( ) );\r
- \r
- { // \83^\83C\83g\83\8b\82Ì\8f\89\8aú\89»\r
- if( true )\r
- {\r
- m_pImpl->pTitleView = new mof::TextView\r
- (\r
- _T("Title") , mof::Font( mof::Font::MS_P_GOTHIC , 25 )\r
- );\r
- m_pImpl->pTitleView->initialize();\r
- mof::Rectangle<int> tmp( bounds.beginX , bounds.beginY , bounds.endX , bounds.beginY + 32 );\r
- m_pImpl->pTitleView->setBounds( tmp );\r
- \r
- }\r
- }\r
- { // \83y\81[\83W\83\83\82Ì\90¶\90¬\r
- mof::LayoutManager* pLayout = new mof::LayoutManager( mof::LayoutManager::HORIZONTAL , 1);\r
- m_pImpl->pPager = new mof::Pager( bounds , pLayout );\r
- }\r
- }\r
-//}}}\r
-//{{{ ~MessageWidget\r
- MessageWidget::~MessageWidget(){\r
- \r
- }\r
-//}}}\r
-//{{{ show\r
- void MessageWidget::show(){\r
- m_pImpl->pPager->show();\r
- m_pImpl->pBackgroundView->show();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->show();\r
- }\r
-//}}}\r
-//{{{ close\r
- void MessageWidget::close()\r
- {\r
- m_pImpl->pPager->close();\r
- m_pImpl->pBackgroundView->close();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->close();\r
- }\r
-//}}}\r
-//{{{ nextPage\r
- void MessageWidget::nextPage(){\r
- if( !m_pImpl->pPager->hasNextPage( ) )close();\r
- else if( !m_pImpl->pPager->hasPreviousPage() )show();\r
- else m_pImpl->pPager->nextPage();\r
- }\r
-//}}}\r
-//{{{ addPage\r
- void MessageWidget::addPage( const PageRequest& page ){\r
- \r
- m_pImpl->pPager->addPage( page );\r
- \r
- std::vector<mof::Rectangle<int> > boundList;\r
- if( m_pImpl->pTitleView )boundList.push_back( mof::Rectangle<int>( 0 , 0 , 1 , 32) );\r
- boundList.push_back( m_pImpl->pPager->getBounds( ) );\r
- \r
- mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );\r
- m_pImpl->pLayout->replace\r
- (\r
- scaling.x , scaling.y ,\r
- boundList.front() , boundList.back()\r
- );\r
-\r
- int i = 0;\r
- if( m_pImpl->pTitleView )\r
- {\r
- mof::Animation<mof::Matrix2D>::Handler children[] =\r
- {\r
- mof::makeConstantHandler\r
- ( \r
- mof::Matrix2D::createScaling\r
- (\r
- mof::Vector2D(boundList.at(i).getWidth( ) , boundList.at(i).getHeight( ) )\r
- )\r
- ) ,\r
- m_pImpl->translation ,\r
- mof::makeConstantHandler\r
- (\r
- mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(i) )\r
- )\r
- }; // array children\r
- \r
- mof::Animation<mof::Matrix2D>::Handler handler\r
- (\r
- new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )\r
- );\r
- i++;\r
- //m_pImpl->pTitleView->setWorldTransform( handler );\r
- //m_pImpl->pTitleView->setColor(mof::Color4f(0 , 1 , 1 , 1));\r
- \r
- } // if\r
- {\r
- const mof::Animation<mof::Vector2D>::Handler children[] =\r
- {\r
- //mof::makeConstantHandler( mof::Vector2D( 300 , 300) ) ,\r
- m_pImpl->translation->get( ) ,\r
- mof::makeConstantHandler\r
- (\r
- m_pImpl->pLayout->getPosition(i) \r
- )\r
- }; // array children\r
- \r
- mof::Animation<mof::Vector2D>::Handler handler\r
- (\r
- new mof::CascadingAnimation<mof::Vector2D , mof::Add<mof::Vector2D> >( children[0] , mof::lastOf( children ) )\r
- );\r
- m_pImpl->pPager->setPosition( handler );\r
- //m_pImpl->pTitleView->setWorldTransform( handler );\r
- //m_pImpl->pTitleView->setColor(mof::Color4f(0 , 1 , 1 , 1));\r
- \r
- } // for \r
- \r
- \r
- }\r
-//}}}\r
-//{{{ draw\r
- void MessageWidget::draw() const{\r
- m_pImpl->pBackgroundView->draw();\r
- \r
- { // \95`\89æ\97Ì\88æ\82ð\90§\8cÀ\r
- mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );\r
- mof::Vector2D translation = m_pImpl->translation->get( )->getValue( m_pImpl->frame );\r
- mof::GraphicsDevice::setViewport \r
- ( \r
- mof::Rectangle<int>( translation.x , translation.y , translation.x + scaling.x , translation.y + scaling.y )\r
- );\r
- }\r
-\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->getEffect()->draw();\r
- m_pImpl->pPager->draw(); \r
- mof::GraphicsDevice::setViewport(mof::Rectangle<int>(0 , 0 , 640 , 480));//TODO\r
- \r
- }\r
-//}}}\r
-//{{{ update\r
- void MessageWidget::update() {\r
- \r
- m_pImpl->pBackgroundView->update();\r
- if( m_pImpl->pTitleView )m_pImpl->pTitleView->update();\r
- m_pImpl->pPager->update(); \r
- m_pImpl->frame++;\r
- }\r
-//}}}\r
-//{{{ hasNextPage\r
- bool MessageWidget::hasNextPage( ){\r
- return m_pImpl->pPager->hasNextPage( );\r
- \r
- }\r
-//}}}\r
-} //namespace mof\r
-\r
+#include "mof/MessageWidget.hpp"
+#include "mof/Effect.hpp"
+#include "mof/utilities.hpp"
+#include "mof/LayoutManager.hpp"
+#include <boost/scoped_array.hpp>
+#include "mof/ConsoleIO.hpp"
+#include "mof/WidgetView.hpp"
+#include "mof/TextView.hpp"
+#include "mof/GraphicsDevice.hpp"
+#include "mof/mofAnimations.hpp"
+#include "mof/TextCompiler.hpp"
+#include "mof/widgets.hpp"
+
+namespace mof
+{
+
+ struct MessageWidget::Impl
+ {
+ mof::WidgetView* pBackgroundView;
+ mof::TextView* pTitleView;
+ mof::LayoutManager* pLayout;
+ //boost::shared_ptr<mof::Matrix2D> pTranslation;
+ mof::TranslationAnimation2D::Handler translation;
+ mof::ScalingAnimation2D::Handler scaling;
+ mof::Pager* pPager;
+ mof::FrameNumber frame;
+ //int width;
+ //int height;
+
+//{{{ Impl
+ Impl()
+ :
+ pBackgroundView(NULL) ,
+ pTitleView(NULL) ,
+ pLayout(NULL) ,
+ pPager( NULL ) ,
+ frame( 0 )
+ {
+ translation = mof::TranslationAnimation2D::Handler
+ (
+ new mof::TranslationAnimation2D
+ (
+ mof::makeConstantHandler
+ (
+ mof::Vector2D( 0 , 0 )
+ )
+ )
+ );
+
+ scaling = mof::ScalingAnimation2D::Handler
+ (
+ new mof::ScalingAnimation2D
+ (
+ mof::makeConstantHandler
+ (
+ mof::Vector2D( 0 , 0 )
+ )
+ )
+ );
+
+ }
+//}}}
+//{{{ ~Impl
+ ~Impl()
+ {
+ delete pLayout;
+ delete pBackgroundView;
+ delete pTitleView;
+ delete pPager;
+ }
+
+//}}}
+ };
+//{{{ MessageWidget
+ MessageWidget::MessageWidget
+ (
+ mof::WidgetView* pBackgroundView ,
+ const mof::Rectangle<int>& bounds ,
+ mof::LayoutManager* pLayout
+ )
+ : m_pImpl( new Impl( ) )
+ {
+ m_pImpl->pLayout = pLayout;
+ m_pImpl->pBackgroundView = pBackgroundView;
+ m_pImpl->pBackgroundView->setBounds( bounds );
+ m_pImpl->translation->set( m_pImpl->pBackgroundView->getPosition( ) );
+ m_pImpl->scaling->set( m_pImpl->pBackgroundView->getSize( ) );
+
+ { // \83^\83C\83g\83\8b\82Ì\8f\89\8aú\89»
+ if( true )
+ {
+ m_pImpl->pTitleView = new mof::TextView
+ (
+ _T("Title") , mof::Font( mof::Font::MS_P_GOTHIC , 25 )
+ );
+ m_pImpl->pTitleView->initialize();
+ mof::Rectangle<int> tmp( bounds.beginX , bounds.beginY , bounds.endX , bounds.beginY + 32 );
+ m_pImpl->pTitleView->setBounds( tmp );
+
+ }
+ }
+ { // \83y\81[\83W\83\83\82Ì\90¶\90¬
+ mof::LayoutManager* pLayout = new mof::LayoutManager( mof::LayoutManager::HORIZONTAL , 1);
+ m_pImpl->pPager = new mof::Pager( bounds , pLayout );
+ }
+ }
+//}}}
+//{{{ ~MessageWidget
+ MessageWidget::~MessageWidget(){
+
+ }
+//}}}
+//{{{ show
+ void MessageWidget::show(){
+ m_pImpl->pPager->show();
+ m_pImpl->pBackgroundView->show();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->show();
+ }
+//}}}
+//{{{ close
+ void MessageWidget::close()
+ {
+ m_pImpl->pPager->close();
+ m_pImpl->pBackgroundView->close();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->close();
+ }
+//}}}
+//{{{ nextPage
+ void MessageWidget::nextPage(){
+ if( !m_pImpl->pPager->hasNextPage( ) )close();
+ else if( !m_pImpl->pPager->hasPreviousPage() )show();
+ else m_pImpl->pPager->nextPage();
+ }
+//}}}
+//{{{ addPage
+ void MessageWidget::addPage( const PageRequest& page ){
+
+ m_pImpl->pPager->addPage( page );
+
+ std::vector<mof::Rectangle<int> > boundList;
+ if( m_pImpl->pTitleView )boundList.push_back( mof::Rectangle<int>( 0 , 0 , 1 , 32) );
+ boundList.push_back( m_pImpl->pPager->getBounds( ) );
+
+ mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );
+ m_pImpl->pLayout->replace
+ (
+ scaling.x , scaling.y ,
+ boundList.front() , boundList.back()
+ );
+
+ int i = 0;
+ if( m_pImpl->pTitleView )
+ {
+ mof::Animation<mof::Matrix2D>::Handler children[] =
+ {
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createScaling
+ (
+ mof::Vector2D(boundList.at(i).getWidth( ) , boundList.at(i).getHeight( ) )
+ )
+ ) ,
+ m_pImpl->translation ,
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(i) )
+ )
+ }; // array children
+
+ mof::Animation<mof::Matrix2D>::Handler handler
+ (
+ new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )
+ );
+ i++;
+ //m_pImpl->pTitleView->setWorldTransform( handler );
+ //m_pImpl->pTitleView->setColor(mof::Color4f(0 , 1 , 1 , 1));
+
+ } // if
+ {
+ const mof::Animation<mof::Vector2D>::Handler children[] =
+ {
+ //mof::makeConstantHandler( mof::Vector2D( 300 , 300) ) ,
+ m_pImpl->translation->get( ) ,
+ mof::makeConstantHandler
+ (
+ m_pImpl->pLayout->getPosition(i)
+ )
+ }; // array children
+
+ mof::Animation<mof::Vector2D>::Handler handler
+ (
+ new mof::CascadingAnimation<mof::Vector2D , mof::Add<mof::Vector2D> >( children[0] , mof::lastOf( children ) )
+ );
+ m_pImpl->pPager->setPosition( handler );
+ //m_pImpl->pTitleView->setWorldTransform( handler );
+ //m_pImpl->pTitleView->setColor(mof::Color4f(0 , 1 , 1 , 1));
+
+ } // for
+
+
+ }
+//}}}
+//{{{ draw
+ void MessageWidget::draw() const{
+ m_pImpl->pBackgroundView->draw();
+
+ { // \95`\89æ\97Ì\88æ\82ð\90§\8cÀ
+ mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );
+ mof::Vector2D translation = m_pImpl->translation->get( )->getValue( m_pImpl->frame );
+ mof::GraphicsDevice::setViewport
+ (
+ mof::Rectangle<int>( translation.x , translation.y , translation.x + scaling.x , translation.y + scaling.y )
+ );
+ }
+
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->getEffect()->draw();
+ m_pImpl->pPager->draw();
+ mof::GraphicsDevice::setViewport(mof::Rectangle<int>(0 , 0 , 640 , 480));//TODO
+
+ }
+//}}}
+//{{{ update
+ void MessageWidget::update() {
+
+ m_pImpl->pBackgroundView->update();
+ if( m_pImpl->pTitleView )m_pImpl->pTitleView->update();
+ m_pImpl->pPager->update();
+ m_pImpl->frame++;
+ }
+//}}}
+//{{{ hasNextPage
+ bool MessageWidget::hasNextPage( ){
+ return m_pImpl->pPager->hasNextPage( );
+
+ }
+//}}}
+} //namespace mof
+
-#pragma once\r
-#include <boost/function/function0.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-#include <boost/scoped_ptr.hpp>\r
-//#include "mof/MenuView.hpp"\r
-#include "mof/widget/WidgetView.hpp"\r
-#include "mof/Font.hpp"\r
-\r
-namespace mof\r
-{\r
- struct PageRequest\r
- {\r
- tstring message;\r
- Font font;\r
- \r
- PageRequest(const tstring& message_ , const Font& font_ )\r
- : message(message_) , font(font_)\r
- {\r
- }\r
- };\r
-\r
- class LayoutManager;\r
- class WidgetView;\r
- class Pager;\r
- struct Page;\r
-\r
- class MessageWidget : boost::noncopyable{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- public:\r
- \r
- MessageWidget\r
- ( \r
- WidgetView* pBackgroundView , \r
- const Rectangle< int >& bounds , LayoutManager* pLayout\r
- );\r
-\r
- ~MessageWidget();\r
- void show();\r
- void close();\r
- void nextPage();\r
- void addPage( const PageRequest& page );\r
- void draw() const;\r
- void update();\r
- bool hasNextPage();\r
-\r
- };\r
-}\r
+#pragma once
+#include <boost/function/function0.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+//#include "mof/MenuView.hpp"
+#include "mof/widget/WidgetView.hpp"
+#include "mof/Font.hpp"
+
+namespace mof
+{
+ struct PageRequest
+ {
+ tstring message;
+ Font font;
+
+ PageRequest(const tstring& message_ , const Font& font_ )
+ : message(message_) , font(font_)
+ {
+ }
+ };
+
+ class LayoutManager;
+ class WidgetView;
+ class Pager;
+ struct Page;
+
+ class MessageWidget : boost::noncopyable{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ public:
+
+ MessageWidget
+ (
+ WidgetView* pBackgroundView ,
+ const Rectangle< int >& bounds , LayoutManager* pLayout
+ );
+
+ ~MessageWidget();
+ void show();
+ void close();
+ void nextPage();
+ void addPage( const PageRequest& page );
+ void draw() const;
+ void update();
+ bool hasNextPage();
+
+ };
+}
-#pragma once\r
-#include <boost/function/function0.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-#include <boost/scoped_ptr.hpp>\r
-//#include "mof/MenuView.hpp"\r
-#include "mof/WidgetView.hpp"\r
-#include "mof/Font.hpp"\r
-\r
-namespace mof\r
-{\r
- struct PageRequest\r
- {\r
- tstring message;\r
- Font font;\r
- \r
- PageRequest(const tstring& message_ , const Font& font_ )\r
- : message(message_) , font(font_)\r
- {\r
- }\r
- };\r
-\r
- class LayoutManager;\r
- class WidgetView;\r
- class Pager;\r
- struct Page;\r
-\r
- class MessageWidget : boost::noncopyable{\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- public:\r
- \r
- MessageWidget\r
- ( \r
- WidgetView* pBackgroundView , \r
- const Rectangle< int >& bounds , LayoutManager* pLayout\r
- );\r
-\r
- ~MessageWidget();\r
- void show();\r
- void close();\r
- void nextPage();\r
- void addPage( const PageRequest& page );\r
- void draw() const;\r
- void update();\r
- bool hasNextPage();\r
-\r
- };\r
-}\r
+#pragma once
+#include <boost/function/function0.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/scoped_ptr.hpp>
+//#include "mof/MenuView.hpp"
+#include "mof/WidgetView.hpp"
+#include "mof/Font.hpp"
+
+namespace mof
+{
+ struct PageRequest
+ {
+ tstring message;
+ Font font;
+
+ PageRequest(const tstring& message_ , const Font& font_ )
+ : message(message_) , font(font_)
+ {
+ }
+ };
+
+ class LayoutManager;
+ class WidgetView;
+ class Pager;
+ struct Page;
+
+ class MessageWidget : boost::noncopyable{
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ public:
+
+ MessageWidget
+ (
+ WidgetView* pBackgroundView ,
+ const Rectangle< int >& bounds , LayoutManager* pLayout
+ );
+
+ ~MessageWidget();
+ void show();
+ void close();
+ void nextPage();
+ void addPage( const PageRequest& page );
+ void draw() const;
+ void update();
+ bool hasNextPage();
+
+ };
+}
-#include <mof/widget/OverlapLayout.hpp>\r
-#include <mof/utilities.hpp>\r
-#include <mof/widgets.hpp>\r
-#include <mof/streams.hpp>\r
-#include <algorithm>\r
-#include <vector>\r
-\r
-using boost::shared_ptr;\r
-using mof::widget::WidgetView;\r
-//{{{ Impl\r
-struct mof::widget::OverlapLayout::Impl\r
-{\r
- \r
- int width , height;\r
- size_t length;\r
- std::vector< shared_ptr<WidgetView> > views;\r
-\r
- Impl( const mof::Vector2D& size )\r
- : \r
- width(size.x) , height(size.y) , length(0)\r
- {}\r
- \r
-\r
- ~Impl()\r
- {\r
- }\r
-};\r
-//}}}\r
-//{{{ OverlapLayout\r
-mof::widget::OverlapLayout::OverlapLayout( const mof::Vector2D& size )\r
-: m_pImpl( new Impl( size ) )\r
-{\r
-}\r
-//}}}\r
-//{{{ ~OverlapLayout\r
-mof::widget::OverlapLayout::~OverlapLayout( )\r
-{\r
-}\r
-//}}}\r
-//{{{ add\r
-void mof::widget::OverlapLayout::add(shared_ptr<WidgetView> pView)\r
-{\r
- /*if(m_pImpl->length == 0 ){\r
- m_pImpl->width = mof::real2int(size.x);\r
- m_pImpl->width = mof::real2int(size.y);\r
- }*/\r
- m_pImpl->length++;\r
- m_pImpl->views.push_back(pView);\r
-}\r
-//}}}\r
-//{{{ getLength\r
-size_t mof::widget::OverlapLayout::getLength() const\r
-{\r
- return m_pImpl->length;\r
-}\r
-//}}}\r
-//{{{ getPreferredSize\r
-mof::Vector2D mof::widget::OverlapLayout::getPreferredSize() const\r
-{\r
- return mof::Vector2D(m_pImpl->width , m_pImpl->height);\r
-}\r
-//}}}\r
-//{{{ getSizeDependencyType\r
-mof::widget::Layout::DependencyType mof::widget::OverlapLayout::getSizeDependencyType() const\r
-{\r
- return mof::widget::Layout::PARENT_LEADING;\r
-}\r
-//}}}\r
-//{{{ connect\r
-void mof::widget::OverlapLayout::connect(WidgetView* pParentView) \r
-{\r
- size_t i = 0;\r
- foreach(shared_ptr<WidgetView> pView , m_pImpl->views) \r
- {\r
- pView->getPositionStream() << pParentView->getPositionStream();\r
- pView->getSizeStream() << pParentView->getSizeStream() << - pView->getSizeStream().value();\r
- }\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsUp\r
-int mof::widget::OverlapLayout::getAdjacencyAsUp(int index) const\r
-{\r
- return mof::rotation_mod(index-1 , m_pImpl->length);\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsDown\r
-int mof::widget::OverlapLayout::getAdjacencyAsDown(int index) const\r
-{\r
- return mof::rotation_mod(index+1 , m_pImpl->length );\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsLeft\r
-int mof::widget::OverlapLayout::getAdjacencyAsLeft(int index) const\r
-{\r
- return mof::rotation_mod(index-1 , m_pImpl->length );\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsRight\r
-int mof::widget::OverlapLayout::getAdjacencyAsRight(int index) const\r
-{\r
- return mof::rotation_mod(index+1 , m_pImpl->length );\r
-}\r
-//}}}\r
+#include <mof/widget/OverlapLayout.hpp>
+#include <mof/utilities.hpp>
+#include <mof/widgets.hpp>
+#include <mof/streams.hpp>
+#include <algorithm>
+#include <vector>
+
+using boost::shared_ptr;
+using mof::widget::WidgetView;
+//{{{ Impl
+struct mof::widget::OverlapLayout::Impl
+{
+
+ int width , height;
+ size_t length;
+ std::vector< shared_ptr<WidgetView> > views;
+
+ Impl( const mof::Vector2D& size )
+ :
+ width(size.x) , height(size.y) , length(0)
+ {}
+
+
+ ~Impl()
+ {
+ }
+};
+//}}}
+//{{{ OverlapLayout
+mof::widget::OverlapLayout::OverlapLayout( const mof::Vector2D& size )
+: m_pImpl( new Impl( size ) )
+{
+}
+//}}}
+//{{{ ~OverlapLayout
+mof::widget::OverlapLayout::~OverlapLayout( )
+{
+}
+//}}}
+//{{{ add
+void mof::widget::OverlapLayout::add(shared_ptr<WidgetView> pView)
+{
+ /*if(m_pImpl->length == 0 ){
+ m_pImpl->width = mof::real2int(size.x);
+ m_pImpl->width = mof::real2int(size.y);
+ }*/
+ m_pImpl->length++;
+ m_pImpl->views.push_back(pView);
+}
+//}}}
+//{{{ getLength
+size_t mof::widget::OverlapLayout::getLength() const
+{
+ return m_pImpl->length;
+}
+//}}}
+//{{{ getPreferredSize
+mof::Vector2D mof::widget::OverlapLayout::getPreferredSize() const
+{
+ return mof::Vector2D(m_pImpl->width , m_pImpl->height);
+}
+//}}}
+//{{{ getSizeDependencyType
+mof::widget::Layout::DependencyType mof::widget::OverlapLayout::getSizeDependencyType() const
+{
+ return mof::widget::Layout::PARENT_LEADING;
+}
+//}}}
+//{{{ connect
+void mof::widget::OverlapLayout::connect(WidgetView* pParentView)
+{
+ size_t i = 0;
+ foreach(shared_ptr<WidgetView> pView , m_pImpl->views)
+ {
+ pView->getPositionStream() << pParentView->getPositionStream();
+ pView->getSizeStream() << pParentView->getSizeStream() << - pView->getSizeStream().value();
+ }
+}
+//}}}
+//{{{ getAdjacencyAsUp
+int mof::widget::OverlapLayout::getAdjacencyAsUp(int index) const
+{
+ return mof::rotation_mod(index-1 , m_pImpl->length);
+}
+//}}}
+//{{{ getAdjacencyAsDown
+int mof::widget::OverlapLayout::getAdjacencyAsDown(int index) const
+{
+ return mof::rotation_mod(index+1 , m_pImpl->length );
+}
+//}}}
+//{{{ getAdjacencyAsLeft
+int mof::widget::OverlapLayout::getAdjacencyAsLeft(int index) const
+{
+ return mof::rotation_mod(index-1 , m_pImpl->length );
+}
+//}}}
+//{{{ getAdjacencyAsRight
+int mof::widget::OverlapLayout::getAdjacencyAsRight(int index) const
+{
+ return mof::rotation_mod(index+1 , m_pImpl->length );
+}
+//}}}
-#include <mof/widget/OverlapLayout.hpp>\r
-#include <mof/utilities.hpp>\r
-#include <mof/widgets.hpp>\r
-#include <mof/streams.hpp>\r
-#include <algorithm>\r
-#include <vector>\r
-\r
-using boost::shared_ptr;\r
-using mof::widget::WidgetView;\r
-//{{{ Impl\r
-struct mof::widget::OverlapLayout::Impl\r
-{\r
- \r
- int width , height;\r
- size_t length;\r
- std::vector< shared_ptr<WidgetView> > views;\r
-\r
- Impl( const mof::Vector2D& size )\r
- : \r
- width(size.x) , height(size.y) , length(0)\r
- {}\r
- \r
-\r
- ~Impl()\r
- {\r
- }\r
-};\r
-//}}}\r
-//{{{ OverlapLayout\r
-mof::widget::OverlapLayout::OverlapLayout( const mof::Vector2D& size )\r
-: m_pImpl( new Impl( size ) )\r
-{\r
-}\r
-//}}}\r
-//{{{ ~OverlapLayout\r
-mof::widget::OverlapLayout::~OverlapLayout( )\r
-{\r
-}\r
-//}}}\r
-//{{{ add\r
-void mof::widget::OverlapLayout::add(shared_ptr<WidgetView> pView)\r
-{\r
- /*if(m_pImpl->length == 0 ){\r
- m_pImpl->width = mof::real2int(size.x);\r
- m_pImpl->width = mof::real2int(size.y);\r
- }*/\r
- m_pImpl->length++;\r
- m_pImpl->views.push_back(pView);\r
-}\r
-//}}}\r
-//{{{ getLength\r
-size_t mof::widget::OverlapLayout::getLength() const\r
-{\r
- return m_pImpl->length;\r
-}\r
-//}}}\r
-//{{{ getPreferredSize\r
-mof::Vector2D mof::widget::OverlapLayout::getPreferredSize() const\r
-{\r
- return mof::Vector2D(m_pImpl->width , m_pImpl->height);\r
-}\r
-//}}}\r
-//{{{ getSizeDependencyType\r
-mof::widget::Layout::DependencyType mof::widget::OverlapLayout::getSizeDependencyType() const\r
-{\r
- return mof::widget::Layout::PARENT_LEADING;\r
-}\r
-//}}}\r
-//{{{ connect\r
-void mof::widget::OverlapLayout::connect(WidgetView* pParentView) \r
-{\r
- size_t i = 0;\r
- foreach(shared_ptr<WidgetView> pView , m_pImpl->views) \r
- {\r
- pView->getPositionStream() << pParentView;\r
- pView->getSizeStream() << pParentView->getSizeStream() << - pView->getSizeStream().value();\r
- }\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsUp\r
-int mof::widget::OverlapLayout::getAdjacencyAsUp(int index) const\r
-{\r
- return mof::rotation_mod(index-1 , m_pImpl->length);\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsDown\r
-int mof::widget::OverlapLayout::getAdjacencyAsDown(int index) const\r
-{\r
- return mof::rotation_mod(index+1 , m_pImpl->length );\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsLeft\r
-int mof::widget::OverlapLayout::getAdjacencyAsLeft(int index) const\r
-{\r
- return mof::rotation_mod(index-1 , m_pImpl->length );\r
-}\r
-//}}}\r
-//{{{ getAdjacencyAsRight\r
-int mof::widget::OverlapLayout::getAdjacencyAsRight(int index) const\r
-{\r
- return mof::rotation_mod(index+1 , m_pImpl->length );\r
-}\r
-//}}}\r
+#include <mof/widget/OverlapLayout.hpp>
+#include <mof/utilities.hpp>
+#include <mof/widgets.hpp>
+#include <mof/streams.hpp>
+#include <algorithm>
+#include <vector>
+
+using boost::shared_ptr;
+using mof::widget::WidgetView;
+//{{{ Impl
+struct mof::widget::OverlapLayout::Impl
+{
+
+ int width , height;
+ size_t length;
+ std::vector< shared_ptr<WidgetView> > views;
+
+ Impl( const mof::Vector2D& size )
+ :
+ width(size.x) , height(size.y) , length(0)
+ {}
+
+
+ ~Impl()
+ {
+ }
+};
+//}}}
+//{{{ OverlapLayout
+mof::widget::OverlapLayout::OverlapLayout( const mof::Vector2D& size )
+: m_pImpl( new Impl( size ) )
+{
+}
+//}}}
+//{{{ ~OverlapLayout
+mof::widget::OverlapLayout::~OverlapLayout( )
+{
+}
+//}}}
+//{{{ add
+void mof::widget::OverlapLayout::add(shared_ptr<WidgetView> pView)
+{
+ /*if(m_pImpl->length == 0 ){
+ m_pImpl->width = mof::real2int(size.x);
+ m_pImpl->width = mof::real2int(size.y);
+ }*/
+ m_pImpl->length++;
+ m_pImpl->views.push_back(pView);
+}
+//}}}
+//{{{ getLength
+size_t mof::widget::OverlapLayout::getLength() const
+{
+ return m_pImpl->length;
+}
+//}}}
+//{{{ getPreferredSize
+mof::Vector2D mof::widget::OverlapLayout::getPreferredSize() const
+{
+ return mof::Vector2D(m_pImpl->width , m_pImpl->height);
+}
+//}}}
+//{{{ getSizeDependencyType
+mof::widget::Layout::DependencyType mof::widget::OverlapLayout::getSizeDependencyType() const
+{
+ return mof::widget::Layout::PARENT_LEADING;
+}
+//}}}
+//{{{ connect
+void mof::widget::OverlapLayout::connect(WidgetView* pParentView)
+{
+ size_t i = 0;
+ foreach(shared_ptr<WidgetView> pView , m_pImpl->views)
+ {
+ pView->getPositionStream() << pParentView;
+ pView->getSizeStream() << pParentView->getSizeStream() << - pView->getSizeStream().value();
+ }
+}
+//}}}
+//{{{ getAdjacencyAsUp
+int mof::widget::OverlapLayout::getAdjacencyAsUp(int index) const
+{
+ return mof::rotation_mod(index-1 , m_pImpl->length);
+}
+//}}}
+//{{{ getAdjacencyAsDown
+int mof::widget::OverlapLayout::getAdjacencyAsDown(int index) const
+{
+ return mof::rotation_mod(index+1 , m_pImpl->length );
+}
+//}}}
+//{{{ getAdjacencyAsLeft
+int mof::widget::OverlapLayout::getAdjacencyAsLeft(int index) const
+{
+ return mof::rotation_mod(index-1 , m_pImpl->length );
+}
+//}}}
+//{{{ getAdjacencyAsRight
+int mof::widget::OverlapLayout::getAdjacencyAsRight(int index) const
+{
+ return mof::rotation_mod(index+1 , m_pImpl->length );
+}
+//}}}
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class OverlapLayout : public Layout\r
- {\r
- public:\r
-\r
- OverlapLayout( const mof::Vector2D& size );\r
- virtual ~OverlapLayout();\r
- virtual void add(boost::shared_ptr<WidgetView> pView);\r
- virtual Vector2D getPreferredSize() const;\r
- virtual DependencyType getSizeDependencyType() const;\r
- virtual void connect(WidgetView* pParentView);\r
- virtual size_t getLength( ) const;\r
- virtual int getAdjacencyAsUp(int index) const;\r
- virtual int getAdjacencyAsDown(int index) const;\r
- virtual int getAdjacencyAsLeft(int index) const;\r
- virtual int getAdjacencyAsRight(int index) const;\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
-} // namepsace mof\r
-\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <mof/widget/Layout.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class OverlapLayout : public Layout
+ {
+ public:
+
+ OverlapLayout( const mof::Vector2D& size );
+ virtual ~OverlapLayout();
+ virtual void add(boost::shared_ptr<WidgetView> pView);
+ virtual Vector2D getPreferredSize() const;
+ virtual DependencyType getSizeDependencyType() const;
+ virtual void connect(WidgetView* pParentView);
+ virtual size_t getLength( ) const;
+ virtual int getAdjacencyAsUp(int index) const;
+ virtual int getAdjacencyAsDown(int index) const;
+ virtual int getAdjacencyAsLeft(int index) const;
+ virtual int getAdjacencyAsRight(int index) const;
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
+} // namepsace mof
+
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include <mof/widget/Layout.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class OverlapLayout : public Layout\r
- {\r
- public:\r
-\r
- OverlapLayout( const mof::Vector2D& size );\r
- virtual ~OverlapLayout();\r
- virtual void add(boost::shared_ptr<WidgetView> pView);\r
- virtual Vector2D getPreferredSize() const;\r
- virtual DependencyType getSizeDependencyType() const;\r
- virtual void connect(boost::shared_ptr<WidgetView> pParentView);\r
- virtual size_t getLength( ) const;\r
- virtual int getAdjacencyAsUp(int index) const;\r
- virtual int getAdjacencyAsDown(int index) const;\r
- virtual int getAdjacencyAsLeft(int index) const;\r
- virtual int getAdjacencyAsRight(int index) const;\r
-\r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
-} // namepsace mof\r
-\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include <mof/widget/Layout.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class OverlapLayout : public Layout
+ {
+ public:
+
+ OverlapLayout( const mof::Vector2D& size );
+ virtual ~OverlapLayout();
+ virtual void add(boost::shared_ptr<WidgetView> pView);
+ virtual Vector2D getPreferredSize() const;
+ virtual DependencyType getSizeDependencyType() const;
+ virtual void connect(boost::shared_ptr<WidgetView> pParentView);
+ virtual size_t getLength( ) const;
+ virtual int getAdjacencyAsUp(int index) const;
+ virtual int getAdjacencyAsDown(int index) const;
+ virtual int getAdjacencyAsLeft(int index) const;
+ virtual int getAdjacencyAsRight(int index) const;
+
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
+} // namepsace mof
+
-#pragma once\r
-\r
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/tstring.hpp"\r
-#include "mof/Font.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include "mof/Animation.hpp"\r
-#include "mof/Vector2D.hpp"\r
-\r
-\r
-namespace mof\r
-{\r
- struct PageRequest; \r
- class LayoutManager;\r
-\r
- /** ページから\r
- */\r
- class Page\r
- {\r
- public:\r
- Page\r
- ( \r
- mof::LayoutManager* pLayout\r
- );\r
-\r
- ~Page( );\r
-\r
- /** このウィジェットを表示にする\r
- * @note 即座に処理されることは保障されない\r
- */\r
- void show( );\r
-\r
- /** このウィジェットを非表示にする\r
- * @note 即座に処理されることは保障されない\r
- */\r
- void hide( );\r
-\r
- /** このウィジェットの内容を描画する\r
- * @note setPosition()やsetSize()で指定した領域外にも描画が行われることもある\r
- */\r
- void draw( ) const;\r
- \r
- /** ウィジェット内のフレームを進める\r
- */\r
- void update( );\r
-\r
- /** このウィジェットがとれる最小の大きさに\r
- */\r
- void pack( );\r
- \r
- /** ウィジェットの左上の位置を得る\r
- * @note このメソッドで得られるハンドラとsetPosition()で\r
- * 指定したハンドラは同一であると扱える\r
- * @retval このウィジェットの左上の位置を得るためのハンドラ \r
- */\r
- mof::Animation< mof::Vector2D>::Handler getPosition( ) const;\r
-\r
- /** ウィジェットの大きさを得る\r
- * @note このメソッドで得られるハンドラとsetSize()で\r
- * 指定したハンドラは同一であると扱える\r
- * @retval このウィジェットの大きさを得るためのハンドラ \r
- */\r
- mof::Animation< mof::Vector2D>::Handler getSize( ) const;\r
-\r
- /** ウィジェットの左上の位置を指定する\r
- * @note このメソッドで指定するハンドラとgetPosition()で\r
- * 得られるハンドラは同一であると扱える\r
- * @retval このウィジェットの左上の位置を得るためのハンドラ \r
- */\r
- void setPosition( const mof::Animation<mof::Vector2D>::Handler& handler ); \r
- \r
- /** ウィジェットの左上の位置を指定する\r
- * @note このメソッドで指定するハンドラとgetPosition()で\r
- * 得られるハンドラは同一であると扱える\r
- * @retval このウィジェットの左上の位置を得るためのハンドラ \r
- */\r
- void setSize( const mof::Animation<mof::Vector2D>::Handler& handler ); \r
- \r
- mof::Rectangle<int> getBounds( ); \r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
+#pragma once
+
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include "mof/tstring.hpp"
+#include "mof/Font.hpp"
+#include "mof/Rectangle.hpp"
+#include "mof/Animation.hpp"
+#include "mof/Vector2D.hpp"
+
+
+namespace mof
+{
+ struct PageRequest;
+ class LayoutManager;
+
+ /** ページから
+ */
+ class Page
+ {
+ public:
+ Page
+ (
+ mof::LayoutManager* pLayout
+ );
+
+ ~Page( );
+
+ /** このウィジェットを表示にする
+ * @note 即座に処理されることは保障されない
+ */
+ void show( );
+
+ /** このウィジェットを非表示にする
+ * @note 即座に処理されることは保障されない
+ */
+ void hide( );
+
+ /** このウィジェットの内容を描画する
+ * @note setPosition()やsetSize()で指定した領域外にも描画が行われることもある
+ */
+ void draw( ) const;
+
+ /** ウィジェット内のフレームを進める
+ */
+ void update( );
+
+ /** このウィジェットがとれる最小の大きさに
+ */
+ void pack( );
+
+ /** ウィジェットの左上の位置を得る
+ * @note このメソッドで得られるハンドラとsetPosition()で
+ * 指定したハンドラは同一であると扱える
+ * @retval このウィジェットの左上の位置を得るためのハンドラ
+ */
+ mof::Animation< mof::Vector2D>::Handler getPosition( ) const;
+
+ /** ウィジェットの大きさを得る
+ * @note このメソッドで得られるハンドラとsetSize()で
+ * 指定したハンドラは同一であると扱える
+ * @retval このウィジェットの大きさを得るためのハンドラ
+ */
+ mof::Animation< mof::Vector2D>::Handler getSize( ) const;
+
+ /** ウィジェットの左上の位置を指定する
+ * @note このメソッドで指定するハンドラとgetPosition()で
+ * 得られるハンドラは同一であると扱える
+ * @retval このウィジェットの左上の位置を得るためのハンドラ
+ */
+ void setPosition( const mof::Animation<mof::Vector2D>::Handler& handler );
+
+ /** ウィジェットの左上の位置を指定する
+ * @note このメソッドで指定するハンドラとgetPosition()で
+ * 得られるハンドラは同一であると扱える
+ * @retval このウィジェットの左上の位置を得るためのハンドラ
+ */
+ void setSize( const mof::Animation<mof::Vector2D>::Handler& handler );
+
+ mof::Rectangle<int> getBounds( );
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
-#include "mof/Pager.hpp"\r
-#include "mof/Sprite.hpp"\r
-#include "mof/utilities.hpp"\r
-#include <vector>\r
-#include "mof/widgets.hpp"\r
-#include "mof/mofAnimations.hpp"\r
-#include "mof/mofGraphics.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-namespace mof\r
-{\r
- struct Pager::Impl\r
- {\r
- std::vector< std::vector<mof::Sprite*> > pages;\r
- mof::FrameNumber frame;\r
- int currentPage;\r
- mof::LayoutManager* pLayout;\r
- mof::TranslationAnimation2D::Handler translation;\r
- mof::ScalingAnimation2D::Handler scaling;\r
-\r
-//{{{ Impl\r
- Impl( const mof::Rectangle<int>& _bounds )\r
- : \r
- currentPage(-1) ,\r
- pLayout(NULL) ,\r
- frame( 0 )\r
- {\r
- translation = mof::TranslationAnimation2D::Handler\r
- (\r
- new mof::TranslationAnimation2D\r
- (\r
- mof::makeConstantHandler\r
- (\r
- mof::Vector2D(_bounds.beginX , _bounds.beginY )\r
- )\r
- )\r
- );\r
-\r
- scaling = mof::ScalingAnimation2D::Handler\r
- (\r
- new mof::ScalingAnimation2D\r
- (\r
- mof::makeConstantHandler\r
- (\r
- mof::Vector2D(_bounds.getWidth( ) , _bounds.getHeight( ) )\r
- )\r
- )\r
- );\r
-\r
- }\r
-//}}}\r
-//{{{ ~Impl\r
- ~Impl(){\r
- delete pLayout;\r
- foreach(std::vector<mof::Sprite*>& page , pages ){\r
- foreach(mof::Sprite*& pSprite , page ){\r
- delete pSprite;\r
- }\r
- }\r
- }\r
-//}}}\r
-//{{{ showPage\r
- void showPage(bool first)\r
- {\r
- mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {\r
- mof::makeKeyFrame(first ? 0 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) ,\r
- mof::makeKeyFrame(first ? 30*2 : 90 , mof::Color4f(1 , 1 , 1 , 1) ) \r
- };\r
- mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));\r
- handler = mof::makeOffsetHandler< mof::Color4f >( handler , -frame );\r
- foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){\r
- pSprite->setColor(handler);\r
- }\r
- }\r
-//}}}\r
-//{{{ closePage\r
- void closePage(bool last){\r
- mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {\r
- mof::makeKeyFrame(0 , mof::Color4f(1 , 1 , 1 , 1) ) ,\r
- mof::makeKeyFrame(last ? 10*2 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) \r
- };\r
- mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));\r
- DEBUG_PRINT( frame);\r
- handler = mof::makeOffsetHandler< mof::Color4f >( handler , -frame );\r
- foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){\r
- pSprite->setColor(handler);\r
- }\r
- }\r
-\r
-//}}}\r
- };\r
-//{{{ Pager\r
- Pager::Pager\r
- (\r
- const mof::Rectangle<int>& bounds ,\r
- mof::LayoutManager* pLayout\r
- )\r
- : m_pImpl( new Impl( bounds ) )\r
- {\r
- m_pImpl->pLayout = pLayout;\r
- }\r
-//}}} \r
-//{{{ ~Pager\r
- Pager::~Pager( )\r
- {\r
- }\r
-//}}} \r
-//{{{ show\r
- void Pager::show( )\r
- {\r
- m_pImpl->currentPage = -1;\r
- m_pImpl->currentPage++;\r
- m_pImpl->showPage(true);\r
- }\r
-//}}} \r
-//{{{ close \r
- void Pager::close( )\r
- {\r
- if(m_pImpl->currentPage < 0)return;\r
- m_pImpl->closePage(true);\r
- }\r
-//}}} \r
-//{{{ nextPage\r
- void Pager::nextPage( )\r
- {\r
- if(m_pImpl->currentPage < 0){\r
- show();\r
- return;\r
- }\r
- m_pImpl->closePage(false);\r
- if(m_pImpl->currentPage >= static_cast<signed int>(m_pImpl->pages.size()) -1 ){\r
- close();\r
- return;\r
- }\r
- m_pImpl->currentPage++;\r
- m_pImpl->showPage(false);\r
- }\r
-//}}} \r
-//{{{ addPage\r
- void Pager::addPage( const mof::PageRequest& page )\r
- {\r
- m_pImpl->pages.push_back(std::vector<mof::Sprite*>());\r
- mof::compileText( page.message , page.font , m_pImpl->pages.back() );\r
- \r
- std::vector< mof::Rectangle<int> > boundList;\r
- \r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.back() ){\r
- pSprite->setFrameNumber( m_pImpl->frame );\r
- mof::Rectangle<int> bounds = pSprite->getWorldTransform().toBoundingBox(); \r
- boundList.push_back(bounds);\r
- }\r
- \r
- mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );\r
- m_pImpl->pLayout->replace\r
- (\r
- scaling.x , scaling.y ,\r
- boundList.front() , boundList.back()\r
- );\r
- \r
- for(unsigned int j = 0 ; j < m_pImpl->pLayout->getLength( ) ; ++j)\r
- {\r
- mof::Animation<mof::Matrix2D>::Handler children[] =\r
- {\r
- mof::makeConstantHandler\r
- ( \r
- mof::Matrix2D::createScaling\r
- (\r
- mof::Vector2D(boundList.at(j).getWidth( ) , boundList.at(j).getHeight( ) )\r
- )\r
- ) ,\r
- m_pImpl->translation , \r
- mof::makeConstantHandler\r
- (\r
- mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(j) )\r
- )\r
- }; // array children\r
-\r
- mof::Animation<mof::Matrix2D>::Handler handler\r
- (\r
- new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )\r
- );\r
-\r
- m_pImpl->pages.back().at(j)->setWorldTransform( handler );\r
- m_pImpl->pages.back().at(j)->setColor(mof::Color4f(0 , 1 , 1 , 1));\r
-\r
- } // for \r
-\r
- }\r
-//}}} \r
-//{{{ draw\r
- void Pager::draw( ) const\r
- {\r
- if(m_pImpl->currentPage < 0)return;\r
- \r
- if(m_pImpl->currentPage > 0){\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){\r
- pSprite->draw();\r
- }\r
- }\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){\r
- pSprite->draw();\r
- }\r
- }\r
-//}}} \r
-//{{{ update\r
- void Pager::update( )\r
- {\r
- if(m_pImpl->currentPage < 0)return;\r
- if(m_pImpl->currentPage > 0){\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){\r
- pSprite->update();\r
- }\r
- }\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){\r
- pSprite->update();\r
- }\r
- m_pImpl->frame++;\r
- }\r
-//}}} \r
-//{{{ hasNextPage\r
- bool Pager::hasNextPage( ) const\r
- { \r
- return m_pImpl->currentPage < static_cast<signed int>(m_pImpl->pages.size()) -1;\r
- }\r
-//}}} \r
-//{{{ hasPreviousPage\r
- bool Pager::hasPreviousPage( ) const\r
- { \r
- return m_pImpl->currentPage >= 0;\r
- }\r
-//}}} \r
-\r
-//{{{ setPosition\r
- void Pager::setPosition( const mof::Animation<mof::Vector2D>::Handler& handler )\r
- {\r
- m_pImpl->translation->set( handler );\r
- }\r
-//}}} \r
-//{{{ setSize\r
- void Pager::setSize( const mof::Animation<mof::Vector2D>::Handler& handler )\r
- {\r
- m_pImpl->scaling->set( handler );\r
- }\r
-//}}} \r
-//{{{ getBounds\r
- mof::Rectangle<int> Pager::getBounds( )\r
- {\r
- mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );\r
- mof::Vector2D translation = m_pImpl->translation->get( )->getValue( m_pImpl->frame );\r
- return mof::Rectangle<int>( translation.x , translation.y , translation.x + scaling.x , translation.y + scaling.y );\r
- }\r
-//}}} \r
-} //namepsace mof\r
-\r
+#include "mof/Pager.hpp"
+#include "mof/Sprite.hpp"
+#include "mof/utilities.hpp"
+#include <vector>
+#include "mof/widgets.hpp"
+#include "mof/mofAnimations.hpp"
+#include "mof/mofGraphics.hpp"
+#include "mof/ConsoleIO.hpp"
+
+namespace mof
+{
+ struct Pager::Impl
+ {
+ std::vector< std::vector<mof::Sprite*> > pages;
+ mof::FrameNumber frame;
+ int currentPage;
+ mof::LayoutManager* pLayout;
+ mof::TranslationAnimation2D::Handler translation;
+ mof::ScalingAnimation2D::Handler scaling;
+
+//{{{ Impl
+ Impl( const mof::Rectangle<int>& _bounds )
+ :
+ currentPage(-1) ,
+ pLayout(NULL) ,
+ frame( 0 )
+ {
+ translation = mof::TranslationAnimation2D::Handler
+ (
+ new mof::TranslationAnimation2D
+ (
+ mof::makeConstantHandler
+ (
+ mof::Vector2D(_bounds.beginX , _bounds.beginY )
+ )
+ )
+ );
+
+ scaling = mof::ScalingAnimation2D::Handler
+ (
+ new mof::ScalingAnimation2D
+ (
+ mof::makeConstantHandler
+ (
+ mof::Vector2D(_bounds.getWidth( ) , _bounds.getHeight( ) )
+ )
+ )
+ );
+
+ }
+//}}}
+//{{{ ~Impl
+ ~Impl(){
+ delete pLayout;
+ foreach(std::vector<mof::Sprite*>& page , pages ){
+ foreach(mof::Sprite*& pSprite , page ){
+ delete pSprite;
+ }
+ }
+ }
+//}}}
+//{{{ showPage
+ void showPage(bool first)
+ {
+ mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {
+ mof::makeKeyFrame(first ? 0 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) ,
+ mof::makeKeyFrame(first ? 30*2 : 90 , mof::Color4f(1 , 1 , 1 , 1) )
+ };
+ mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));
+ handler = mof::makeOffsetHandler< mof::Color4f >( handler , -frame );
+ foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){
+ pSprite->setColor(handler);
+ }
+ }
+//}}}
+//{{{ closePage
+ void closePage(bool last){
+ mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {
+ mof::makeKeyFrame(0 , mof::Color4f(1 , 1 , 1 , 1) ) ,
+ mof::makeKeyFrame(last ? 10*2 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) )
+ };
+ mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));
+ DEBUG_PRINT( frame);
+ handler = mof::makeOffsetHandler< mof::Color4f >( handler , -frame );
+ foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){
+ pSprite->setColor(handler);
+ }
+ }
+
+//}}}
+ };
+//{{{ Pager
+ Pager::Pager
+ (
+ const mof::Rectangle<int>& bounds ,
+ mof::LayoutManager* pLayout
+ )
+ : m_pImpl( new Impl( bounds ) )
+ {
+ m_pImpl->pLayout = pLayout;
+ }
+//}}}
+//{{{ ~Pager
+ Pager::~Pager( )
+ {
+ }
+//}}}
+//{{{ show
+ void Pager::show( )
+ {
+ m_pImpl->currentPage = -1;
+ m_pImpl->currentPage++;
+ m_pImpl->showPage(true);
+ }
+//}}}
+//{{{ close
+ void Pager::close( )
+ {
+ if(m_pImpl->currentPage < 0)return;
+ m_pImpl->closePage(true);
+ }
+//}}}
+//{{{ nextPage
+ void Pager::nextPage( )
+ {
+ if(m_pImpl->currentPage < 0){
+ show();
+ return;
+ }
+ m_pImpl->closePage(false);
+ if(m_pImpl->currentPage >= static_cast<signed int>(m_pImpl->pages.size()) -1 ){
+ close();
+ return;
+ }
+ m_pImpl->currentPage++;
+ m_pImpl->showPage(false);
+ }
+//}}}
+//{{{ addPage
+ void Pager::addPage( const mof::PageRequest& page )
+ {
+ m_pImpl->pages.push_back(std::vector<mof::Sprite*>());
+ mof::compileText( page.message , page.font , m_pImpl->pages.back() );
+
+ std::vector< mof::Rectangle<int> > boundList;
+
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.back() ){
+ pSprite->setFrameNumber( m_pImpl->frame );
+ mof::Rectangle<int> bounds = pSprite->getWorldTransform().toBoundingBox();
+ boundList.push_back(bounds);
+ }
+
+ mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );
+ m_pImpl->pLayout->replace
+ (
+ scaling.x , scaling.y ,
+ boundList.front() , boundList.back()
+ );
+
+ for(unsigned int j = 0 ; j < m_pImpl->pLayout->getLength( ) ; ++j)
+ {
+ mof::Animation<mof::Matrix2D>::Handler children[] =
+ {
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createScaling
+ (
+ mof::Vector2D(boundList.at(j).getWidth( ) , boundList.at(j).getHeight( ) )
+ )
+ ) ,
+ m_pImpl->translation ,
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(j) )
+ )
+ }; // array children
+
+ mof::Animation<mof::Matrix2D>::Handler handler
+ (
+ new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )
+ );
+
+ m_pImpl->pages.back().at(j)->setWorldTransform( handler );
+ m_pImpl->pages.back().at(j)->setColor(mof::Color4f(0 , 1 , 1 , 1));
+
+ } // for
+
+ }
+//}}}
+//{{{ draw
+ void Pager::draw( ) const
+ {
+ if(m_pImpl->currentPage < 0)return;
+
+ if(m_pImpl->currentPage > 0){
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){
+ pSprite->draw();
+ }
+ }
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){
+ pSprite->draw();
+ }
+ }
+//}}}
+//{{{ update
+ void Pager::update( )
+ {
+ if(m_pImpl->currentPage < 0)return;
+ if(m_pImpl->currentPage > 0){
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){
+ pSprite->update();
+ }
+ }
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){
+ pSprite->update();
+ }
+ m_pImpl->frame++;
+ }
+//}}}
+//{{{ hasNextPage
+ bool Pager::hasNextPage( ) const
+ {
+ return m_pImpl->currentPage < static_cast<signed int>(m_pImpl->pages.size()) -1;
+ }
+//}}}
+//{{{ hasPreviousPage
+ bool Pager::hasPreviousPage( ) const
+ {
+ return m_pImpl->currentPage >= 0;
+ }
+//}}}
+
+//{{{ setPosition
+ void Pager::setPosition( const mof::Animation<mof::Vector2D>::Handler& handler )
+ {
+ m_pImpl->translation->set( handler );
+ }
+//}}}
+//{{{ setSize
+ void Pager::setSize( const mof::Animation<mof::Vector2D>::Handler& handler )
+ {
+ m_pImpl->scaling->set( handler );
+ }
+//}}}
+//{{{ getBounds
+ mof::Rectangle<int> Pager::getBounds( )
+ {
+ mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );
+ mof::Vector2D translation = m_pImpl->translation->get( )->getValue( m_pImpl->frame );
+ return mof::Rectangle<int>( translation.x , translation.y , translation.x + scaling.x , translation.y + scaling.y );
+ }
+//}}}
+} //namepsace mof
+
-#include "mof/Pager.hpp"\r
-#include "mof/Sprite.hpp"\r
-#include "mof/utilities.hpp"\r
-#include <vector>\r
-#include "mof/widgets.hpp"\r
-#include "mof/mofAnimations.hpp"\r
-#include "mof/mofGraphics.hpp"\r
-#include "mof/ConsoleIO.hpp"\r
-\r
-namespace mof\r
-{\r
- struct Pager::Impl\r
- {\r
- std::vector< std::vector<mof::Sprite*> > pages;\r
- mof::FrameNumber frame;\r
- int currentPage;\r
- mof::LayoutManager* pLayout;\r
- mof::TranslationAnimation2D::Handler translation;\r
- mof::ScalingAnimation2D::Handler scaling;\r
-\r
-//{{{ Impl\r
- Impl( const mof::Rectangle<int>& _bounds )\r
- : \r
- currentPage(-1) ,\r
- pLayout(NULL) ,\r
- frame( 0 )\r
- {\r
- translation = mof::TranslationAnimation2D::Handler\r
- (\r
- new mof::TranslationAnimation2D\r
- (\r
- mof::makeConstantHandler\r
- (\r
- mof::Vector2D(_bounds.beginX , _bounds.beginY )\r
- )\r
- )\r
- );\r
-\r
- scaling = mof::ScalingAnimation2D::Handler\r
- (\r
- new mof::ScalingAnimation2D\r
- (\r
- mof::makeConstantHandler\r
- (\r
- mof::Vector2D(_bounds.getWidth( ) , _bounds.getHeight( ) )\r
- )\r
- )\r
- );\r
-\r
- }\r
-//}}}\r
-//{{{ ~Impl\r
- ~Impl(){\r
- delete pLayout;\r
- foreach(std::vector<mof::Sprite*>& page , pages ){\r
- foreach(mof::Sprite*& pSprite , page ){\r
- delete pSprite;\r
- }\r
- }\r
- }\r
-//}}}\r
-//{{{ showPage\r
- void showPage(bool first)\r
- {\r
- mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {\r
- mof::makeKeyFrame(first ? 0 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) ,\r
- mof::makeKeyFrame(first ? 30*2 : 90 , mof::Color4f(1 , 1 , 1 , 1) ) \r
- };\r
- mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));\r
- handler = mof::makeOffsetHandler< mof::Color4f >( handler , -frame );\r
- foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){\r
- pSprite->setColor(handler);\r
- }\r
- }\r
-//}}}\r
-//{{{ closePage\r
- void closePage(bool last){\r
- mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {\r
- mof::makeKeyFrame(0 , mof::Color4f(1 , 1 , 1 , 1) ) ,\r
- mof::makeKeyFrame(last ? 10*2 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) \r
- };\r
- mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));\r
- DEBUG_PRINT( frame);\r
- handler = mof::makeOffsetHandler< mof::Color4f >( handler , -frame );\r
- foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){\r
- pSprite->setColor(handler);\r
- }\r
- }\r
-\r
-//}}}\r
- };\r
-//{{{ Pager\r
- Pager::Pager\r
- (\r
- const mof::Rectangle<int>& bounds ,\r
- mof::LayoutManager* pLayout\r
- )\r
- : m_pImpl( new Impl( bounds ) )\r
- {\r
- m_pImpl->pLayout = pLayout;\r
- }\r
-//}}} \r
-//{{{ ~Pager\r
- Pager::~Pager( )\r
- {\r
- }\r
-//}}} \r
-//{{{ show\r
- void Pager::show( )\r
- {\r
- m_pImpl->currentPage = -1;\r
- m_pImpl->currentPage++;\r
- m_pImpl->showPage(true);\r
- }\r
-//}}} \r
-//{{{ close \r
- void Pager::close( )\r
- {\r
- if(m_pImpl->currentPage < 0)return;\r
- m_pImpl->closePage(true);\r
- }\r
-//}}} \r
-//{{{ nextPage\r
- void Pager::nextPage( )\r
- {\r
- if(m_pImpl->currentPage < 0){\r
- show();\r
- return;\r
- }\r
- m_pImpl->closePage(false);\r
- if(m_pImpl->currentPage >= static_cast<signed int>(m_pImpl->pages.size()) -1 ){\r
- close();\r
- return;\r
- }\r
- m_pImpl->currentPage++;\r
- m_pImpl->showPage(false);\r
- }\r
-//}}} \r
-//{{{ addPage\r
- void Pager::addPage( const mof::PageRequest& page )\r
- {\r
- m_pImpl->pages.push_back(std::vector<mof::Sprite*>());\r
- mof::compileText( page.message , page.font , m_pImpl->pages.back() );\r
- \r
- std::vector< mof::Rectangle<int> > boundList;\r
- \r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.back() ){\r
- pSprite->setFrameNumber( m_pImpl->frame );\r
- mof::Rectangle<int> bounds = pSprite->getWorldTransform().toBoundingBox(); \r
- boundList.push_back(bounds);\r
- }\r
- \r
- mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );\r
- m_pImpl->pLayout->replace\r
- (\r
- scaling.x , scaling.y ,\r
- boundList.front() , boundList.back()\r
- );\r
- \r
- for(unsigned int j = 0 ; j < m_pImpl->pLayout->getLength( ) ; ++j)\r
- {\r
- mof::Animation<mof::Matrix2D>::Handler children[] =\r
- {\r
- mof::makeConstantHandler\r
- ( \r
- mof::Matrix2D::createScaling\r
- (\r
- mof::Vector2D(boundList.at(j).getWidth( ) , boundList.at(j).getHeight( ) )\r
- )\r
- ) ,\r
- m_pImpl->translation , \r
- mof::makeConstantHandler\r
- (\r
- mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(j) )\r
- )\r
- }; // array children\r
-\r
- mof::Animation<mof::Matrix2D>::Handler handler\r
- (\r
- new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )\r
- );\r
-\r
- m_pImpl->pages.back().at(j)->setWorldTransform( handler );\r
- m_pImpl->pages.back().at(j)->setColor(mof::Color4f(0 , 1 , 1 , 1));\r
-\r
- } // for \r
-\r
- }\r
-//}}} \r
-//{{{ draw\r
- void Pager::draw( ) const\r
- {\r
- if(m_pImpl->currentPage < 0)return;\r
- \r
- if(m_pImpl->currentPage > 0){\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){\r
- pSprite->draw();\r
- }\r
- }\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){\r
- pSprite->draw();\r
- }\r
- }\r
-//}}} \r
-//{{{ update\r
- void Pager::update( )\r
- {\r
- if(m_pImpl->currentPage < 0)return;\r
- if(m_pImpl->currentPage > 0){\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){\r
- pSprite->update();\r
- }\r
- }\r
- foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){\r
- pSprite->update();\r
- }\r
- m_pImpl->frame++;\r
- }\r
-//}}} \r
-//{{{ hasNextPage\r
- bool Pager::hasNextPage( ) const\r
- { \r
- return m_pImpl->currentPage < static_cast<signed int>(m_pImpl->pages.size()) -1;\r
- }\r
-//}}} \r
-//{{{ hasPreviousPage\r
- bool Pager::hasPreviousPage( ) const\r
- { \r
- return m_pImpl->currentPage >= 0;\r
- }\r
-//}}} \r
-\r
-//{{{ setPosition\r
- void Pager::setPosition( const mof::Animation<mof::Vector2D>::Handler& handler )\r
- {\r
- m_pImpl->translation->set( handler );\r
- }\r
-//}}} \r
-//{{{ setSize\r
- void Pager::setSize( const mof::Animation<mof::Vector2D>::Handler& handler )\r
- {\r
- m_pImpl->scaling->set( handler );\r
- }\r
-//}}} \r
-//{{{ getBounds\r
- mof::Rectangle<int> Pager::getBounds( )\r
- {\r
- mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );\r
- mof::Vector2D translation = m_pImpl->translation->get( )->getValue( m_pImpl->frame );\r
- return mof::Rectangle<int>( translation.x , translation.y , translation.x + scaling.x , translation.y + scaling.y );\r
- }\r
-//}}} \r
-} //namepsace mof\r
-\r
+#include "mof/Pager.hpp"
+#include "mof/Sprite.hpp"
+#include "mof/utilities.hpp"
+#include <vector>
+#include "mof/widgets.hpp"
+#include "mof/mofAnimations.hpp"
+#include "mof/mofGraphics.hpp"
+#include "mof/ConsoleIO.hpp"
+
+namespace mof
+{
+ struct Pager::Impl
+ {
+ std::vector< std::vector<mof::Sprite*> > pages;
+ mof::FrameNumber frame;
+ int currentPage;
+ mof::LayoutManager* pLayout;
+ mof::TranslationAnimation2D::Handler translation;
+ mof::ScalingAnimation2D::Handler scaling;
+
+//{{{ Impl
+ Impl( const mof::Rectangle<int>& _bounds )
+ :
+ currentPage(-1) ,
+ pLayout(NULL) ,
+ frame( 0 )
+ {
+ translation = mof::TranslationAnimation2D::Handler
+ (
+ new mof::TranslationAnimation2D
+ (
+ mof::makeConstantHandler
+ (
+ mof::Vector2D(_bounds.beginX , _bounds.beginY )
+ )
+ )
+ );
+
+ scaling = mof::ScalingAnimation2D::Handler
+ (
+ new mof::ScalingAnimation2D
+ (
+ mof::makeConstantHandler
+ (
+ mof::Vector2D(_bounds.getWidth( ) , _bounds.getHeight( ) )
+ )
+ )
+ );
+
+ }
+//}}}
+//{{{ ~Impl
+ ~Impl(){
+ delete pLayout;
+ foreach(std::vector<mof::Sprite*>& page , pages ){
+ foreach(mof::Sprite*& pSprite , page ){
+ delete pSprite;
+ }
+ }
+ }
+//}}}
+//{{{ showPage
+ void showPage(bool first)
+ {
+ mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {
+ mof::makeKeyFrame(first ? 0 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) ) ,
+ mof::makeKeyFrame(first ? 30*2 : 90 , mof::Color4f(1 , 1 , 1 , 1) )
+ };
+ mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));
+ handler = mof::makeOffsetHandler< mof::Color4f >( handler , -frame );
+ foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){
+ pSprite->setColor(handler);
+ }
+ }
+//}}}
+//{{{ closePage
+ void closePage(bool last){
+ mof::KeyFrameAnimation<mof::Color4f>::KeyFrame keyFrames[] = {
+ mof::makeKeyFrame(0 , mof::Color4f(1 , 1 , 1 , 1) ) ,
+ mof::makeKeyFrame(last ? 10*2 : 10*2 , mof::Color4f(0 , 1 , 1 , 1) )
+ };
+ mof::Animation<mof::Color4f>::Handler handler(new mof::KeyFrameAnimation<mof::Color4f>(keyFrames[0] , keyFrames[1]));
+ DEBUG_PRINT( frame);
+ handler = mof::makeOffsetHandler< mof::Color4f >( handler , -frame );
+ foreach(mof::Sprite*& pSprite , pages.at(currentPage) ){
+ pSprite->setColor(handler);
+ }
+ }
+
+//}}}
+ };
+//{{{ Pager
+ Pager::Pager
+ (
+ const mof::Rectangle<int>& bounds ,
+ mof::LayoutManager* pLayout
+ )
+ : m_pImpl( new Impl( bounds ) )
+ {
+ m_pImpl->pLayout = pLayout;
+ }
+//}}}
+//{{{ ~Pager
+ Pager::~Pager( )
+ {
+ }
+//}}}
+//{{{ show
+ void Pager::show( )
+ {
+ m_pImpl->currentPage = -1;
+ m_pImpl->currentPage++;
+ m_pImpl->showPage(true);
+ }
+//}}}
+//{{{ close
+ void Pager::close( )
+ {
+ if(m_pImpl->currentPage < 0)return;
+ m_pImpl->closePage(true);
+ }
+//}}}
+//{{{ nextPage
+ void Pager::nextPage( )
+ {
+ if(m_pImpl->currentPage < 0){
+ show();
+ return;
+ }
+ m_pImpl->closePage(false);
+ if(m_pImpl->currentPage >= static_cast<signed int>(m_pImpl->pages.size()) -1 ){
+ close();
+ return;
+ }
+ m_pImpl->currentPage++;
+ m_pImpl->showPage(false);
+ }
+//}}}
+//{{{ addPage
+ void Pager::addPage( const mof::PageRequest& page )
+ {
+ m_pImpl->pages.push_back(std::vector<mof::Sprite*>());
+ mof::compileText( page.message , page.font , m_pImpl->pages.back() );
+
+ std::vector< mof::Rectangle<int> > boundList;
+
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.back() ){
+ pSprite->setFrameNumber( m_pImpl->frame );
+ mof::Rectangle<int> bounds = pSprite->getWorldTransform().toBoundingBox();
+ boundList.push_back(bounds);
+ }
+
+ mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );
+ m_pImpl->pLayout->replace
+ (
+ scaling.x , scaling.y ,
+ boundList.front() , boundList.back()
+ );
+
+ for(unsigned int j = 0 ; j < m_pImpl->pLayout->getLength( ) ; ++j)
+ {
+ mof::Animation<mof::Matrix2D>::Handler children[] =
+ {
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createScaling
+ (
+ mof::Vector2D(boundList.at(j).getWidth( ) , boundList.at(j).getHeight( ) )
+ )
+ ) ,
+ m_pImpl->translation ,
+ mof::makeConstantHandler
+ (
+ mof::Matrix2D::createTranslation( m_pImpl->pLayout->getPosition(j) )
+ )
+ }; // array children
+
+ mof::Animation<mof::Matrix2D>::Handler handler
+ (
+ new mof::CascadingAnimation<mof::Matrix2D>( children[0] , mof::lastOf( children ) )
+ );
+
+ m_pImpl->pages.back().at(j)->setWorldTransform( handler );
+ m_pImpl->pages.back().at(j)->setColor(mof::Color4f(0 , 1 , 1 , 1));
+
+ } // for
+
+ }
+//}}}
+//{{{ draw
+ void Pager::draw( ) const
+ {
+ if(m_pImpl->currentPage < 0)return;
+
+ if(m_pImpl->currentPage > 0){
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){
+ pSprite->draw();
+ }
+ }
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){
+ pSprite->draw();
+ }
+ }
+//}}}
+//{{{ update
+ void Pager::update( )
+ {
+ if(m_pImpl->currentPage < 0)return;
+ if(m_pImpl->currentPage > 0){
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage-1) ){
+ pSprite->update();
+ }
+ }
+ foreach(mof::Sprite*& pSprite , m_pImpl->pages.at(m_pImpl->currentPage) ){
+ pSprite->update();
+ }
+ m_pImpl->frame++;
+ }
+//}}}
+//{{{ hasNextPage
+ bool Pager::hasNextPage( ) const
+ {
+ return m_pImpl->currentPage < static_cast<signed int>(m_pImpl->pages.size()) -1;
+ }
+//}}}
+//{{{ hasPreviousPage
+ bool Pager::hasPreviousPage( ) const
+ {
+ return m_pImpl->currentPage >= 0;
+ }
+//}}}
+
+//{{{ setPosition
+ void Pager::setPosition( const mof::Animation<mof::Vector2D>::Handler& handler )
+ {
+ m_pImpl->translation->set( handler );
+ }
+//}}}
+//{{{ setSize
+ void Pager::setSize( const mof::Animation<mof::Vector2D>::Handler& handler )
+ {
+ m_pImpl->scaling->set( handler );
+ }
+//}}}
+//{{{ getBounds
+ mof::Rectangle<int> Pager::getBounds( )
+ {
+ mof::Vector2D scaling = m_pImpl->scaling->get( )->getValue( m_pImpl->frame );
+ mof::Vector2D translation = m_pImpl->translation->get( )->getValue( m_pImpl->frame );
+ return mof::Rectangle<int>( translation.x , translation.y , translation.x + scaling.x , translation.y + scaling.y );
+ }
+//}}}
+} //namepsace mof
+
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/tstring.hpp"\r
-#include "mof/Font.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include "mof/stream/Manipulator.hpp"\r
-#include "mof/Vector2D.hpp"\r
-\r
-\r
-namespace mof\r
-{\r
- struct PageRequest; \r
- class LayoutManager;\r
-\r
- /** \83y\81[\83W\82©\82ç\r
- */\r
- class Pager\r
- {\r
- public:\r
- Pager\r
- ( \r
- const mof::Rectangle<int>& bounds ,\r
- mof::LayoutManager* pLayout\r
- );\r
-\r
- ~Pager( );\r
-\r
- void show( );\r
- void close( );\r
- void nextPage( );\r
- void addPage( const mof::PageRequest& page );\r
- void draw( ) const;\r
- void update( );\r
- bool hasNextPage( ) const;\r
- bool hasPreviousPage( ) const;\r
- void setPosition( const mof::Animation<mof::Vector2D>::Handler& handler ); \r
- void setSize( const mof::Animation<mof::Vector2D>::Handler& handler ); \r
- mof::Rectangle<int> getBounds( ); \r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include "mof/tstring.hpp"
+#include "mof/Font.hpp"
+#include "mof/Rectangle.hpp"
+#include "mof/stream/Manipulator.hpp"
+#include "mof/Vector2D.hpp"
+
+
+namespace mof
+{
+ struct PageRequest;
+ class LayoutManager;
+
+ /** \83y\81[\83W\82©\82ç
+ */
+ class Pager
+ {
+ public:
+ Pager
+ (
+ const mof::Rectangle<int>& bounds ,
+ mof::LayoutManager* pLayout
+ );
+
+ ~Pager( );
+
+ void show( );
+ void close( );
+ void nextPage( );
+ void addPage( const mof::PageRequest& page );
+ void draw( ) const;
+ void update( );
+ bool hasNextPage( ) const;
+ bool hasPreviousPage( ) const;
+ void setPosition( const mof::Animation<mof::Vector2D>::Handler& handler );
+ void setSize( const mof::Animation<mof::Vector2D>::Handler& handler );
+ mof::Rectangle<int> getBounds( );
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
-#pragma once\r
-#include <boost/scoped_ptr.hpp>\r
-#include "mof/tstring.hpp"\r
-#include "mof/Font.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include "mof/Animation.hpp"\r
-#include "mof/Vector2D.hpp"\r
-\r
-\r
-namespace mof\r
-{\r
- struct PageRequest; \r
- class LayoutManager;\r
-\r
- /** \83y\81[\83W\82©\82ç\r
- */\r
- class Pager\r
- {\r
- public:\r
- Pager\r
- ( \r
- const mof::Rectangle<int>& bounds ,\r
- mof::LayoutManager* pLayout\r
- );\r
-\r
- ~Pager( );\r
-\r
- void show( );\r
- void close( );\r
- void nextPage( );\r
- void addPage( const mof::PageRequest& page );\r
- void draw( ) const;\r
- void update( );\r
- bool hasNextPage( ) const;\r
- bool hasPreviousPage( ) const;\r
- void setPosition( const mof::Animation<mof::Vector2D>::Handler& handler ); \r
- void setSize( const mof::Animation<mof::Vector2D>::Handler& handler ); \r
- mof::Rectangle<int> getBounds( ); \r
- private:\r
- struct Impl;\r
- boost::scoped_ptr<Impl> m_pImpl;\r
- };\r
-\r
-}\r
+#pragma once
+#include <boost/scoped_ptr.hpp>
+#include "mof/tstring.hpp"
+#include "mof/Font.hpp"
+#include "mof/Rectangle.hpp"
+#include "mof/Animation.hpp"
+#include "mof/Vector2D.hpp"
+
+
+namespace mof
+{
+ struct PageRequest;
+ class LayoutManager;
+
+ /** \83y\81[\83W\82©\82ç
+ */
+ class Pager
+ {
+ public:
+ Pager
+ (
+ const mof::Rectangle<int>& bounds ,
+ mof::LayoutManager* pLayout
+ );
+
+ ~Pager( );
+
+ void show( );
+ void close( );
+ void nextPage( );
+ void addPage( const mof::PageRequest& page );
+ void draw( ) const;
+ void update( );
+ bool hasNextPage( ) const;
+ bool hasPreviousPage( ) const;
+ void setPosition( const mof::Animation<mof::Vector2D>::Handler& handler );
+ void setSize( const mof::Animation<mof::Vector2D>::Handler& handler );
+ mof::Rectangle<int> getBounds( );
+ private:
+ struct Impl;
+ boost::scoped_ptr<Impl> m_pImpl;
+ };
+
+}
-#pragma once\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/stream/Manipulator.hpp>\r
-#include <boost/utility.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class Widget : public boost::noncopyable \r
- {\r
- public:\r
- virtual ~Widget(){}\r
- virtual FrameNumber show(bool imidiately = false) = 0;\r
- virtual FrameNumber hide(bool imidiately = false) = 0;\r
- virtual const boost::shared_ptr<WidgetView> getView() const = 0;\r
- virtual boost::shared_ptr<WidgetView> getView() = 0;\r
- virtual void update() = 0;\r
- };\r
-\r
-}\r
-}\r
+#pragma once
+#include <mof/widget/WidgetView.hpp>
+#include <mof/stream/Manipulator.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class Widget : public boost::noncopyable
+ {
+ public:
+ virtual ~Widget(){}
+ virtual FrameNumber show(bool imidiately = false) = 0;
+ virtual FrameNumber hide(bool imidiately = false) = 0;
+ virtual const boost::shared_ptr<WidgetView> getView() const = 0;
+ virtual boost::shared_ptr<WidgetView> getView() = 0;
+ virtual void update() = 0;
+ };
+
+}
+}
-#pragma once\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/stream/Manipulator.hpp>\r
-#include <boost/utility.hpp>\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class Widget : public boost::noncopyable \r
- {\r
- public:\r
- virtual ~Widget(){}\r
- virtual FrameNumber show(bool imidiately = false) = 0;\r
- virtual FrameNumber hide(bool imidiately = false) = 0;\r
- virtual const shared_ptr<WidgetView> getView() const = 0;\r
- virtual shared_ptr<WidgetView> getView() = 0;\r
- virtual void update() = 0;\r
- };\r
-\r
-}\r
-}\r
+#pragma once
+#include <mof/widget/WidgetView.hpp>
+#include <mof/stream/Manipulator.hpp>
+#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+
+ class Widget : public boost::noncopyable
+ {
+ public:
+ virtual ~Widget(){}
+ virtual FrameNumber show(bool imidiately = false) = 0;
+ virtual FrameNumber hide(bool imidiately = false) = 0;
+ virtual const shared_ptr<WidgetView> getView() const = 0;
+ virtual shared_ptr<WidgetView> getView() = 0;
+ virtual void update() = 0;
+ };
+
+}
+}
-#pragma once\r
-#include "mof/Component2D.hpp"\r
-#include "mof/ColorComponent.hpp"\r
-#include "mof/Drawable.hpp"\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class WidgetView \r
- :\r
- public Component2D ,\r
- public ColorComponent ,\r
- public Drawable \r
- {\r
- public:\r
-\r
- virtual ~WidgetView(){};\r
-\r
- // TODO \83\8c\83C\83A\83E\83g\82Ì\83A\83j\83\81\82Æ\83C\83x\83\93\83g\8e\9e\82Ì\83A\83j\83\81\81A\82»\82ê\82¼\82ê\82Ç\82±\82Å\82Ç\82Ì\82æ\82¤\82É\90Ý\92è\82·\82é\82©\r
- // TODO \83G\83t\83F\83N\83g\82ð\8aO\82©\82ç\90Ý\92è\82Å\82«\82é\82æ\82¤\82É\82·\82é\r
- // TODO \93Á\8eê\82È\83R\83\93\83|\81[\83l\83\93\83g\82à\8aO\82©\82ç\90Ý\92è\82Å\82«\82é\82æ\82¤\82É\r
- // TODO \83X\83v\83\89\83C\83g\82Í\82Ç\82±\82ª\8e\9d\82Â\82©\r
- virtual FrameNumber show( bool imidiately = false ) = 0; \r
- virtual FrameNumber hide( bool imidiately = false ) = 0;\r
- virtual FrameNumber focus( bool imidiately = false ) = 0; \r
- virtual FrameNumber blur( bool imidiately = false ) = 0;\r
- virtual FrameNumber click( bool imidiately = false ) = 0;\r
-\r
- virtual void update() = 0;\r
- virtual void draw() const = 0;\r
- };\r
-\r
-}\r
-}\r
+#pragma once
+#include "mof/Component2D.hpp"
+#include "mof/ColorComponent.hpp"
+#include "mof/Drawable.hpp"
+
+namespace mof
+{
+namespace widget
+{
+
+ class WidgetView
+ :
+ public Component2D ,
+ public ColorComponent ,
+ public Drawable
+ {
+ public:
+
+ virtual ~WidgetView(){};
+
+ // TODO \83\8c\83C\83A\83E\83g\82Ì\83A\83j\83\81\82Æ\83C\83x\83\93\83g\8e\9e\82Ì\83A\83j\83\81\81A\82»\82ê\82¼\82ê\82Ç\82±\82Å\82Ç\82Ì\82æ\82¤\82É\90Ý\92è\82·\82é\82©
+ // TODO \83G\83t\83F\83N\83g\82ð\8aO\82©\82ç\90Ý\92è\82Å\82«\82é\82æ\82¤\82É\82·\82é
+ // TODO \93Á\8eê\82È\83R\83\93\83|\81[\83l\83\93\83g\82à\8aO\82©\82ç\90Ý\92è\82Å\82«\82é\82æ\82¤\82É
+ // TODO \83X\83v\83\89\83C\83g\82Í\82Ç\82±\82ª\8e\9d\82Â\82©
+ virtual FrameNumber show( bool imidiately = false ) = 0;
+ virtual FrameNumber hide( bool imidiately = false ) = 0;
+ virtual FrameNumber focus( bool imidiately = false ) = 0;
+ virtual FrameNumber blur( bool imidiately = false ) = 0;
+ virtual FrameNumber click( bool imidiately = false ) = 0;
+
+ virtual void update() = 0;
+ virtual void draw() const = 0;
+ };
+
+}
+}
-#pragma once\r
-#include "mof/Component2D.hpp"\r
-#include "mof/ColorComponent.hpp"\r
-#include "mof/Drawable.hpp"\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
-\r
- class WidgetView \r
- :\r
- public Component2D ,\r
- public ColorComponent ,\r
- public Drawable \r
- {\r
- public:\r
-\r
- virtual ~WidgetView() = 0;\r
-\r
- // TODO \83\8c\83C\83A\83E\83g\82Ì\83A\83j\83\81\82Æ\83C\83x\83\93\83g\8e\9e\82Ì\83A\83j\83\81\81A\82»\82ê\82¼\82ê\82Ç\82±\82Å\82Ç\82Ì\82æ\82¤\82É\90Ý\92è\82·\82é\82©\r
- // TODO \83G\83t\83F\83N\83g\82ð\8aO\82©\82ç\90Ý\92è\82Å\82«\82é\82æ\82¤\82É\82·\82é\r
- // TODO \93Á\8eê\82È\83R\83\93\83|\81[\83l\83\93\83g\82à\8aO\82©\82ç\90Ý\92è\82Å\82«\82é\82æ\82¤\82É\r
- // TODO \83X\83v\83\89\83C\83g\82Í\82Ç\82±\82ª\8e\9d\82Â\82©\r
- virtual FrameNumber show( bool imidiately = false ) = 0; \r
- virtual FrameNumber hide( bool imidiately = false ) = 0;\r
- virtual FrameNumber focus( bool imidiately = false ) = 0; \r
- virtual FrameNumber blur( bool imidiately = false ) = 0;\r
- virtual FrameNumber click( bool imidiately = false ) = 0;\r
-\r
- virtual void update() = 0;\r
- virtual void draw() const = 0;\r
- };\r
-\r
-}\r
-}\r
+#pragma once
+#include "mof/Component2D.hpp"
+#include "mof/ColorComponent.hpp"
+#include "mof/Drawable.hpp"
+
+namespace mof
+{
+namespace widget
+{
+
+ class WidgetView
+ :
+ public Component2D ,
+ public ColorComponent ,
+ public Drawable
+ {
+ public:
+
+ virtual ~WidgetView() = 0;
+
+ // TODO \83\8c\83C\83A\83E\83g\82Ì\83A\83j\83\81\82Æ\83C\83x\83\93\83g\8e\9e\82Ì\83A\83j\83\81\81A\82»\82ê\82¼\82ê\82Ç\82±\82Å\82Ç\82Ì\82æ\82¤\82É\90Ý\92è\82·\82é\82©
+ // TODO \83G\83t\83F\83N\83g\82ð\8aO\82©\82ç\90Ý\92è\82Å\82«\82é\82æ\82¤\82É\82·\82é
+ // TODO \93Á\8eê\82È\83R\83\93\83|\81[\83l\83\93\83g\82à\8aO\82©\82ç\90Ý\92è\82Å\82«\82é\82æ\82¤\82É
+ // TODO \83X\83v\83\89\83C\83g\82Í\82Ç\82±\82ª\8e\9d\82Â\82©
+ virtual FrameNumber show( bool imidiately = false ) = 0;
+ virtual FrameNumber hide( bool imidiately = false ) = 0;
+ virtual FrameNumber focus( bool imidiately = false ) = 0;
+ virtual FrameNumber blur( bool imidiately = false ) = 0;
+ virtual FrameNumber click( bool imidiately = false ) = 0;
+
+ virtual void update() = 0;
+ virtual void draw() const = 0;
+ };
+
+}
+}
-#pragma once\r
-\r
-#include "mof/Vector2D.hpp"\r
-#include "mof/Rectangle.hpp"\r
-#include <boost/shared_ptr.hpp>\r
-\r
-namespace mof\r
-{\r
-namespace widget\r
-{\r
- class WidgetView;\r
-\r
- class Layout\r
- {\r
-\r
- public:\r
- enum DependencyType\r
- {\r
- PARENT_LEADING ,\r
- CHILD_LEADING\r
- };\r
-\r
- virtual ~Layout(){}\r
- //virtual void add(const Vector2D& size) = 0;\r
- //virtual Vector2D getPositionOf(int index) const = 0 ;\r
- //virtual Vector2D getSizeOf(int index) const = 0 ;\r
- //virtual Vector2D getBounds() const = 0;\r
- virtual void add(boost::shared_ptr<WidgetView> pView) = 0;\r
- virtual Vector2D getPreferredSize() = 0;\r
- virtual DependencyType getSizeDependencyType() = 0;\r
- virtual void connect( boost::shared_ptr<WidgetView> pParentView) = 0;\r
- virtual size_t getLength() const = 0;\r
- virtual int getAdjacencyAsUp(int index) const = 0;\r
- virtual int getAdjacencyAsDown(int index) const = 0;\r
- virtual int getAdjacencyAsLeft(int index) const = 0;\r
- virtual int getAdjacencyAsRight(int index) const = 0;\r
- };\r
-}\r
-}\r
+#pragma once
+
+#include "mof/Vector2D.hpp"
+#include "mof/Rectangle.hpp"
+#include <boost/shared_ptr.hpp>
+
+namespace mof
+{
+namespace widget
+{
+ class WidgetView;
+
+ class Layout
+ {
+
+ public:
+ enum DependencyType
+ {
+ PARENT_LEADING ,
+ CHILD_LEADING
+ };
+
+ virtual ~Layout(){}
+ //virtual void add(const Vector2D& size) = 0;
+ //virtual Vector2D getPositionOf(int index) const = 0 ;
+ //virtual Vector2D getSizeOf(int index) const = 0 ;
+ //virtual Vector2D getBounds() const = 0;
+ virtual void add(boost::shared_ptr<WidgetView> pView) = 0;
+ virtual Vector2D getPreferredSize() = 0;
+ virtual DependencyType getSizeDependencyType() = 0;
+ virtual void connect( boost::shared_ptr<WidgetView> pParentView) = 0;
+ virtual size_t getLength() const = 0;
+ virtual int getAdjacencyAsUp(int index) const = 0;
+ virtual int getAdjacencyAsDown(int index) const = 0;
+ virtual int getAdjacencyAsLeft(int index) const = 0;
+ virtual int getAdjacencyAsRight(int index) const = 0;
+ };
+}
+}
-#include "mof/widget/utilities.hpp"\r
-#include "mof/widget/WidgetView.hpp"\r
-#include "mof/Sprite.hpp"\r
-\r
-namespace mof\r
-{\r
-/*\r
- void setStreamAsChild( Sprite* sprite , const WidgetView* view )\r
- {\r
- sprite->getColorStream( ) << view->getColorStream( );\r
- sprite->getPositionStream() << view->getPositionStream( );\r
- }\r
- \r
- void setStreamAsChild( WidgetView* child , const WidgetView* parent )\r
- {\r
- child->getColorStream() << parent->getColorStream( );\r
- child->getPositionStream() << parent->getPositionStream( );\r
- }\r
-*/\r
-}\r
+#include "mof/widget/utilities.hpp"
+#include "mof/widget/WidgetView.hpp"
+#include "mof/Sprite.hpp"
+
+namespace mof
+{
+/*
+ void setStreamAsChild( Sprite* sprite , const WidgetView* view )
+ {
+ sprite->getColorStream( ) << view->getColorStream( );
+ sprite->getPositionStream() << view->getPositionStream( );
+ }
+
+ void setStreamAsChild( WidgetView* child , const WidgetView* parent )
+ {
+ child->getColorStream() << parent->getColorStream( );
+ child->getPositionStream() << parent->getPositionStream( );
+ }
+*/
+}
-#include "mof/widget/utilities.hpp"\r
-#include "mof/widget/WidgetView.hpp"\r
-#include "mof/Sprite.hpp"\r
-\r
-namespace mof\r
-{\r
-\r
- void setStreamAsChild( Sprite* sprite , const WidgetView* view )\r
- {\r
- sprite->getColorStream( ) << view->getColorStream( );\r
- sprite->getPositionStream() << view->getPositionStream( );\r
- }\r
- \r
- void setStreamAsChild( WidgetView* child , const WidgetView* parent )\r
- {\r
- child->getColorStream() << parent->getColorStream( );\r
- child->getPositionStream() << parent->getPositionStream( );\r
- }\r
-\r
-}\r
+#include "mof/widget/utilities.hpp"
+#include "mof/widget/WidgetView.hpp"
+#include "mof/Sprite.hpp"
+
+namespace mof
+{
+
+ void setStreamAsChild( Sprite* sprite , const WidgetView* view )
+ {
+ sprite->getColorStream( ) << view->getColorStream( );
+ sprite->getPositionStream() << view->getPositionStream( );
+ }
+
+ void setStreamAsChild( WidgetView* child , const WidgetView* parent )
+ {
+ child->getColorStream() << parent->getColorStream( );
+ child->getPositionStream() << parent->getPositionStream( );
+ }
+
+}
-#pragma once\r
-#include <boost/function.hpp>\r
-#include <mof/widget/WidgetView.hpp>\r
-\r
-\r
-namespace mof\r
-{\r
- class WidgetView;\r
- class Sprite;\r
-/*\r
- void setStreamAsChild( Sprite* spritem , const WidgetView* view );\r
-\r
- void setStreamAsChild( WidgetView* child , const WidgetView* parent );\r
-*/\r
-}\r
-\r
-\r
-\r
-\r
+#pragma once
+#include <boost/function.hpp>
+#include <mof/widget/WidgetView.hpp>
+
+
+namespace mof
+{
+ class WidgetView;
+ class Sprite;
+/*
+ void setStreamAsChild( Sprite* spritem , const WidgetView* view );
+
+ void setStreamAsChild( WidgetView* child , const WidgetView* parent );
+*/
+}
+
+
+
+
-#pragma once\r
-#include <boost/function.hpp>\r
-#include <mof/widget/WidgetView.hpp>\r
-#include <mof/FactoryMethod.hpp>\r
-\r
-\r
-namespace mof\r
-{\r
- class WidgetView;\r
- class Sprite;\r
- typedef <WidgetView* (void)> WidgetViewFactoryMethod;\r
-/*\r
- void setStreamAsChild( Sprite* spritem , const WidgetView* view );\r
-\r
- void setStreamAsChild( WidgetView* child , const WidgetView* parent );\r
-*/\r
-}\r
-\r
-\r
-\r
-\r
+#pragma once
+#include <boost/function.hpp>
+#include <mof/widget/WidgetView.hpp>
+#include <mof/FactoryMethod.hpp>
+
+
+namespace mof
+{
+ class WidgetView;
+ class Sprite;
+ typedef <WidgetView* (void)> WidgetViewFactoryMethod;
+/*
+ void setStreamAsChild( Sprite* spritem , const WidgetView* view );
+
+ void setStreamAsChild( WidgetView* child , const WidgetView* parent );
+*/
+}
+
+
+
+
-#pragma once\r
-#include "mof/Message.hpp"\r
-//#include "mof/Pager.hpp"\r
-//#include "mof/Page.hpp"\r
-//#include "mof/PlainWidgetView.hpp"\r
-//#include "mof/TextCompiler.hpp"\r
-#include "mof/widget/Widget.hpp"\r
-#include "mof/widget/Menu.hpp"\r
-#include "mof/widget/Frame.hpp"\r
-#include "mof/widget/FrameBuilder.hpp"\r
-#include "mof/widget/WidgetView.hpp"\r
-#include "mof/widget/ImageView.hpp"\r
-#include "mof/widget/Container.hpp"\r
-#include "mof/widget/Layout.hpp"\r
-#include "mof/widget/GridLayout.hpp"\r
-#include "mof/widget/OverlapLayout.hpp"\r
-#include "mof/widget/Widget.hpp"\r
-#include "mof/widget/utilities.hpp"\r
+#pragma once
+#include "mof/Message.hpp"
+//#include "mof/Pager.hpp"
+//#include "mof/Page.hpp"
+//#include "mof/PlainWidgetView.hpp"
+//#include "mof/TextCompiler.hpp"
+#include "mof/widget/Widget.hpp"
+#include "mof/widget/Menu.hpp"
+#include "mof/widget/Frame.hpp"
+#include "mof/widget/FrameBuilder.hpp"
+#include "mof/widget/WidgetView.hpp"
+#include "mof/widget/ImageView.hpp"
+#include "mof/widget/Container.hpp"
+#include "mof/widget/Layout.hpp"
+#include "mof/widget/GridLayout.hpp"
+#include "mof/widget/OverlapLayout.hpp"
+#include "mof/widget/Widget.hpp"
+#include "mof/widget/utilities.hpp"
# set compile flags
if (MSVC)
- set(CMAKE_CXX_FLAGS "/EHsc /nologo /W4 /WX")
+ set(CMAKE_CXX_FLAGS "/EHsc /nologo /W4")
elseif (CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_CXX_FLAGS " -Wall -O3 -DNDEBUG -std=c++0x")
#set(CMAKE_CXX_FLAGS "-Wall -Werror -g -DPSTSDK_VALIDATION_LEVEL_FULL -std=c++0x")
# boost
find_package(Boost)
-include_directories(BOOST_INCLUDE_DIR)
+include_directories(${Boost_INCLUDE_DIR})
subdirs(numeric)
# numeric
#----------------------
add_executable(numeric main.cpp)
-if (CMAKE_COMPILER_IS_GNUCC)
+if (MSVC)
+ target_link_libraries(numeric "winmm")
+elseif (CMAKE_COMPILER_IS_GNUCC)
target_link_libraries(numeric "rt") # TODO delete this line
endif ()
target_link_libraries(numeric "mofutil")
class raw_type
{
float data[Dim];
+ public:
+ // ランタイムチェックに引っかからないように
+ raw_type()
+ {
+ }
};
//}}}
mof::math::vector2 unused1;// block compile optimation
# set compile flags
if (MSVC)
- set(CMAKE_CXX_FLAGS "/EHsc /nologo /W4 /WX")
+ set(CMAKE_CXX_FLAGS "/EHsc /nologo /W4")
+ set(TEST_BIN_POSTFIX ".exe")
elseif (CMAKE_COMPILER_IS_GNUCC)
- set(CMAKE_CXX_FLAGS "-Wall -Werror -g -DPSTSDK_VALIDATION_LEVEL_FULL -std=c++0x")
+ set(CMAKE_CXX_FLAGS "-Wall -g -DPSTSDK_VALIDATION_LEVEL_FULL -std=c++0x")
+ set(TEST_BIN_POSTFIX "")
endif()
# include (FindBoost)
# find_package(Boost 1.42.0 REQUIRED)
# boost
find_package(Boost)
-include_directories(BOOST_INCLUDE_DIR)
+include_directories(${Boost_INCLUDE_DIR})
# test
set(tests vector2_test vector3_test matrix2_test matrix3_test make_matrix_test)
# run test
foreach(test ${tests})
- add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test})
+ add_test(${test} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${test}${TEST_BIN_POSTFIX})
endforeach(test)
# header install
{
Derived retval;
const int SIZE = Dim + 1;
-
+
// calculate the last element previously
int b = last_index() - Dim;
int c = Dim;
}
return Coordinate(arr);
}
-
-
- friend Derived operator*(float rhs1, Derived& rhs2)
- {
- Derived retval;
- const size_t END = rhs2.last_index() - 1;// 最後の要素は1で保存
- for (size_t i = 0; i <= END; ++i) {
- retval.elements_[i] = rhs1 * rhs2.elements_[i];
- }
- return retval;
- }
//}}}
//{{{ operator /=
Derived& operator/=(float rhs)
for (size_t i = 0; i < Dim; ++i) components_[i] *= rhs;
return *reinterpret_cast<Derived*>(this);//thisがDerived型であることは保証されている.
}
-
- friend Derived operator*(float rhs1, Derived& rhs2)
- {
- Derived retval;
- for (size_t i = 0; i < Dim; ++i) retval.components_[i] = rhs1 * rhs2.components_[i];
- return retval;
- }
//}}}
//{{{ operator /=
Derived& operator/=(float rhs)
//{{{ operator =
matrix2& operator = (const matrix2& rhs)
{
- for (size_t i = 0; i <= last_index(); ++i) {
+ for (size_t i = 0; i <= last_index() - 1; ++i) {
elements_[i] = rhs.elements_[i];
}
return *this;
//{{{ copy constructor
matrix3(const matrix3& rhs)
{
- for (size_t i = 0; i < last_index(); ++i) {
+ for (size_t i = 0; i <= last_index(); ++i) {
elements_[i] = rhs.elements_[i];
}
}
*/
matrix3& operator = (const matrix3& rhs)
{
- for (size_t i = 0; i < last_index(); ++i) {
+ for (size_t i = 0; i <= last_index() -1; ++i) {
elements_[i] = rhs.elements_[i];
}
return *this;
matrix3 N2(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 0, 0, 0);
matrix3 N = N1 * N2;
matrix3 A(44, 50, 56, 66, 116, 134, 152, 178, 188, 218, 248, 290, 0, 0, 0);
+ cout << N << endl;
if (N != A) {
cerr << "Failed:" << "Affine matrix N1 * N2 test" << endl;
failed_count++;
matrix3 N = N1 * N2;
matrix3 A
(
- 0.25840f, 0.28424f, 0.31008, 0.17054f,
+ 0.25840f, 0.28424f, 0.31008f, 0.17054f,
0.58915f, 0.65633f, 0.72351f, 0.45995f,
0.91990f, 1.02842f, 1.13695f, 0.74935f,
0.70801f, 0.81912f, 0.93023f
project(mofutil)
# build util
-if (CMAKE_COMPILER_IS_GNUCC)
+if (MSVC)
+ file(GLOB src FILES windows/*.cpp)
+elseif (CMAKE_COMPILER_IS_GNUCC)
file(GLOB src FILES linux/*.cpp)
endif()
add_library(mofutil STATIC ${src})
# boost
find_package(Boost)
-include_directories(BOOST_INCLUDE_DIR)
+include_directories(${Boost_INCLUDE_DIR})
# build test
#set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/test/testbin/)
--- /dev/null
+#include <mof/util/multimedia_timer.hpp>
+#include <windows.h>
+#include <iostream>
+
+
+namespace mof
+{
+namespace util
+{
+//{{{ impl
+ struct multimedia_timer::impl
+ {
+ LARGE_INTEGER start_time_;
+ double frequency_;
+ };
+//}}}
+//{{{ constructor
+ multimedia_timer::multimedia_timer()
+ : pimpl_(new impl)
+ {
+ LARGE_INTEGER frequency;// count per sec
+ QueryPerformanceFrequency(&frequency);
+ pimpl_->frequency_ = static_cast<double>(frequency.QuadPart) / 1000000;// count per micro sec
+ reset();
+ }
+//}}}
+//{{{ destructor
+ multimedia_timer::~multimedia_timer(){}
+//}}}
+//{{{ reset
+ void multimedia_timer::reset()
+ {
+ QueryPerformanceCounter(&pimpl_->start_time_);
+ }
+//}}}
+//{{{ get_time_in_micro_sec
+ int multimedia_timer::get_time_in_micro_sec() const
+ {
+ LARGE_INTEGER current_time;
+ QueryPerformanceCounter(¤t_time);
+ double span = static_cast<double>(current_time.QuadPart - pimpl_->start_time_.QuadPart) / pimpl_->frequency_;
+ return static_cast<int>(span);
+ }
+//}}}
+
+}// namespace util
+}// namespace mof
+