2 UV maps on mesh - 1 with alpha? (warning! contains images)

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
nixnerd
Posts: 14
Joined: Mon Jan 31, 2005 2:00 am
Location: United Kingdom

2 UV maps on mesh - 1 with alpha? (warning! contains images)

Post by nixnerd »

Hello,

I'd like to use multiple UV maps on a mesh, one of which will be using alpha. Do any of the native mesh file formats that Irrlicht uses support this?

I'd also want to animate the mesh and have the texture maps animate accordingly. The pictures below can explain what I'm trying to do, better than I can.

ImageImage
Here's a test UV mapped .x mesh in the viewer, with the .jpeg UV bitmap thats applied to it.

ImageImage
ImageImage
Here's a test UV mapped .x mesh in the viewer, with a .tga UV map with an alpha channel. Also is the view of the same tga file in the Gimp, showing the alpha. I've also included images of the 'channels' and 'layers' tool for the same image.

Image
Here's what I want to achieve, using multiple image maps, one of which has an alpha channel. I want to use the two separate UV maps on the same mesh and combine them using the Irrlich engine and code, rather than combining them into one texture using a paint program.

I'm not sure what I'm doing so far is correct, as I'm a complete newbie when it comes to Irrlicht. If someone can post some code as an example, or explain what I need to do next to achieve the effect I'm looking for, I would be very appreciative.
Last edited by nixnerd on Mon Sep 19, 2005 6:44 pm, edited 2 times in total.
Guest

Post by Guest »

http://irrlicht.sourceforge.net/docu/st ... erial.html

thats the way to load 2 textures and you can click the "ITexture" and it will show how to load one or 2 as an alpha

and when you animate you wesh "deforms" accordingly and the texture does to automaticly. so you dont have to worry about that and by the way my name on the forums is xtheagonyscenex private message if you need help.
nixnerd
Posts: 14
Joined: Mon Jan 31, 2005 2:00 am
Location: United Kingdom

Thnks xtheagonyscenex, I'll look at that :)

Post by nixnerd »

Thnks xtheagonyscenex, I'll look at that :)
nixnerd
Posts: 14
Joined: Mon Jan 31, 2005 2:00 am
Location: United Kingdom

Still needing some guidance...

Post by nixnerd »

I've updated my original question to now include some pictures.

As everyone may have guessed I'm still needing some guidance on how I can do multitexture uv maps one of which includes alpha.

:?
Guest

Post by Guest »

you need to seperate the 2 and load one at a time in the api you can load a texture and an aplha_texture so look at it
Guest

Post by Guest »

this is from the link a gave ealier



Code: Select all

SMaterial()
00237                 : AmbientColor(255,255,255,255), DiffuseColor(255,255,255,255),
00238                 EmissiveColor(0,0,0,0), SpecularColor(255,255,255,255), Texture1(0), Texture2(0),
00239                         MaterialType(EMT_SOLID), Wireframe(false), Lighting(true),
00240                         ZBuffer(true), ZWriteEnable(true), BackfaceCulling(true),
00241                         GouraudShading(true), Shininess(0.0f), MaterialTypeParam(0.0f),
00242                         BilinearFilter(true), TrilinearFilter(false), FogEnable(false),
00243                         NormalizeNormals(false)
xtheagonyscenex
Posts: 131
Joined: Fri Jun 03, 2005 7:26 pm

Post by xtheagonyscenex »

what do you want to do only show the smileys or what?
"Held in Your arms but too far from my heart." "These thoughts will carry me through the darkest nights...while your eyes rest in mine."
"How quickly I forget that this is meaningless."
nixnerd
Posts: 14
Joined: Mon Jan 31, 2005 2:00 am
Location: United Kingdom

Post by nixnerd »

xtheagonyscenex wrote:what do you want to do only show the smileys or what?
Im trying to load an X file that conatins a UV mapped image (the red, green and blue box mesh), then I want to also load another UV mapped image with an alph channel and attach it to the same mesh.

The effect I'm trying to achieve is to map the 'smiley faces' on top of the red, blue and green texture in a way that overlays the smiley faces on top of the existing texture, as in the last image in my first post
nixnerd
Posts: 14
Joined: Mon Jan 31, 2005 2:00 am
Location: United Kingdom

Slight progress made...

Post by nixnerd »

Well, i've made some slight progress.

