Modeling

Topics related to Modeling with the XSI SDK

Table of contents

Building a Geometry

All operations of creating primitives and then editing the shapes can be scripting, based on the commands that are logged when doing these operations in the user interface.

It is also possible to programmatically define an entire geometry based on the definition of its points, polygons, normals etc. This approach is commonly used when importing geometry.

From Scripting use X3DObject.AddPolyonMesh (http://softimage.wiki.avid.com/sdkdocs/X3DObject_AddPolygonMesh.htm), X3DObject.AddNurbsCurve (http://softimage.wiki.avid.com/sdkdocs/X3DObject_AddNurbsCurve.htm) etc to create a geometry.

Alternatively, it is possible to replace an existing geometry by calling PolygonMesh.Set, NurbsSurfaceMesh.Set, NurbsSurface.Set etc. This can only be done within a frozen object (FreezeObj command) or from a Custom Operator. In the Custom Operator case the .Set method is used to provide an entire geometry, in which case it is a "Generator" style operator, or to adjust the content of an existing geometry in which case it is a "Deform" style operator, as discussed below.

Normals and other data is provided by building Clusters and ClusterProperties on the mesh.

From C++ the same methods are available, but starting with XSI v5.0 there is a CMeshBuilder (http://softimage.wiki.avid.com/sdkdocs/sicppsdk/html/classXSI_1_1CMeshBuilder.html) object for fast creation of Polygon Meshes. It makes it possible to provide Edge Crease data, assign Materials and other mesh data directy. Use this method to create the empty mesh and access the CMeshBuilder:

CStatus X3DObject::AddPolygonMesh(	const CString&	in_name,
           X3DObject&	out_3dobj,
           CMeshBuilder&	out_meshBuilder );

Positioning a X3DObject

See Math Library#Manipulating the Transform of an Object

Deforming an entire Geometry

As mentioned previously, the PolygonMesh.Set() method (and similar Nurbs methods) can be used to replace an entire geometry with in an operator. A "Deform" operator does not provide the original geometry, but instead it sits higher in the "ConstructionHistory" and adjusts the geometry generated by other operators beneath it.

A deform operator would normally read the existing geometry, makes adjustments, and then provides the entire changed geometry back into XSI with the .Set method. It does not add or remove points (or edges or polygons), but just repositions the points.

This is clearly most efficient when a large portion of the geometry is being adjusted by the operator. If the deform operator is more localized it can use the Point.Position method as described below to move individual points.

Changing an Existing Geometry

XSI does not fully support the creation of Custom Operators that actually change the geometry, in terms of adding or removing points. This is called a "Topological" operator. It can be done, but at the risk of Clusters and Cluster Properties becoming out of sync with the altered Geometry. If no Cluster Properties have been applied there is no problem.


However you can use the SDK to apply XSI's built-in Topology Operators, see Changing the Topology (Adding and Removing Components) (http://softimage.wiki.avid.com/sdkdocs/cf448413.htm).

Positioning a Point

Most basic way to move points is to use the same commands that are logged when the operation is done manually.

You can also use the Point objects directly from within a Custom Operator or on a frozen mesh, as shown in the following example.

//Jscript example submitted to XSI list by Helge Mathee
//Selected mesh must be frozen
var x3dObj = selection(0);
var prim = x3dObj.ActivePrimitive;
var geo = prim.Geometry;
var points = geo.Points;
var point = geo.Points(0);
 
var vMove = XSIMath.CreateVector3();
vMove.Set(0,1,2);
 
// for absolute positioning
point.position = vMove;
 
// for relative positioning (additional movement)
point.position.Add(point.position,vMove);

This page was last modified 13:32, 4 Jul 2006.
This page has been accessed 186960 times.

© Copyright 2009 Autodesk Inc. All Rights Reserved. Privacy Policy | Legal Notices and Trademarks | Report Piracy