Search Home Members Contacts
About Us
Products
Downloads
Community
Support
Pages: [1]
  Print  
Author Topic: Texture ID problem. Need Help !!!  (Read 1236 times)
harikumar001
Customers
Community Member
*****
Posts: 65


« on: September 24, 2010, 08:05:23 AM »

Hey Guys,

Have a good day.

Stuck with a problem yet again. Been working on an application for a few months using TV3D. My users can load models into the application and change their textures. Everything was working fine, until I recently discovered that whenever I have two or more different meshes using same texture file and I delete a texture in my application using textureFactory.DeleteTexture(ID_of_any_one_mesh_sharing_texture), and add a new texture to that slot, the textures on all other meshes get updated.

Here are some observations:

1. I took output from the debug file after dumping textures
Slot 1:C:\PIC1.JPG   TEX1
Slot 2:C:\PIC2.JPG   TEX2
Slot 3:C:\PIC1.JPG   TEX3
Slot 4:C:\PIC1.JPG   TEX4

This is before I delete anything. When I execute Globals.GetTex("TEX1"), Globals.GetTex("TEX3"), Globals.GetTex("TEX4") all these return the same TexID. From what I understand, TV3D keeps referring to the same slot where the texture to be shared loads for the first time. For instance, here PIC1 is loaded in slot 1 for first time and everytime a texture using file PIC1 it asked to return an ID, it returns the same value 1.

2. The problem is solved by using textureFactory.SetTextureSharing(false). But I do not think that would be resource friendly.

Is there a work around to this problem?? Please help guys.

Regards
Logged
Toaster
Community Member
*
Posts: 378


WWW
« Reply #1 on: September 24, 2010, 08:58:32 AM »

Well your texture files should have different names however, you if you know their are going to be different files loading in with the same name you can call  textureFactory.SetTextureSharing(false) and then back to true again once you finish loading those.

Otherwise really you need to make sure the names are different in my opinion.

-Toaster
Logged

Visit my site at: Unknown Abstraction
harikumar001
Customers
Community Member
*****
Posts: 65


« Reply #2 on: September 24, 2010, 10:48:11 PM »

Thank you Toaster

I am not loading different files with same name, I am loading same file with different names which is giving me the problem.

Regards
Logged
TecnoBacon
Customers
Community Member
*****
Posts: 305


WWW
« Reply #3 on: September 25, 2010, 10:18:50 AM »

Same here, what I did to fix it was ask for the id after creating it, not trusting the return value of the create func.

I handle them myself but have to keep sharing true or models with textures cause a major upset when trying to delete textures.

OH and I keep a list as the same id is issued to any texture that matches an already loaded texture, this way I decrement the list for that id number and actually delete it when it hits 0.

i.e.   IDarray[] can be fixed or growing

IDarray[gettextureid()]++  to add to list
IDarray[...]-- to delete
if IDarray[...] < 1 ( deletetexture(IDarray[...]) )

unfortunately textures loaded with models will sometimes use an already loaded texture so I name all my textures with a prefix to make them unique from my model textures.


« Last Edit: September 25, 2010, 10:31:10 AM by TecnoBacon » Logged

www.TecnoBacon.com - the other side of the Bacon family! 3D Development, Music and more.
TecnoBacon
Customers
Community Member
*****
Posts: 305


WWW
« Reply #4 on: September 25, 2010, 10:34:06 AM »

OH Yea, TV assigns the id based on the filename (complete) not the name you give it.
Logged

www.TecnoBacon.com - the other side of the Bacon family! 3D Development, Music and more.
harikumar001
Customers
Community Member
*****
Posts: 65


« Reply #5 on: September 27, 2010, 12:43:40 AM »

Thanks you TecnoBacon, that was really helpful  Smiley

I guess managing textures myself is the only way out.

Regards
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.3 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks