Horde3D

Next-Generation Graphics Engine
It is currently 16.06.2024, 11:08

All times are UTC + 1 hour




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: ResourceType::Material
PostPosted: 15.05.2009, 14:26 
Offline

Joined: 15.05.2009, 14:14
Posts: 7
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.


Top
 Profile  
Reply with quote  
PostPosted: 15.05.2009, 15:01 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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


Top
 Profile  
Reply with quote  
PostPosted: 15.05.2009, 16:41 
Offline

Joined: 15.05.2009, 14:14
Posts: 7
I tried that too, but it returned 0.


Top
 Profile  
Reply with quote  
PostPosted: 15.05.2009, 20:29 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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)?


Top
 Profile  
Reply with quote  
PostPosted: 16.05.2009, 12:08 
Offline

Joined: 15.05.2009, 14:14
Posts: 7
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.


Top
 Profile  
Reply with quote  
PostPosted: 16.05.2009, 12:13 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
What about using Horde3D::findResource ?


Top
 Profile  
Reply with quote  
PostPosted: 16.05.2009, 12:15 
Offline

Joined: 15.05.2009, 14:14
Posts: 7
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?


Last edited by SirLancelot on 16.05.2009, 12:23, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: 16.05.2009, 12:20 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
We will very soon have improved resource data handling. This should solve your problem.


Top
 Profile  
Reply with quote  
PostPosted: 16.05.2009, 12:28 
Offline

Joined: 15.05.2009, 14:14
Posts: 7
Looks promising. When is very soon? :)


Top
 Profile  
Reply with quote  
PostPosted: 17.05.2009, 09:26 
Offline

Joined: 15.05.2009, 14:14
Posts: 7
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?


Top
 Profile  
Reply with quote  
PostPosted: 17.05.2009, 10:51 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
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.


Top
 Profile  
Reply with quote  
PostPosted: 17.05.2009, 11:56 
Offline

Joined: 15.05.2009, 14:14
Posts: 7
Oh, be damned my keyboard, making typos while i look away... :evil:


Top
 Profile  
Reply with quote  
PostPosted: 17.05.2009, 18:11 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
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).


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 50 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group