Texture selection

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Gaurav Gangwar
Posts: 23
Joined: Thu Jul 31, 2008 7:35 am

Texture selection

Post by Gaurav Gangwar »

Hi all,

I am having a sm.bsp in that there are a number of textures and b3d files.
So here are my question :

1:- can i interact with those textures
2: When i use getMesh(sm.bsp ) a lot of b3d files also get loaded with it i am not able to animate them is it possible to interact with such animated files

if yes then pls give me some idea or if possible some link will be very help full

I m making a game in which the player has to interact with such textures depending on the task given

thanks
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

What do you mean by 'interact' with a texture and 'interact' with a model??
Image Image Image
Gaurav Gangwar
Posts: 23
Joined: Thu Jul 31, 2008 7:35 am

Post by Gaurav Gangwar »

i mean to say if on mouse click event use getRayFromScreenCoordinates()

and pass the camera position and mouseposition then in the code how can i know that in n number of textures on which one player has
clicked ??
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Do you mean textures...? or materials? or objects? Could you explain what you're trying to achieve? Is it like a game where players have to click on objects to win or something?
Image Image Image
Gaurav Gangwar
Posts: 23
Joined: Thu Jul 31, 2008 7:35 am

Post by Gaurav Gangwar »

yes i mean textures

like i have got some items in supermarket then the player has to click on those textures and i should know the texture on which player has clicked

i know how to put the b3d files etc and then clicking on them i can know that
this b3d file has been clicked and so i get the score

but putting so many b3d models on my supermarket takes lot of memory and i cant play the game .

so if i put simple textures then size of supermarket will be low and i can play the game
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

I think using a model would be simpler, if you're experiencing performance issues then we can suggest some ways to enhance performance.

But how are you drawing your textures currently? driver->draw2DImage?
Image Image Image
porcus
Posts: 149
Joined: Sun May 27, 2007 6:24 pm
Location: Germany

Post by porcus »

I think he wants to get the texture from a scenenode.

maybe you're searching for this:
irr::scene::ISceneNode Class Reference wrote:virtual video::SMaterial & getMaterial (u32 num)
Returns the material based on the zero based index i.
and this:
irr::video::SMaterial Class Reference wrote:ITexture * getTexture (u32 i) const
Gets the i-th texture.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

No, he doesn't :lol:
Image Image Image
Gaurav Gangwar
Posts: 23
Joined: Thu Jul 31, 2008 7:35 am

Post by Gaurav Gangwar »

there are textures in my supermarket that are inside a pk3 file

sm.pk3 and when i call get mesh(sm.bsp) every thing inside the pk3 is loaded into the memory
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You probably want to find the polygon that has been clicked on and then find out which texture is applied to that polygon...
Image Image Image
Gaurav Gangwar
Posts: 23
Joined: Thu Jul 31, 2008 7:35 am

Post by Gaurav Gangwar »

100% correct ,

and i am not able find the way to do that
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Sorry, I can't think of an easy way to do that. Irrlicht's collision detection only tells you the geometry of the intersected triangle, not which node it's part of. There's some patches in the tracker that address this, but I think they've rotted.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

Finding the clicked triangle is easy, covered in the collision tutorial, but finding what texture is applied to that is harder i think...

i guess maybe you'd have to check each meshbuffer of your model and see if the clicked triangleis within that meshbuffer, which i suppose you could do by checking each set of 3 indices in the meshbuffer (which form a triangle of the mesh) and see if the vertices those indices refer to are at the same position as the 3 vertices in the clicked triangle. when you've found the triangle then you can grab the corresponding meshbuffer's material and texture.

unless anyone else knows a better way!
Image Image Image
Gaurav Gangwar
Posts: 23
Joined: Thu Jul 31, 2008 7:35 am

Post by Gaurav Gangwar »

Thanks a lot :)

I follow the way JP has told me
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

You'd probably also have to transform the mesh buffers triangles into its node's transformation before checking...

Imagine you've scaled up your map by 10x on each axis. The vertices in the mesh buffer will not be affected, only the maps' node knows about this scaling and will scale it up when it's drawn only.

When you do the collision detection i imagine it would return you the scaled up triangle rather than the original triangle from the mesh buffer.

But this would be fairly easy to do, you just grab the node's transformation and apply it to the vertices before checking them against the collided polygon. (obviously you don't actually want to change the mesh buffer's vertices, just a local copy of them).
Image Image Image
Post Reply