OgreMagic Library[** MagicPro Ver 0.5 released **]

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
User avatar
Emil_halim
Gnome
Posts: 337
Joined: Fri Oct 27, 2006 8:56 am
Location: Alex, Egypt
x 1
Contact:

Post by Emil_halim »

OgreMagic 0.8 uses FFmpeg for playing movie , so I did not implement sound when playing movie.

You can extract the sound from your movie then use Fmod or Bass library for playing audio.

You can use OgreMagic with your commercial work , it is free library.

If you credit it that will be good idea , and if you wont there is no problem.

Have fun with OgreMagic.

jonnys
Halfling
Posts: 77
Joined: Thu Mar 27, 2008 7:40 pm

Jerky video problem

Post by jonnys »

When I try to play a video that I encoded it plays with jerks and pauses every 3 seconds... but the videos that comes with the examples play perfectly.

1. Are there any limitations to the videos that ogremagic can play?

2. Do you have to encode videos in a special format?

3. What would be the most suitable format to encode video in, to play using ogremagic 0.80? (taking into consideration quality, speed and compatibility)

User avatar
Emil_halim
Gnome
Posts: 337
Joined: Fri Oct 27, 2006 8:56 am
Location: Alex, Egypt
x 1
Contact:

Post by Emil_halim »

The movie formats that OgreMagic can play is the same formats that FFmpeg con do.

Here is a link to Wikipedia of FFmpeg , so can chech it by yourself.
http://en.wikipedia.org/wiki/FFmpeg

The best format that will playing fine depends mainly on the computer system that playing in , I have test AVI-DivX and gave me good results , you know AVI-DivX is near to DVD quality , but remember it will be jerky if the system is slow.

I think you can use WMV format for speed sake but not for quality.

User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: OgreMagic Library[ Ver 0.80 released]

Post by boyamer »

Doesn OgreMagic 0.80 works with Ogre OpenGL RenderSystem?

Thanks

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by jacmoe »

No, it doesn't. It's written in 'pure D3D9'. I don't think much have happened in over a year.
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

Re: OgreMagic Library[ Ver 0.80 released]

Post by compvis »

Hi Emil_halim,

Will you implement a background resources loading with OgreMagic Library ?

Thank you for nice library !!!

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by jacmoe »

compvis wrote:Hi Emil_halim
Emil's last visit to the Ogre forum was Wed Jun 11, 2008 7:39 pm.
He might turn up, but don't expect it. He stopped visiting his own forum at roughly the same time, AFAIK. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

User avatar
Emil_halim
Gnome
Posts: 337
Joined: Fri Oct 27, 2006 8:56 am
Location: Alex, Egypt
x 1
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by Emil_halim »

Hi All

Oh , it was a very long time since I posted here, I was preparing for my wedding.
And expecting a baby now.

At the moment , I am working in OgreMagic Ver 1.0 which is the first stable release.

There well be a new features and deprecated other features.

Hope to uploading it by next week.

@:compvis
What do you mean by background resources loading ?

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by jacmoe »

What an unexpected surprise!
I think you're excused. Congratulations on that! :D

A lot of people want to use pure 2D in Ogre, so your library is wanted. :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

Re: OgreMagic Library[ Ver 0.80 released]

Post by compvis »

@:compvis
What do you mean by background resources loading ?
I want to Display a custom window with progress bar on while system loading resources by use OgreMagic Library !

Emil_halim ! Happy with family !

User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: OgreMagic Library[ Ver 0.80 released]

Post by boyamer »

Congrats man,looking forward on trying your new version :) hope will support Open GL too..
Thanks you Emil

User avatar
Emil_halim
Gnome
Posts: 337
Joined: Fri Oct 27, 2006 8:56 am
Location: Alex, Egypt
x 1
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by Emil_halim »

Hi all

Thanks guys for your good feeling.

@:boyamer

Some day I will try to support OpenGL.

@:compvis

It is so easy to do that, here is the Quake Oger demo that uses a loading bar , I have adapted it to use OgreMagic animatiom instead of the progress bar.

For the sake of simplicity , I draw a simple string instead of progress bar , of course you can apply your own imagination.

The code here is belong to OgreMagic version 1 , so you can see different Function name and different coding style.

Hope it help.

Code: Select all


class LoadingQueue:public Ogre::RenderQueueListener
{
   private:
         // Here we declare our variable


