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!
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 1.00 released]

Post by Emil_halim »

Hi Entropai:

I will test it with Ogre Version 1.6.5. but want to make things more clear.

Here is the searching order when OgreMagic tries to load a Sprite.

1- If the name includes "HTTP:" then OgreMagic loads the Sprite from internet.
2- If the name has a specific Drive Name such as "C://" , "D://" then it load the sprite from that path.
3- Search in attached Zip files One by One if OgreMagic found it then loads it from Zip file.
4- Search in the path that specified by ML_SetMediaDirectory or ML_SetMediaDirectoryFromFile function.
5- Search in current exe file directory that run from.

So try to put the image to fits this system and try again.
Entropai
Kobold
Posts: 30
Joined: Fri Jan 19, 2007 10:42 am

Re: OgreMagic Library[ Ver 1.00 released]

Post by Entropai »

Yes, if i set the path directly it will work just fine.

How should the setMediaDirectoryFromFile work then? Is it similar to Ogres (resources.cfg) or does it have special format cause i couldnt get it working properly, ML_setMediaDirectory seems to work properly. I seem to have some problems with some examples that just crash, i'll debug them when i have more time to see whats causing the problems (its most likely my setup anyways).
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 1.00 released]

Post by Emil_halim »

Yes setMediaDirectoryFromFile works like Ogres (resources.cfg) , so you can change the path of Media Directory with out the needing to recompile your source code again.

MagicMedia.cfg is just a plain text file , and you put the same argument of ML_SetMediaDirectory function. For Example , Here is the path in MagicMedia.cfg file

Code: Select all

../../OgreMagic/MagicMedia/
 
Hope it is clear now , and feel free to ask any question , enjoy coding with OgreMagic.
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 1.00 released]

Post by Emil_halim »

Hi all

Tow weeks ago , I was trying to integrate Irrlicht engine with my OgreMagic library and in the same time it works with Ogre 3D Engine.

Finally I have successfully did it, made some changes in irrlicht version 1.6 and added some new functions.

So if you moved from Irrlich to Ogre and still want to use irrlicht , here is your solution.

Later I will post the changes that made for Irrlicht , and add some examples those showing you how to mix it with Oger.

Here is a screenshot

Image

Here is the code

Code: Select all


class MyRenderQueue:public Ogre::RenderQueueListener
{
   private:
         // Here we declare our variable
         irr::IrrlichtDevice*       device;
         irr::scene::ISceneManager* smgr;
         irr::video::IVideoDriver*  driver;
         irr::gui::IGUIEnvironment* env;
   public:

        MyRenderQueue(RenderWindow*    mWin)
         {
             // Here we initializing our variable

             if(ML_FileExist("MagicMedia.cfg"))
                ML_SetMediaDirectoryFromFile("MagicMedia.cfg");
             else
                ML_SetMediaDirectory("../../OgreMagic/MagicMedia/");

             device = (irr::IrrlichtDevice*) Irr_GetDevice();

             smgr = device->getSceneManager();
	         driver = device->getVideoDriver();
	         env = device->getGUIEnvironment();

	         env->addStaticText(L"Hello World! This is the Irrlicht render with Ogre!",
		           irr::core::rect<int>(10,10,260,22), true);

		     env->addImage(driver->getTexture("irr_media/irrlichtlogo2.png"),
			  irr::core::position2d<int>(10,20));

	         irr::scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
	         cam->setTarget(irr::core::vector3df(0,0,0));

	         irr::scene::ISceneNodeAnimator* anim =
		          smgr->createFlyCircleAnimator(irr::core::vector3df(0,15,0), 30.0f);
	         cam->addAnimator(anim);
	         anim->drop();

	         irr::scene::ISceneNode* cube = smgr->addCubeSceneNode(20);

	         cube->setMaterialTexture(0, driver->getTexture("irr_media/wall.bmp"));
	         cube->setMaterialTexture(1, driver->getTexture("irr_media/water.jpg"));
	         cube->setMaterialFlag( irr::video::EMF_LIGHTING, false );
	         cube->setMaterialType( irr::video::EMT_REFLECTION_2_LAYER );

	         smgr->addSkyBoxSceneNode(
	         driver->getTexture("irr_media/irrlicht2_up.jpg"),
	         driver->getTexture("irr_media/irrlicht2_dn.jpg"),
	         driver->getTexture("irr_media/irrlicht2_lf.jpg"),
	         driver->getTexture("irr_media/irrlicht2_rt.jpg"),
	         driver->getTexture("irr_media/irrlicht2_ft.jpg"),
	         driver->getTexture("irr_media/irrlicht2_bk.jpg"));

         }

        virtual ~MyRenderQueue()
         {

         }

        /// Called by Ogre, for being a render queue listener
        virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
         {
           // very important
           // first check the invocation  and queueGroupId parameters
           if(  queueGroupId == RENDER_QUEUE_BACKGROUND && invocation != "SHADOWS")
            {

                    ML_UpdateTimer();

                    ML_Use3DView();
                    smgr->drawAll();
                    env->drawAll();
                    ML_Stop3DView();

            }
         }


        /// Called by Ogre, for being a render queue listener
        virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
         {
              if(  queueGroupId == RENDER_QUEUE_OVERLAY && invocation != "SHADOWS")
               {

               }
         }
};


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

Re: OgreMagic Library[ Ver 1.00 released]

Post by boyamer »

Would love to see how is possible to merge ogre with irrlicht :)
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 1.00 released]

Post by Emil_halim »

Hi boyamer

In fact , the previous Demo is already an example of mixing Ogre and Irrlicht, any way here is an other one.

The rotating box is created and rendered with Irrlicht , also the Irrlicht logo rendered by Irrlicht, the floor , the mesh, the shadow and light was rendered by Oger , finally the title is rendered by OgreMagic.

In the next screenshots you can note that , Oger Mesh is intersecting with cube Irrlicht mesh , although the tow meshes , Ogre & Irrlicht , was rendered with tow different cameras.

Note well , it is just the beginning , so may be I get some problems , need more tests.

Here are the screenshots.

Image

Image

Image

Here is the full code.

Code: Select all


/*************************************************************
*
*            OgreMagic Library For Ogre
*                 version  1.50
*                 by Emil Halim
*
*        Name    : Irr_test2 Demo
*
*
**************************************************************/


// ----------------------------------------------------------------------------
// Include the main OGRE header files
// Ogre.h just expands to including lots of individual OGRE header files
// ----------------------------------------------------------------------------
#include <Ogre.h>


// here we include the header of Magic Library
#include "OgreMagic.h"


using namespace Ogre;



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

class MyRenderQueue:public Ogre::RenderQueueListener
{
   private:
         // Here we declare our variable
         irr::IrrlichtDevice*       device;
         irr::scene::ISceneManager* smgr;
         irr::video::IVideoDriver*  driver;
         irr::gui::IGUIEnvironment* env;
   public:

        MyRenderQueue(RenderWindow*    mWin)
         {
             // Here we initializing our variable

             if(ML_FileExist("MagicMedia.cfg"))
                ML_SetMediaDirectoryFromFile("MagicMedia.cfg");
             else
                ML_SetMediaDirectory("../../OgreMagic/MagicMedia/");

             device = (irr::IrrlichtDevice*) Irr_GetDevice();

             smgr = device->getSceneManager();
	         driver = device->getVideoDriver();
	         env = device->getGUIEnvironment();

	         env->addStaticText(L"Hello World! This is the Irrlicht render with Ogre!",
		           irr::core::rect<int>(10,10,260,22), true);

		     env->addImage(driver->getTexture("irr_media/irrlichtlogo2.png"),
			  irr::core::position2d<int>(10,20));

	         irr::scene::ICameraSceneNode* cam = smgr->addCameraSceneNode();
	         cam->setTarget(irr::core::vector3df(0,0,0));

	         irr::scene::ISceneNodeAnimator* anim =
		          smgr->createFlyCircleAnimator(irr::core::vector3df(0,15,0), 30.0f);
	         cam->addAnimator(anim);
	         anim->drop();

	         irr::scene::ISceneNode* cube = smgr->addCubeSceneNode(20);

	         cube->setMaterialTexture(0, driver->getTexture("irr_media/wall.bmp"));
	         cube->setMaterialTexture(1, driver->getTexture("irr_media/water.jpg"));
	         cube->setMaterialFlag( irr::video::EMF_LIGHTING, false );
	         cube->setMaterialType( irr::video::EMT_REFLECTION_2_LAYER );

         }

