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.

Dark GDK / how to use Dword for getting RGB values?

Author
Message
haliop
User Banned
Posted: 5th May 2010 15:57
well, how?
if i use dbPoint to get a color
i want it to be placed inside an RGB like format like Dword or something then exctracting those numbers for edit.
JTK
14
Years of Service
User Offline
Joined: 10th Feb 2010
Location:
Posted: 5th May 2010 16:19
Assuming 32-bit color with alpa (ARGB); I think what your looking for is:



All other formats are just some variation of the above. I posted a group of 2d code files that have various macros defined in one of the pixel perfect threads - I believe. Look for the ripcolor macros for more formats.

Hope this helps

JTK
haliop
User Banned
Posted: 5th May 2010 16:51
i honestly can say i do not understand what is written above. sorry.
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 5th May 2010 17:57
So you want to get the RGB values from what is returned by dbPoint (the color of a certain pixel)?
Didn't test it, but I think you can use these commands:



They basically work like the opposite of dbRGB(). Give them the color and they return the R / G / B values of it.

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
haliop
User Banned
Posted: 5th May 2010 22:52
from 0 to 255?
i will check this , ty pauli this will be very very helpful.
here take a look about what im working on :
http://forum.thegamecreators.com/?m=forum_view&t=155919&b=22&msg=2009657#m2009657
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 5th May 2010 23:35
Yes, the commands return values in the range from 0 to 255, just as you would pass them to dbRGB().

Quote: "take a look about what im working on"


Ah ok, I see what you're trying to do.
Actually I did something similar with these commands
I used it for painting directly on a multi-layer terrain in a world editor that I did about 2 months ago.
I used different colors on a bitmap to indicate where (and how transparent) certain textures show up on a terrain.
Well, I attached a screenshot of the editor in action (although it might not be useful to you at all )

Good luck with your project!

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.

Attachments

Login to view attachments
haliop
User Banned
Posted: 5th May 2010 23:49
editor looks good!
im more after a nature like enviorment random
meaning , you have a huge terrain but you are not an artist
you are a programmer.. therefor let the cpu and gpu do the work for you, so actually i dont use textures i create them randomly and placing them randomly after coloring just regions where i want grass and where i want snow or a road and stuff.

so , ok its not the best artistic way but it gives you a high detail mapping with no alpha textures on top of it so it cost less cpu.

but the best thing , is that i want to make a Automate Normal Map using the randomly created texture. it just save you ton of work and still everything looks awesome.
Mireben
15
Years of Service
User Offline
Joined: 5th Aug 2008
Location:
Posted: 6th May 2010 08:38 Edited at: 6th May 2010 08:41
Quote: "i honestly can say i do not understand what is written above. sorry. "


Just thought I'd explain. That code is using binary AND operations to mask out the bits of the DWORD which store the individual colors (and the alpha channel) and then shifts the result right by the appropriate number of bits to get the numbers into the 0-256 range. The blue does not need to be shifted because that part is already within range. I haven't tried but the code looks good and should give the same result as the dbRGBR, dbRGBG and dbRGBB commands. However, use what is more understandable and readable for you.
haliop
User Banned
Posted: 10th May 2010 20:26
yo Pauli , i may need some assitance
i am looking after your terrain color brush tool you posted above, do you mind sharing the code for painting with the mouse?
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 10th May 2010 20:43
Ok, wait. I will have to take a look into the code again, as I didn't touch it for a month or so.

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 10th May 2010 20:56
So, here is what happens when the user clicks on the terrain in draw mode:



What you get from this are the results u & v. I use them to draw pixels (in various brushes/sizes) to draw on an alpha map. This alpha map (a bitmap image) is used to blend different textures together in a shader for the final render of the terrain.

Well, this is something from the very interns of this programs, so something may not make lots of sense to others. But it works well.
I hope it gives you some ideas.

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
haliop
User Banned
Posted: 10th May 2010 21:15
yeah i thought it something like that , ty so much man!
by the way how do you get TileSize X and Z ?
and what is PickOffset?
last thing , alphamapwidth is equal to ?
can you explain just a bit more?
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 10th May 2010 21:45
Yeah no problem dude, it's just everything tightly bound to the structure of this program. So I have to get my head around it for myself, too

Basically you can forget TileSize at all. This is only relevant in this program because it deals with multiple terrain objects (I called them terrain tiles) that form the whole terrain together.
Just leave ' - ( Terrain.TileSizeX() / 2 )' and ' / Terrain.TileSizeX()' out of the equations. That should do it.

PickOffset is just something I had to take into the equations because there was a small in-accuracy when drawing. Don't know what caused this, maybe the Pick-commands in general...
You should experiment with this value. If it fits right away with set to 0 then leave it out...

AlphaMapWidth & AlphaMapHeight are the width and height of the alpha map image that I draw on.

I you really want to, I could upload a compiled version of this tool so you can see it in action. (I hope you understand that I'm not just going to put all the source code up here, because it was a LOT of hard work)

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
haliop
User Banned
Posted: 10th May 2010 23:14
tnx man!
and sure i had no intention to get the source code i understand it completly just needed some explanation.

the good thing about my idea is that there is no need for multiple terrain and non alpha map is needed there for more fps less to calculate, today i got a 1024 x 1024 to get really high ,visual wise, i need your method or similar just to paint the Clean RGB colors the algorithem will do the rest.
haliop
User Banned
Posted: 11th May 2010 00:23
about limbs , ???
i dont understand how you do it..
how do you know what limb is selected?
and limbPositionX and y and z , gives me 0...
_Pauli_
AGK Developer
14
Years of Service
User Offline
Joined: 13th Aug 2009
Location: Germany
Posted: 11th May 2010 00:39 Edited at: 11th May 2010 00:39
In my case this was easy:

As I said my terrain was composed of several terrain tiles (= limbs). These were located on a grid of a certain tile size.
So I just had to calculate the grid x and z values and check in an array which limb has these values.

Example:

- Tile width/depth = 32
- pick x = 44, z = 12
- x / tile width = 1.375 -> grid x = 1
- z / tile depth = 0.375 -> grid z = 0
- check array for limb/tile with that grid position x and z
- now you know what limb/tile you're on

But again this only works for a grid with a fixed size.

Now the plot thickens, the fps decreases, and the awesomeness goes through the roof.
haliop
User Banned
Posted: 11th May 2010 02:00
ohhh ok ok , i see. ty. i thought you ment
Tile = diffrent Terrain Objects
and Limbs was the Terrain Limbs.. nvm then

Login to post a reply

Server time is: 2024-07-07 01:24:30
Your offset time is: 2024-07-07 01:24:30