Answered step by step
Verified Expert Solution
Question
1 Approved Answer
If anyone could show me the code for this I would really appreciate it. The code is supposed to be done in Visual Studio Code
If anyone could show me the code for this I would really appreciate it. The code is supposed to be done in Visual Studio Code (as a python file) and sent to Maya.
This is what I have so far from the lecture. Thank you so much in advance
Challenge 7 - part 1 Amend the code we used in class to create trees with a random y scale (hint use random.random()). If the y scale is smaller than 0.3 then set the y scale to be 0.3 You will need to figure out how much to translate it in y to fit on the tree trunk Get this working for 5 trees If the trees overlap a bit that's okay You can move them by hand by selecting the GROUP and pressing Wand then dragging around the axis Now show me 100 trees on a 200 by 200 grid Hint you should just have to change ONE VALUE Mbu Shippin iis ma Now show me 2000 trees on a 500 by 400 grid This time you will want to make three small changes It may take a little time to draw 2000 trees. import random print(random.randint(3, 9)) print (random.random()) # Lets say my "forest" is 20 by 20 #lets place some trees. # lets make a tree from a cylinder and a sphere # We can use random to set the positon leaves = cmds.polysphere(r = 3, n=' leaves') cmds.move(0, 5.5, 0, leaves) trunk = cmds.polycylinder (r = 1, h=6, n='trunk') tree = cmds.group( 'leaves', 'trunk', n='tree' ) cmds.move(0, 3, 0, tree) # okay lets be more efficient leaveRadius = 5 trunkRadius = 1 trunkheight = 9 yTranslateTree = trunkheight/2 Leaves = cmds.polysphere(r = leaveRadius, n='Leaves') cmds.move(0, trunkHeight-.05, 0, leaves) trunk = cmds.polycylinder (r = trunkRadius, h=trunkHeight, n='trunk') tree = cmds.group( 'leaves', 'trunk', n='tree' ) cmds.move(o, trunkHeight/2, 0, tree) # We now have all the tools to make a forest! # we can write a while loop = let's start with 5 trees numberOfTrees = 5 trees import maya.cmds as cmds import random # do a new scene first or the names will get messed up # We can write a while loop = let's start with 5 trees numberof Trees = 50 trees while treesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started