        virtual ~MyRenderQueue()
         {

         }

        /// Called by Ogre, for being a render queue listener
        virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
         {
           // very important
           // first check the invocation  and queueGroupId parameters
           if(  queueGroupId == RENDER_QUEUE_BACKGROUND && invocation != "SHADOWS")
            {

                    ML_UpdateTimer();

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

                    ML_CenterString("Ogre & Irrlicht & OgreMagic Demo",100);

                    ML_Stop2DView();


            }
         }


        /// Called by Ogre, for being a render queue listener
        virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
         {
              if(  queueGroupId == RENDER_QUEUE_OVERLAY && invocation != "SHADOWS")
               {
                    ML_Use3DView();
                    smgr->drawAll();
                    env->drawAll();
                    ML_Stop3DView();
               }
         }
};


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

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



#include "ExampleApplication.h"

#define NUM_JAIQUAS 6
AnimationState* mAnimState[NUM_JAIQUAS];
Real mAnimationSpeed[NUM_JAIQUAS];
Vector3 mSneakStartOffset;
Vector3 mSneakEndOffset;

Quaternion mOrientations[NUM_JAIQUAS];
Vector3 mBasePositions[NUM_JAIQUAS];
SceneNode* mSceneNode[NUM_JAIQUAS];
Degree mAnimationRotation(-60);
Real mAnimChop = 7.96666f;
Real mAnimChopBlend = 0.3f;

// Event handler to animate
class SkeletalAnimationFrameListener : public ExampleFrameListener
{
protected:
public:
	SkeletalAnimationFrameListener(RenderWindow* win, Camera* cam, const std::string &debugText)
        : ExampleFrameListener(win, cam)
    {
		mDebugText = debugText;
    }

    bool frameStarted(const FrameEvent& evt)
    {
	if( ExampleFrameListener::frameStarted(evt) == false )
		return false;

        for (int i = 0; i < NUM_JAIQUAS; ++i)
        {
			Real inc = evt.timeSinceLastFrame * mAnimationSpeed[i];
			if ((mAnimState[i]->getTimePosition() + inc) >= mAnimChop)
			{
				// Loop
				// Need to reposition the scene node origin since animation includes translation
				// Calculate as an offset to the end position, rotated by the
				// amount the animation turns the character
				Quaternion rot(mAnimationRotation, Vector3::UNIT_Y);
				Vector3 startoffset = mSceneNode[i]->getOrientation() * -mSneakStartOffset;
				Vector3 endoffset = mSneakEndOffset;
				Vector3 offset = rot * startoffset;
				Vector3 currEnd = mSceneNode[i]->getOrientation() * endoffset + mSceneNode[i]->getPosition();
				mSceneNode[i]->setPosition(currEnd + offset);
				mSceneNode[i]->rotate(rot);

				mAnimState[i]->setTimePosition((mAnimState[i]->getTimePosition() + inc) - mAnimChop);
			}
			else
			{
				mAnimState[i]->addTime(inc);
			}
        }

        return true;
    }
};



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

