Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Finding materials used by an X file?

Author
Message
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 19th Dec 2011 22:22
Hey all


My level editor attempts to copy the selected file to a local folder and then loads the object from there. So how would I go about reading the file and figuring out which materials it uses so I can copy them across too?

This code doesn't work at all:



You will need the multijoy plugin for search string to work.

TheComet

Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 19th Dec 2011 22:44
An ugly solution might be to use limb texture on the loaded object and simply resave them to the desired folder.

Also when searching for a file name, it is probably better to scan for the expected extensions (png, tga, etc. in this case). A texture that resides in the same folder as the mesh won't have a backslash in its file names.


"Why do programmers get Halloween and Christmas mixed up?"
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 19th Dec 2011 22:44
Hi there.
TheComet, we can guess material with "name$= limb texture name(1,lm)"

Attached example code.



Cheers.


TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 19th Dec 2011 23:31
Oh wow, thanks a lot chafari! I didn't even know that command existed

TheComet

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 25th Dec 2011 23:20 Edited at: 25th Dec 2011 23:20
Here's a new problem : My light mapping program exports models with no limbs (except for limb 0). How would I get the texture name of an object? This returns an empty string:




Any ideas?

TheComet


Don't click.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 26th Dec 2011 00:18 Edited at: 26th Dec 2011 00:20
This code give us the name texture of the whole object



Cheers.



I'm not a grumpy grandpa
Quel
17
Years of Service
User Offline
Joined: 13th Mar 2009
Location:
Posted: 26th Dec 2011 01:05
Limb zero is practically the object itself.

This is true for all the commands where there is a limb ID involved.

-In.Dev.X: A unique heavy story based shoot'em ~35%
-CoreFleet: An underground commander unit based RTS ~15%
-TailsVSEggman: An Sonic themed RTS under development for idea presentation to Sega ~15%
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 26th Dec 2011 14:18 Edited at: 26th Dec 2011 14:24
Quote: "Here's a new problem : My light mapping program exports models with no limbs (except for limb 0). How would I get the texture name of an object?"

Use zero for limb number and negative numbers for texture stage

Quote: "Limb zero is practically the object itself.

This is true for all the commands where there is a limb ID involved."

NOT exactly

limb angle y(object_number,0) isn't the same as object angle y(object_number)

SoftMotion3D
AGK Developer
20
Years of Service
User Offline
Joined: 24th Aug 2005
Location: Calgary,Alberta
Posted: 26th Dec 2011 22:41
also limb 0 may be the base and only limb of an object that is created with darkbasic....however

a 3ds or x file loaded in may have a few blanks at the start....at least 1 anyways that has absolutely no object limb directly but would modify its child limbs connected to it. (but not textures)

Each limb can have a different texture as well.

Would be best to scan through all the limbs to see what the texture names are. then copy them all over...

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 27th Dec 2011 22:04
Limb 0 doesn't work. I've attached a small example, please look into it

TheComet


Don't click.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 27th Dec 2011 23:34
Quote: "Limb 0 doesn't work"

i tried it, it works. The problem is your model isn't textured or isn't exported correctly. Model contains 2 materials. First material doesn't contains texture, second does. Your model is textured with first material (which doesn't contain texture).

Conclusion: code works, your model doesn't

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Dec 2011 01:03
I don't quite understand. So my model has a 2 layered texture, where the first layer is blank, and the second layer contains the texture? Why is DBP able to display it correctly? And is it therefore possible to obtain the texture name by specifying a negative parameter?

TheComet


Don't click.
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 28th Dec 2011 01:11 Edited at: 28th Dec 2011 01:13
Quote: "So my model has a 2 layered texture, where the first layer is blank, and the second layer contains the texture?"

No, your model file has 2 materials defined and only 1 of the materials has texture defined.

Quote: "Why is DBP able to display it correctly?"

In the model file i've seen that all the polygons are textured using second material. The model shouldn't be textured. If it is, i don't know why.

Quote: " And is it therefore possible to obtain the texture name by specifying a negative parameter?"

This method can be used when different polys of the sam elimb are textured with different textures. It probably won't wotk in this case.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 28th Dec 2011 01:30
@ Brendy boy - The model is textured when loaded into DBP. I saw an example showing an object with 5 different materials textured to it and it showed up fine in DBP. I think DBP supports multiple materials.

Does anyone know how to get the texture names of multiple materials?

TheComet


Don't click.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 28th Dec 2011 01:32
@TheComet
Quote: "My level editor attempts to copy the selected file to a local folder and then loads the object from there. So how would I go about reading the file and figuring out which materials it uses so I can copy them across too?"


Well, the best way in my opinion, is to understand the file format of the files you are using. You need to be able to parse the files and get the information you need directly from them. That way, you can get exactly what you want, how you want it.

In a direct x file, for example, a material can be assigned to an entire mesh (limb), an individual face, it may contain a reference to a texture or not, it may be defined within a mesh or at the beginning of the file. With all of these variations it has a few consistent properties such as always being defined with a template header labeled

Material

It's harder to parse the file than to use ready made options that may be available in DarkBASIC, but you'd have more flexibility with your own methods.

Enjoy your day.
chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 28th Dec 2011 01:45
Quote: "I saw an example showing an object with 5 different materials textured to it and it showed up fine in DBP"


You mean the example I saw you ?....I made it 3DMax....I'm not sure if AC3D can do that....I will test it tomorow, and will come again with the result.

Cheers.

I'm not a grumpy grandpa
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 28th Dec 2011 01:53
Quote: "@ Brendy boy - The model is textured when loaded into DBP. I saw an example showing an object with 5 different materials textured to it and it showed up fine in DBP. I think DBP supports multiple materials."

I know. But in your example model is textured with material 1 which doesn't have texture defined. Material 2 has texture defined but the model isn't textured with it. Because of that i think the model should't be textured.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 28th Dec 2011 02:23
@TheComet

As Brendy boy says, your model is not correctly textured. I have loaded it in AC3D and give some textures to it, and now you can see the name of the textures. Attached the 2 examples working ok made in AC3D.

Cheers.

I'm not a grumpy grandpa

Login to post a reply

Server time is: 2026-07-11 08:46:51
Your offset time is: 2026-07-11 08:46:51