Tue. Dec. 18th Scriptor Meeting

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Tue. Dec. 18th Scriptor Meeting // Collaboration

1  2  |  

Post by frootee // Dec 27, 2007, 6:35am

frootee
Total Posts: 2667
pic
Cool Thanks Délé!

Now if we can get a lot of colors, like we are supposed to, we'll be good to go! I don't understand why we only get 3 or 4 colors, instead of oh, 65 million. I am trying to generate a random value for R, G, and B, individually.


Yeah, that's pretty cool Froo! I hooked a timer event up to the script to animate it. Looks like Christmas lights. Nice job. :) It was actually easy on the CPU too. So it's a nice effect with little drain on the scene. Definitely could be a useful visual effect.

Post by Délé // Dec 27, 2007, 12:33pm

Délé
Total Posts: 1374
pic
I was messing around a bit with your idea here Froo. I thought maybe if I used random RGB values and then converted them to Hex it would work. Unfortunately I can't seem to figure out what the heck to assign to that "vizStrmData.color(i)".


Your method seems to produce a decimal number, which works but for some reason isn't getting all of the colors. I also tried that commented out hex number just below the vizStrmData.color(i) statement and that seems to work too. I tried a Hex triplet "FFFFFF" and it wouldn't work. I even tried putting the number sign in front like "#FFFFFF".


So apparently it has to be a straight number like you are producing or a hex number starting with 0x and then having 8 more numbers. :confused:


I really don't know much about hex. I read a little bit about it a long time ago but don't remember much. So I'm probably just missing something simple. Anyway, I did dig around on the internet and found some conversion code. So I whipped up a little RGB/Hex/Dec converter object. I'll post it below. It can convert user defined RGB to decimal and hexadecimal OR if the check box is checked, it can randomly produce correlating RGB, decimal, and hexadecimal numbers. Seeing as I'm kind of lost in this stuff, I'm not sure if it works properly or not. It looks like it is working right though.


As I said above, I tried using some of that conversion code in the torus script but I guess I wasn't producing proper color information. I really just can't figure out what kind of value I'm supposed to feed into that statement.


Anyway, perhaps you would be able to play with the conversion functions and figure out something that I'm missing.

Post by trueBlue // Dec 27, 2007, 12:38pm

trueBlue
Total Posts: 1761
pic
Over my head, but what if you were to change the Object's/Render Attributes/Point Color randomly?

Post by Délé // Dec 27, 2007, 12:45pm

Délé
Total Posts: 1374
pic
That certainly would be easier if you want all verts the same color. Froo is creating multi colored verts though. There is a loop and every time it loops it changes the next vert in the mesh to a different random color. I think that's what's happening anyway. All this hexadecimal stuff is a bit over my head as well. :o

Post by trueBlue // Dec 27, 2007, 1:52pm

trueBlue
Total Posts: 1761
pic
This is true but the point color does affect it. :)

Post by Délé // Dec 27, 2007, 2:01pm

Délé
Total Posts: 1374
pic
Hey, that's pretty cool trueBlue. It works like a multiplier. That could create some interesting effects too. :)

Post by frootee // Dec 27, 2007, 5:08pm

frootee
Total Posts: 2667
pic
HI Dele. Thanks for trying that out.

FFFF FFFF is actually a Negative number. The variable is apparently a signed integer. The First 'F' in this value is the Most Significant Digit. Change the F to a 7. Note the difference between F and 7 in binary:

F = 1111
7 = 0111

Note the '0' in the MSB (Most Significant Bit)?

I ran into this problem earlier also. I was planning on putting together a little tutorial on decimal, hex, and binary numbers, since it is important for scripting and C++ / C# programming.

In terms of scripting, we can use 0x7000 0000 (hex version) or 1879048192 (decimal version, without any preceding number system prefix) to represent the same number. The key to note is, if using hex numbers, we need the number system prefix: 0x. I suspect we could also use the octal number system or binary, as long as we use the right prefix. So yes, that script does generate a decimal value. You can probably display it as a hex value also I suppose.

Basically, with the hex number system, we can represent decimal numbers from 0-15 with a single digit, 0 - F. Also note, in binary:

15 (decimal) = 0F (hex) = 0000 1111 (binary)

if we add '1' to these, in hex and binary, we get a 'rollover situation:

16 (decimal) = 10 (hex) = 0001 0000 (binary)

just like, in the decimal system, when we add 1 to the number 09:

09 + 1 = 10

the decimal system is based on powers of 10 (decimal): possible values for each digit are 0 thru 9.
the hexadecimal system is based on powers of F (hex) / 16 (decimal): possible values for each digit are 0 thru F (0 thru 15 decimal)
the binary system is based on powers of 2: possible values for each digit are 0 or 1

I was using the hex version, since the RGB color value is represented as RR GG BB AA, and each color component has a range 0-255 (decimal), which is also 0-FF (hex). But it looks like we ran into a problem with using FF for the red component, since that appears to make the RGB value a negative number.


Froo

Post by frootee // Dec 27, 2007, 5:17pm

frootee
Total Posts: 2667
pic
Thanks trueblue. That is closer to what I am trying to achieve.

Post by frootee // Dec 28, 2007, 6:00am

frootee
Total Posts: 2667
pic
Thanks for your help guys.


Actually, I found that if we just set the Points Color in the Object Render Attributes panel in the LE to Black, we get very similar results as with trueblue's solution.


Black is RGB: 00 00 00 00


so when we generate our random colors, those color values are blended with the Points Color, as trueblue pointed out. So if we set the Points Color to pure black, the blended color is only our random colors we generated for the vertices.


If we set the Points Color to some other value, say blue, or Red, this serves as a 'blend factor' for our random colors. In other words, if we choose a red hue, then we will see random colors, but only in the red part of the spectrum. So we'll see variations of red, going between red, yellow, and orange.


Set that Points Color to Black to see what I mean. Cool!


Froo

Post by trueBlue // Dec 30, 2007, 10:21am

trueBlue
Total Posts: 1761
pic
Isn't Norm Cool! :)
Yet another Metaphor:

Post by frootee // Dec 30, 2007, 5:30pm

frootee
Total Posts: 2667
pic
Wow. Guess I'm about6 months behind and catching up ... :p
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn