prideslayer Posted July 4, 2014 Posted July 4, 2014  So the RGB value should be 00172228Why are there 8 numbers? And why would it have leading zeroes? And, couldn't that possibly be a problem? IIRC, kid had a number issue in a C++ script that we couldn't figure out until I remembered that a leading zero made it think it was in octal. Leading zeroes are for readability. There are 8 digits because it's a 32bit number. In hex, a 32bit value is 4 octets that are one byte each, and one byte is represented by two digits in hex.  There's no octal in geck scripts, or anything but base10 decimal for that matter.
jaam Posted July 4, 2014 Posted July 4, 2014 Update. eh, I'm going to read Pridelsayer's post.  OK. How do you get that value that you get?  Prideslayer's method. let cc := (15 * 256 * 256) | (240 * 256) | 255 R ==40 G==34 B==23   (R * B+1 * B+1) + G * B+1 + B   (23040) + (816) + 23 == 23879  how do you get 00172228 ?  First, I messed up the order of RGB in my original post, where I calculated BGR instead. See my edit. prideslayer formula is R + (G * 256) + (B * 256 * 256) = R + 256 * ( B + ( G * 256) ) .  Each color ends up occupying one byte in a four byte number.  Sorry we are getting quite technical.
nyaalich Posted July 4, 2014 Posted July 4, 2014 In the initial example, Blue was 255. 255 + 1 = 256. If Blue had been 254, it would be (stuff * Blue + 2). Very unreliable way to calculate, I would think.       EDIT: Of course, since you are setting the color, you know what you'd want the value of Blue to be. It seems like the GECK kind of way of doing things, though.Â
prideslayer Posted July 4, 2014 Posted July 4, 2014 prideslayer formula is R + (G * 256) + (B * 256 * 256) = R + 256 * ( B + ( G * 256) ) . No no, my formula is:  (R * 256 * 256) + (G * 256) + B  R * 256 * 256 == R << 16 G * 256 == G << 8 B = B
nyaalich Posted July 4, 2014 Posted July 4, 2014 Leading zeroes are for readability. There are 8 digits because it's a 32bit number. In hex, a 32bit value is 4 octets that are one byte each, and one byte is represented by two digits in hex. There's no octal in geck scripts, or anything but base10 decimal for that matter.  But isn't NVSE written in C++, and thus having...something...*cringe* < insert appropriate blushy face of shame >
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 yes, I got the Idea.  I take RGB (89;34;89)   Then I assume that they are Decimal and transfrom them into HEXa  592259  then I add "00" prefix so it looks awesome  00592259   Jaam, I understand your method now too.   Thanks, Pride, thanks Jaam!! Â
nyaalich Posted July 4, 2014 Posted July 4, 2014 then I add "00" prefix so it looks awesome  This is the correct response.
prideslayer Posted July 4, 2014 Posted July 4, 2014 looks like everybody posting at the same time. Yes, looks like.  IMHO there's only one right, "readable" way to do this.  A 32bit color takes this format in hex:  0xAARRGGBB  AA is the alpha channel value RR is the read channel value GG is the green channel value BB is the blue channel value  Each one is one byte. Two hex digits from 0x00 - 0xFF.  When you have a single one of those values as a byte in that range, you need to get them into the proper position in the 32bit value. You do that by shifting each one to the left by enough bits to get it into the right spot, and then ORing or ADDing them all together.  Shifting left by 8 bits is the same as multiplying by 256, and turns the value 0xNN into 0xNN00. Shifting left by 16 bits is the same as multiplying by 16384 (aka 256 * 256, aka shifting left by 8 twice) and turns 0xNN into 0xNN0000.  This is not directed to you jaam, I know you know how to handle hex/binary values; just explaining in pedantic detail for everyone else, especially tomm since he seems to need a primer on hex.
jaam Posted July 4, 2014 Posted July 4, 2014 I finally saw all the posts.  The way NVSE is coded, the R byte is the least significant byte. Which color do we get with  SetHairColor 255  It should be red.   EDIt: multi posting again
prideslayer Posted July 4, 2014 Posted July 4, 2014 Â Leading zeroes are for readability. There are 8 digits because it's a 32bit number. In hex, a 32bit value is 4 octets that are one byte each, and one byte is represented by two digits in hex. Â There's no octal in geck scripts, or anything but base10 decimal for that matter. Â But isn't NVSE written in C++, and thus having...something...*cringe* < insert appropriate blushy face of shame > Â It is, but that doesn't matter. Â It's literal values in the C++ sourcecode that are affected by prefixes according to the rules of the C++ language and compiler. This is geck script code, not C++ code being run through a C++ compiler.
prideslayer Posted July 4, 2014 Posted July 4, 2014 I finally saw all the posts.  The way NVSE is coded, the R byte is the least significant byte. Which color do we get with  SetHairColor 255  It should be red.   EDIt: multi posting again Ah so it *is* in BGR?  Figures.. goddamn gamebryo.
prideslayer Posted July 4, 2014 Posted July 4, 2014 In that case you want this instead:  (blue << 16) | (green << 8) | red  OR  (blue << 16) + (green << 8) + red  OR  (blue * 256 * 256) | (green * 256) | red  OR  (blue * 256 * 256) + (green * 256) + red   All four of those mean exactly the same thing.
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 In that case you want this instead:  (blue << 16) | (green << 8) | red  OR  (blue << 16) + (green << 8) + red  OR  (blue * 256 * 256) | (green * 256) | red  OR  (blue * 256 * 256) + (green * 256) + red   All four of those mean exactly the same thing.  Oh, I get last 2 examples but what does "<<" mean? Â
prideslayer Posted July 4, 2014 Posted July 4, 2014 << is shiftleft as I explained a post or two back. Â Shiftleft means "take this value and move it X bits to the left". Â A byte is 8 bits, so shifting left 8 bits means "moving" the value one byte to the left. Moving a value 8 bits left is the same as multiplying it by 256. Â 0xNN << 0 == 0x00NN 0xNN << 4 == 0x0NN0 0xNN << 8 == 0xNN00 Â There is a shiftright >> as well that does the opposite.
Guest tomm434 Posted July 4, 2014 Posted July 4, 2014 YES! Now I remember something like that back from school.
prideslayer Posted July 4, 2014 Posted July 4, 2014 The shift should be preferred in general, since it's almost always faster than multiplication or division. Now the geck script language, being interpreted, might just be converting shifts to mul/div's for you at run time, but if it's actually translating them to native shifts (which would not be difficult for it), it'll be slightly faster -- and in a loop, it'll be *much* faster.
Guest luthienanarion Posted July 4, 2014 Posted July 4, 2014 Ok, now whats a single "|" mean? Â Binary/bitwise OR. Gamebryo scripting doesn't support bitwise operators, as far as I know.
Halstrom Posted July 4, 2014 Author Posted July 4, 2014 In that case you want this instead:  (blue << 16) | (green << 8) | red  OR  (blue << 16) + (green << 8) + red  OR  (blue * 256 * 256) | (green * 256) | red  OR  (blue * 256 * 256) + (green * 256) + red   All four of those mean exactly the same thing. Ok I'll just take that last one and run with it, before my brain explodes in a rainbow of colors
prideslayer Posted July 4, 2014 Posted July 4, 2014 Â Ok, now whats a single "|" mean? Â Binary/bitwise OR. Gamebryo scripting doesn't support bitwise operators, as far as I know. Â It doesn't natively, but NVSE added it. I doublechecked and it's there, and I have been actively using it for some time to apply the inuse flag bitmask to variable04.
Guest Posted July 5, 2014 Posted July 5, 2014  Yeah, it works just fine with objects, but not with character's X angle (-90 to 90 degrees). Works fine with Z axis though.Yep, working on timer right now. Trig functions are used to find X angle. set iUnits to player.GetDistance ffTarget set posZ to ffTarget.GetPos Z set playerZ to player.GetPos Z set offsetZ to posZ - playerZ set gg to 0 - (offsetZ/iUnits) set arctan to tan gg 1 player.setangle x arctan  Not sure what you achieve there, but if you're going to find the X-heading angle to the player on a certain ref, I would be interested in understanding more. My formula implies both sin and sqrt, yours only arctan >>> should be definetely faster
Xilandro Posted July 5, 2014 Posted July 5, 2014 It's fast, but not accurate enough, so I have a lot of manually added numbers into the script =\
Xilandro Posted July 5, 2014 Posted July 5, 2014 X-heading angle to the player on a certain ref exactly. Btw, it will be great if you can share your code, I would love to see it, bc arctan is the only way I found how to implement it =\
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now