Skip to main content
GameDev.net gamedev.net
🔒 Locked

Textures!!?!? grr

Started by Samith Dec 21, 2001 at 6:20 PM 4 replies 250+ views
Original Post
Samith
Samith
When you play games, they have lots of objects that have been loaded from 3d file formats (for quake 2 its md2), well, how do the programmers get their programs to texture the objects?? I mean, they cant load each texture induvidually in the code, because then the user created objects wouldnt work right. So they must have some kinda of loop to read thru each 3d file, find the texture name and put that texture name into some variable, then load the texture into the memory, texture the object etc right?? well, i know its probably a pretty newbie question but, what''s bothering me is, i dont know how to make that loop/function thing! If you know what i mean and can help me, please do!! Thanks a lot, Samith PS: This isnt requiered, but, if you decide to help me, could you use the 3ds file format as an example, because thats the one im working on, thanks again!!
Zeblar Nagrim
Zeblar Nagrim
I think that most engines use a technic called "expressions". That is a rectangular area around the beholder. When the beholder walk around in the 3D world he collidate with object expressions. When a object expression pop up, all textures that belongs to that object are loaded from file to memory. When the viewer expression move away from the object expression all textures are destroyed.

You should design a texture manager class that may be a dynamic list of some other kind and your 3DS renderscene class should use that class to load and unload texture data.
Samith
Samith
really all i want is for my program to read thru a 3d file to find what the texture name is, then take that texture name into a variable so i can use the variable in the texture loading function instead. That way my game can have user created objects etc, do you understand what i mean?

and i dont know how to do this. so dont just tell me what to do, tell me how
Zeblar Nagrim
Zeblar Nagrim
Do you know how to look for information in a 3DS file?
If you do you must look for chunk A300. I call that chunk MAPPING_FILENAME in my 3dsparser and here is the code for that part:

  

char g_sTexName[100];

void C3DSFile::CopyChunkData(unsigned short ID, char *pData, int Offset)
{
...

case MAPPING_FILENAME:
strcpy(g_sTexName, pData+CurrOffset); CurrOffset += (strlen(strName) + 1);
break;
...
}


Keep in mind that the search path to the texture are not included in a typical 3ds file, so you must put all your textures in a special folder somewhere.



Zeblar Nagrim, Lord of Chaos
Samith
Samith
thank you!! thats just what i needed

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.