Author Archives: happyneal

linkedChainPreview

Autogenerate Chainlinks Along Curve

Well modeling chains can be tedious, so here we go, a small script that creates a chained link for a provided curve

'''
Linked Chain

Creates a Torus like object, links them together as linked Chain and positions the chain along a curve

Example:
1. Select a curve in Maya
2. Execute command:

Poly_Linked_Chain(radius = 1, sectionradius =0.1, extrude = 1, variation = 20, name="chain").createChainForSelectedCurve()

Created on May 7, 2013

@author: Neal Buerger www.nealbuerger.com
'''
import pymel.core as pm
import random

class Poly_Linked_Chain:
    
    def __init__(self, **kwargs):
        """
        Accepts following Keywords:
        radius: of the Torus created (Default 1)
        sectionradius: of the Torus (Default 0.1)
        extrude: length of the torus extrusion (Default 0)
        variation: along the rotation of the linked elements (Default 0)
        name: name of the chain (Default chain)
        """
        
        self.radius = kwargs.get("radius" ,1)
        self.sectionradius = kwargs.get("sectionradius" ,0.1)
        self.extrude = kwargs.get("extrude" ,0)
        self.variation = kwargs.get("variation" ,0)
        if self.variation < 0:
            self.variation = abs(self.variation)
        if  self.variation > 45:
            self.variation = 45
        
        self.name = kwargs.get("name" , "chain")
        self.name = self.name + str(len(pm.ls(regex= "%s\d*" % self.name))+1)
        
  
   
    def createLink(self):
        """
        creates a Torus and extrudes half of it
        To be used as alternative to a provided geometry
        
        """
        basechain = pm.polyTorus(radius = self.radius, sr = self.sectionradius, tw= 0, sx = 20, sy = 20, ax = (0,1,0), ch = 1)[0]    
        if self.extrude is not 0:
            faces = []
            for j in basechain.vtx:
                if j.getPosition()[0] > 0:
                    faces.append(j.connectedFaces())
            pm.polyExtrudeFacet(faces, translateX=self.extrude)
        return basechain
        
    
    def makeChain(self, obj, linklenght, chainlenght, preserveObj = False):
        """
        Uses provided geometry to create a straight chain
        
        obj: object to be used for the chain
        linklenght: lenght of the obj
        chainlenght: number of links that are created
        """
        if preserveObj:
            obj = pm.duplicate(obj, un=True)[0]
        pm.move(obj, 0,0,0)
        chain = [obj]
            
        rotValue = 0
        for i in range(1, chainlenght):
            obj = pm.duplicate(chain[0])[0]
            rotValue += 90 + random.randint(-self.variation, self.variation)
            if rotValue >= 360:
                rotValue -= 360
            pm.rotate(obj, [rotValue, 0, 0])        
            distance = linklenght * i
            pm.move(obj, distance,0,0)
            chain.append(obj)
        return chain
    
    def rigChain(self, chain):
        """
        takes chain and adds joints and a smooth bind to rig it
        
        chain: list of objects 
        """
        pm.select(deselect = True)
        jnts = []
        for obj in chain:
            pos = obj.translateX.get(), obj.translateY.get(), obj.translateZ.get()
            jnt =  pm.joint(p = pos)
            jnts.append(jnt)
            pm.rename(jnt, self.name + "_joint%d" % len(jnts))
        linked = pm.polyUnite(chain, ch = 0)[0]
        self.name = pm.rename(linked, self.name)
        pm.skinCluster(linked, jnts[0])
        return jnts
    
    def addClusterHandles(self, crv):
        """
        Adds Cluster Handles to Curve for every cv
        """
        for i in crv.cv:
            pm.parent(pm.cluster(i), crv)
    
    def createChainForCurve(self, crv, obj = None, linklenght = 1):
        """
        Uses the Curve and creates a chain based on the object that is passed into the function
        
        crv = curve to be used
        obj = object to be used
        linklength = lenght of the obj
        """
                
        if obj is None:
            obj = self.createLink()
            linklenght = (2*(self.radius - self.sectionradius*2)+self.extrude)
        chainlenght = int(pm.PyNode(crv).length()/linklenght)
        chain = self.makeChain(obj = obj, linklenght = linklenght, chainlenght = chainlenght)
        jnts = self.rigChain(chain)
        
        ik = pm.ikHandle( startJoint=jnts[0], endEffector=jnts[-1], solver='ikSplineSolver', createCurve=False, curve=crv)[0]
        pm.rename(ik, self.name + "_ikHandle")
            
        ctrlgrp = pm.group(jnts[0], ik, n = "%sctrl_grp" % self.name)
        ctrlgrp.v.set(False)
        pm.group(crv, self.name, ctrlgrp, n = "%s_grp" % self.name)
        
        self.addClusterHandles(crv)
        pm.select(deselect = True)
        
        return self.name
    
    
    def createChainForSelectedCurve(self):
        """
        Creates Chains for selected curves
        """
        return [self.createChainForCurve(i) for i in pm.ls(sl =True, tr=True) if pm.nodeType(i.getShape()) == "nurbsCurve"]
        
    
    def deleteRig(self, name):
        """
        Removes Rig from geometry
        
        name: name of geometry
        """
        parent = pm.PyNode(name).getParent()
        pm.delete(name, ch = True)
        pm.parent(name, w = True)
        pm.delete(parent)
        
        
