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 / Copy UV and material/textures to another object

Author
Message
RustyKristy
2
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 11th Jul 2018 12:22
It's been a while since and I have to follow up with a new thread since I can't reply on my old one here

The above thread already solved copying the UV set to another object and I had a chance to get back to this and now checking with other dbo models, there's a problem with getting the right material from the 2nd UV as opening the output model, it seems it is reading from the 1st UV but both UV channels materials are there.
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 11th Jul 2018 13:15
ah yes, I recall posting a code error on that thread. I am interested in this and will have a "revisit" and get some code together as I've done a lot of DBO/texture/multi material type of code and format conversion stuff which has been pretty challenging and very satisfying. I'll fire up DBPro and have a play with some code after work.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Mage
11
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 11th Jul 2018 21:22
I have also been working on converting the DBO format and found the going slow. I have noticed there are omission errors in the DBO specification document. I also have been doing a little bit of work a day so I don't burn out and can maintain progress. It's been slow going but I haven't run into any road blocks yet. I will first read all of the codes and dump the data into a text file (phase 1). Then I will convert that code to store the data in appropriate variables and arrays (phase 2). Then I will have the code repack the data into a byte for byte perfect DBO file (phase 3). Since I have already done this for the other format I am working with I will then begin code to convert the data from one format to the other (phase 4). Then do the reverse (phase 5). Then the easy part give it all a nice GUI (phase 6).

I'm sure weighted verts and animations will be convoluted an nearly impossible to figure out. Especially if the angles are stored differently and some sort of university level calculus course is needed understand and implement the conversions. Maybe.
RustyKristy
2
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 16th Jul 2018 14:43 Edited at: 16th Jul 2018 14:44
Hey, nice to hear from you again BoTR that would be awesome, thanks. Any update on this btw?

@Mage
Actually I'm only concerned with static objects with multiple UVs/materials and it would also be interesting to check out your work if it supports it and then some.
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 16th Jul 2018 19:10
@RustyKristy: ah, I knew I meant to do something......will have a look as soon as I get some spare time...shouldn't be long.....
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Mage
11
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 16th Jul 2018 19:58
RustyKristy wrote: "Actually I'm only concerned with static objects with multiple UVs/materials and it would also be interesting to check out your work if it supports it and then some."

What I am working on would cover that but I am still a long way from releasing anything viable as I am too distracted with other things to work at a fast pace. Also I am working purely from a file format perspective. That involves basically needing to be able to parse and repack objects completely.

This seems like a "Phase 3" problem.

I am getting confused by your grammar in the opening post. Can you in detail describe the information that needs to be copied from Object 1 to Object 2? If I get to Phase 3 then I will be able to open the file up, make changes, and save it again.
For example I have already done this for another file format where the material is merely stored as a string. So opening the file, changing the string, and then re-saving would change the material.
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 19th Jul 2018 06:54 Edited at: 19th Jul 2018 07:33
@RustyKristy-I'm having a look at this currently, and I'm not sure what your code looks like, but if your using Chris Tates' original code, I think I may have (or not) spotted a potential error. Just finding my DBO with multi texture staging and will play around wth the code and correct where applicable. In the meantime, what happens if you use this code (Chris Tates')?:

I think the issue here is the original code that copies all the uv layers of 1 object to another is only looking at stage 1 (sourceUV), so I changed the sourceStage (1) to the same as the var targetStage i.e. I've set sourceStage to the same as targetStage, but can't test to see if it works yet until I find my DBO. Obviously update the code to copy from whatever stage to whatever stage you like. Will test as soon as I can get to my DBO that uses multi-staging. Change the FOR ... NEXT statement to whatever values you need to :

[update-tested on the "Hummer_dynamic.DBO" from the DesertStorm Pack (FPSC model 75) and ran code and copied UV layers ok. Attached files here. out.dbo is the result. ]

For targetStage = 0 to 7
` Copy the UV layer on limb zero
//CopyObjectUVLayer(2,0,1,0,targetStage,1)
sourceStage = targetStage
CopyObjectUVLayer(2,0,1,0,targetStage,sourceStage)
Next


Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 19th Jul 2018 09:43
actually the above initial testing isn't the best test as the cloned object already has the same texture data as the source DBO object. So I will test the source DBO against a plain and untextured DBO and see if the code still works. I'm not sure 100% it will, but you never know.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 19th Jul 2018 13:40
ok, so it appears that after testing against a non-textured object, the code above doesn't really work. When I exported both the source / target DBO's out locally and imported / exported back out from Fragmotion as X format, the target only has 1 material/texture in the materiallist part of the X file. I'm going to try my converter and see if I get a fully multi textured Hummer or single textured even though both materials/textures show in Fragmotion in DBO format, but only 1 texture/mat comes is shown when importing X file back into FM. In theory my program should work. Confused? same here ha ... just kidding.....
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 19th Jul 2018 17:43
ok, missed this code mistake, should be source not target:

Still playing around with all this, as there are other issues with the code.
` Lock source limb for vertex access
// Lock VertexData For Limb targetObject, targetLimb, 2
Lock VertexData For Limb sourceObject, sourceLimb
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 19th Jul 2018 22:30 Edited at: 20th Jul 2018 12:33
After a bit more 'dabbling', for the Humvee example. It has 1 limb and 2 textures/materials. And the actual UV data is actually present in staging (or layers) 0 and 8, so not 0 and 1 as I would have thought. Now in X format , my DBO2X program grabs these UVs from the DBO data and in the materiallist , the 2 UV's are actually 0,0,0,0,0 etc and 1,1,1,1,1 and then the 2 materials/texturefilenames are embedded near the "texturefilename" part of the ascii file. I think I'll get the code right and tidied up and then post here as soon as possible.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 20th Jul 2018 17:22 Edited at: 20th Jul 2018 22:08
final code and DBO/textures attached so you can play around. Obviously change what stages/layers you want to copy, experiment. I can't take credit for the original code which was supplied by Chris Tate (thanks Chris), but I've made some small corrections to it:

