Archive for the ‘Jscript’ Category

Scripting

Tuesday, November 15th, 2011

Yesterday I was asked by one of my students, Andrew, where I learned scripting and what sources I’d recommend for learning scripting. To the first question, I learned on my own, with no formal training. I bought books, I read websites on the topic, and I read the SDKs of the software, over and over again. I gradually became more familiar with the syntax, the logic, and my own patience. In 2002, I started with Actionscript, AS, for Flash, which is based on a type of J-script, and from there I graduated to Softimage XSI. XSI had large libriaries of examples in the SDK, software developers kit, written in J-script, and I was able to read and write from those examples based on my experience with Actionscript 1.0. In 2008, I was back into Actionscript for a short while, on the social networking website prototype, at that point it was now AS 3.0. A fully object oriented programming language, or OOP, and I took to that right away. It took me several years of work in XSI and AS to understand OOP. I’ve also attempted to learn Python, though I haven’t committed the time and resources to use it well enough.

It takes me a long time to write code of any kind, and I require 50-60% guidance, the rest I dream up on my own. Whenever the software couldn’t solve a problem, or when I became very curious on how something works in a software, I’d take the time to write it myself. Sometimes, I’ll automate a task, just to see it in code, and from there it encourages me to take on something a little bigger. Changing software, like the switch from Lightwave to Softimage XSI back in 2005, motivates me to make tools to ease my transition from one software to software. For example, I’m quite happy with my abiility to model with curves in Maya, and I’d like that ability in Softimage (curve modeling being one of SI’s weaknesses).

As for the second question, here is a list of books in my library that have helped me over the years. I recommend all of these authors.

Any book on the subject of J-script or programming syntax and logic. Each language has it’s own particulars, but all languages share similar rules. Learning one language makes learning a second far easier.

Python
John Zelle (Personlly, if I were to start all over again, I’d start here. Not because it’s pythin, but because this guy is a great teacher).

Actionscript
Keith Peters
Joshua Davis (I’m not sure if he has published anything recently).

MEL (Maya Embedded Language)
David Gould

There are many other good references, but these authors stand out in my mind. You can find more information about these authors and other great people by sifting through my links to the right.

I have to mention that programming has led me to love math. More specifically, programming has allowed me to see math in action, and I understand it better and apply it better as a result of learning programming.

SI: Bouncing Ball Rigging

Sunday, September 19th, 2010

From September 2008.

The Bouncing Ball Rig – Inspired by and specials thanks to Jason Schleifer.

These videos are from the course Art New Media 421, 3D Character Modeling and Rigging, at American River College in Sacramento, California. They are the first three weeks of rigging training. I cover the theory and discuss the setup more thoroughly in the classroom, but the following 40 minutes will get you up and running. I hope you can learn from these few videos. Please, e-mail me if you have questions or comments.

The project directory has all the files you need. Use the Project Manager to add the project to XSI. Then you’re good to go!

Updated 2:15 PM 2/16/2009, added XSI 6.0 – 6.5 compatible models.
Project Directory

Introduction, 9 MB
Importing Models, 18 MB
Hierarchy, 58 MB
Envelope and Lattice, 34 MB
Groups, 22 MB
Scripted Ops and Pose Constraint, 18 MB
Cleanup, Locks, and Key Limits, 20 MB
Neutral Pose, 9 MB
Tools, 9 MB
Final, 9 MB

Or, download all at once.

167 MB, WinRAR Required

.

Note:   I didn’t review these old videos, if something has significantly change in SI 2011, please let me know.

SI: Modeling Tool Set

Sunday, September 19th, 2010

Here’s the modeling toolbar from my Intro to 3d Modeling course when we used Softimage XSI.  It’s an xsiaddon, so just drag and drop into an empty view port.  Once installed, you can find the toolbar under the menu, View > Toolbars >  formandspace_modeling.  Let me know if there are any problems installing or running them.

Segment Curve

Monday, May 31st, 2010

This script will segment an entire curve from knot to knot. I needed something like this tool for my current project. I found this most useful for linear curves, but I added the code to segment a CV curve, as well.