protected:
	std::string mDebugText;

    // Just override the mandatory create scene method
    void createScene(void)
    {
		mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE);
		mSceneMgr->setShadowTextureSize(512);
		mSceneMgr->setShadowColour(ColourValue(0.6, 0.6, 0.6));

        // Setup animation default
        Animation::setDefaultInterpolationMode(Animation::IM_LINEAR);
        Animation::setDefaultRotationInterpolationMode(Animation::RIM_LINEAR);

        // Set ambient light
        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5));

		// The jaiqua sneak animation doesn't loop properly, so lets hack it so it does
		// We want to copy the initial keyframes of all bones, but alter the Spineroot
		// to give it an offset of where the animation ends
		SkeletonPtr skel = SkeletonManager::getSingleton().load("jaiqua.skeleton",
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
		Animation* anim = skel->getAnimation("Sneak");
		Animation::NodeTrackIterator trackIter = anim->getNodeTrackIterator();
		while (trackIter.hasMoreElements())
		{
			NodeAnimationTrack* track = trackIter.getNext();

			TransformKeyFrame oldKf(0, 0);
			track->getInterpolatedKeyFrame(mAnimChop, &oldKf);

			// Drop all keyframes after the chop
			while (track->getKeyFrame(track->getNumKeyFrames()-1)->getTime() >= mAnimChop - mAnimChopBlend)
				track->removeKeyFrame(track->getNumKeyFrames()-1);

			TransformKeyFrame* newKf = track->createNodeKeyFrame(mAnimChop);
			TransformKeyFrame* startKf = track->getNodeKeyFrame(0);

			Bone* bone = skel->getBone(track->getHandle());
			if (bone->getName() == "Spineroot")
			{
				mSneakStartOffset = startKf->getTranslate() + bone->getInitialPosition();
				mSneakEndOffset = oldKf.getTranslate() + bone->getInitialPosition();
				mSneakStartOffset.y = mSneakEndOffset.y;
				// Adjust spine root relative to new location
				newKf->setRotation(oldKf.getRotation());
				newKf->setTranslate(oldKf.getTranslate());
				newKf->setScale(oldKf.getScale());


			}
			else
			{
				newKf->setRotation(startKf->getRotation());
				newKf->setTranslate(startKf->getTranslate());
				newKf->setScale(startKf->getScale());
			}
		}




        Entity *ent;
		Real rotInc = Math::TWO_PI / (float)NUM_JAIQUAS;
		Real rot = 0.0f;
        for (int i = 0; i < NUM_JAIQUAS; ++i)
        {
			Quaternion q;
			q.FromAngleAxis(Radian(rot), Vector3::UNIT_Y);

			mOrientations[i] = q;
			mBasePositions[i] = q * Vector3(0,0,-20);

            ent = mSceneMgr->createEntity("jaiqua" + StringConverter::toString(i), "jaiqua.mesh");
            // Add entity to the scene node
			mSceneNode[i] = mSceneMgr->getRootSceneNode()->createChildSceneNode();
			mSceneNode[i]->attachObject(ent);
			mSceneNode[i]->rotate(q);
			mSceneNode[i]->translate(mBasePositions[i]);

            mAnimState[i] = ent->getAnimationState("Sneak");
            mAnimState[i]->setEnabled(true);
			mAnimState[i]->setLoop(false); // manual loop since translation involved
            mAnimationSpeed[i] = Math::RangeRandom(0.5, 1.5);

			rot += rotInc;
        }



        // Give it a little ambience with lights
        Light* l;
        l = mSceneMgr->createLight("BlueLight");
		l->setType(Light::LT_SPOTLIGHT);
        l->setPosition(-200,150,-100);
		Vector3 dir(-l->getPosition());
		dir.normalise();
		l->setDirection(dir);
        l->setDiffuseColour(0.5, 0.5, 1.0);

        l = mSceneMgr->createLight("GreenLight");
		l->setType(Light::LT_SPOTLIGHT);
        l->setPosition(0,150,-100);
		dir = -l->getPosition();
		dir.normalise();
		l->setDirection(dir);
        l->setDiffuseColour(0.5, 1.0, 0.5);

        // Position the camera
        mCamera->setPosition(100,30,-150);
        mCamera->lookAt(0,60,0);

        // Report whether hardware skinning is enabled or not
        Technique* t = ent->getSubEntity(0)->getMaterial()->getBestTechnique();
        Pass* p = t->getPass(0);
        if (p->hasVertexProgram() && p->getVertexProgram()->isSkeletalAnimationIncluded())
            mDebugText = "Hardware skinning is enabled";
        else
            mDebugText = "Software skinning is enabled";

		Plane plane;
		plane.normal = Vector3::UNIT_Y;
		plane.d = 100;
		MeshManager::getSingleton().createPlane("Myplane",
			ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane,
			1500,1500,20,20,true,1,60,60,Vector3::UNIT_Z);
		Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" );
		pPlaneEnt->setMaterialName("Examples/Rockwall");
		pPlaneEnt->setCastShadows(false);
		mSceneMgr->getRootSceneNode()->createChildSceneNode(Vector3(0,99,0))->attachObject(pPlaneEnt);

        ///****************************************
        /// Magic Stuff
        /// and our RenderQueueListener
        ///****************************************
         std::string RenderName;
         RenderName = Ogre::Root::getSingleton().getRenderSystem()->getName();
         if(RenderName == "Direct3D9 Rendering Subsystem")
          {
             void* DX9Device;
             mWindow->getCustomAttribute("D3DDEVICE", &DX9Device);
             if(DX9Device != 0)
              {
                   Ogre::LogManager::getSingleton().logMessage("MagicDXManager: ok , getting D3DDEVICE\n");
              }
             InitialMagicLibrary(DX9Device);
             MyRenderQueue* MyRQueue = new MyRenderQueue(mWindow);
             mSceneMgr->addRenderQueueListener(MyRQueue);
          }


    }

    // Create new frame listener
    void createFrameListener(void)
    {
        mFrameListener= new SkeletalAnimationFrameListener(mWindow, mCamera, mDebugText);
        mRoot->addFrameListener(mFrameListener);
    }


};

