Magic Library - True Type windows font

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
zarstar
Posts: 16
Joined: Mon May 22, 2006 12:12 pm

Post by zarstar »

After a day that I've leaved you in peace ( ;) ) :

1 - I've studied how to have a constant fps with Irrlicht, so my question it's not a real problem, but I'm curious to know if in your library it's included a function to do it (have a constant fps)


2 - Have you found anything on the problem of collision?

Like ever, I thank you.
More I work with your library, more I want to thank you! :)
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

zarstar as io said you are welcome any time.

there is a TFPS class that works as you want but for certain task not for all animation.

i found a good solution for collision but not implement it yet,sooner i will.
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

Hi Everybody

here is a small update for Magic2D Library, only it have an include header file and a MSvc lib file.

there are new functions for collision detection.

old CheckCollide function now has a new name 'CheckBoxCollide' that will chech a retio rectangle against retio rectangle.

CheckPointCollide uesful for check a small sprite against big sprite, it is a pixel level collision.

CheckPixelCollide uesful for chech collision between two big sprites,it is a pixel level collision.


CheckBoxCollide is faster than CheckPointCollide , and CheckPointCollide faster than CheckPixelCollide one.

also there are many new classes but thay have some bug still,TMagicTextSceneNode,TMagicCharSceneNode,TAnimImageSceneNode.

the first class allow you to use a Magic2d fonts as a scene node,you can use it to put a text on the top of your 3D character as a relative scenenode.

next release will have some examples that explain how to use them.

here is a link for the updating.
http://bcxdx.spoilerspace.com/BCXGL/Mag ... ate_09.zip

Enjoy it.
zarstar
Posts: 16
Joined: Mon May 22, 2006 12:12 pm

Post by zarstar »

Hi emil!

You're great, man!

I've finished the code to move my soccer player on the screen (with and without the ball! ;) ) but I need to improve the collision code..
So now I run to test your improvement and new functions!!! :D