Image

I've managed to piece together the following code, which loads an .x uv textured mesh. Now I've just got to try and figure out how to apply the 2nd texture with the alpha on top of the existing texture :)

Code: Select all

/*
This is a test compile to:
     1) Set up GL Redering
     2) Load a UV mapped .X file
     3) Map and additional texture onto the mesh 
*/

#include <irrlicht.h>

using namespace irr;

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

#pragma comment(lib, "Irrlicht.lib"

int main()
{
  // Set up video driver
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(320, 240), 16, false, false, false, 0);

  if (device == 0)
    return 1;

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
 
device->setWindowCaption(L"Texture Test");

IAnimatedMesh* mesh = smgr->getMesh("mesh/cube_uv_map.x");
IAnimatedMeshSceneNode* node = smgr->addAnimatedMeshSceneNode( mesh );

if (node)
{
	node->setMaterialFlag(EMF_LIGHTING, false);
	node->setMaterialTexture( 0, driver->getTexture("mesh/cube_colours.jpg") );
}
 
 // add a camera scene node 
	smgr->addCameraSceneNodeMaya();
	
 while(device->run())
{
   	driver->beginScene(true, true, SColor(0,128,128,128));

	smgr->drawAll();
	guienv->drawAll();

	driver->endScene();
}
	device->drop();
 return 0;
}
            
nixnerd
Posts: 14
Joined: Mon Jan 31, 2005 2:00 am
Location: United Kingdom

Drat! - What am I doing wrong here?...

Post by nixnerd »

Drat, tried to add in the alphamap stuff and can see no difference at all. Is it because I'm using GL?, What am I doing wrong here?

Code: Select all

/*
This is a test compile to:
     1) Set up GL Redering
     2) Load a UV mapped .X file
     3) Map and additional texture onto the mesh 
*/

#include <irrlicht.h>

using namespace irr;

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

#pragma comment(lib, "Irrlicht.lib"

int main()
{
  // Set up video driver
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(320, 240), 16, false, false, false, 0);

  if (device == 0)
    return 1;

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
 
device->setWindowCaption(L"Texture Test");

device->getVideoDriver()->setTextureCreationFlag(irr::video::ETCF_ALWAYS_32_BIT,true);
device->getVideoDriver()->setTextureCreationFlag(irr::video::ETCF_ALWAYS_16_BIT,false);
device->getVideoDriver()->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS,false);

   IAnimatedMesh* boxMesh = smgr->getMesh("mesh/cube_uv_map.x");
   IAnimatedMeshSceneNode* box = smgr->addAnimatedMeshSceneNode(boxMesh);
   box->setMaterialFlag(EMF_LIGHTING, false);

   ITexture* box_alpha = driver->getTexture("mesh/cube_alpha.tga");
   driver->makeColorKeyTexture(box_alpha, position2d<s32>(0,0));

   box->getMaterial(0).Texture1 = box_alpha;
   box->getMaterial(0).BackfaceCulling = false;

   box->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
  
// add a camera scene node 
	smgr->addCameraSceneNodeMaya();
	
 while(device->run())
{
   	driver->beginScene(true, true, SColor(0,128,128,128));

	smgr->drawAll();
	guienv->drawAll();

	driver->endScene();
}
	device->drop();
 return 0;
}
                  

Bluelight
Posts: 31
Joined: Mon Sep 19, 2005 10:25 pm
Location: Norway
Contact:

UV map..

Post by Bluelight »

How do I make a picture file of the mesh from every angle to create a texture containing all the grafics needed on lets say, a human?

Face, fron, back in same picture/image..
Unwraping and so on..
I'm using 3dsmax7
BlueLight
Guest

Re: UV map..

Post by Guest »

Try finding a 3dmax forum and ask there.
infernus wrote:How do I make a picture file of the mesh from every angle to create a texture containing all the grafics needed on lets say, a human?

Face, fron, back in same picture/image..
Unwraping and so on..
I'm using 3dsmax7
luckymutt
Posts: 453
Joined: Sun Mar 06, 2005 11:56 pm
Location: C-Ville

Post by luckymutt »

@infernus - Don't hijack the man's thread. Start your own, preferrably with a question about Irrlicht.

