PDA

View Full Version : polyop + smoothinggroups

 STINGRAY_AUT01-13-2008, 06:40 PMHi Everybody, i need your help, as i can't figure out how to set different smoothinggrups on an editable poly ... here is a simple script, that generate 9 surfaces, which i want to assign different smoothinggroups. it works fine as long as the line "polyop.setFaceSmoothGroup obj poly i add:false" is deleted. Would be fine, if someone could give me some glue on how to get the smoothing groups working ... Markus PoAr = #() FaAr =#() Fa =#() Cou = 0 obj = editable_mesh name:"test" convertto obj editable_poly for i = 1 to 10 do ( Px = i * 10 Py = 0 Pz1 = 0 Pz2 = 10 Po1 =[Px,Py,Pz1] Po2 =[Px,Py,Pz2] cou = Cou+1 append PoAr Po1 if i < 10 do ( Fa[1] = cou Fa[2] = Cou +1 ) cou = Cou+1 append PoAr Po2 if i < 10 do ( Fa[3] = cou + 2 Fa[4] = Cou + 1 ) append FaAr Fa Fa =#() ) for i = 1 to PoAr.count do ( polyop.createVert obj PoAr[i] ) for i = 1 to FaAr.count do ( poly = polyop.createPolygon obj FaAr[i] polyop.setFaceSmoothGroup obj poly i add:false )
Pjanssen
01-13-2008, 07:22 PM
Did you realise that the setFaceSmoothGroup operation takes a binary input?
So say smoothing group 1 and 2 would mean you set it to 3 (1 + 2). For just smoothing group 3, set it 4. For smoothing group 1, 2 and 3, set it to 7. Etcetera.

STINGRAY_AUT
01-14-2008, 07:43 PM
okay, thats one point i didn't realized until now, thanks you very much Pier...

but there is on thing i don't understand:

this is the error message it get from max : -- Runtime error: Cannot convert value to bitArray: undefined

this means to me, i should convert my value for the smoothinggroup to a bitarray, but i got no glue how to manage this ....

any suggestions ???

U.S.S. Speed
01-15-2008, 02:33 AM
Huh... The error say the value is undefined... If I'm not mistaken.

So, you should have a proper integer or float to be able to convert it to a bitArray.

Avatarye
01-15-2008, 08:39 AM
I got same problem like STINGRAY_AUT's. I got 4 groups of face in a object, then used a for loop to assign 1 to 4 SG to each face group respectively. But what I got was group 1's SG is 1234, group 2's was 123, 3 was 12 and 4 is 1. Before I accidently saw this thread here, I had no idea that SG needs a binary input and it's not mentioned by the MAXScript help. Pjanssen, could you please explain this with more details? THANKS!!

U.S.S. Speed
01-15-2008, 11:40 AM
You can easily find the binary value with the function Bit.set.

Example, you want to set the bit 25 to true...
You do :

bit.set 0 25 True

It return the integer value when you turn the 25th bit to true using the value 0 as base.

It would return : 16777216

Now imagine I want to add the bit 31 to the above value...

bit.set 16777216 31 True

It would return : 1090519040
That number means the 25th and the 31th bit are true.

Pjanssen
01-15-2008, 03:25 PM
And what can also be useful for testing is this function:

function getBitsAsArray bits = (
arr = #{}
for i = 1 to 32 do (
arr[i] = bit.get bits i;
)
return arr;
)

it returns a byte value split out into a bytearray. So you can see which bits are set.

STINGRAY_AUT
01-15-2008, 05:33 PM
cool explainations, and looking at them isolated, they make sense to me...., but i'm simply not able to transform this to the smoothing group issue

when i look at the line

when i want to assign smoothinggroup 4, what must SMG be ?

maybe i'm just to stupid for such kind of tasks..

anyway, thank you very much for spending your time on my problem

Markus

Pjanssen
01-15-2008, 09:19 PM
For just smoothing group 4, you have to set the fourth bit of your input. Look at it like this:
4 3 2 1 <- Bit number, or smoothing group if you wish.
8 4 2 1 <- Bit value.
1 0 0 0 <- Bits set. Smoothing group 4.
Resulting integer: 8
1 0 1 0 <- Smoothing groups 4 and 2
Resulting integer: 10 (8 + 2)
1 1 1 1 <- Smoothing groups 1 to 4 set.
Resulting integer: 15 (8 + 4 + 2 + 1)

I'm saying this without reference, so please check this in the maxscript help, but are you sure you input a bytearray for the polygon set?
Try something like this on a mesh with 1 polygon first:
Where of course you have the object it should be applied to selected.

Avatarye
01-15-2008, 11:27 PM
Thanks, Pjanssen, thank you, U.S.S. Speed and thanks to you, STINGRAY_AUT, for raising the right question at right timing :). Now I totally understand, and my script works now. THANK YOU GUYS!!

STINGRAY_AUT
01-16-2008, 12:16 PM
okay ... i finally got it ....
Thank you guys very much !

Markus

CGTalk Moderation
01-16-2008, 12:16 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.