   public:
        LoadingQueue()
         {
             // Here we initializing our variable
             if(ML_FileExist("MagicMedia.cfg"))
                ML_SetMediaDirectoryFromFile("MagicMedia.cfg");
             else
                ML_SetMediaDirectory("../../OgreMagic/MagicMedia/");


         }

        virtual ~LoadingQueue()
         {
         }

        virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
         {
           if(  queueGroupId == RENDER_QUEUE_BACKGROUND && invocation != "SHADOWS")
            {
                    ML_Use2DView();
                    ML_SetAlpha(1.0);
                    ML_SetColor(255,255,255);
                    ML_SetBlendMode(ALPHABLEND);
                    ML_DrawString("OgreMagic Makes your dreams come true",350,400);
                    ML_Stop2DView();
            }
         }

        virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
         {
              if(  queueGroupId == RENDER_QUEUE_OVERLAY && invocation != "SHADOWS")
               {
               }
         }
};

/*
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
*/

#include "ExampleApplication.h"

class ExampleLoadingAnim : public ResourceGroupListener
{
protected:
	RenderWindow* mWindow;
	SceneManager* mSceneMgr;
	LoadingQueue* MyRQueue;

public:
	ExampleLoadingAnim() {}
	virtual ~ExampleLoadingAnim(){}

	virtual void start(RenderWindow* window,SceneManager* SceneMgr)
	{
		mWindow = window;
		mSceneMgr = SceneMgr;
		ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");

		std::string RenderName;
        RenderName = Ogre::Root::getSingleton().getRenderSystem()->getName();
        if(RenderName == "Direct3D9 Rendering Subsystem")
          {
             void* DX9Device;
             int screenwidth  = mWindow->getWidth();
             int screenheight = mWindow->getHeight();
             mWindow->getCustomAttribute("D3DDEVICE", &DX9Device);
             if(DX9Device != 0)
              {
                   Ogre::LogManager::getSingleton().logMessage("MagicDXManager: ok , getting D3DDEVICE\n");
              }
             InitialMagicLibrary(DX9Device,screenwidth,screenheight);
             MyRQueue = new LoadingQueue();
             mSceneMgr->addRenderQueueListener(MyRQueue);
          }

		ResourceGroupManager::getSingleton().addResourceGroupListener(this);
	}

	virtual void finish(void)
	{
        mSceneMgr->removeRenderQueueListener(MyRQueue);
		ResourceGroupManager::getSingleton().removeResourceGroupListener(this);
	}

	void resourceGroupScriptingStarted(const String& groupName, size_t scriptCount)
	{
	    mWindow->update();
	}
	void scriptParseStarted(const String& scriptName)
	{
	    mWindow->update();
	}
	void scriptParseEnded(const String& scriptName)
	{
	    mWindow->update();
	}
	void resourceGroupScriptingEnded(const String& groupName)
	{
	    mWindow->update();
	}
	void resourceGroupLoadStarted(const String& groupName, size_t resourceCount)
	{
	    mWindow->update();
	}
	void resourceLoadStarted(const ResourcePtr& resource)
	{
	    mWindow->update();
	}
	void resourceLoadEnded(void)
	{
	    mWindow->update();
	}
	void worldGeometryStageStarted(const String& description)
	{
	    mWindow->update();
	}
	void worldGeometryStageEnded(void)
	{
	    mWindow->update();
	}
	void resourceGroupLoadEnded(const String& groupName)
	{
	    mWindow->update();
	}

};


class MyExampleApplication : public ExampleApplication
{
public:
    MyExampleApplication() {}

protected:

    String mQuakePk3;
	String mQuakeLevel;
    ExampleLoadingAnim mLoadingAnim;

    void loadResources(void)
	{
        mLoadingAnim.start(mWindow,mSceneMgr);
		// Turn off rendering of everything except overlays
		mSceneMgr->clearSpecialCaseRenderQueues();
		mSceneMgr->addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
		mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
        // Set up the world geometry link
		ResourceGroupManager::getSingleton().linkWorldGeometryToResourceGroup(
			ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
			mQuakeLevel, mSceneMgr);
		// Initialise the rest of the resource groups, parse scripts etc
		ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
		ResourceGroupManager::getSingleton().loadResourceGroup(
			ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
			false, true);
		// Back to full rendering
		mSceneMgr->clearSpecialCaseRenderQueues();
		mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
		mLoadingAnim.finish();
	}