/*
-----------------------------------------------------------------------------
          Main function
-----------------------------------------------------------------------------
*/

#ifdef __cplusplus
extern "C" {
#endif

#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
    // Create application object
    SkeletalApplication app;

    try {
        app.go();
    } catch( Exception& e ) {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else
        std::cerr << "An exception has occured: " << e.getFullDescription();
#endif
    }


    return 0;
}

#ifdef __cplusplus
}
#endif


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

Re: OgreMagic Library[ Ver 1.00 released]

Post by boyamer »

I think there is missing the Irr_GetDevice method
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 1.00 released]

Post by Emil_halim »

yes , Irr_GetDevice method was missing here because it is new function that i will include it with next release , also there will be many other method will be in next release of OgerMagic.
cutomayngu
Gnoblar
Posts: 5
Joined: Tue Feb 23, 2010 4:22 pm

Re: OgreMagic Library[ Ver 1.00 released]

Post by cutomayngu »

Hi, Emil_halim
I have MSVC++ 2008 but i don't download full source code OgreMagic Library and precomplied OgreMagic Library. I hope you maybe upload full source code OgreMagic Library for everbody. Thanks
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 1.00 released]

Post by Emil_halim »

Hi All

Here is an example that showing you the capability of loading many different mesh formats those supported by Irrlicht sush as , 3ds - obj - b3d - md2 - md3 - x - lwo , and display them with your original Ogre Scene.

Not well , all meshes was rendering with Ogre camera , so that the demo saves the view & projection matrixes in RENDER_QUEUE_MAIN by using ML_CaptureViewProjection function and later in RENDER_QUEUE_OVERLAY restores them by using ML_Use3DView function.

Although the meshes rendered by irrlicht uses the lights of Ogre engine ,they did not produced any shadows on the floor.

Here is a screenshot of the demo.

Image

Here is the code.

Code: Select all


using namespace Ogre;
using namespace irr;

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

class MyRenderQueue:public Ogre::RenderQueueListener
{
   private:
         // Here we declare our variable
         IrrlichtDevice*       device;
         video::IVideoDriver*  driver;
         scene::ISceneManager* smgr;
         scene::IAnimatedMeshSceneNode* node;
         scene::IMeshSceneNode* node1;

   public:

