Magic Library - True Type windows font

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

Hi riya

welcome a board.

please not well,there are many versions of Magic2d library,one for OpenGL driver which called "Magic2d",and one for DirectX9 driver which called "DxMagic2d".

some features of OpenGL could not be done with Dx one,so each one has it's own features and has it's own header and Lib files, so do not mix them ,ie do not tring to use DxMagic2d.h with OpenGl one.

also , for the sake of linking without error,i have decided to make a DLL version of OpenGL driver ,it was DLLMagic2d,
again do not mix it with a static OpenGL Lib version because static lib has more advanced features than Dll.

finally , you must decid which one you will work with.

hope that will guide you, Enjoy programing with Irrlicht.
riya
Posts: 5
Joined: Fri Mar 03, 2006 3:45 pm
Location: Taiwan

Post by riya »

Sorry, It my mistake... :oops:
I'm forgot remove the annotation that in code of run device for play movie,
I can use DXMagic2D very well,
And I know you meaning, I'm never mix DXMagic2D and OpenGLMagic2D,
or set wrong include file,thanks your warning:wink:

Finally,Thank you very much for your help :D
Guest

Fade 3D char by Shader

Post by Guest »

Hi everybody

sometimes we need to Fade in/out our 3D character , or blending the 3D char with a specified alpha value.
so that i have decided to make a new Material that allow us control the blending operation and with the fast shader laguage we change the alpha.

the Idea is very simple,the material allows blending operation that rely
on alpha value of each vertex, then we use a small lowlevel Vertex Shader program that changes the alpha value of each vertex in our mesh,(thanks for shder laguage that allows do it very fast).

here is the code , hope it will be useful for someone.

Code: Select all

/************************************
       Magic library

   Fading 3D Char by Shader
       By Emil Halim
*************************************/


#include <irrlicht.h>

#include <Magic2d.hpp>

using namespace irr;


using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;

// global declration of Irrlicht interfaces
IrrlichtDevice* device;
IVideoDriver*   driver;
ISceneManager*  smgr;
IGUIEnvironment* guienv;

TShader* MyShader;

class MagicMaterial : public video::IMaterialRenderer
{
       PFNGLACTIVETEXTUREARBPROC pGlActiveTextureARB;
  public:

	MagicMaterial()
	 {
          pGlActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
	 }

  virtual void OnSetMaterial( video::SMaterial& material, const video::SMaterial& lastMaterial,
                              bool resetAllRenderstates, video::IMaterialRendererServices* services )
    {
        if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
		{

            pGlActiveTextureARB(GL_TEXTURE0_ARB);

			glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);

			glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_ALPHA_EXT, GL_REPLACE);
			glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_EXT, GL_PRIMARY_COLOR_EXT );

			glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
			glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR_EXT );
			glTexEnvf(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);

            glDisable(GL_LIGHTING);

            SetBlend(ALPHABLEND);

            MyShader->Start();
		}

		material.ZWriteEnable =  false;
		services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);

    }

  virtual void OnUnsetMaterial( )
    {
         MyShader->Stop();
         SetBlend(SOLIDBLEND);
    }

   //! Returns if the material is transparent.
	virtual bool isTransparent()
	{
		return true;
	}

};

int main()
{

    device = createDevice(EDT_OPENGL, dimension2d<s32>(640, 480), 32);
    bool rslt = InitMagic(device);
    if(rslt == false)
          printf("Magic Library will only work with OpenGL driver");

	device->setWindowCaption(L"Hello World! - Magic 2d library for Irrlicht");

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

        MyShader = new TShader();
        MyShader->CreatVProg();
        MyShader->AddToVertxProg("!!ARBvp1.0");
        MyShader->AddToVertxProg("ATTRIB InPos    = vertex.position;");
        MyShader->AddToVertxProg("ATTRIB InColor  = vertex.color;");
        MyShader->AddToVertxProg("ATTRIB InTexCoord = vertex.texcoord;");
        MyShader->AddToVertxProg("OUTPUT OutPos   = result.position;");
        MyShader->AddToVertxProg("OUTPUT OutColor = result.color;");
        MyShader->AddToVertxProg("OUTPUT OutTexCoord = result.texcoord;");
        MyShader->AddToVertxProg("PARAM  MVP[4]   = { state.matrix.mvp };");
        MyShader->AddToVertxProg("PARAM  Alpha = program.local[0];");
        MyShader->AddToVertxProg("TEMP   col;");
        MyShader->AddToVertxProg("MOV col, InColor;");
        MyShader->AddToVertxProg("MOV col.w, Alpha.x;");
        MyShader->AddToVertxProg("DP4 OutPos.x, InPos , MVP[0];");
        MyShader->AddToVertxProg("DP4 OutPos.y, InPos , MVP[1];");
        MyShader->AddToVertxProg("DP4 OutPos.z, InPos , MVP[2];");
        MyShader->AddToVertxProg("DP4 OutPos.w, InPos , MVP[3];");
        MyShader->AddToVertxProg("MOV OutColor, col;");
        MyShader->AddToVertxProg("MOV OutTexCoord, InTexCoord;");
        MyShader->AddToVertxProg("END");
        MyShader->FinishVertProg();



    MagicMaterial* myMat = new MagicMaterial();
	s32 myMaterialType = driver->addMaterialRenderer( myMat );
    myMat->drop();


    IAnimatedMesh* mesh = smgr->getMesh("../../media/sydney.md2");
    IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );
    node->setMaterialFlag(EMF_LIGHTING, false);
    node->setFrameLoop(0, 310);
    node->setMaterialTexture( 0, driver->getTexture("../../media/sydney.bmp"));
    node->setMaterialType((video::E_MATERIAL_TYPE)myMaterialType);

   	smgr->addCameraSceneNode(0, vector3df(0,30,-40), vector3df(0,5,0));


    int lastFPS = -1;

	while(device->run())
	{

		driver->beginScene(true, true, SColor(0,200,200,200));

                 static f32 Inc,Sinx;
                 Inc += 0.001;
                 Sinx = abs(sin(Inc));
                 MyShader->SetVLocalParam(&Sinx, 0, 1);

                 smgr->drawAll();

		         guienv->drawAll();

		driver->endScene();
		int fps = driver->getFPS();
         if (lastFPS != fps)
         {
            wchar_t tmp[1024];
            swprintf(tmp, 1024, L"Hello World! - Magic 2d library for Irrlicht (%s)(fps:%d)",driver->getName(), fps);
            device->setWindowCaption(tmp);
            lastFPS = fps;
         }
	}

	device->drop();

	return 0;
}