	void setupResources(void)
	{
		ConfigFile cf;
		cf.load("quake3settings.cfg");
		mQuakePk3 = cf.getSetting("Pak0Location");
		mQuakeLevel = cf.getSetting("Map");
		ExampleApplication::setupResources();
		ResourceGroupManager::getSingleton().addResourceLocation(
			mQuakePk3, "Zip", ResourceGroupManager::getSingleton().getWorldResourceGroupName());
	}

	void chooseSceneManager(void)
	{
		mSceneMgr = mRoot->createSceneManager("BspSceneManager");
	}

    void createScene(void)
    {
		mCamera->setNearClipDistance(4);
		mCamera->setFarClipDistance(4000);
		ViewPoint vp = mSceneMgr->getSuggestedViewpoint(true);
		mCamera->setPosition(vp.position);
		mCamera->pitch(Degree(90));
		mCamera->rotate(vp.orientation);
		mCamera->setFixedYawAxis(true, Vector3::UNIT_Z);
    }
};



compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

Re: OgreMagic Library[ Ver 0.80 released]

Post by compvis »

thank you so much ! Emil_halim,

I will try !!!
The code here is belong to OgreMagic version 1 , so you can see different Function name and different coding style.
But where i can get Version 1 ?
Last edited by compvis on Wed Jun 03, 2009 1:22 am, edited 1 time in total.

User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: OgreMagic Library[ Ver 0.80 released]

Post by boyamer »

Thank you for reporting this,can't wait to try this out :)

User avatar
Emil_halim
Gnome
Posts: 337
Joined: Fri Oct 27, 2006 8:56 am
Location: Alex, Egypt
x 1
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by Emil_halim »

Hi all

I am still working in OgreMagic Version 1.0.

Here is an other loading animation demo, it loading an Ogre Logo from Ogre Site , uses cairo to create fantastic loading Resources text, playing music.

It fading in 5 seconds, of course it fade in the sound with the graphics.

Here is the pic of demo

Image

enjoy coding with OgreMagic

Code: Select all


class LoadingQueue:public Ogre::RenderQueueListener
{
   private:
         // Here we declare our variable
         HSPRITE pic;
         HSPRITE txt;
         HMUSIC  Mus;

   public:
        LoadingQueue()
         {
             // Here we initializing our variable
             if(ML_FileExist("MagicMedia.cfg"))
                ML_SetMediaDirectoryFromFile("MagicMedia.cfg");
             else
                ML_SetMediaDirectory("../../OgreMagic/MagicMedia/");

             pic = ML_LoadSprite("http://www.ogre3d.org/forums/styles/proogre/imageset/site_logo.gif");
             if(!pic) ML_EmitToLogFile("can not load from net");

             txt = ML_CreateSprite(575,65);
             ML_StartDrawingToSprite(txt);
             cairo_t *cr = ML_GetCairoCr();
             cairo_select_ft_font(cr,ML_GetWindowsPath("fonts/tahomabd.ttf"));
             cairo_set_font_size(cr, 60);
             cairo_pattern_t* pattern = cairo_pattern_create_linear(0,10,0,50);
             cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT);
             cairo_pattern_add_color_stop_rgba(pattern,0.0, 0.0,0.0,1.0,1);
             cairo_pattern_add_color_stop_rgba(pattern,0.4, 0.6,0.6,1.0,1);
             cairo_pattern_add_color_stop_rgba(pattern,0.5, 0.6,0.6,1.0,1);
             cairo_pattern_add_color_stop_rgba(pattern,0.5, 0.0,0.0,0.2,1);
             cairo_pattern_add_color_stop_rgba(pattern,1.0, 0.0,0.0,1.0,1);
             cairo_move_to(cr,0,50);
             cairo_set_source(cr, pattern);
             cairo_text_path(cr,"Loading Resources");
             cairo_fill_preserve(cr);
             cairo_set_source_rgba(cr,0.0,0.0,0.8,1);
             cairo_set_line_width(cr,3);
             cairo_stroke(cr);
             cairo_pattern_destroy(pattern);
             ML_StopDrawingToSprite(txt);