/*
SEGMENTS A CURVE FROM KNOT TO KNOT
*/
var oSel = Application.Selection(0);
if(oSel.Type != “crvlist”)
{
fTrace(“Select a curve”);
}
else
{
if(Application.Selection.Count > 1)
{
fTrace(“Select only one curve.”);
}
else
{
fSegmentCurve(oSel);
}
}
/*———–
FUNCTIONS
————*/
function fTrace(m){
Application.LogMessage(m);
}
function fSegmentCurve(oSel){
var oSelName = oSel.FullName;
var oType = oSel.Type;
var oGeometry = oSel.ActivePrimitive.Geometry;
var oNumKnots = oGeometry.Curves(0).Knots.Count;
fTrace(oNumKnots + ” – Knots”);
//FOR CUBIC CURVES – DEGREE 3
if(oGeometry.Curves(0).Degree == 3){
fTrace(oSelName + ” is a cubic cv curve.”)
for(i=0; i < oNumKnots-1; i++)
{
//SKIP FIRST THREE KNOTS & LAST THREE KNOTS
if(i < oNumKnots-5){
ApplyGenOp(“CrvExtractSeg”, “”, oSelName +”.knot[" +i+ ","+ (i+1) +" ];”+ oSelName +”.knot["+ (i+1) +"]“);
}
}
}
//FOR LINEAR CURVES – DEGREE 1
if(oGeometry.Curves(0).Degree == 1){
fTrace(oSelName + ” is a linear curve.”)
for(i=0; i < oNumKnots-1; i++)
{
ApplyGenOp(“CrvExtractSeg”, “”, oSelName +”.knot[" +i+ ","+ (i+1) +" ];”+ oSelName +”.knot["+ (i+1) +"]“);
}
}
}

Two Rigging Tools

Sunday, May 30th, 2010

I wish I made these tools a long time ago.     Script #1 is “Create Null as Parent”.  I especially like this one.  You can make fast hierarchies with this.

Script #1


/*
SELECT THE OBJECTS YOU WANT PARENTED TO A NULL, THEN RUN.
MATCHES THE NULL TO THE FIRST CHILD’S POSITION AND ROTATION.
*/
/*——————–
User Input
——————–*/
var oRoot = Application.ActiveProject.ActiveScene.Root;
var oSel = Application.Selection;
/*——————–
FUNCTIONS
——————–*/
fRun(oSel);
function fRun(oSel){
var oNull = oRoot.AddPrimitive(“Null”, oSel(0).Name+”_null”)
oNull.Kinematics.Local.PosX.Value = oSel(0).Kinematics.Local.PosX.Value;
oNull.Kinematics.Local.PosY.Value = oSel(0).Kinematics.Local.PosY.Value;
oNull.Kinematics.Local.PosZ.Value = oSel(0).Kinematics.Local.PosZ.Value;
oNull.Kinematics.Local.RotX.Value = oSel(0).Kinematics.Local.RotX.Value;
oNull.Kinematics.Local.RotY.Value = oSel(0).Kinematics.Local.RotY.Value;
oNull.Kinematics.Local.RotZ.Value = oSel(0).Kinematics.Local.RotZ.Value;
oNull.AddChild(oSel)
SelectObj(oNull);
}


Script #2

Create Null as Parent at First Point on Curve


/*——————–
SELECT CURVE(S) AND RUN
User Input
——————–*/
var oRoot = Application.ActiveProject.ActiveScene.Root;
var oSel = Application.Selection;
var oCurveList = XSIFactory.CreateActiveXObject(“XSI.Collection”);
/*——————–
FUNCTIONS
——————–*/
fCollectCurves(oSel);
function fCollectCurves(oSel){

for(var en = new Enumerator (oSel); !en.atEnd(); en.moveNext())
{
oEn = en.item()
oCurveList.Add(oEn);
}

for(k=0; k < oCurveList.Count; k++)
{
fTranslateNull(oCurveList(k));
}
}

function fTranslateNull(inPath)
{
var oPntX = new Array();
var oPntY = new Array();
var oPntZ = new Array();
var oNull = oRoot.AddPrimitive(“null”);
oVB = new VBArray(inPath.ActivePrimitive.Geometry.Points.PositionArray);
oPntArray = oVB.toArray();
for(i=0; i < oPntArray.length; i += 3)
{
oPntX[i] = oPntArray[i];
oPntY[i] = oPntArray[i+1];
oPntZ[i] = oPntArray[i+2];
if(i == 0){

oNull.Kinematics.Local.PosX.Value = oPntX[0];
oNull.Kinematics.Local.PosY.Value = oPntY[0];
oNull.Kinematics.Local.PosZ.Value = oPntZ[0];
}
}

oNull.AddChild(inPath);
}