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 / [SOLVED] How to get color of an object?

Author
Message
Alduce
20
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 18th Oct 2021 18:03
Hi all, just can't find how to check what is the color of a specified object.

Something like get object color (num obj)

Thx

The author of this post has marked a post as an answer.

Go to answer

Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 19th Oct 2021 07:05 Edited at: 19th Oct 2021 07:17
This post has been marked by the post author as the answer.
Return DWORD=GET VERTEXDATA DIFFUSE(Vertex Index)

when you use lock vertexdata for limb and unlock vertexdata commands

there doesn't seem to be a get object diffuse in DBPro, probably because you can have multiple meshes with different colour so you would need to read them in by looking at FVF for each mesh in the object.
if you have a dbo that contains the diffuse color you will need to read in the dbo embedded codes see attached. diffuse is a set bit in the mesh FVF. I have converted DBOs to various formats so if you need any more info let me know I will try and help.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Alduce
20
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 19th Oct 2021 21:57
Thank you Bored of the Rings.. a bit complex solution but a workable solution
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 20th Oct 2021 12:46
actually, I'm just going to check the plugin Matrix1Utils that IanM created. I'll get back to you.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Alduce
20
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 24th Oct 2021 20:57
Bored of the Rings Thank you!
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 25th Oct 2021 08:18
No problem, Ian m matrix utils doesn't have a get object diffuse or color that I can see, but my dbo conversion does return color of object per mesh in the dbo. This is in the material info hidden in the dbo. I will either write a small DLL that gets this info or see if I can do some dbpro code to return it. Or both.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 30th Oct 2021 05:47 Edited at: 30th Oct 2021 06:34
Here is example code (cut down from my DBOFastReader app), which returns the RGBA color of any specified mesh. I've attached example DBOs with different diffuse colors Red, Green, Blue, Grey.
It could be stripped further, but will leave as is for now. I will (at some point) make a dll which will do the same thing but with a loaded DBO. There may be a way of doing it in DBPro using IanM matrix which I have some ideas, will see. Adding this also to the Code Snippets for reference.

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

Attachments

Login to view attachments
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 30th Oct 2021 07:23
update to come soon to handle multimeshes correctly. I am putting back code that handles that which I incorrectly removed. So the code at the moment will only return correctly if the DBO contains a single mesh with a color.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 30th Oct 2021 08:47 Edited at: 30th Oct 2021 08:50
ok, multimesh diffuse colors now display per mesh correctly. What I did to test was change the material diffuse color per LOD mesh to Red, Green and Blue (don't ask me how yet) , and then loaded the object back in and the app output the correct diffuse color (DWORD and BYTE values).





will upload code shortly. doing some last moment checks.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 30th Oct 2021 09:01
updated code using both single and multi mesh/ material detection. To come will be returning the info when the dbo is loaded.

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 30th Oct 2021 09:01 Edited at: 30th Oct 2021 09:03
updated code using both single and multi mesh/ material detection. To come will be returning the info when the dbo is loaded. Feel free to do what you want with it. Change function names, reduce code, make it better , whatever suits you/your project if it helps

Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 31st Oct 2021 04:51 Edited at: 31st Oct 2021 05:06
updated code again, now can set each mesh color. Uses "Make Object From Pointer" command from IanM Matrix1Utils plugin. Thanks IanM for a great plugin.
Code has been reduced as much as I want to for now. Not sure why DBPro has a "Set Object Diffuse" command but no "Get Object Diffuse" unless undocumented or I'm missing something.
Actually, I will try the Set Object Diffuse command to see if it does anything, I've seen forum posts that state it doesn't work, but will try it myself and see what happens.

[update-set diffuse ok if you want all meshes to be same color-can't set individual meshes to separate colours]



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

Attachments

Login to view attachments
Alduce
20
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 1st Nov 2021 07:40
Wow bored of rings, you better than a DBPro manual! REALLY THANK you!!
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 1st Nov 2021 08:22 Edited at: 1st Nov 2021 08:30
thanks Alduce, I have updated the code to convert models that don't have FVF size of at least 338 i.e. larger than 274. 338 means that the model should have at least vertex x,y, and z positions, normals x,y,z , diffuse and at least 1 set of texture coords. It renames the original DBO with _274 and then creates _338 files and uses that for the diffuse mesh colour reading/writing.



Of course, I will really need to get the stored diffuse colour for each meah that is actually stored in the FVF bits i.e. 0x040. This is actually stored as a DWORD value (RGB). To get this we need to obtain the offset within the VERTEX DATA. This is easily done. Already done in my conversion program. It's just a case of pulling it out and returning that value when a command is called.
This way we don't need to rely on material info being present we can just return the diffuse value which I should have done in the first place, but gives you more ways to get the color of each mesh.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 2nd Nov 2021 04:25
Actually that would be the diffuse per vertex same as lock vertexdata for limb or mesh etc. So probably not what we want.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Bored of the Rings
17
Years of Service
User Offline
Joined: 25th Feb 2005
Location: Middle Earth
Posted: 2nd Nov 2021 06:15 Edited at: 2nd Nov 2021 06:27
small fixes update:



if I get time, I will add back in the code that handles GG Classic/MAX type DBO FVF where FVF is usually 0 but the FVF Size could be 2130, XYZ, Normals XYZ, Diffuse and 8 texture coord sets.

even works for FPSC levels:


Here, I've set random RGB colors per mesh. Patchwork look.
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others

Attachments

Login to view attachments
Alduce
20
Years of Service
User Offline
Joined: 26th Oct 2002
Location: Rama spaceship
Posted: 13th Nov 2021 20:35
Thank you again Bored of the Rings!

Login to post a reply

Server time is: 2023-02-01 12:08:34
Your offset time is: 2023-02-01 12:08:34