maya-2014-banner-lockup-286x66

Maya 2014 and Bonus Tool Update

Maya 2014 Trial Download

The new version of Maya has been released and it has the NEX modelling tool-set integrated.

Download: http://www.autodesk.com/products/autodesk-maya/free-trial

Bonus Tools 2014

As usual a new updated version of the bonus tools is available.

More information: http://area.autodesk.com/bonus_tools

Download (from Autodesk Exchange): http://apps.exchange.autodesk.com/MAYA/Detail/Index?id=appstore.exchange.autodesk.com%3aautodeskmayabonustools2014%3aen

inspiron15r

How to buy a Dell Laptop (Germany)

Yes, you need a guide to buy a Dell laptop — and Dell is wondering why nobody is buying their products. Well this is a guide to buy a laptop, not a post-pc touch device.

Choosing the Laptop Series

The first step is to figure out the technical specifications and what kind of laptop you want to have.

You can choose as a normal person from the Laptops available from “Privatkunden” (If you are representing a school etc. other benefits are also available, for simplicity we will just go with a average consumer).

Currently all 14” Laptops have a HD+ display and all 15” Laptops have a FullHD (1920×1080) display.

In this category there are two product lines: The cheaper Inspiron series and the more expensive XPS line (Only the XPS 14 and XPS 15 are Laptops, all other Models in the series are touch devices).

If you do not find a suitable laptop you also can look in the “Mittelstand” Category (However sales tax has to be added to the price)

Getting the best deal

Ok choosing the Laptop series was the easy part. To get the best deal you got to use coupons. In many cases you save 100Eur or more, or you get a laptop with better technical specifications for a lower price. Coupons are even available for laptops that are currently on sale.

So where do you get these Coupons? For one they are located on the top of the website. (Usually you just scroll down and miss them)

Dell Screenshot1

Location of the Coupons

In addition coupons are available when you subscribe to newsletters. Specialized sites like http://dell.awardspace.info/ collect and display current coupons available. (When you scroll all the way down on that site you can select your series laptop and the various coupons are then displayed)

When buying the laptop, you have to try out different combinations of the available coupons to get the best deal.

You usually only can apply a single coupon for a laptop. However, an independent coupon to discount the shipping costs is usually available.

When all is said and done, the price of the laptop is reduced by 100-200eur, making it competitive to laptops available in stores or Amazon. Frankly, I believe if Dell would simply apply their coupons directly and not have customers go on a coupon hunt they would sell more laptops.

BevelHardEdges

Polygon Bevel Hard Edges Script

When working with polygons, it is helpful to bevel all hard edges to have a non-CG look.

This basic script bevels the hard edges on all selected objects.

import pymel.core as pm

def obj_is_poly(obj):
    #Evaluates if Object is Polygon
    return pm.nodeType(obj) is "mesh"

def bevelHardEdges(obj, offset = 0.5, segments = 1):
    if obj_is_poly(obj):
        pm.select(obj)
        pm.polySelectConstraint( m=3, t=0x8000, sm=1 ) # to get hard edges
        pm.polyBevel(offset = offset, segments = segments,autoFit = True, offsetAsFraction = True, fillNgons = True)

def bevelHardEdgesOnSelected():
    for item in pm.selected():
        bevelHardEdges(item.getShape())

bevelHardEdgesOnSelected()