2D images.

mharezlak96

08-11-2010 16:45:05

Hi. How I can use 2D images (.jpg) in my game? I'd like make a main manu, I have strings, but I 'd like have background in main menu. How I can use images?

ianhfar

09-11-2010 09:52:07

Have a look at Billboards
Do a search for Billboards

Some code to get you looking in the right direction


BillboardSet mJpgSet = sceneMgr.CreateBillboardSet("JpgsEx");
mJpgSet.SetMaterialName("YOUR MATERIAL HERE");
mJpgSet.CullIndividually = true;
mJpgSet.QueryFlags = 0; // They should not be detected by rays.

mNode.AttachObject(mJpgSet);
// where mNode is your SceneNode you want to attach to, could be your default main node the camera is attached to.

// -------------------------------
// Creation of the billboards
// -------------------------------
Billboard Picture = mJpgSet.CreateBillboard(0, 0, 120);
Picture.SetDimensions(10, 10);

mharezlak96

09-11-2010 16:13:58

It's my code:
BillboardSet mJpgSet = Engine.Singleton.SceneManager.CreateBillboardSet("JpgsEx");
mJpgSet.SetMaterialName("Vase/TEXFACE/vase.jpg");
mJpgSet.CullIndividually = true;
mJpgSet.QueryFlags = 0; // They should not be detected by rays.
SceneNode mNode = new SceneNode(Engine.Singleton.SceneManager);
// where mNode is your SceneNode you want to attach to, could be your default main node the camera is attached to.

// -------------------------------
// Creation of the billboards
// -------------------------------
Billboard Picture = mJpgSet.CreateBillboard(2, 2, 2);
Picture.SetDimensions(10, 10);

But I can't see thia image. What is bad?

issingle

10-11-2010 01:08:56

u need read more about ogre's material.
u can find it in ogre's manual.

mharezlak96

10-11-2010 13:11:48

I read it. Material name is good, i see log and all is ok, but i can't see this image.

ianhfar

10-11-2010 14:47:01

You need to attach it to the node

mJpgSet.SetMaterialName("Vase_Texface"); // Material name NOT jpg file
mNode.AttachObject(mJpgSet); // this line seems to be missing in your code, plus ensure you have a scenemanager and camera set up!


Add your jpgs to the Media\materials\textures folder

Create a material file in
Media\materials\scripts


material Vase_Texface
{
technique
{
pass
{
texture_unit
{
//texture "vase.jpg"
texture "Your Jpg name.jpg"
}
}
}
}

mharezlak96

13-11-2010 12:50:15

Now all is ok. I set bad position, code i s ok.

Thank you.