Skip to content

Commit

Permalink
Merge pull request #192 from TrevisanGMW/dev-feature/minor_updates
Browse files Browse the repository at this point in the history
Dev feature/minor updates
  • Loading branch information
TrevisanGMW authored Sep 27, 2023
2 parents 8affaed + 93d0378 commit 07f75c5
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gt/utils/data/py_meshes/scale_volume.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Parametric Mesh Creation Scripts (Meshes with Logic or extra components)
Parametric Mesh Creation functions for Scale and Volume meshes (Meshes with Logic or extra components)
"""
from gt.utils.iterable_utils import round_numbers_in_list
from gt.utils.data.py_meshes.mesh_data import MeshData
Expand Down
74 changes: 74 additions & 0 deletions gt/utils/data/py_meshes/scene_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
"""
Parametric Mesh Creation for Scene Setup
"""
from gt.utils.data.py_meshes.mesh_data import MeshData
import maya.cmds as cmds
import logging

# Logging Setup
logging.basicConfig()
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)


def create_studio_background(name="studio_background", initial_scale=1):
"""
Creates a studio background mesh
Args:
name (str, optional): The name for the created mesh.
initial_scale (int, float, optional): Sets the initial scale of the mesh object
"""
selection = cmds.ls(selection=True)
plane_transform, poly_plane_node = cmds.polyPlane(name=name, w=1, h=1, sx=10, sy=10, ax=(0, 1, 0), cuv=2, ch=1)

# Set attributes for the poly plane
cmds.setAttr(f"{poly_plane_node}.height", 40)
cmds.setAttr(f"{poly_plane_node}.width", 40)
cmds.setAttr(f"{poly_plane_node}.subdivisionsHeight", 50)
cmds.setAttr(f"{poly_plane_node}.subdivisionsWidth", 50)

cmds.rename(poly_plane_node, f'{name}_polyPlane')

# Create a bend deformer and set its attributes
bend_node_one, bend_handle_one = cmds.nonLinear(plane_transform, name=f'{name}_bendY', typ="bend",
lowBound=0, highBound=1, curvature=90)

cmds.rotate(0, -90, 0, bend_handle_one, r=True, os=True, fo=True)
cmds.rotate(0, 0, 90, bend_handle_one, r=True, os=True, fo=True)

bend_node_two, bend_handle_two = cmds.nonLinear(plane_transform, name=f'{name}_bendZ', typ="bend",
lowBound=-1, highBound=1, curvature=110)

bend_handles = [bend_handle_one, bend_handle_two]

cmds.rotate(0, -90, 0, bend_handle_two, r=True, os=True, fo=True)
cmds.rotate(-90, 0, 0, bend_handle_two, r=True, os=True, fo=True)
cmds.move(0, 0, 7, bend_handle_two, r=True)

cmds.parent([bend_handle_one, bend_handle_two], plane_transform)

cmds.move(0, 0, -10, plane_transform, r=True)
cmds.xform(plane_transform, piv=(0, 0, 11), ws=True)
cmds.move(0, 0, 0, plane_transform, a=True, rpr=True) # rpr flag moves it according to the pivot

for handle in bend_handles:
cmds.setAttr(f'{handle}.v', 0)

cmds.setAttr(f'{plane_transform}.sx', initial_scale)
cmds.setAttr(f'{plane_transform}.sy', initial_scale)
cmds.setAttr(f'{plane_transform}.sz', initial_scale)

cmds.select(clear=True)
if selection:
try:
cmds.select(selection)
except Exception as e:
logger.debug(f'Unable to recover selection. Issue: {str(e)}')

return MeshData(name=plane_transform, setup=bend_handles)


if __name__ == "__main__":
logger.setLevel(logging.DEBUG)
cmds.file(new=True, force=True)
create_studio_background()
3 changes: 2 additions & 1 deletion gt/utils/mesh_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
Mesh (Geometry) Utilities
github.com/TrevisanGMW/gt-tools
"""
from gt.utils.data.py_meshes import scale_volume, scene_setup
from gt.utils import system_utils, iterable_utils
from gt.utils.data.py_meshes import scale_volume
from gt.utils.data_utils import DataDirConstants
from collections import namedtuple
import maya.cmds as cmds
Expand Down Expand Up @@ -665,6 +665,7 @@ def __init__(self):
# Creatures/Bipeds
scale_human_male = ParametricMesh(build_function=scale_volume.create_scale_human_male)
scale_human_female = ParametricMesh(build_function=scale_volume.create_scale_human_female)
studio_background = ParametricMesh(build_function=scene_setup.create_studio_background)


def print_code_for_obj_files(target_dir=None, ignore_private=True, use_output_window=False):
Expand Down

0 comments on commit 07f75c5

Please sign in to comment.