Sunday, June 24, 2012

Synoptic View in Softimage using VBScript



Here is the link to the VBScript file for the synoptic view-

Download File

Here is the code-

<html>
<body version="2">
<script language="VBScript">


sub Select_All(in_obj,in_mousebutton,in_keymodifier)
dim sel
Set sel = GetValue("SelectionList")
set oRoot = Application.ActiveProject.ActiveScene.Root
set myObj = oRoot.FindChild(in_obj)
SelectMembers myObj.model & ".Key"
end sub


sub Deselect_All(in_obj,in_mousebutton,in_keymodifier)
DeselectAll
end sub


sub Reset_Pose(in_obj,in_mousebutton,in_keymodifier)
dim sel
Set sel = GetValue("SelectionList")
set oRoot = Application.ActiveProject.ActiveScene.Root
set myObj = oRoot.FindChild(in_obj)
ApplyAction myObj.model & ".mixer.ResetPose"
end sub


sub Key_All(in_obj,in_mousebutton,in_keymodifier)
dim sel
Set sel = GetValue("SelectionList")
set oRoot = Application.ActiveProject.ActiveScene.Root
set myObj = oRoot.FindChild(in_obj)
SelectMembers myObj.model & ".Key"
SelectChildNodes
SetMarking "MarkingSet"
SaveKey,GetValue ("PlayControl.Key")
SelectObj sel
end sub


sub Remove_All(in_obj,in_mousebutton,in_keymodifier)
dim sel
Set sel = GetValue("SelectionList")
set oRoot = Application.ActiveProject.ActiveScene.Root
set myObj = oRoot.FindChild(in_obj)
SelectMembers myObj.model & ".Key"
SelectChildNodes
SetMarking "MarkingSet"
RemoveKey,GetValue ("PlayControl.Key")
SelectObj sel
end sub


sub Hide_Ctrls(in_obj,in_mousebutton,in_keymodifier)
dim sel
Set sel = GetValue("SelectionList")
set oRoot = Application.ActiveProject.ActiveScene.Root
set myObj = oRoot.FindChild(in_obj)
SetValue myObj.model & ".Key.viewvis", 0
end sub


sub Unhide_ctrls(in_obj,in_mousebutton,in_keymodifier)
dim sel
Set sel = GetValue("SelectionList")
set oRoot = Application.ActiveProject.ActiveScene.Root
set myObj = oRoot.FindChild(in_obj)
SetValue myObj.model & ".Key.viewvis", 2
end sub