             Mus  = ML_Music_Load("mod/lotus20.mod");

         }

        virtual ~LoadingQueue()
         {
         }

        virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
         {
           if(  queueGroupId == RENDER_QUEUE_BACKGROUND && invocation != "SHADOWS")
            {
                    ML_UpdateTimer();

                    ML_Use2DView();
                    ML_SetAlpha(1.0);
                    ML_SetColor(255,255,255);
                    ML_SetBlendMode(ALPHABLEND);

                    static float mx = ML_GetScreenWidth()/2.0;
                    static float my = ML_GetScreenHeight()/2.0;

                    ML_FadeIn(5000);               // fading in 5 seconds

                    ML_DrawSprite(pic,mx,my);

                    ML_DrawSprite(txt,mx,my+100);

                    ML_Music_AlphaPlay(Mus);       // also fade the music

                    ML_Stop2DView();
            }
         }

        virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
         {
              if(  queueGroupId == RENDER_QUEUE_OVERLAY && invocation != "SHADOWS")
               {
               }
         }
};

/*
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
*/

#include "ExampleApplication.h"

class ExampleLoadingAnim : public ResourceGroupListener
{
protected:
	RenderWindow* mWindow;
	SceneManager* mSceneMgr;
	LoadingQueue* MyRQueue;

public:
	ExampleLoadingAnim() {}
	virtual ~ExampleLoadingAnim(){}

	virtual void start(RenderWindow* window,SceneManager* SceneMgr)
	{
		mWindow = window;
		mSceneMgr = SceneMgr;
		ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");

		std::string RenderName;
        RenderName = Ogre::Root::getSingleton().getRenderSystem()->getName();
        if(RenderName == "Direct3D9 Rendering Subsystem")
          {
             void* DX9Device;
             int screenwidth  = mWindow->getWidth();
             int screenheight = mWindow->getHeight();
             mWindow->getCustomAttribute("D3DDEVICE", &DX9Device);
             if(DX9Device != 0)
              {
                   Ogre::LogManager::getSingleton().logMessage("MagicDXManager: ok , getting D3DDEVICE\n");
              }
             InitialMagicLibrary(DX9Device,screenwidth,screenheight);
             MyRQueue = new LoadingQueue();
             mSceneMgr->addRenderQueueListener(MyRQueue);
          }

		ResourceGroupManager::getSingleton().addResourceGroupListener(this);
	}

	virtual void finish(void)
	{
        mSceneMgr->removeRenderQueueListener(MyRQueue);
		ResourceGroupManager::getSingleton().removeResourceGroupListener(this);
	}

	void resourceGroupScriptingStarted(const String& groupName, size_t scriptCount)
	{
	    mWindow->update();
	}
	void scriptParseStarted(const String& scriptName)
	{
	    mWindow->update();
	}
	void scriptParseEnded(const String& scriptName)
	{
	    mWindow->update();
	}
	void resourceGroupScriptingEnded(const String& groupName)
	{
	    mWindow->update();
	}
	void resourceGroupLoadStarted(const String& groupName, size_t resourceCount)
	{
	    mWindow->update();
	}
	void resourceLoadStarted(const ResourcePtr& resource)
	{
	    mWindow->update();
	}
	void resourceLoadEnded(void)
	{
	    mWindow->update();
	}
	void worldGeometryStageStarted(const String& description)
	{
	    mWindow->update();
	}
	void worldGeometryStageEnded(void)
	{
	    mWindow->update();
	}
	void resourceGroupLoadEnded(const String& groupName)
	{
	    mWindow->update();
	}

};


class MyExampleApplication : public ExampleApplication
{
public:
    MyExampleApplication() {}

protected:

    String mQuakePk3;
	String mQuakeLevel;
    ExampleLoadingAnim mLoadingAnim;

    void loadResources(void)
	{
        mLoadingAnim.start(mWindow,mSceneMgr);
		// Turn off rendering of everything except overlays
		mSceneMgr->clearSpecialCaseRenderQueues();
		mSceneMgr->addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
		mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
        // Set up the world geometry link
		ResourceGroupManager::getSingleton().linkWorldGeometryToResourceGroup(
			ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
			mQuakeLevel, mSceneMgr);
		// Initialise the rest of the resource groups, parse scripts etc
		ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
		ResourceGroupManager::getSingleton().loadResourceGroup(
			ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
			false, true);
		// Back to full rendering
		mSceneMgr->clearSpecialCaseRenderQueues();
		mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
		mLoadingAnim.finish();
	}