        MyRenderQueue(RenderWindow*    mWin)
         {
             // Here we initializing our variable

             if(ML_FileExist("MagicMedia.cfg"))
                ML_SetMediaDirectoryFromFile("MagicMedia.cfg");
             else
                ML_SetMediaDirectory("../../OgreMagic/MagicMedia/");

             device = (IrrlichtDevice*) Irr_GetDevice();

             smgr = device->getSceneManager();
             driver = device->getVideoDriver();

             scene::IMesh* mesh1 = smgr->getMesh("3DSmesh/m_chld4.3DS");
             node1 = smgr->addMeshSceneNode( mesh1 );
             node1->setMaterialTexture( 0, driver->getTexture("irr_media/babyhaut.tga"));
             node1->setPosition(core::vector3df(25,10,10));
             node1->setScale(core::vector3df(0.15,0.15,0.15));
             node1->setMaterialFlag(video::EMF_LIGHTING, true);

             smgr->getParameters()->setAttribute(scene::MY3D_TEXTURE_PATH, "../../OgreMagic/MagicMedia/ObjMesh");
             mesh1 = smgr->getMesh("ObjMesh/link.obj");
             node1 = smgr->addMeshSceneNode( mesh1 );
             node1->setMaterialTexture( 0, driver->getTexture("ObjMesh/link2.tga"));
             node1->setPosition(core::vector3df(35,0,-20));
             node1->setRotation(core::vector3df(-90,-110,0));
             node1->setScale(core::vector3df(0.3,0.3,0.3));
             node1->setMaterialFlag(video::EMF_LIGHTING, true);

             scene::IAnimatedMesh* mesh = smgr->getMesh("md3Mesh/ranger_statue.md3");
             node = smgr->addAnimatedMeshSceneNode( mesh );
             node->setMaterialTexture( 0, driver->getTexture("md3Mesh/blue.tga"));
             node->setPosition(core::vector3df(-30,0,30));
             node->setRotation(core::vector3df(0,45,0));
             node->setScale(core::vector3df(0.2,0.2,0.2));
             node->setMaterialFlag(video::EMF_LIGHTING, true);

             mesh = smgr->getMesh("irr_media/dragon.md2");
             node = smgr->addAnimatedMeshSceneNode( mesh );
             node->setPosition(core::vector3df(0,9.5,15));
             node->setScale(core::vector3df(0.4,0.4,0.4));
             node->setMaterialFlag(video::EMF_LIGHTING, true);
             node->setMD2Animation(scene::EMAT_STAND);
             node->setMaterialTexture( 0, driver->getTexture("irr_media/dragon.bmp"));

             mesh = smgr->getMesh("irr_media/ninja.b3d");
             node = smgr->addAnimatedMeshSceneNode( mesh );
             node->setPosition(core::vector3df(-25,0,-10));
             node->setScale(core::vector3df(2,2,2));
             node->setRotation(core::vector3df(0,180,0));
             node->setAnimationSpeed(10);
             node->setFrameLoop(0,13);

             mesh = smgr->getMesh("irr_media/dwarf.x");
             node = smgr->addAnimatedMeshSceneNode(mesh);
             node->setPosition(core::vector3df(0,0,100));
             node->setRotation(core::vector3df(0,360,0));
             node->setScale(core::vector3df(0.8,0.8,0.8));
             node->setAnimationSpeed(20.f);

             mesh1 = smgr->getMesh("LWOmesh/misaki.lwo");
             node1 = smgr->addMeshSceneNode(mesh1);
             node1->setPosition(core::vector3df(50,0,50));
             node1->setRotation(core::vector3df(0,360,0));
             node1->setScale(core::vector3df(20,20,20));

         }

        virtual ~MyRenderQueue()
         {

         }

        /// Called by Ogre, for being a render queue listener
        virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
         {
           // very important
           // first check the invocation  and queueGroupId parameters
           if(  queueGroupId == RENDER_QUEUE_BACKGROUND )
            {
                    ML_UpdateTimer();
                    ML_Use2DView();
                    ML_SetAlpha(1.0);
                    ML_SetColor(255,255,255);
                    ML_SetBlendMode(ALPHABLEND);
                    ML_CenterString("Ogre & Irrlicht & OgreMagic Demo",100);
                    ML_Stop2DView();
            }

         }


        /// Called by Ogre, for being a render queue listener
        virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
         {
           if(  queueGroupId ==  RENDER_QUEUE_MAIN  )
            {
                    ML_CaptureViewProjection();
            }
           if(  queueGroupId == RENDER_QUEUE_OVERLAY  )
            {
                    ML_Use3DView();
                    Irr_DrawSolidNodes();
                    ML_Stop3DView();
            }
         }
};

cutomayngu
Gnoblar
Posts: 5
Joined: Tue Feb 23, 2010 4:22 pm

Re: OgreMagic Library[ Ver 1.00 released]

Post by cutomayngu »

WOW great
Please please please please release upload full source. You can share full source code OgreMagic Library for everybody and me. Thank Emil_halim
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 1.00 released]

Post by Emil_halim »

My Dir cutomayngu.

Thank for you word.

Want to tell you that , OgreMagic library is closed source code , but it has many examples that open source code to let you know , how to use it with your code.

As you know integrating irrlicht with OgreMagic library and Ogre Engine is not easy task , so needs more tests , when it will be solid I will release new version with more new examples.
User avatar
Pokemonster
Gnoblar
Posts: 23
Joined: Tue Jun 30, 2009 2:53 pm
Location: Darmstadt / Germany