thanks also to the person (I can't recall) who created the Humvee model from the Desert Storm Pack. This is free on github FPSC open source. model pack 75 if I remember.

Also note, that this DBO has 1 limb so the target limb will be 1 as there are NO verts/UV's in limb 0. Change to use 0 if no limbs in your DBO/model. I find it useful to use PERFORM CHECKLIST FOR OBJECT LIMBS and then loop through each limb and see if it has an FVF size / verts/ indices etc.

For learners of the language, texture staging can be achieved by using:

Texture objectId, stagenum, image-->

e.g.
Texture 1,1,1 -> texture object 1, assign to stage/layer 1 and use image number 1
Texture 1,2,2 -> texture object 1, assign to stage/layer 2 and use image number 2

There is also a 'TEXTURE LIMB' command which allows you to texture limbs individually if your using commands such as ADD LIMB/Link Limb etc.
been a while since I played with those for my own tools, but they are useful.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
RustyKristy
2
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 21st Jul 2018 00:29
This is so awesome BOTR! I already tested your previous Humvee output and so far it looks good! I will give it a try asap. Big Thanks buddy!
RustyKristy
2
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 21st Jul 2018 00:37
Quote: "I am getting confused by your grammar in the opening post. Can you in detail describe the information that needs to be copied from Object 1 to Object 2? If I get to Phase 3 then I will be able to open the file up, make changes, and save it again.
For example I have already done this for another file format where the material is merely stored as a string. So opening the file, changing the string, and then re-saving would change the material."


@Mage

Yes, again basically I have a standard DBO model with a 2nd UV texture (ie. lightmap) and I want to have a separate model with the lightmapped texture only. That's all. unfortunately, there is not a lot of editor tools out there that fully supports the DBO format (except a few paid ones which is also not 100% working). There are some that I tried, but features are lacking like this one that I posted.

btw, Is DBO still supported on newer products like Game Guru or AGK2? just curious
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 21st Jul 2018 08:06 Edited at: 21st Jul 2018 08:11
@RustyKristy: no problem at at. I will have to test out using lightmap texture (FPSC DBO by any chance?). GameGuru supports DBO as it originally was written in DBPro and later got converted to C+. AppGameKit doesn't support DBO at the moment. my current version app DBO2X does convert to either X or OBJ that can be imported into AGK. It still needs more work to get it as close to perfect as possible as it also converts GameGuru's PBR / EBE DBO structures as Lee updated the DBO format for those when making updates to GameGuru.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
RustyKristy
2
Years of Service
User Offline
Joined: 13th Jan 2016
Location:
Posted: 21st Jul 2018 12:19 Edited at: 21st Jul 2018 12:30
Nice! Yes, I was hoping that it will cover all DBO versions, particularly the ones with multiple UVs or at least UV2 for lightmapping like FPSC as you mentioned. I'm not sure with animations though as with my experience so far, I have not found any use case where it will be needed.

So I already made the effort to create a basic FPSC map with lightmaps baked in for UV2 (see Attachment). I just got the assets from the Arteria Sci-Fi pack posted on the Github FPSC repo link. Here is the screencap..





I have tested this with the old code on the previous thread and so far it is the same problem and here are the results:





The first two at top was produced with the said older code with some modification to output both diffuse and the objective and attempt to export the uv2 object (OutLM.dbo). I have provided a compiled exe as well for fast checking.

As for the bottom left, this is a quick attempt to check the result by manually assigning it in fragmotion with the single lightmap texture and so it seems it does not copy or assign the material to the transferred UV, which I would think would be the case and as far as I know that technically this needs to be done by code as well.

The bottom right would be the ideal result which I have assigned manually in fragmotion, matching the material number and group number, as simple as that it turns out. I'm not sure how to go about this with DBPro and it would be nice to just export two dbo outputs that can be merged with outside tools like Blender, since it is still a problem to import, open or convert a DBO file to a common/standard format.

As for the above code that you posted recently, apparently I'm just seeing vertices when opening it with fragmotion with my earlier tests.

Typo: The last bottom right result is actually a fragmotion UGH file and not in DBO format (ManualAssignMaterial.UGH, see zip file).

Attachments

Login to view attachments
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 21st Jul 2018 12:32 Edited at: 21st Jul 2018 14:22
@RustyKristy-ok, I see what you want now, thanks for the pics/zip. My segautowelder/autowelder imports/exports FPSC textured levels so you can import into GG or what ever loads in an X or DBO file. It unfortunately ignores lightmaps, but now I think about it, I could just get it to look at the lightmaps and ignore the .dds textures etc. So it might be I have the code already just needs some tweaking. So in theory it should texture/bake the lightmaps into the DBO FPSC level for each limb in Fragmotion but might be more to it than I realise. This should be possible to do, let's see what I can come up with.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 21st Jul 2018 19:30 Edited at: 21st Jul 2018 19:45
here is a code snippet from my Autowelder tool (the next SegAutoWelder incarnation), which has super fast FPSC level import/export feature (fully textured). This bit of code excludes the lightmap files. So I will update the code and do some reworking to get the program to reproduce the FPSC level but using the lightmaps. But I'm assuming from the above pic (bottom right) you still want to see the segment textures that were used? A lot of the code needs major improvments anyway with some new techniques I've picked up over the last few months or so. The level exporter also allows other options and re-centers the level a 0,0,0 if you want to or keep the original position. once I get some good results, I'll upload some pics.

[edit-added a pic of Autowelder with the In.DBO level displayed untextured at the moment. So the plan is to get it textured using the 2nd UV layer (lightmap) textures]
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Bored of the Rings
13
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 21st Jul 2018 21:36 Edited at: 21st Jul 2018 21:59
here is the In.DBO level now textured using the lightmap textures using the updated Autowelder and another pic showing the wall textures. there's hope in all this after all , time to have more fun with this and get it to look like the bottom right pic above that RustyKritst posted
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments

Login to post a reply

Server time is: 2018-07-23 03:16:16
Your offset time is: 2018-07-23 03:16:16