	void setupResources(void)
	{
		ConfigFile cf;
		cf.load("quake3settings.cfg");
		mQuakePk3 = cf.getSetting("Pak0Location");
		mQuakeLevel = cf.getSetting("Map");
		ExampleApplication::setupResources();
		ResourceGroupManager::getSingleton().addResourceLocation(
			mQuakePk3, "Zip", ResourceGroupManager::getSingleton().getWorldResourceGroupName());
	}

	void chooseSceneManager(void)
	{
		mSceneMgr = mRoot->createSceneManager("BspSceneManager");
	}

    void createScene(void)
    {
		mCamera->setNearClipDistance(4);
		mCamera->setFarClipDistance(4000);
		ViewPoint vp = mSceneMgr->getSuggestedViewpoint(true);
		mCamera->setPosition(vp.position);
		mCamera->pitch(Degree(90));
		mCamera->rotate(vp.orientation);
		mCamera->setFixedYawAxis(true, Vector3::UNIT_Z);
    }
};


compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

Re: OgreMagic Library[ Ver 0.80 released]

Post by compvis »

wow, thank for nice library !

but such resource loading screen without progressbar ???

User avatar
Emil_halim
Gnome
Posts: 337
Joined: Fri Oct 27, 2006 8:56 am
Location: Alex, Egypt
x 1
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by Emil_halim »

Here it is with Progress Bar.

Here are the Screenshots

Image

Image

Image

Image

Here is the code.

Code: Select all


//====================================================================================

float  progres;


class LoadingQueue:public Ogre::RenderQueueListener
{
   private:
         // Here we declare our variable
         HSPRITE pic;
         HSPRITE txt;
         HSPRITE bar;
         HMUSIC  Mus;

   public:
        LoadingQueue()
         {
             // Here we initializing our variable
             if(ML_FileExist("MagicMedia.cfg"))
                ML_SetMediaDirectoryFromFile("MagicMedia.cfg");
             else
                ML_SetMediaDirectory("../../OgreMagic/MagicMedia/");

             pic = ML_LoadSprite("http://www.ogre3d.org/forums/styles/proogre/imageset/site_logo.gif");
             if(!pic) ML_EmitToLogFile("can not load from net");

             txt = ML_CreateSprite(575,65);
             ML_StartDrawingToSprite(txt);
             cairo_t *cr = ML_GetCairoCr();
             cairo_select_ft_font(cr,ML_GetWindowsPath("fonts/tahomabd.ttf"));
             cairo_set_font_size(cr, 60);
             cairo_pattern_t* pattern = cairo_pattern_create_linear(0,10,0,50);
             cairo_pattern_set_extend(pattern, CAIRO_EXTEND_REFLECT);
             cairo_pattern_add_color_stop_rgba(pattern,0.0, 0.0,0.0,1.0,1);
             cairo_pattern_add_color_stop_rgba(pattern,0.4, 0.6,0.6,1.0,1);
             cairo_pattern_add_color_stop_rgba(pattern,0.5, 0.6,0.6,1.0,1);
             cairo_pattern_add_color_stop_rgba(pattern,0.5, 0.0,0.0,0.2,1);
             cairo_pattern_add_color_stop_rgba(pattern,1.0, 0.0,0.0,1.0,1);
             cairo_move_to(cr,0,50);
             cairo_set_source(cr, pattern);
             cairo_text_path(cr,"Loading Resources");
             cairo_fill_preserve(cr);
             cairo_set_source_rgba(cr,0.0,0.0,0.8,1);
             cairo_set_line_width(cr,3);
             cairo_stroke(cr);
             cairo_pattern_destroy(pattern);
             ML_StopDrawingToSprite(txt);


             unsigned int buf[256];
             for(int i=0; i<64; i++)
              {
                 buf[i]    = (i*2)<<16 | (i*4) | 0xFF000000;
                 buf[64+i] = (128+i*2)<<16 | (i*4)<<8 | (63-i)*4 | 0xFF000000;
                 buf[128+i]=  255 << 16 | ((63-i)*4) << 8 | 0xFF000000;
                 buf[192+i]= ((63-i)*4) << 16 | 0xFF000000;
              }
             bar = ML_CreateSprite(256,1);
             ML_StartDrawingToSprite(bar);
             ML_WriteRGBAFromBuffer(buf,256*4);
             ML_StopDrawingToSprite(bar);


             Mus  = ML_Music_Load("mod/lotus20.mod");

         }

        virtual ~LoadingQueue()
         {
         }

        virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
         {
           if(  queueGroupId == RENDER_QUEUE_BACKGROUND && invocation != "SHADOWS")
            {
                    ML_UpdateTimer();

                    ML_Use2DView();
                    ML_SetAlpha(1.0);
                    ML_SetColor(255,255,255);
                    ML_SetBlendMode(ALPHABLEND);

                    static float mx = ML_GetScreenWidth()/2.0;
                    static float my = ML_GetScreenHeight()/2.0;



                    ML_FadeIn(5000);               // fading in 5 seconds

                    ML_DrawSprite(pic,mx,my);

                    ML_DrawSprite(txt,mx,my+100);

                    ML_Music_AlphaPlay(Mus);       // also fade the music

                    ML_SetAlpha(1.0);
                    ML_SetScale(1,20);
                    ML_DrawPartOfSprite(bar,mx-128+128*progres,my+200,0,0,255*progres,1);
                    ML_SetScale(1,1);
                    ML_DrawFormatedString(mx,my+200,"%0.2f %%",progres);


                    ML_Stop2DView();
            }
         }

        virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
         {
              if(  queueGroupId == RENDER_QUEUE_OVERLAY && invocation != "SHADOWS")
               {
               }
         }
};

/*
-----------------------------------------------------------------------------

-----------------------------------------------------------------------------
*/

#include "ExampleApplication.h"

class ExampleLoadingAnim : public ResourceGroupListener
{
protected:
	RenderWindow* mWindow;
	SceneManager* mSceneMgr;
	LoadingQueue* MyRQueue;
	float         progInc;

public:
	ExampleLoadingAnim() {}
	virtual ~ExampleLoadingAnim(){}

	virtual void start(RenderWindow* window,SceneManager* SceneMgr)
	{
		mWindow = window;
		mSceneMgr = SceneMgr;
		ResourceGroupManager::getSingleton().initialiseResourceGroup("Bootstrap");

		std::string RenderName;
        RenderName = Ogre::Root::getSingleton().getRenderSystem()->getName();
        if(RenderName == "Direct3D9 Rendering Subsystem")
          {
             void* DX9Device;
             int screenwidth  = mWindow->getWidth();
             int screenheight = mWindow->getHeight();
             mWindow->getCustomAttribute("D3DDEVICE", &DX9Device);
             if(DX9Device != 0)
              {
                   Ogre::LogManager::getSingleton().logMessage("MagicDXManager: ok , getting D3DDEVICE\n");
              }
             InitialMagicLibrary(DX9Device,screenwidth,screenheight);
             MyRQueue = new LoadingQueue();
             mSceneMgr->addRenderQueueListener(MyRQueue);
          }

        progres = 0;

		ResourceGroupManager::getSingleton().addResourceGroupListener(this);
	}

	virtual void finish(void)
	{
        mSceneMgr->removeRenderQueueListener(MyRQueue);
		ResourceGroupManager::getSingleton().removeResourceGroupListener(this);
	}

	void resourceGroupScriptingStarted(const String& groupName, size_t scriptCount)
	{
	    progInc = 1.0 / (float)scriptCount;
	    mWindow->update();
	}
	void scriptParseStarted(const String& scriptName)
	{
	    mWindow->update();
	}
	void scriptParseEnded(const String& scriptName)
	{
	    progres += progInc;
	    if(progres>1.0)progres=1.0;
	    mWindow->update();
	}
	void resourceGroupScriptingEnded(const String& groupName)
	{
	    mWindow->update();
	}
	void resourceGroupLoadStarted(const String& groupName, size_t resourceCount)
	{
	    mWindow->update();
	}
	void resourceLoadStarted(const ResourcePtr& resource)
	{
	    mWindow->update();
	}
	void resourceLoadEnded(void)
	{
	    mWindow->update();
	}
	void worldGeometryStageStarted(const String& description)
	{
	    mWindow->update();
	}
	void worldGeometryStageEnded(void)
	{
	    progres += progInc;
	    if(progres>1.0)progres=1.0;
	    mWindow->update();
	}
	void resourceGroupLoadEnded(const String& groupName)
	{
	    mWindow->update();
	}

};


class MyExampleApplication : public ExampleApplication
{
public:
    MyExampleApplication() {}

protected:

    String mQuakePk3;
	String mQuakeLevel;
    ExampleLoadingAnim mLoadingAnim;

