Hi !
I looking for to create a little script who makes planes around my bounding box : like this picture ...
http://img15.hostingpics.net/pics/230428bboxplane.jpg
I don't need the top and bottom plane.
And I need too another script can attach all mesh together without lost Texture Information.
Someone know how I can do this?
Regards
Kasimashi
By
Comments (17)
Comment policy
One of the textures can be saved. You have tochoos which one.
:)
Works perfectly thanks you :)
But what about Attach all mesh ?
How exactly do you want to preserve the textures? If you have a Box and in the diffuse slot you have bitmap with texture - "forest.jpg",and you have a Sphere with the bitmap with texture -"rain.jpg" in the diffuse slot, when you attach the Box and the Sphere w\ich of the bitmaps should be assigned to the diffuse slot of the new object?
Ok !!!!!
Ok That why the initial texture is lost !!! :D ok ! :D
Thanks you !!! :D
Have a nice day :)
Regards
Kasimashi
Try this:
A better method to detect the plane width and length can be added, but I don't have time right now.
As planes:
Now you have both versions complited
fn createBoxAsCage obj = if isValidNode obj do
(
local bb = in coordsys local nodeLocalBoundingBox obj
local wX = abs((bb[1]-bb[2]).x) , lY = abs((bb[1]-bb[2]).y) , hZ = abs((bb[1]-bb[2]).z)
local cage = convertToPoly (box width:wX length:lY height:hZ mapcoords:on name:"Cage" wirecolor:black)
CenterPivot cage
local tm = obj.transform
tm.row4 = obj.center
cage.transform = tm
polyop.deleteFaces cage #{1,2}
local mtlArr = #()
for m = 4 to 1 by -1 do
(
id = (polyop.getFaceMatID cage m) - 2
side = ("Side_"+m as string)
polyop.setFaceMatID cage m id
polyop.detachFaces cage #{m} delete:true asNode:true node:boxAsCage name:side
(getnodebyname side).material = standard name:("Mtl_" + m as string) diffuse:(random black white)
CenterPivot (getnodebyname side)
)
delete cage
)
-- example
delete objects
tea = Teapot pos:[20,50,30] dir:[0.616459,-0.51929,0.591875] scale:[.8,.8,.8]
createBoxAsCage tea
Hey Kostadin,
you left over one dead geometry using detach method, because after detaching all four faces main object stay dead. :)
Yep. :) I forgot it. :)
:p
Thanks ! but last thing :) It's standard primitive plane not a editable poly :)
Regards Friend !
Hey dude you are not serious. Next time be more specific. On this forum I already write snippet for plane aligment. You need to find this by yourself.
I'm really Sorry :(
Yes but don't work correctly, the plane have not exactly the same dimension than face :(
look : http://img15.hostingpics.net/pics/217522exempledontwork.png
(green : default box with you script you have been write)
(yellow : the script wrote before a few month ago )
Regards
Kasimashi
Thanks !!!!
Thanks you miauu and barigazy but I need 4 Planes :) I don't need a box :p How can I detach face ?
Thanks again for your help !
What about "attach all mesh"?
Regards friend!
Local BBox of the selected object or world bbox?
This is for world bbox:
It will create a editable poly box around your object. If you want planes - detach the faces of the created box.
What is texture information?
:)
A bit acurate. This time I will consider object orientation, scale and mtlID's
fn createBoxAsCage obj = if isValidNode obj do
(
local bb = in coordsys local nodeLocalBoundingBox obj
local wX = abs((bb[1]-bb[2]).x) , lY = abs((bb[1]-bb[2]).y) , hZ = abs((bb[1]-bb[2]).z)
local cage = convertToPoly (box width:wX length:lY height:hZ mapcoords:on)
CenterPivot cage
local tm = obj.transform
tm.row4 = obj.center
cage.transform = tm
polyop.deleteFaces cage #{1,2}
local mtlArr = for m = 1 to 4 collect
(
local id = (polyop.getFaceMatID cage m) - 2
polyop.setFaceMatID cage m id
standard name:("Mtl_" + m as string) diffuse:(random black white)
)
cage.material = Multimaterial materialList:mtlArr
cage
)
-- example
delete objects
tea = Teapot pos:[20,50,30] dir:[0.616459,-0.51929,0.591875] scale:[.8,.8,.8]
createBoxAsCage tea
Your code works with local bbox, mine with world bbox, so he can combine both methods.
Yup. Both solutions are good
Regards friend!