Enjoy it.
luced

capture

Post by luced »

well, i did eveything right, the capture code was right, but when i do execute the exe and make the capture, i get a error saying that isnt canable to read the memory. i dont know what is wrong.
jrambo
Posts: 1
Joined: Mon Apr 24, 2006 9:48 pm

Problems compiling Magic 2D Examples

Post by jrambo »

Hi you all,

I'm working on an Irrlicht project and I'd like to include Magic 2D. I've been trying to compile the magic2D examples with no success. I'm using visual studio 7.1, and the problem I have is that I don't have the library: avifil32.lib. I've tryied to download the library from the net... no way...

Could any of you help me with this?

Thanks in advance!
bicunisa
Posts: 34
Joined: Thu Apr 27, 2006 10:34 pm
Contact:

Post by bicunisa »

Does Magic 2D Library work with Irrlicht 1.0?

I'm in doubt because in the download section of M2DL it reads:
"Downloading Magic Libaray for Irr0.14.0"

Thanks in advance!
OMG another MMORPG project! AztlanRPG
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

sorry for not answering the posts till now, My Father is in the hospital
,when every thnig will be ok,i will get back to the form.

thanks
bicunisa
Posts: 34
Joined: Thu Apr 27, 2006 10:34 pm
Contact:

Post by bicunisa »

Sorry to hear that man, I hope your father gets ok soon ;)

And glad to see you are still around :D
OMG another MMORPG project! AztlanRPG
Cutler
Posts: 1
Joined: Thu May 04, 2006 4:54 pm
Location: Czech Republic
Contact:

Good Work:-)

Post by Cutler »

I would like to pay a compliment on your great work.You're doing very well. :D
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

Hi everybody

My Dear father passed away on 11 th, it is hard to loss someone you love,but this is the life, heeeeeeeeh, My condolences are that , now he is in paradise with jesus.

any way , every thing is ok now , and here is the new Magic2d version 0.8 for irrlicht1.0 , it has meny new functions such as StartDrawing,StopDrawing,SetDepth,SetXXRotation,.....
that allow you to work in z-z axis,usefule for 3d scroling text {see 3DTextScrol Example}.

also it has a TMagicSceneNode class which has many fetures of blitzbasic and at the same time has the SceneNode fetures so you code load 2D Image and apply 2d effects and at the same apply any 3d animatore and it will draw automatically with smgr->drawAll().

Download it from here
http://bcxdx.spoilerspace.com/BCXGL/Magic2d_08.rar

please if you found any bug in the library feel free to tell me.

Enjoy it.
gfxstyler
Posts: 222
Joined: Tue Apr 18, 2006 11:47 pm

Post by gfxstyler »

man thats bad :( i feel very sorry for you!

how old are you? i imagine loosing his own father is hard, but when you are a little younger (like omaremad or me), its even harder :/

if you want to talk or need support you can visit irc.freenode.net , channel: #irrlicht (actually this sounds stupid of me you sure have real friends which you can talk to :D )

keep it up man :) see you!
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

thanks a lot gfxstyler for your good feeling, your are a good man.

I am 34 years old, so do not worry,i feel ok now.

yours Emil
andrei25ni
Posts: 326
Joined: Wed Dec 14, 2005 10:08 pm

Post by andrei25ni »

:shock: Your work is awsome ! I like it very much. :D Nicely done.
zarstar
Posts: 16
Joined: Mon May 22, 2006 12:12 pm

Post by zarstar »

Hi Emil!
First of all, I'm sorry for your lost ... I hope you will be totally ok soon...
Second: your work is very ver good... personal congratulations by me!

Third, the real question: Have you in program to make a Magic library for Directx for irrlicht 1.0? if yes, when (of course about..)?

Me and my team want to make a MMOG of sport, a real great project, and we want to make it in 2d.

Sincerely I don't know really what can be better, if Directx or OpenGL, but I've seen that DX are more diffused and don't take problems...
For example: I've tried to execute your demo and I see that some images (I think they are gifs: the animation of the mouse!) doesn't appear good: they have a border colored on the left! (a vertical stripe that I think is the left border).

Why I see it?
I've tried also to change my OpenGl config from the Api Center control, but nothing.
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

@andrei25ni: thanks you very Much.

@zarstar: thank you very much for your words,i am ok now.
actually Dx version of Magic for Irrlicht 1.0 is not in my current plan because some features can not be done by Dx,but i am thinking in
making it totally by shader language for Dx.

can not wait to see this real great project,good luck for you and your team.

could you please take a screenshot of that wrong part of Mouse animation and send it to me
to see what is the problem.

here is my Email
emil_halimg@yahoo.com
Post Reply