SpriteManager2d in Mogre?

boyamer

05-06-2009 11:35:02

Anyone ported out Ogre3d wiki SpriteManager2d to Mogre?

http://www.ogre3d.org/wiki/index.php/OgreSprites
http://www.ogre3d.org/wiki/index.php/SpriteManager2d

Thanks

smiley80

05-06-2009 12:17:29

Here you go:
MOGRE_SpriteManager2d

It's not a 1:1 port, because I'm planning to use that in Miyagi and have played around with it a bit.

Usage:
Somewhere after you create the SceneManager:
SpriteManager.Initialize(sceneMgr);

in Scene_FrameStarted:
SpriteManager.QueueTexture(textureName, x1, y1, x2, y2, alpha);
x and y range from -1 to 1, so e.g.:
SpriteManager.QueueTexture(textureName, 0, -1, 1, 0, alpha);
would draw the texture from the middle of the screen to the lower-left corner.

and before root.Dispose():
SpriteManager.Shutdown();

Edit: replaced code with link to wiki

boyamer

05-06-2009 13:38:07

And what about usage of X,Y system,for example: draw sprite on x = 320,y = 240; and the texture width?

smiley80

05-06-2009 14:02:12

The formulas are:
((float)x / screen-width) * 2 - 1
and
-(((float)y / screen-height) * 2 - 1)

Let's say the screen res is 1280x960.

x1 = 320, y1 = 240 => x1 = -0.5, y1 = 0.5
and you want the texture to be 640x480.
x2 = 960, y2 = 720 => x1 = 0.5, y2 = -0.5


SpriteManager.QueueTexture(textureName, -0.5f, 0.5f, 0.5f, -0.5f, alpha);


Edit: correction

boyamer

06-06-2009 09:04:22

And could be apply shaders to sprites? Like into XNA? Apply a pixel shader?

And change blend state?

Thank you

smiley80

06-06-2009 11:15:50

Haven't tested shaders yet.
It might be easier if you use Manual Object 2D or Rectangle2D where you can use materials.

Beauty

14-06-2009 04:06:33

Smiley80, it would be nice if you add your source code + usage informations to the wiki.
Also you could add a screenshot.
Maybe create the page title: Mogre_SpriteManager

Do you have a similar code which follows a SceneNode to use as a HUD (head up display)?

AndroidAdam

14-06-2009 06:23:18

you`d probably want to use manual object for a hud, you can do a lot of cool things with materials.

smiley80

14-06-2009 12:37:52

Wikified: http://www.ogre3d.org/wiki/index.php/MO ... eManager2d
Screenshot follows...

There was a bug in the old version (texture filtering didn't work in OpenGL).

And as mentioned in the wiki article, there is a performance issue when enqueuing a lot of textures.


Do you have a similar code which follows a SceneNode to use as a HUD (head up display)?

I'd like to have that in Miyagi.
I tried it with Overlays, and used this for the position and the distance from the camera for the scale. It looked okay, but it screwed up the way how I check if the cursor is over an overlay.

Beauty

14-06-2009 15:40:48

Generally nice is MOGRE_MovableText, but for including this, we have to compile Mogre again.
Maybe there are some solutions how to handle the position/scale problem.

(Alternatively it would be nice to find a way how to include MovableText without recompiling. Maybe without an additionally property of SceneNode, but something similar.)

JoshD522

15-09-2009 22:59:10

Hello,

I am brand new to graphics programming. I am trying to get a quick prototype running that is all 2D right now. I found Mogre and the SpriteManager class. I was happy with how quickly I was able to use it to get images on the screen. For my prototype, I want a simple animation. I am doing it by starting an image off of the screen and slowly moving it down. The engine is crashing randomly with access violation exceptions. Is this because I am drawing off of the screen? If not, any ideas? I am calling EnqueueTexture 17 times per frame. Two frames are full window (1024x768) with some transparency. The other 15 are each 168x168 squares, 5 of which start off of the screen (above the top).

Thanks for any help/advice.

Beauty

17-11-2009 16:59:21

If I understood right, this class only can add textures to a fixed position of the screen.
It seems not to be possible to write text.
Is it right?
I didn't found a description of functionality. What exaclty can it do?

I look for something like MovableText.

Smiley80, your screenshot promise is still missing :wink:
(send one or more examples to me and I will add it to the wiki - beautyod @ gmx .de)

Also this class could be added to the list of Mogre Add-ons in the wiki.

smiley80

17-11-2009 17:46:39

If I understood right, this class only can add textures to a fixed position of the screen.
Since the sprites are deleted after each rendering, you can change their position when you add them back again.


It seems not to be possible to write text.

You can also write text. Use a font textures and set the uv-coordinates appropriately.


I didn't found a description of functionality. What exaclty can it do?

Render two dimensional images.


Smiley80, your screenshot promise is still missing

Oops, forgot about that.