ruchit
Hi, First of all i m newbie to Maya API (C++) and want to start learning API. In step one i ve decide to make custom poly primitive command(Capsule). Below is pseudo code for generating capsule vertex
with given radius, height & subdivision Attr.

Now tell me how to write down plugs for this??

i chck polyPrimitiveCmd.cpp in example files but it's hard to understand.


Code:

import math
def drawCapsule(radius, slices, sphStacks, cynStacks ):
    #Slice = Subdivision axis
    #sphStacks = Subdivision Height (Hemi-Sphere)
    #cynStacks = Subdivision Height (Cylinder)
    pi = 3.1415926535897932384626433832795
    twoPI = 2.0 * pi
    PID2 = pi / 2.0
    height = 1.0
  ##########################################
    #Top HemiSphere
    ##########################################
    for i in range(0, (((sphStacks+1)/2)+1), 1):
        # V texture coordinate.
        V = i / sphStacks
        phi = V * pi;
        for j in range(0, (slices+1), 1 ):
            # U texture coordinate.
            U = j / slices
            theta = U * twoPI
            X = cos(theta) * sin(phi)
            Y = cos(phi) + (height/2)
            Z = sin(theta) * sin(phi)
            mc.polySphere(n='uvSphere', r=0.01)
            mc.move(X,Y,Z)
    
    #########################################
    #Cylinder
    #########################################
    deg = 360.0/slices
    hSize = height/cynStacks
    X=Y=Z= height/2.0
    for i in range(0, (cynStacks+1), 1):
        for j in range((slices-1), -1, -1):
            angle = deg * j / 180.0 * pi
            X = cos(angle)
            Z = sin(angle)
            mc.polySphere(n='uvSphere', r=0.01)
            mc.move(X,Y,Z)
        Y -= hSize
    ##########################################
    #Bottom HemiSphere
    ##########################################
    for i in range((((sphStacks+1)/2)), (sphStacks+1), 1):
        # V texture coordinate.
        V = i / sphStacks
        phi = V * pi;
    
        for j in range(0, (slices+1), 1 ):
            # U texture coordinate.
            U = j / slices
            theta = U * twoPI 
            
            X = cos(theta) * sin(phi)
            Y = cos(phi) + (-height/2)
            Z = sin(theta) * sin(phi)
            mc.polySphere(n='uvSphere', r=0.01)
            mc.move(X,Y,Z)
  

drawCapsule(5.0, 30.0, 30.0, 5.0 )
Quote 0 0
pshipkov
I am not sure what you want to do here.
You want to create a new Maya primitive that represents polygonal geometry, or just want to create a poly capsule object ?
If looking for option 2 then just use polyCylinder and make the caps round - there is an option for that.
If option one - ugh, you are in for a ride !
Quote 0 0
ruchit
Trying first option (new Maya primitive).
Quote 0 0
pshipkov
ughh, don't do that :)
use a proxy locator and draw things there.
Quote 0 0

Add a Website Forum to your website.