Horde3D
http://horde3d.org/forums/

ResourceType::Material
http://horde3d.org/forums/viewtopic.php?f=2&t=741
Page 1 of 1

Author:  SirLancelot [ 15.05.2009, 14:26 ]
Post subject:  ResourceType::Material

Hi. I'm trying to create gui so i have been playing around with showOverlay(). I ended up to situation where i need to know dimensions of image being drawn. Is there any way get that information?
I tried use getResourceParami() in a few different ways, but i got out only 0.

Author:  Volker [ 15.05.2009, 15:01 ]
Post subject:  Re: ResourceType::Material

Don't know why you have chosen ResourceType::Material as the topic, but to query the texture size you have to use
getResourceParami(TextureResParams::Width) or Height

Author:  SirLancelot [ 15.05.2009, 16:41 ]
Post subject:  Re: ResourceType::Material

I tried that too, but it returned 0.

Author:  Volker [ 15.05.2009, 20:29 ]
Post subject:  Re: ResourceType::Material

Are you sure your texture is loaded? Did you check the log for errors? Did you pass the texture handle to the function(not the material handle)?

Author:  SirLancelot [ 16.05.2009, 12:08 ]
Post subject:  Re: ResourceType::Material

Whole problem here is that showOverlay seems to want handle for Material, not Texture. If i try feed it with Texture it will whine about it not being eglible resource type. So what i want is to get Texture out of Material, which seems to be somewhat impossible.

Author:  Volker [ 16.05.2009, 12:13 ]
Post subject:  Re: ResourceType::Material

What about using Horde3D::findResource ?

Author:  SirLancelot [ 16.05.2009, 12:15 ]
Post subject:  Re: ResourceType::Material

That returns name of xml file for material.

edit:excuse me, i mistake for another function...
edit2: findResource takes filename/path for image, so if i know it, it will work fine. But where from i get that filename then?

Author:  marciano [ 16.05.2009, 12:20 ]
Post subject:  Re: ResourceType::Material

We will very soon have improved resource data handling. This should solve your problem.

Author:  SirLancelot [ 16.05.2009, 12:28 ]
Post subject:  Re: ResourceType::Material

Looks promising. When is very soon? :)

Author:  SirLancelot [ 17.05.2009, 09:26 ]
Post subject:  Re: ResourceType::Material

I found temporary solution for my problem. It's dirty and i have no idea what unwanted side effects it might bring, if any.

So, practically i'm misusing material class like this:
Code:
<Material class = "overlays/logo.tga">
   <Shader source="shaders/overlay.shader"/>
   <Sampler name="albedoMap" map="overlays/logo.tga" />
</Material>

And in code:
Code:
const char* resName = Horde3D::getResourceParamstr(materialRes, MaterialResParams::Class);
ResHandle tempRes = Horde3D::findResource(ResourceTypes::Texture, thing);

int width = Horde3D::getResourceParami(tempnam, TextureResParams::Width);
int height = Horde3D::getResourceParami(tempnam, TextureResParams::Height);


Dirty, but it works. Will there be any side effects/problems if i'll do this?

Author:  Volker [ 17.05.2009, 10:51 ]
Post subject:  Re: ResourceType::Material

I can't imagine that there should be any sideeffects, since it only calls getter functions.

Not sure, what you mean with this:
Quote:
Code:
const char* resName = Horde3D::getResourceParamstr(materialRes, MaterialResParams::Class);
ResHandle tempRes = Horde3D::findResource(ResourceTypes::Texture, thing);

The resname of the material is irrelevant for the call to findResource. There you need the texture resource name, not the one from the material.
But since your solution works, I guess it's just a typo in your post.

Author:  SirLancelot [ 17.05.2009, 11:56 ]
Post subject:  Re: ResourceType::Material

Oh, be damned my keyboard, making typos while i look away... :evil:

Author:  marciano [ 17.05.2009, 18:11 ]
Post subject:  Re: ResourceType::Material

The material class is only referenced in the pipeline for limiting rendering to a specific class of objects (e.g. only tranparent objects). I don't expect side effects with the sample pipelines. But of course, as you state yourself, it is just a hack (although a clever one) and should be replaced as soon as the new material interface is ready (maybe in a few days).

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/