@nixnerd - i am not so sure this can be done, the more I think about it. Even if you can get them to both display, they are located in the same position in space and will be "competing" for which gets shown, regardless of the order that they are loaded.
In fact, with what you have now, it may very well be that both are shown, but the one is drowning out the other.

Try this:
on your solid color image, cut out circles that correspond to your smilies which become alpha, keeping your code as it is.
This will tell you whether or not they are both showing up at least, and if indeed they are competing for display is washing out the smilies.
Make sense?
nixnerd
Posts: 14
Joined: Mon Jan 31, 2005 2:00 am
Location: United Kingdom

Thanks for the tip luckymutt...

Post by nixnerd »

Thanks for the tip luckymutt, I'll have a play around and see what I can deduce :)
luckymutt wrote:@infernus - Don't hijack the man's thread. Start your own, preferrably with a question about Irrlicht.

@nixnerd - i am not so sure this can be done, the more I think about it. Even if you can get them to both display, they are located in the same position in space and will be "competing" for which gets shown, regardless of the order that they are loaded.
In fact, with what you have now, it may very well be that both are shown, but the one is drowning out the other.

Try this:
on your solid color image, cut out circles that correspond to your smilies which become alpha, keeping your code as it is.
This will tell you whether or not they are both showing up at least, and if indeed they are competing for display is washing out the smilies.
Make sense?
nixnerd
Posts: 14
Joined: Mon Jan 31, 2005 2:00 am
Location: United Kingdom

A challenge - can *Anyone* get this to work?...

Post by nixnerd »

OK, here's a challenge, can *Anyone* get this to work?

Here's the code I'm using:

Code: Select all

/*
This is a test compile to:
     1) Set up GL Redering
     2) Load a UV mapped .X file
     3) Map and additional texture onto the mesh 
*/

#include <irrlicht.h>

using namespace irr;

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


#pragma comment(lib, "Irrlicht.lib"

scene::ISceneNode* SkyBox = 0;

int main()
{
  // Set up video driver
IrrlichtDevice *device = createDevice(EDT_OPENGL, dimension2d<s32>(320, 240), 16, false, false, false, 0);

  if (device == 0)
    return 1;

IVideoDriver* driver = device->getVideoDriver();
ISceneManager* smgr = device->getSceneManager();
IGUIEnvironment* guienv = device->getGUIEnvironment();
 
device->setWindowCaption(L"Texture Test");

device->getVideoDriver()->setTextureCreationFlag(irr::video::ETCF_ALWAYS_32_BIT,true);
device->getVideoDriver()->setTextureCreationFlag(irr::video::ETCF_ALWAYS_16_BIT,false);
device->getVideoDriver()->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS,false);

   IAnimatedMesh* boxMesh = smgr->getMesh("mesh/cube_uv_alpha_map.x");
   IAnimatedMeshSceneNode* box = smgr->addAnimatedMeshSceneNode(boxMesh);
   box->setMaterialFlag(EMF_LIGHTING, false);

   ITexture* box_alpha = driver->getTexture("mesh/cube_alpha.tga");
   driver->makeColorKeyTexture(box_alpha, position2d<s32>(0,0));

   box->getMaterial(0).Texture1 = box_alpha;
   box->getMaterial(0).BackfaceCulling = false;

   box->setMaterialType(EMT_TRANSPARENT_ALPHA_CHANNEL);
   
   	SkyBox = smgr->addSkyBoxSceneNode(
		driver->getTexture("mesh/media/irrlicht2_up.jpg"),
		driver->getTexture("mesh/media/irrlicht2_dn.jpg"),
		driver->getTexture("mesh/media/irrlicht2_lf.jpg"),
		driver->getTexture("mesh/media/irrlicht2_rt.jpg"),
		driver->getTexture("mesh/media/irrlicht2_ft.jpg"),
		driver->getTexture("mesh/media/irrlicht2_bk.jpg"));
  
// add a camera scene node 
	smgr->addCameraSceneNodeMaya();
	
 while(device->run())
{
   	driver->beginScene(true, true, SColor(0,128,128,128));

	smgr->drawAll();
	guienv->drawAll();

	driver->endScene();
}
	device->drop();
 return 0;
}
   
Here's what I'm getting

Image
Image

Here's downloads for the mesh, code and textures

4 meg texture 1 file!
4 meg texture 2 file!
mesh file in .x format
The code - ready to compile

Any help would be appreciated :)
Post Reply