    void loadResources(void)
	{
        mLoadingAnim.start(mWindow,mSceneMgr);
		// Turn off rendering of everything except overlays
		mSceneMgr->clearSpecialCaseRenderQueues();
		mSceneMgr->addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND);
		mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE);
        // Set up the world geometry link
		ResourceGroupManager::getSingleton().linkWorldGeometryToResourceGroup(
			ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
			mQuakeLevel, mSceneMgr);
		// Initialise the rest of the resource groups, parse scripts etc
		ResourceGroupManager::getSingleton().initialiseAllResourceGroups();
		ResourceGroupManager::getSingleton().loadResourceGroup(
			ResourceGroupManager::getSingleton().getWorldResourceGroupName(),
			false, true);
		// Back to full rendering
		mSceneMgr->clearSpecialCaseRenderQueues();
		mSceneMgr->setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE);
		mLoadingAnim.finish();
	}

	void setupResources(void)
	{
		ConfigFile cf;
		cf.load("quake3settings.cfg");
		mQuakePk3 = cf.getSetting("Pak0Location");
		mQuakeLevel = cf.getSetting("Map");
		ExampleApplication::setupResources();
		ResourceGroupManager::getSingleton().addResourceLocation(
			mQuakePk3, "Zip", ResourceGroupManager::getSingleton().getWorldResourceGroupName());
	}

	void chooseSceneManager(void)
	{
		mSceneMgr = mRoot->createSceneManager("BspSceneManager");
	}

    void createScene(void)
    {
		mCamera->setNearClipDistance(4);
		mCamera->setFarClipDistance(4000);
		ViewPoint vp = mSceneMgr->getSuggestedViewpoint(true);
		mCamera->setPosition(vp.position);
		mCamera->pitch(Degree(90));
		mCamera->rotate(vp.orientation);
		mCamera->setFixedYawAxis(true, Vector3::UNIT_Z);
    }
};



compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

Re: OgreMagic Library[ Ver 0.80 released]

Post by compvis »

Wow, very nice !

User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: OgreMagic Library[ Ver 0.80 released]

Post by boyamer »

what about release?

User avatar
Emil_halim
Gnome
Posts: 337
Joined: Fri Oct 27, 2006 8:56 am
Location: Alex, Egypt
x 1
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by Emil_halim »

Sooner surly , but the point is , I want to make all the changes before the releasing , so that you can start using it without warring of coming changes.

An other reason, I have found some bugs , I am working to fix them.

compvis
Gremlin
Posts: 165
Joined: Wed Sep 10, 2008 6:14 am

Re: OgreMagic Library[ Ver 0.80 released]

Post by compvis »

OgreMagic 1.0 just released !!! :D

User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: OgreMagic Library[ Ver 0.80 released]

Post by boyamer »

Where? :)

MagicUser
Gnoblar
Posts: 1
Joined: Fri Jul 10, 2009 12:16 pm

Re: OgreMagic Library[ Ver 0.80 released]

Post by MagicUser »

Hi Emil, many thanks for providing your excellent library and numerous code snippets. I have been on the lookout for sometime for a good 2D library to remake some old classic games. I have already dabbled with the Dark GDK but did not like its inherently procedural approach to everything which perhaps reflects its C heritage. I have two questions for you :)
1. As a newbie, would you advise that I wait for version 1.0 to be released before I start my new projects i.e. will there a lot of significant changes to the API from the current release?
2. Do you plan to release documentation for the new library functions at some future date? I realize this is a big job and you are probably very busy with other things.

Thanks again. :D

User avatar
boyamer
Orc
Posts: 459
Joined: Sat Jan 24, 2009 11:16 am
Location: Italy
x 6

Re: OgreMagic Library[ Ver 0.80 released]

Post by boyamer »

Can't wait to try out version 1.0 :P

User avatar
Emil_halim
Gnome
Posts: 337
Joined: Fri Oct 27, 2006 8:56 am
Location: Alex, Egypt
x 1
Contact:

Re: OgreMagic Library[ Ver 0.80 released]

Post by Emil_halim »

Hi MagicUser

I do recommend that , wait for OgreMagic version 1.0 , it will have a huge difference.

Also , I am working in integrating Box2d physics in simple and easy way to work with OgreMagic library , may be that will help you add 2D physics to your ported games.

Really writing a help file is hard work for me , but I am already start doing it , do not know when it will be finished.

Post Reply