Re: OgreMagic Library[ Ver 1.00 released]

Post by Pokemonster »

Hi there,

we need video playback capabilities in our software and I'm currently evaluating the OgreMagic library for doing this. So far it looks great, I just have a problem
detecting the end of a video stream. Is there a way to check for "end of streams", something I'm missing maybe?

At the moment when playing back a video, the function ML_GetNextMovieFrame() doesn't return when the video is finished which is kind of anyoing. I also couldn't
figure out what the returned BOOL does. It always returns false, no matter if the video plays or is done.

As a side note, I don't know how long the videos we are going to play out will be, so "frame counting" is not an option :-)

Any help apreciated!

- ALex
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 1.00 released]

Post by jacmoe »

OgreMagic is a fine piece of software, no doubt about that.
But why choose it for a video library when there's dedicated such libraries available for Ogre?
Like the TheoraVideoPlugin :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Pokemonster
Gnoblar
Posts: 23
Joined: Tue Jun 30, 2009 2:53 pm
Location: Darmstadt / Germany

Re: OgreMagic Library[ Ver 1.00 released]

Post by Pokemonster »

To be honest, theora was my first choice but I couldn't get it to work with Ogre 1.7. In addition, we're using mpeg2 for video playback and are also producing
movies in this format so OgreMagic allows us to avoid the extra conversion step. Also we have the option to use h264 videos in the future if the need arises.

But as soon as the theora plugin is working with 1.7, I might take another look :-) No harm in using both...
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 1.00 released]

Post by Emil_halim »

Hi Pokemonster

As you know , OgreMagic uses FFMPEG library to play the movie. And ML_GetNextMovieFrame function uses av_read_frame of FFMPEG to get the naxt frame.

So av_read_frame tells us if the movie is finished or not , by return true if it is finished or false if it is steel playing.

You can check the return value of ML_GetNextMovieFrame function to know when the movie ended.
User avatar
Pokemonster
Gnoblar
Posts: 23
Joined: Tue Jun 30, 2009 2:53 pm
Location: Darmstadt / Germany

Re: OgreMagic Library[ Ver 1.00 released]

Post by Pokemonster »

Hey,

yes, that was what I was hoping for. But ML_GetNextMovieFrame doesn't return once the movie is done playing and while it is
playing, it always returns false.

I'm using ffmpeg in another project myself and as far as I remeber, you have to keep reading&decoding until the frame is
complete, right ? Maybe this loop doesn't exit for whatever reason ?

I tried my own movies (which work on our player using ffmpeg) as well as your example movies, same problem :(
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 1.00 released]

Post by Emil_halim »

Here is a snippet code that works fine with me.

Code: Select all


class MyRenderQueue:public Ogre::RenderQueueListener
{
   private:
         // Here we declare our variable
         HMOVIE   Movie;
         HSPRITE  MovieSprite;
         HSPRITE  Font;
         const char * buf;


   public:

        MyRenderQueue(RenderWindow*    mWin)
         {
             // Here we initializing our variable

             if(ML_FileExist("MagicMedia.cfg"))
                ML_SetMediaDirectoryFromFile("MagicMedia.cfg");
             else
                ML_SetMediaDirectory("../../OgreMagic/MagicMedia/");

             Font = ML_CreateFont("TTFont/Vera.ttf",18);
             ML_SetActiveFont(Font);

             DWORD size;
             buf = (const char *)ML_LoadResource("D:\\clips\\Don't Cry.flv", &size);
             Movie = ML_LoadMovieFromMemory((void*)buf,size);
             if(Movie==0) ML_EmitToLogFile("Can't load Movie \n");
             ML_SetMovieFPS(Movie,32);
             ML_SetMoviePlayLoop(Movie,false);
             int width = ML_GetMovieWidth(Movie);
             int height= ML_GetMovieHeight(Movie);
             MovieSprite = ML_CreateSprite(width,height);
         }

        virtual ~MyRenderQueue()
         {
             ML_FreeResource((void*)buf);
             ML_DestroyMovie(Movie);
         }