sub Head(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "head_control"
end sub

sub Neck_upper(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "neck_upper_control"
end sub

sub Neck_mid(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "neck_mid_control"
end sub

sub Neck_lower(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "neck_lower_control"
end sub



'---------------------------------------------
' Synoptic Select
'---------------------------------------------
function SynopticSelect (in_obj, inName)

    set oRoot = Application.ActiveProject.ActiveScene.Root
    set myObj = oRoot.FindChild(in_obj)
    if IsComponent(myObj.model & "." & inName) = False then
        logmessage "RigSynoptic: " & inName & " not found"
        SynopticSelect2 = False
    else  

    GetKeyboardState , modKey

    select case CByte(modKey)
   
        case 0 ' "Nothing Selected"
            SelectObj myObj.model & "." & inName  
        case 1 logmessage "Shift"      
            'check the object isn't already selected
            if checkCollision(myObj.model.FindChild(inName)) = False then  
                AddToSelection myObj.model & "." & inName  
            end if
          
        case 2 ' "Ctrl"
            ToggleSelection myObj.model & "." & inName  
        case 3 ' "Shift/Ctrl"  
            RemoveFromSelection myObj.model & "." & inName              
        case 4 ' "Alt"
            SelectObj myObj.model & "." & inName, "BRANCH", True
        case 5 ' "Alt/Shift"
            'check the object isn't already selected
            if checkCollision(myObj.model.FindChild(inName)) = False then
                AddToSelection myObj.model & "." & inName, "BRANCH", True
            end if
        case 6 ' "Alt/Ctrl"
            ToggleSelection myObj.model & "." & inName, "BRANCH", True
        case 7 ' "Alt/Shift/Ctrl"
            RemoveFromSelection myObj.model & "." & inName
    end select


    end if
end function

'---------------------------------------------
' Synoptic Select 2
'---------------------------------------------
function SynopticSelect2(in_obj, inName)

    set oRoot = Application.ActiveProject.ActiveScene.Root
    set myObj = oRoot.FindChild(in_obj)
    if IsComponent(myObj.model & "." & inName) = False then
        logmessage "RigSynoptic: " & inName & " not found"
        SynopticSelect2 = False
    else  
        SelectObj myObj.model & "." & inName, "BRANCH", True
    end if
end function

' Check Selection Collision  
'--------------------------------------
function checkCollision(inObj)
   
    dim sel, elem
    set sel = GetValue("SelectionList")
   
    SelectChildNodes
   
    for each elem in Selection
        if elem = inObj then
            checkCollision = True
            SelectObj sel
            exit function
        end if
    next
   
    checkCollision = False
    SelectObj sel
   
end function
'--------------------------------------

' Is Component
'--------------------------------------
function IsComponent(in_string)
   
    dim oRoot
    IsComponent = True
    set oRoot = Application.ActiveProject.ActiveScene.Root
    if typename(oRoot.FindChild(in_string)) = "Nothing" then IsComponent = False
   
end function


sub Right(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_arm_ctrl_parent"
end sub

sub Left_arm(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_arm_ctrl_parent"
end sub

sub Right_foot(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_foot_ctrl"
end sub

sub Left_foot(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_foot_ctrl"
end sub

sub Spine_upper(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "Spine_upper_ctrl"
end sub

sub Spine_mid(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "Spine_mid_ctrl"
end sub

sub Spine_lower(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "Spine_lower_ctrl"
end sub

sub COG(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "COG_parent"
end sub

sub Hip(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "Hip_ctrl"
end sub

sub IK_spine_upper(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "IK_Spine_upper_ctrl_parent"
end sub

sub IK_chest_handle(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "IK_chest_handle"
end sub

sub Ik_hip_handle(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "IK_hip_handle"
end sub

sub IK_spine_lower_ctrl(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "IK_spine_lower_ctrl"
end sub


sub R_FK_wrist(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_wrist_bone"
end sub

sub R_FK_lowerArm(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_lowerarm_bone"
end sub


sub R_Fk_upperarm(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_upperarm_bone"
end sub

sub R_arm_upvector(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_arm_UpVector_ctrl"
end sub

sub R_clavical(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_clavical_ctrl"
end sub

sub L_clavical(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_clavical_ctrl"
end sub

sub L_FK_upperarm(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_upperarm_bone"
end sub

sub L_FK_lowerarm(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_lowerarm_bone"
end sub

sub L_FK_wrist(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_wrist_bone"
end sub

sub L_arm_upvector(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_arm_UpVector_ctrl"
end sub

sub L_knee_poleVector(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_knee_poleVector"
end sub

sub L_leg_poleVector(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "L_leg_poleVector"
end sub

sub R_knee_poleVector(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_knee_poleVector"
end sub

sub R_leg_poleVector(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "R_leg_poleVector"
end sub

</SCRIPT>

<map name="SynopticMap">
<area shape="rect" coords="446,29,566,61" title="" NOHREF onClick="Select_All">
<area shape="rect" coords="444,88,565,119" title="" NOHREF onClick="Deselect_All">
<area shape="rect" coords="444,147,565,178" title="" NOHREF onClick="Reset_Pose">
<area shape="rect" coords="446,208,566,239" title="" NOHREF onClick="Key_All">
<area shape="rect" coords="446,263,566,291" title="" NOHREF onClick="Remove_All">
<area shape="rect" coords="444,319,564,350" title="" NOHREF onClick="Hide_Ctrls">
<area shape="rect" coords="444,375,565,403" title="" NOHREF onClick="Unhide_ctrls">
<area shape="circle" coords="318,25,9" title="" NOHREF onClick="Head">
<area shape="circle" coords="289,35,10" title="" NOHREF onClick="Neck_upper">
<area shape="circle" coords="272,57,10" title="" NOHREF onClick="Neck_mid">
<area shape="circle" coords="249,72,9" title="" NOHREF onClick="Neck_lower">
<area shape="circle" coords="73,175,10" title="" NOHREF onClick="Right">
<area shape="circle" coords="382,207,9" title="" NOHREF onClick="Left_arm">
<area shape="circle" coords="217,530,10" title="" NOHREF onClick="Right_foot">
<area shape="circle" coords="284,511,9" title="" NOHREF onClick="Left_foot">
<area shape="circle" coords="271,167,9" title="" NOHREF onClick="Spine_upper">
<area shape="circle" coords="262,194,10" title="" NOHREF onClick="Spine_mid">
<area shape="circle" coords="258,219,9" title="" NOHREF onClick="Spine_lower">
<area shape="circle" coords="260,248,11" title="" NOHREF onClick="COG">
<area shape="circle" coords="258,276,10" title="" NOHREF onClick="Hip">
<area shape="circle" coords="253,161,7" title="" NOHREF onClick="IK_spine_upper">
<area shape="circle" coords="242,192,7" title="" NOHREF onClick="IK_chest_handle">
<area shape="circle" coords="240,216,8" title="" NOHREF onClick="Ik_hip_handle">
<area shape="circle" coords="243,244,7" title="" NOHREF onClick="IK_spine_lower_ctrl">
<area shape="circle" coords="85,192,10" title="" NOHREF onClick="R_FK_wrist">
<area shape="circle" coords="142,148,9" title="" NOHREF onClick="R_FK_lowerArm">
<area shape="circle" coords="205,106,10" title="" NOHREF onClick="R_Fk_upperarm">
<area shape="circle" coords="159,174,5" title="" NOHREF onClick="R_arm_upvector">
<area shape="circle" coords="239,91,6" title="" NOHREF onClick="R_clavical">
<area shape="circle" coords="305,101,5" title="" NOHREF onClick="L_clavical">
<area shape="circle" coords="306,130,9" title="" NOHREF onClick="L_FK_upperarm">
<area shape="circle" coords="330,177,10" title="" NOHREF onClick="L_FK_lowerarm">
<area shape="circle" coords="370,220,10" title="" NOHREF onClick="L_FK_wrist">
<area shape="circle" coords="309,191,5" title="" NOHREF onClick="L_arm_upvector">
<area shape="circle" coords="341,401,7" title="" NOHREF onClick="L_knee_poleVector">
<area shape="circle" coords="363,401,9" title="" NOHREF onClick="L_leg_poleVector">
<area shape="circle" coords="293,425,8" title="" NOHREF onClick="R_knee_poleVector">
<area shape="circle" coords="313,425,8" title="" NOHREF onClick="R_leg_poleVector">
</map>

<img src="index.jpg" usemap="#SynopticMap">

</body>
</html>

Master Project Final




My Master Project at Bournemouth University was based on rigging of a werewolf. I was responsible for modeling, texturing and rigging of the character.
I would like to thank-
Chua Han Xiang who created the animation
Samir Rout provided me with base mesh on which I further built my model
Chitra Saini helped me with lighting and compositing
Dipti Gandhi guided me time to time on rigging issues

Saturday, June 25, 2011

3 Bone leg chain solved

Finally, I have created my 3 bone leg chain. The task was challenging. I could get away by creating a normal 3 bone IK leg as the proportion of all the leg joints in model were correct. I wanted a solid full proof IK chain where the leg joints would deform properly on rotation. I and Dipti discussed a lot on it and she gave me a solution which was complicated for my beginner mind. The ankle joint gets scaled with help of the reference chain if the deformation of the joint is not correct. With the scaling the the thigh and the calf joint never merges on rotation. This is the example of what I am talking.


Here, I created a 2 bone IK just like a biped and then created one more IK for the ankle joint. I linked my setup with a proper 3 bone joint setup which has a correct joint structure indifferent of my character design. Now my IK leg joint setup (according to the legs of my character) follows the reference IK joint leg setup and the ankle joint of my setup scales to maintain the angle of joints.

While I was talking to J about the issue I am facing, Jon suggested me to use the reverse foot technique for the 3 joint chain. He talked with me and Dipti about his logic and we stated digging into it as we both are crazy to find different methods/solutions. Yesterday, after coming back from Buffalo's I decided to stay at uni and work on the leg chain. I hacked it!!

This is what I have come up with.



I will discuss on how I created this soon...

Wednesday, June 15, 2011

3 bone leg chain or 2 bone leg chain?

After almost completing my leg rig, Dipti comments!!

Dipti- Your third leg joint is breaking, this is not correct.
Ruha- I saw few tutorials, they follow the same techniques.
Dipti- In prana these kind of characters were famous, so I am quite aware of the joint structure. You will have to create a 3 joint leg chain.
Ruha- Isn't there any other way, the DT tutorial have a horse rig and it works on 2 joint leg chain.
Dipti- That is a horse, your werewolf leg is quite different.
Ruha- @#$^, I am screwed. I have spend 3 days working out the IK FK leg and now I need to create it once again?

I am now tensed, very tensed.

I need to finish this rig soon, I don't have time :(

This is what I am talking about (I have send this question to the CG Coach tutors):

I created a 2 bone leg chain for the digitigrade , and for the third joint I added a separate bone like a human heel joint.



The issue I am having with two bone leg joint for the leg is that on translating the  leg on the right or left side the third joint doesn't maintain the angle, it seems like the leg joints are breaking. I quickly created a 3 joint leg chain to compare and show what I am talking about. What do you suggest in this, what kind of joint setup would be better?


Haven't yet receive any answer from CG coach, its been 6 days.

Why not an inverse foot 2 joint IK?
  -Because you need to manually rotate the last joint every time you translate the leg. Although its easy for me and the animators are acquainted to the inverse foot, I want to go more advanced and discard the need of creating and animating one more control. Knee and ankle are always linked together, so a setup is required to automate their relation.
  -Now if I create a 2 bone IK, it should effect the complete leg, that is the knee as well as the ankle.
  -The leg should remain STRAIGHT when you translate the IK

These are one of the prime reasons why I am researching on digitigrade leg rig which has 2 IK but still works like a 3 bone chain.


Rigging Begins

Until now I have created almost 3 versions of the werewolf leg. Every tutorial has a different technique and it doesn't seem to be a proper clean rig. I need a simple rig with advanced controls giving complete freedom to the animator to use the controls for animation. I don't want automated stuff like my previous rigs for the group project.

Everytime I have created the leg rig, I have learnt something new about rigging. It seems as if I am researching different techniques along with rigging my character. Most of the tutorials I found online for the quadruped (as my werewolf has digitigrade legs) are for horse and the leg structure of the horse is a bit different and this changes the approach for the rig.

While I was rigging, I discovered few things. I will consider them the golden rules as I am a newbie.
1. Always always always create your leg joints in LEFT view.
- What would happen if I don''t do that?

You get the wrong axis for the joints, you Y axis faces negative. This might create issue while rigging, the most important thing in rigging is the joint orientation.

2. In softimage, keep the Align Root to First Bone when Drawing ON
3. Your controls should be aligned to your joints.
4. Keep separate layer for joints and controls.
5. Never mess with the resolution plane and roll of the lower bone for the leg. It will restrict the knee from moving along with the IK and won't change even if you undo.

I will keep adding more as I discover.



Animation

Animation References-


The animation is about a werewolf running through a landscape like a biped and then change to a quadruped run. I have chosen this act to show smooth transition of the rig from biped to quadruped. As there are no real footages of werewolf running, I took reference of canine run (Video 1) and human run (Video 2) to study the motion. I found some references of people walking with homemade digitigrade legs (Video 3). I also found few references of people running like dogs, which were the key reference for my animation sequence (Video 4, 5).







Animatics-


These are the thumbnails I created for the animatics, I am not very good at drawing but this gives me an idea of how the animation would flow.



 Line of Action