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 / Need Help Saving Loaded Model with only 2nd UV Channel

Author
Message
RustyKristy
8
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 24th Jun 2017 08:23 Edited at: 24th Jun 2017 09:58
Hi,

I would like to know how to capture the 2nd uv channel and mesh from a DBO file and save it separately as DBO or X model

Thanks.

Edit: I got a snippet here that I found with some changes, I don't know how it completely works but I'm sure it's related to what I'm trying to accomplish..




Maybe someone here can pick up and point me in the right direction. I just need to swap UV channels and then save to dbo or x.
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 24th Jun 2017 11:07
Prior to saving the object, the program is obtaining UV coordinates from UV layer one, and writing the coordinates to layer zero, which is the default layer used by textures when not specifying texture stages.

(Textures set on stage 1, would use UV layer 1, textures on stage 2 would use UV layer 2 and so on.)


You can use a new mesh or a clone and have its UV coordinates set using the source UV data.
RustyKristy
8
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 24th Jun 2017 11:18 Edited at: 24th Jun 2017 11:19
Thanks Chris! Can you post a snippet on how it works? Sorry, I'm really new to DBPro and these types of command manipulation.

I just really need to transfer the 2nd UV or Stage 1? to Stage 0 and save it, that's all.
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 25th Jun 2017 13:29
I had to write this code untested and away from my development PC. For all the limbs you need to work with, copy a source UV stage to a target UV stage. Play around with it.

RustyKristy
8
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 26th Jun 2017 00:25
This is awesome Chris, thanks!
RustyKristy
8
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 26th Jun 2017 01:56
I tried opening it with DBO viewers like Ulitmate Unwrap, and the UV1 is still there and now kind of stretched out and also UV2 channel is still in place.

Anyway, I'll try to check the options you got in there.. thanks again.
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 26th Jun 2017 17:22
If UV1 (stage zero) is stretched out after copying UV2, then assuming that you are copying a light-mapping (or similar) UV coordinates then that is correct; it will look stretched out.

Do you need to remove the second UV layer?
RustyKristy
8
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 27th Jun 2017 02:53 Edited at: 27th Jun 2017 02:58
Yes, I just need the UV2 in a separate model.
Bored of the Rings
User Banned
Posted: 27th Jun 2017 07:57
slight mistake in Chris's code:

u#(v) = Get VertexData U(v, sourceUVLayer)
v#(v) = Get VertexData U(v, sourceUVLayer)->> change to Get VertexData V


Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Chris Tate
DBPro Master
15
Years of Service
User Offline
Joined: 29th Aug 2008
Location: London, England
Posted: 27th Jun 2017 12:47
Thanks BotR - (Get VertexData V not U)



Quote: "Yes, I just need the UV2 in a separate model."


In that case, use the UV coordinates on stage 2 to write to all of the layers in the new model like so


Now in the new model, any applied shader and textures will use the same UV data from UV2. Assuming that there is only one limb in the object.
RustyKristy
8
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 30th Jun 2017 10:24
Thanks Chris and Bored of the Rings! Yes, I see the UV is now fixed.

Login to post a reply

Server time is: 2024-04-20 10:39:24
Your offset time is: 2024-04-20 10:39:24