        /// Called by Ogre, for being a render queue listener
        virtual void renderQueueStarted(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &skipThisInvocation)
         {
           // very important
           // first check the invocation  and queueGroupId parameters
           if(  queueGroupId == RENDER_QUEUE_BACKGROUND )
            {
                    ML_UpdateTimer();
                    ML_Use2DView();
                    ML_SetAlpha(1.0);
                    ML_SetColor(255,255,255);
                    ML_SetBlendMode(ALPHABLEND);

                    bool MovieFinished = ML_GetNextMovieFrame(Movie);

                    if( MovieFinished ) ML_CenterString("playing is finished",300);  //here we check the end of movie

                    ML_CopyMovieFrameToSprite(MovieSprite,0,0,Movie);
                    ML_DrawSpriteToFullScreen(MovieSprite);

                    ML_DrawFormatedString(midWidth-200,100,"Frames:  = %d",ML_GetMovieCurrentPos(Movie));

                    ML_Stop2DView();

            }
         }

        /// Called by Ogre, for being a render queue listener
        virtual void renderQueueEnded(Ogre::uint8 queueGroupId, const Ogre::String &invocation, bool &repeatThisInvocation)
         {
              if(  queueGroupId == RENDER_QUEUE_OVERLAY )
               {


               }

         }
};


User avatar
Pokemonster
Gnoblar
Posts: 23
Joined: Tue Jun 30, 2009 2:53 pm
Location: Darmstadt / Germany

Re: OgreMagic Library[ Ver 1.00 released]

Post by Pokemonster »

Hmm, I tried your code and it doesn't work either. I'm using Ogre 1.7 at the moment, but I also tried the latest 1.6 now, same problem. That's really weird.
There's also no indication in any of the log files.

The only thing I can do is try it on a different machine... I'm running Windows 7 64bit, but the code is 32bit.
But I don't see any problem here, as I said, the video plays fine up to the point where it is finished :-)
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 1.00 released]

Post by Emil_halim »

my be it is a bug in ML_GetNextMovieFrame function itself. so i do recommend to wait and test it with the new release of OgreMagic library, if things will be ok , i will post the new version in a few days.
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 1.00 released]

Post by Emil_halim »

Hi all

Here is a new version 1.5 of OgreMagic library , integrated Irrlicht version 1.6 with OgreMagic in one DLL . So Irrlicht will only work Directx9.

Note well , Irrlicht uses Left hand Perspective Matrix and Ogre uses Right hand Perspective Matrix. so if you want to render irrlicht mesh with Ogre camera , you have to flip the indeses by using Mesh Manipulator or use Irr_LoadMesh function.

You can download it from here
http://bcxdx.spoilerspace.com/Ogre/Ogre ... X_1.50.zip

Feel free to report any bug that you can found.

@ Pokemonster:
you can test it with this version, works well with me.

Enjoy coding with OgreMagic.
User avatar
Pokemonster
Gnoblar
Posts: 23
Joined: Tue Jun 30, 2009 2:53 pm
Location: Darmstadt / Germany

Re: OgreMagic Library[ Ver 1.50 released - irrlicht integrat

Post by Pokemonster »

Cool. Will do tomorrow and tell you how it went.
User avatar
Pokemonster
Gnoblar
Posts: 23
Joined: Tue Jun 30, 2009 2:53 pm
Location: Darmstadt / Germany

Re: OgreMagic Library[ Ver 1.50 released - irrlicht integrat

Post by Pokemonster »

Hey,

it works using Ogre 1.6 as well as 1.7 . Thanks alot! :-)

- ALex
cutomayngu
Gnoblar
Posts: 5
Joined: Tue Feb 23, 2010 4:22 pm

Re: OgreMagic Library[ Ver 1.50 released - irrlicht integrat

Post by cutomayngu »

Fun Bad Bye
maygugu
Gnoblar
Posts: 8
Joined: Tue May 04, 2010 1:30 pm

Re: OgreMagic Library[ Ver 1.50 released - irrlicht integrat

Post by maygugu »

When I use OgreMagic, some issues, such as I used SceneManager by setting two camera to watch the 3d objects in the scene, when I use ogremagic drawing on a Camera, the second will also draw on the Camera the same Patterns, how to solve only one specific use OGREMAGIC Camera drawing on it, thank you
Post Reply