It all seems to work very good...
Now on the screen there is a player and an interface in which you can change the player name, that is always over the head of the player, and the color of each part of the player (shoes, skin, eyes, ...).
It seems so cool! :) (even if the sprites are only simple stickman 'cause I hadn't the time to create good sprites, I've studied the code and your very good library!)
Of course you can move the player around the screen, take the ball and shoot! (a load bar indicate the power with you shoot the ball - When the ball touch a screen border it turns back).

When I'll finish it I can send it to you to publish it like an example for your library!
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

it will be my pleasure,to include your work with mine. put your name in the title of the game.
zarstar
Posts: 16
Joined: Mon May 22, 2006 12:12 pm

Post by zarstar »

Emil can I know how the new collision functions work?
So I've tested them, but I didn't understand how the new 2 functions (Point and Pixel Collision) work...

I've tried to check collision between two little sprites (one tanim image and one smaterial), but I can't succeed to work with a"two pixels width image" (my stickman have shoes of two pixels of height and two pixels of width). But it works with, for example, the head of the stickman.

So maybe the function don't see little parts of the image? or other?
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

the point function chech the middle point of Image1 ,the first parameter, against the entire image2,the second parameter, and if the piont is inside the image2 it will chech vlaue of of the point in image2 if it is not 0 then the collision will take place, the first parameter must be SMaterial type and the second parameter must be SMaterial or TAnimImage* type.

the Pixel function will chech the overlap rectangle of the first parameter against the overlap rectangle of second parameter we scan the hole overlaped two rectangles untill we found that any pixel in the same coordenat are not 0 then the collision will take place. also the first parameter must be SMaterial and the second parameter must be SMaterial or TAnimImage* type.

use the first function if you chech between one small sprite and the other is big sprite , or the two sprite are small.

use the second function if you have two big sprites.

i think that you better use the first one in your case.

if you still have the same problem, you could post the your sprites to me to see if i can fix any bug in the functions.

good luck
zarstar
Posts: 16
Joined: Mon May 22, 2006 12:12 pm

Post by zarstar »

The functions seems to not work in my program.

I post some screenshots and the code:


SMaterial grp_ball_collision; //Sprite for the collision of the ball (the ball is a Tanim)
grp_ball_collision.Texture1 = driver->getTexture("graphics/ball_collision.bmp");
driver->makeColorKeyTexture(grp_ball_collision.Texture1,position2d<s32>(1,1));

TAnimImage* grp_player_head_stand_n = new TAnimImage(driver);
TAnimImage* grp_player_head_stand_ne = new TAnimImage(driver);
grp_player_head_stand_ne->Load(add_head,PLAYER_W*1,PLAYER_H*0,PLAYER_W*1,PLAYER_H*1,PLAYER_W*1,PLAYER_H*1);
grp_player_head_stand_ne->setSpeed(70);
//This is the code for loading head of the player in Nord-Est direction. Of course in my program there are 8 of them (Nord; Nord-Est; Est; Sud-Est; ....) -> then the right image become the grp_actual_player_head (that is in the collision code)


//....
//....


//Code for the collision
if (CheckPixelCollide (grp_ball_collision , ball.pos_x , ball.pos_y , grp_actual_player_head, My_Player.pos_x , My_Player.pos_y) )
{
My_Player.possess_ball=true;
ball.possessed=true;
ball.shooted=false;
}




Screenshots:
As you can see the collision work in vertical positions:
1: now the player is extremely near the ball, but doesn't touch
Image

2: Now he have touched with only one pixel the ball and he take possess of the ball
Image

But see it:
1: the player is near the ball, but with some distance
Image

2: The player come forward the ball and...He doesn't touch it but it take possess of the ball!!!!
Image




There is also the sprites of the ball_collision and of the player head
Image

Image
juliusctw
Posts: 392
Joined: Fri Apr 21, 2006 6:56 am
Contact:

silly question

Post by juliusctw »

Hello
I just have silly question, i hope you haven't posted before already but the reading was too long to catch to this point

does your library work with linux?
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

@zarstar:

Still, i am working in new collision detection system,so it may take some times to impelement it ,you know real time needs some attentions.

@juliusctw:

i wish i could to make a linux version but i do not have any linux system.
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

hi EveryBody

I have just discovered some bad thing that upset me very much in Irrlicht.

why irrlicht resize the texture when we load it by driver->getTexture() function?

i know that Texture must be power of 2,but i am talking about the actual size of image.

For Example

i have an 160X128 image,when loading it it will be 256X128 and this is not the problem,if you chech the width in the texture you will see that it is bigger than 160 pixel,and this is the problem that make the collesion detection is not good.

so does any one has any idea about that !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!????????

thanks
juliusctw
Posts: 392
Joined: Fri Apr 21, 2006 6:56 am
Contact:

are you sharing your source_

Post by juliusctw »

are you sharing your source? i can write a linux version for you
juliusctw
Posts: 392
Joined: Fri Apr 21, 2006 6:56 am
Contact:

actually

Post by juliusctw »

actually, if you are sharing your source, I can "attempt" to write linux version for you
zarstar
Posts: 16
Joined: Mon May 22, 2006 12:12 pm

Post by zarstar »

Sorry Emil, I have not idea why Irrlicht do it... but I think that if you write a post in the general forums there will be people that can solve the problem!

Tell me if anthing changes!
Emil_halim
Posts: 518
Joined: Tue Mar 29, 2005 9:02 pm
Location: Alex,Egypt
Contact:

Post by Emil_halim »

Hi EvryBody

i have made a new 2D system for collision detection "TMaskCollision" class, it is based on the last one,but because irrlicht resize the texture behind the sence when loading it, i have decided to make a masked collision detection system.

you must create a mask only one time for each object that you want to check for collision,the object could be SMaterial or TAnimImage type,TAnimImage type has new method "GetCurntFrame()" that needed when chack the collision.

it is faster than old one because it check the mask instead of lock the images then scane for check if the collision was took place then unlock the images.



Example

Code: Select all

after you create your sprites as following

    SMaterial  Missle;
    Missle.Texture1 = driver->getTexture("../../media/Missle.Bmp");
    driver->makeColorKeyTexture(Missle.Texture1,position2d<s32>(0,0));
    TAnimImage* Explode = new TAnimImage(driver);
    Explode->Load("../../media/Explode.bmp",0,0,1024,64,64,64);
    Explode->setSpeed(50);
    Explode->setRepeatPlay(2);
    TAnimImage* Sprite = new TAnimImage(driver);
    Sprite->Load("../../media/sonwalk.bmp",0,0,40*8,40,40,40);
    Sprite->setSpeed(100); 

you make the collision mask as following

    // collision stuff
    TMaskCollision* SpriteCollide = new  TMaskCollision;
    SpriteCollide->Create("../../media/sonwalk.bmp",40,40);
    TMaskCollision* MsslCollide = new  TMaskCollision;
    MsslCollide->Create("../../media/Missle.Bmp");

then later you could check for collision as following

    if(SpriteCollide->CheckPixelCollide(MsslCollide,Mx,My,
                            SprtX,100,Sprite->GetCurntFrame()))
      {    

          //do collision stuff here ,draw the explation Image

      }
here are the new header and lib files,download them and replace them in your system.
http://bcxdx.spoilerspace.com/BCXGL/Mag ... te_092.zip

Enjoy it.
Post Reply