About this site
ScriptSpot is a diverse online community of artists and developers who come together to find and share scripts that empower their creativity with 3ds Max. Our users come from all parts of the world and work in everything from visual effects to gaming, architecture, students or hobbyists.
Comments
Realworld Scale Unwrap
Found a script by Igor Znag.
Select all vertices in Unwrap and then apply script.
macroscript unwrap_uvw_real_world_map_size category:"_igorznag" buttontext:"RWMS"
(
if selection.count==1 then
(
obj=selection[1]
if superclassof obj==GeometryClass then
(
m=undefined; m_count=0
for i=1 to obj.modifiers.count where classof obj.modifiers[i]==Unwrap_uvw do (m=obj.modifiers[i]; m_count+=1)
if m!=undefined then
(
if m_count==1 then
(
obj_mesh = snapshotasmesh obj
n=obj_mesh.numfaces
if n>0 do
(
mesh_area=meshop.getFaceArea obj_mesh #{1..n}
uv_area=0
for i=1 to obj_mesh.numfaces do
(
tv_face=getTVFace obj_mesh i
v1=getTVert obj_mesh tv_face[1]; v2=getTVert obj_mesh tv_face[2]; v3=getTVert obj_mesh tv_face[3]
a=length (v2-v1); b=length (v3-v1); c=length (v3-v2); p=1.0*(a+b+c)/2
area_=sqrt(p*(p-a)*(p-b)*(p-c)); uv_area+=area_
)--for i=1 to obj_mesh.numfaces do
if uv_area!=0 do
(
n=m.NumberVertices(); aspect=sqrt (1.0*mesh_area/uv_area)
undo on
(
for i=1 to n do
(
vp=m.getVertexPosition 0 i; vp*=aspect; m.SetVertexPosition 0 i vp
)--for i=1 to n do
)--undo on
)--if uv_area!=0 do
)--if n>0 do
delete obj_mesh
)else "Select one geometry object with one Unwrap UVW modifier!"
)else "Select one geometry object with Unwrap UVW modifier!"
)else "Select one geometry object!"
)else "Select one object!"
completeredraw()
)--macro