PDA

View Full Version : Item ID



kyuzo
02-10-2010, 08:18 AM
I'm playing around with dp's item info Node, using the Item ID to affect the colour of a surface. Everything was going well, until I noticed that soem combination of cloning produces an item number with a letter rather than just digits...

For example, I get loads of items loaded as:
LoadObjectLayer 1 10000000
LoadObjectLayer 1 10000001
LoadObjectLayer 1 10000002, etc...
But I have also found I am geting some objects loading as:
LoadObjectLayer 1 1000000b
LoadObjectLayer 1 1000000c, etc..

These objects don't play ball with the Item ID node, so I'd like to know how to avoid creating them.

I haven't been able to work out reliable steps to reproduce this yet, but wondered if any scripting folks can shed any light...

cheers,

Derek

Sensei
02-10-2010, 08:42 AM
Item id is not decimal, but hexadecimal. Valid digits are 0...9 and a...f. a = 10, b= 11, etc. until f.

kyuzo
02-10-2010, 08:55 AM
Ahhhh.. that makes sense now. Cheers sensei..

So is there any way to make DPs Item ID to make use of the IDs with letters in them?
Like some way within nodes to convert a hexadecimal ID number to a decimal?

This isn't causing any production problems, I'm just playing around with some new ideas...

Derek

Sensei
02-10-2010, 09:16 AM
It doesn't matter whether you write f.e. 240 or 0xF0 or $F0 or %11110000, it's still the same value regardless of visual presentation.
Use scientific calculator to convert hex to dec and vice versa. Built-in WinXP calculator is fine, just enable extended mode.

With ItemID/Clone Index people usually use gradient. Different id, different color/scalar which is driving some other stuff.

I have never used DP, but TrueArt's Node Library http://www.trueart.eu Extended Item Info has Clone Index, that's extracting digits from cloned item name, and give it back in Node Editor. This way they start at 1. If you have couple cloned source objects, they will be in same range, and you won't have to remember from what values they start as ItemID.

Lightwolf
02-10-2010, 09:30 AM
They should work absolutely fine with it. The object IDs are saved as a hexadecimal number, and those are represented as digits from 0 to 9 and a to f.

http://en.wikipedia.org/wiki/Hexadecimal

Cheers,
Mike

kyuzo
02-10-2010, 10:04 AM
Thanks for the replies guys,

Here's a screen grab of what I have set up. As you can see, the cloned items that have a letter as part of their ID are just shaded in the lowest value in the gradient.

Maybe I'm doing something wrong..?

I'll take a look at TrueArt's node library. Thanks for the link sensei.

Derek

Sensei
02-10-2010, 10:49 AM
ItemID is integer, but Gradient takes floating point as input. So your 0x1000000 is in dec 268435456. Subtract it from ItemID and it'll give you value 0.

Lightwolf
02-10-2010, 10:51 AM
ItemID is integer, but Gradient takes floating point as input. So your 0x1000000 is in dec 268435456. Subtract it from ItemID and it'll give you value 0.
Either that or try the Extended Spot Info which is a part of the free db&w Tools, it provides you with a slightly different set out item ID based outputs.

Cheers,
Mike

kyuzo
02-11-2010, 03:16 AM
Cheers Mike, that Extended Spot Info did the trick - exactly what I was expecting first time around!

But just for my own curiosity sensei, can you explain again what I subtract from what for the other node? From what you wrote I think I should be subtracting 268435456 from the ItemID, then plugging the result into the gradient input...? I tried that, but didn't get any colour variation in the objects...

Thanks,

Derek

Lightwolf
02-11-2010, 03:36 AM
Cheers Mike, that Extended Spot Info did the trick - exactly what I was expecting first time around!
Great.


But just for my own curiosity sensei, can you explain again what I subtract from what for the other node? From what you wrote I think I should be subtracting 268435456 from the ItemID, then plugging the result into the gradient input...? I tried that, but didn't get any colour variation in the objects...
10000000 is the id of the first object. That's hex, in decimal it's 268435456.
Basically, the object ID is a 32-bit value, and the higher bits define what kind of item it is: object, bone, camera or light.
If you look at the same value in binary it's:
0001 0000 0000 0000 0000 0000 0000 0000 (there you go, 32bits all lined up).
As you can see, the upper 4 bits are used to designate the item type.

The Extended Spot Info just removes those bits (and fiddles some more for the other outputs).

Cheers,
Mike

Sensei
02-11-2010, 03:53 AM
I can only speak about my own TrueArt's Node Library Extended Item Info and Extended Spot Info, because I don't have neither d&b tools nor Dpont nodes. So, if you have ItemID in its natural form like it's in LightWave and LWS text file like 0x10000000, then you have to take it and subtract from it 0x10000000 (dec 268435456) to receive 0. Then it's connected to Gradient Input, with some colors assigned to 0.0, 1.0, 2.0 etc. and connect output to f.e. Diffuse Shading.
I have just tried it, and worked no problem. ItemID with 0x10000000 gave me red, 0x10000001 yellow, 0x10000002 green. As expected.
But universal form ItemID, is not human friendly as you noticed- that's why TrueArt's Node Library Extended Item Info has Clone Index output, which is extracting number of duplicated item (the same which you see clicking in Layout viewport item).

Why there is 0x10000000? Because it means that item is mesh object. Lights have 0x20000000, bones 0x40000000 and cameras 0x30000000.
My nodes work with all of them. That's why ItemID is untouched.

If you can't use Clone Index, instead of remembering 268435456, you can just write 2^28 in Subtract, or in Gradient directly.

kyuzo
02-11-2010, 04:47 AM
Much appreciate the explanations guys... I now know far more about hexadecimal numbers than I did before! (which I appreciate, compared to you two is still probably sod all..)

Sensei, I managed to get your nodes doing what I wanted too, I hadn't realised that I needed to plug your spot info 'item' node in... that was the missing link, and why I wasn't getting any colour variation.

Thanks again! :thumbsup:


Derek

kyuzo
02-11-2010, 04:52 AM
Oops.. update... I just realised that I shaould have been using sensei's Extended SPOT Info node. Doh. I was using the Extended ITEM info.

That didn't help... :)

Lightwolf
02-11-2010, 04:52 AM
Much appreciate the explanations guys... I now know far more about hexadecimal numbers than I did before! (which I appreciate, compared to you two is still probably sod all..)
We didn't mention nibbles yet, did we ? ;)
(A nibble is, obviously, half a byte. Which makes it 4 bits assuming the current standard 8 bits per byte. And yes, every digit in the binary number shown below is a bit).

Cheers,
Mike

Sensei
02-11-2010, 05:42 AM
Sensei, I managed to get your nodes doing what I wanted too, I hadn't realised that I needed to plug your spot info 'item' node in... that was the missing link, and why I wasn't getting any colour variation.


Extended Item Info is working with what is picked up in pop-up control in GUI- double click node to show window with options. Otherwise it's working with what is put in input ItemID. Which can be other Extended Item Info, Extended Spot Info or anything which has LWItemID output.