Category: Manual (page 1 of 2)

Exporting Models from Archimatix

If you would like to bring the fruits of your Archimatix (AX) labor to external applications such as Substance Painter or Quixel, you can export your models as OBJ or FBX. It is easy to export models from archimatix as OBJ or FBX using any of the free or paid assets in the Asset Store, once you Stamp your model out.

 

Stamping

When you Stamp your Archimatix model, you are creating a clone of the standard Unity GameObject hierarchy that AX and stripping it of any AX metadata. This leaves a GameObject hierarchy that is essentially “frozen,” i.i, no longer parametric.

To Stamp a model, be sure that it is selected in the Hierarchy window and then click at bottom of the Stamp button in the Scene View or the the upper right of the Archimatix  Node Graph Editor window.

At this point, the Stamped model no  longer needs Archimatix to be in the scene. It is also ready tobe further modified  by other assets in the Asset Store, such as ProBuilder for polygonal modeling or Surforge for PBR texture painting.

Prefabbing

The only way to create a Unity Prefab from an Archimatix model is to make sure the model  is selected in the Hierarchy window and then click the Prefab button at the upper right of the  Node Graph Editor window. This is similar to Stamping in that it “freezes” the model, but it also saves all of the meshes in the GameObjects to the AssetDatabase in an optimized way.

Note that you can not simply drag a Stamped model to the Project window to create a Prefab, since the meshes will not be in the AssetDatabase.

Exporting

Archimatix does not have a buit-in exporter yet, but once an Archimatix model as been Stamped or Prefabbed, you will find several free or paid assets for exporting models from Unity as OBJ or FBX.  For example, Scene OBJ Exporter.

Archimatix Runtime For Artists

If you’re artist who is not that into coding (just yet!), but you still want to create Archimatix Pro (AX) runtime behaviors, well, you can in version 1.0.6 and later!

While Archimatix parameters can be exposed to the interface of your model, allowing easy access to them via custom game scripts, you may also use  Unity’s built-in UI system or assets like PlayMaker to control the values of AX parameters with the help of an easy to create runtime controller.

Let’s jump right into a short example to show rather than tell! While you can control any manner of complex and sublime models you have created in AX using runtime parameters, in this example, we will keep it simple and just adjust the height of a Box at runtime using a UI Slider. For this example, we won’t eve use the Node Graph Editor.

 

Step 1. From the Unity menus, create an Archimatix Box.

 

Step 2. Select the Box in the Scene.

Step 3. In the Inspector choose to expose the Height parameter as a runtime parameter by clicking the checkbox to the left of the parameter name.

Step 4. Note that the Height parameter has appeared in the list of the model’s runtime parameters.

The exposed runtime variables are easy to use in any game script, but they can also be easily made  available for binding to Unity’s UI system, PlayMaker, or any other system that connects to dynamic variables. All we have to do is create an AXRuntimeController asset. Fortunately, this is done with the click of a button!

 

Step 5. Make sure the AXModel GameObject is selected.

Step 6. Click on the “Create Runtime Controller” button.

Step 7. Save the new controller file anywhere  in your Asset folder.

 

You’ve done it!

You now have an Asset that connects to Archimatix’s runtime parameters and serves as a source for for Unity’s UI system, PlayMaker, etc. When choosing a connection, use the runtimeController asset you just created as your source of variables.

You may not have realized it, but by clicking that button, you 1. created a GameObject in the AXModel hierarchy and 2. added a new component to it, the runtimeController asset you created.

If you select other parameters in your AX model to become exposed as runtime parameters, just click the “Create Runtime Controller” button again. This time it will not ask you to locate the file, but just overwrite the one you have already created.

 

Now let’s take a look at how we can connect your new controller to Unity’s UI.

Step 8. Create a UI Slider. Adjust its Max Value to 10.

 

Step 9. Add an Action to the Slider.

 

 

Step 10. Unfold the Box model, click on the Slider in the Hierarchy and drag the runtimeController to the ObjectField in the Slider Inspector.

 

Step 11.  For the Function pulldown in the Slider Inspector, choose your controller and the Box_Height variable.

 

By Jove! You’ve done it again!

You have just empowered your game interface to do runtime modeling! Check it out!

 

Step 12. Check your UI to make sure the Slider is visible in the Game View. Click Play and manipulate the Slider. The Box height should be adjusting as you move the Slider.

 

 

 

Colliders

 

Archimatix lets you specify the type of Collider you would like on the GameObjects that it generates. All of the Unity Colliders are supported. In order to have a collider automatically enclose a series of meshes, in the node palette you can specify that all of the individual meshes being output are combined.

 

Archimatix also lets you use meshes as colliders only, by letting you specify that the mesh should not have a Renderer attached.

Runtime Archimatix

Runtime Archimatix is available in version 1.0.5 -full documentation  coming soon!

With Runtime Archimatix available only in Archimatix Pro, you can create in-game interactive modelers of your own design. A good example is the Spaceship Shop demo scene included in Archimatix Pro. In this demo, you can use the in-game UI to deliver simple modeling functionality, such as changing the shape of the hull with runtime handles, choosing the engine type and size, as well as sizing and positioning the weapons. Such a shop could be part of a game or its own independent application.

Other examples might include in-game house construction, maze design and, well, anything you can dream up! By creating such runtime applications, you not only make environment and prop building simple, fun and thematic, but also generate opportunities for in-app purchases that go beyond the acquisition of modular inventory items.

In its first iteration, runtime Archimatix (AX) allows you to control AX parameters from your runtime scripts. This means that you can connect your  runtime UI to an AX model and control it in a way that works with your game design. For example, if your player can spend game dollars to build a house, then they can size the house interactively while watching the cost of the house vary with the floor area of the building.

To facilitate this, AX has an “Expose” checkbox under each parameter in the node palette. Once you check that, the parameter will be displayed in the Inspector for the AXModel. With the variable exposed at the model level, your script can easily access the variable to get and set its value.

 

In order to modify these parameters in runtime, you need a reference to the AXModel (a Component of a GameObject in your scene). In your MonoBehavior, add a public member of type AXModel:

using AX;

public class GrayShipDesigner : MonoBehaviour {

    public AXModel model;

}

 

After doing this, you can drag the AXModel aGameObject into the ObjectField in your runtime script. With this reference to the parametric model, you can get and set the parameters that you have promoted put to the model interface. When you set these parameters, they will ripple their value change throughout the graph based on the Relations you have established between parameters.

To make your code more readable, it may be good to set up references to the parameters so they are easier to get to:

using AX;

public class GrayShipDesigner : MonoBehaviour {

    public AXModel model;

    public AXParameter P_Radius;
    public AXParameter P_Channel;

}

In the Start function, you can establish these parameter references using the getParameter function. This function uses the name you have given the parameter in the graph to find the parameter:

 // Use this for initialization
 void Start () {

    // Establish refernces to AXModel parameters.

    if (model != null)
    {
        P_Channel = model.getParameter("Engine.Channel");
        P_Radius  = model.getParameter("Engine.radius");
    }
}

   

 

To modify the parameters you have a reference to, use AXParameter.intiateRipple_setFloatValueFromGUIChange(floats value) and then let the model know you are ready to have the changes regenerate the model while dragging with model.isAltered() or after UI edits are complete with model.autobuild().

 

 // Example of a UI callback function. This could be a delegate of a Slider that controls the radius. 

 public void radiusSliderUpdate()
 {
    // Set the value of the parameter and let this change ripple through the network of Relations

    P_Radius.intiateRipple_setFloatValueFromGUIChange(radiusSlider.value);


    // Let the model know that you are done making your changes,
    // but not necessarily to create new game objects.
    // isAltered() is often called during a repetitive change such as with a slider.

    model.isAltered();

     // Other relevant game state changes not necessarily related to Archimatix 
     
     radius = radiusSlider.value;
     recalculate();
 }

   
 public void engineTypeDropdownUpdate()
 {
     // Set the value of the parameter and let this change ripple through the network of Relations

    P_Channel.intiateRipple_setIntValueFromGUIChange(engineTypeDropdown.value);



    // Tell the model to rebuild its GameObjects. 
    // autobuild() is often called after a Dropdown or Checkbox UI is modified.
    
    model.autobuild();

    // Other relevant game state changes not necessarily related to Archimatix

    recalculate();
 }

That’s all that you need to get started with runtime Archimatix! There will be full API published soon as well as some example scenes.

 

Detail Level

Since Archimatix is a non-destructive modeler that gives you great control over detail level, you can iteratively reach the optimal triangle efficiency versus aesthetic richness you would like for your model by simply dragging local parameters in the nodes or the global Detail Level slider.

Triangle density tends to be a product of 2D Shape segmentation.  You can set the segmentation of Plan and Section shapes to control the number of triangles in the meshes generated by the shapes. As you model, if you think certain forms look too faceted, you can go to their generating shapes and up the segs parameter.

Alternatively, you can use the Detail Level parameter at the lower right hand corner of the Node Graph Editor to decimate segs variables where ever they are found in the graph.

You can also use this detail control to create LOD version of the model. Eventually Archimatix will have an LODGroup creator.

 

Creating Custom Nodes

A great way to extend Archimatix is to create your own node to work with other nodes in the graph. While you can create your own node by saving  a graph you create to the Library or by creating a custom parametric Shape using AX Turtle scripting, you have the most power and flexibility to change the course of AX history by coding a node in c#.

Fortunately, its not that hard to create a node. All you have to do is derive a class from one of AX’s Generator classes. Most commonly, you will subclass Generator2D or Generator3D. You only need to override a couple of functions and, voila, you have created a custom node.

Location, Location, Location

Your script file and icon file can be anywhere in the project’s Asset folder your new node will be discoverable by AX. The only requirement for discoverability of your class is that, in addition to subclassing a Generator, you need to implement the interface ICustomNode. AX uses this Interface to search for custom node classes.

While your node icon can be anywhere in the Asset folder, it will be discoverable only if you name the icon image file according to the convention zz_AXNode-MyNodeName.jpg and place it anywhere in the Asset folder, your node will appear in the right sidebar menu of the node graph window, toward the bottom of the menu.

Making your Node Iconic

If you don’t create your own node icon image, one will be automatically displayed for you in the right sidebar of the node graph. AS a generic icon, the only way a user will know that it creates an instance of your node is by the tool tip that appears when you mouse over it. For this reason, it is probably best to create your own distinctive look!

Your node icon image should be square and saved as a jpg file. If you have named your image file according to the convention above, then it will be displayed in the sidebar at 64×64 pixels so your original image file should be that size or larger. In order to work contextually with the other nodes in the sidebar color-wise, you can use the blank image icon to the right as a background. Once your image is saved, select it in your Unity Project window and, in the Inspector, set the Texture Type to Editor GUI.

Its All What You Node

A custom node written in C# is really just a subclass of a AX.Generator. A Generator has inputs, parameters, generative logic and outputs. The inputs may be Shapes, Meshes, Prefabs, or the output of any AX node. You can determine what output parameters you would like to provide for.

A Generator gives a node a behavior. The actual node class itself  is AXParametricObject, which subclasses AXNode. Before going too deeply into the structure of AX, lets look at an example of what a Generator subclass might look like.

Custom Zones in the Node Palette

In addition to SceneView Handles, you can also create custom GUI to insert into the node palette. There are four zones in the node palette which are controlled by GeneratorHandler functions you can override. The four zones are depicted in the following diagram.

To add GUI elements to your custom node palette, override one of these four functions. The current y-value for the GUI zone is passed into the function. You must keep adding to this cur_y and return the final value for cur_y at the end of the function.

The function may initialize variables to help with layout of the EditorGUI elements.

public override int customNodeGUIZone_1(int cur_y, AXNodeGraphEditorWindow editor, AXParametricObject po)
 {
     int     gap         = ArchimatixUtils.gap;
     int     lineHgt     = ArchimatixUtils.lineHgt;
     float     winMargin     = ArchimatixUtils.indent;
     float     innerWidth     = po.rect.width - 2*winMargin;
 
     Rect pRect = new Rect(winMargin, cur_y, innerWidth, lineHgt);
 
     // Create GUI here
 
 
     return cur_y;
 }
  
  
 

 

 

 

Texture Mapping

Textures are often thought of in two ways. Either tiled textures that can repeat indefinitely with no apparent seams or texture atlases, where a region in the texture image is exclusive to a polygon in the mesh.

2D Library

We can consider Shapes to be “closed’ or “open.” Of course, any open shape can be closed and any closed shape set to open, but some shapes lend themselves to one or the other. For example, a gear shape, would normally be closed while a molding profile would normally be open.

Closed Shapes

 

Primitives

 

 

 

 

 

Plans

 

 

 

 

 

Sections

 

Open Shapes

Column Profiles the are Lathed

 

Wall Sections the are PlanSwept

 

Moldings that are PlanSwept


Archimatix Turtle Script API

Turtle logic, originally developed as a feature in the Logo programing language, is an important tool for the description of line shapes. Each line of a turtle script draws a 2D line relative to the current position of the turtle cursor. While this may seem conceptually simple, it is a powerful concept in parametric graphics. For example, to draw circular arc, with five segments, one need not calculate each of the five vertices, if one can simply tell the turtle to draw an arc to the right through 45 degrees at a radius or 3 units. The command in turtle script may look like this.

arcr 45 3 5

Archimatix has its own implementation of a turtle scripting API, borrowing more closely from GSDL, a 4th generation language developed by GIST, Inc., than from Logo.

 

Absolute Commands

mov x y <a>

Before drawing a shape, we have to place the turtle somewhere in 2D space and point it in a certain direction.  This command moves the turtle to the point x, y with out drawing any lines. The optional argument a tells the turtle in which direction to face. The default direction is 90 degrees.

 dir a

dir sets an absolute direction.

This command, which reorients the turtle to a new direction,  can be called anywhere in the script whenever you would like it to abruptly change direction.

drw x y

Draw a straight line from the current point to x, y.

closed

Closes the shape. Shapes are open by default.

//

Comments in follow the standard double-slash. Any text after this will be ignored by the script parser.

 

Relative Commands

rmov dx dy

Moves the turtle pen tip to a new point and resets the current direction to the line from the pervious to the moved point..

 

turnl avoila_capture-2016-12-03_07-37-00_pm

Turns the current direction a degrees to the left.

turnr a

Turns the current direction a degrees to the right.


fwd c <d>

Draws a line c units long in the current direction. For example, fwd 30, or if using a parameter, fwd height. Optionally, d offsets the point from the directional axis so that a diagonal line will be drawn c units forward and d units perpendicular to the current direction. This offset is useful for drawing a shape that fits with in box, but that has corners chipped off, so to speak.

For example, this is a box with the two top corners inset:

mov 0 0 angle
fwd height/2
fwd height/2 -inset
left width-2*inset
back height/2 -inset
back height/2

 back c <d>

voila_capture-2016-12-03_07-57-33_pmDraws a line c units long, backwards, or in the opposite of the current direction.

right c

voila_capture-2016-12-03_07-58-27_pmDraws a line c units long to the right, without changing direction.

left c

Draws a line c units long to the right, without changing direction.

arcr a r s

voila_capture-2016-12-03_08-13-10_pm Draws a circular arc of a degrees, with a radius of r, beginning at the current point and tangential to the current direction and arcing to the right. After the command is execute, the turtle’s direction is automatically turned to the tangent of the end of the arc. For example, with a dir 45, arcr 45 3 5 will leave the turtle at a direction of 0 degrees so that if you follow with a fwd 4, the turtle will draw a line 4 units long at an angle of 0 degrees.

arcl a r s

Similar to arcr, but curving to the left.

Mathf Functions

All of the Mathf Functions have been mapped to AX Turtle Script. They follow the general form of:

cos(degs) 

or

Cos(degs)

A rad2degs conversion goes on inside the function, so the argument is in degrees.

Another example is

atan(x, y)

Mathf variables can also be used in your equations such as x*PI

PI

degs2rad

 

 Looping

AX Script has a limited looping syntax that basically repeats the code with a counter.

loop repeats <counterName> <step>

The loop command opens the scope of the loop. The repeats argument specifies the number of times to run through the loop. Th optional counterName  is a string name for the internal counter variable. The optional step is a number or expression that tells the loop how much to advance the counter by each time.

endloop

Teminates the scope of the loop.

 

In this example, the loop will draw a dotted line with 10 unconnected segments.  The counter variable i multiplied by span will start an unconnected line segment every 5 units with a segment length of 2.5.

let segs=10
let span=5;

loop segs i
    mov i*span 0
    fwd span/2
endloop


In this example, the loop will draw a gear shape with teeth number of teeth. No counterName is needed here.

loop teeth
    arcl degs radius segs
    right tooth
    arcl degs radius+tooth segs
    left tooth
endloop

This example will produce a stair shape:

loop steps-1
fwd ariser
left tread
endloop
 


Conditional Block

The conditional command does not use parentheses. There is currently no else or else if, though they are planned.

if var1 GT var2

You can also reference a bool parameter

if bool

endif

Closes the conditional block.

The conditional uses the boolean operators:

LT for "equals"

GT for "greater than"

EQ for "equals"

NE for "not equals"

 

There is currently no elseif, else, continue, or break but theses are planned. The workaround for else is to create a second block with the opposite conditional.

 

end

Terminates the turtle script execution early.

 

Parameter and Variables

set parameter value

The set command will set a parameter based on the parameter’s name. This is particularly useful for defining a max and min value for a parametr.

set width greater(width, .01)

 

Or for making sure a parameter never rises above another:

set width lesser(shaftHeight, columnHeight)

Thus, even as the user drags a handle or types a value in a float field, it will not break the rule defined in the set command.

 

let tempVar value

The let command defines or resets a temporary variable. This is useful in the case that you have a long expression that you need to use in multiple function calls while drawing.

let buildingLength sine(angle)*buildingHeight

To reset a temporary variable, you must use let again.

let buildingLength 5

Absolute Commands (Cont.)

 

Special Curves

bezier   ax  ay   ahx  ahy   bhx  bhy   bx  by   segs

Draws a cubic Bezier curve between points a and b. The curve is modified by handles defined by absolute endpoints ah and bh.

 

archimatix-2016-12-04_10-25-57_am

 

molding  type  ax, ay  bx, by segs, tension

Moldings profiles are Shapes that have a very common use in architecture. This command uses one or more bezier curves to and makes certain assumptions about the handles so that you do not have to construct a sequence of beliers curves yourself. Borrowing from the timeless art of molding design, we have a few types that can be called in the molding command, including cove, ovolo, cyma recta, cyma reversa and onion.

voila_capture-2016-12-04_04-09-19_pm2

 

 

6. Getting to Know Your Relations Better

stacking

Simple Relation for stacking: the Cylinder is always atop the Box.

archimatix-2016-09-08_09-30-07_am

archimatix-2016-09-08_09-30-33_am

 

Artful parametric modeling is all about managing relationships. Not the personal kind, but the algorithmic kind.

By defining meaningful relationships among your parameters, you can encode a new and powerful morphological genus – creating a new species DNA, as it were, that can be used to generate hundreds of variations of models.

When you connect parameters to each other, you are authoring behaviors for your parametric model. When you modify one parameter, all sorts of changes may ripple through the model according to the logic you encoded via Relation connections and mathematical expressions within the Relation. Furthermore, these Relations may be bi-directional, meaning that you can change a parameter anywhere in the graph and changes will ripple out from that parameter.  The default mathematical expression set  when you fist specify a Relation is simply “=,” or equals.

Equal Relations

A common case for an equals Relation is when you want one object to always sit atop another, regardless of how tall the bottom object is. In the example to the right, the behavior illustrated is that the blue Cylinder is always atop the red Box.

Try This!

To set up this parametric behavior:

  1. Choose a Cylinder and a Box from the 3D Library (left sidebar in the NodeGraphWindow.
  2. Unfold the Controls of the Box and the
    archimatix-2016-09-07_10-49-17_pm

    A simple “equals” expression.

    Transformations of the Cylinder.

  3. Click on the red connector box on the parameter Extrude in the Box node palette.
  4. Click on the red connector button next to the Trans_Y parameter on the Cylinder node palette.
  5. To test: either click on the Box in the SceneView and then drag the green knob to make the Box taller, or click on the Cylinder and then drag the Y-Axis Position Handle.

You will notice that the relation is bi-directional. Modifying either parameter will alter the related parameter. This is a departure from other parametric modelers which feature uni-directional relations. The benefit of bi-directional is that, when playing with a parametric model in the SceneView, you can click just about anywhere you like and start modifying, rather than searching for the “master” parameter.

However, this freedom is not free: the bi-directionality requires inverse expressions to be input. In the case of our simple example, we did not edit the expression found in th relation, relying on the default equals expression. Let’s take a look at how we might make a slightly more complex relation expression.

Expressing Relations

When would like to have more interesting Relations, you can use the ExpressionEditorWindow that pops up when you click on the green button at the center of the Relation connector cable. In the ExpressionEditorWindow are two text fields allowing you to edit the bi-directional relationship between the two parameters.

Try This!

pistonsimple

Simple piston with sinusoidal relation to shaft rotation.

Lets say that we would like to simulate the movement of a piston relative to the rotation of a crankshaft in a car engine. The piston rises and falls sinusoidally as the shaft turns. The expression is Piston.Trans_Y=Sin(Crankshaft.Rot_X). Lets go ahead and set this up:

  1. Choose a Cylinder from the 3D Library.
  2. Click on the name button at the top of the node palette and rename it “Piston.”
  3. Use your copy and paste short cuts to create a second Cylinder. Name it “Crankshaft.”
  4. Next to the Transformations foldout, click the axis button until it show “X.”
  5. Open the Transformations foldout and choose “Align_X” choose “Center.”
  6. Click on the Crankshaft in the SceneView and reduce the radius a bit.
  7. Connect the Piston.Trans_Y to the Crankshaft.RotX.
  8. Try rotating the Crankshaft – the Piston will continue upward or downward.
  9. Click on the green button in the middle of the red connector cable.
  10. archimatix-2016-09-07_11-47-12_pm

    The Edit Relation window lets you define the bi-directional mathematical expression.

    In the ExpressionEditor, in the field filled in with Crankshaft.Rot_X, change the expression to: Sin(Crankshaft.Rot_X) and then click on the Save button just below.

  11. Test by rotating the Crankshaft again. The Piston will oscillate up an down.
  12. Make the Piston more responsive to the rotation, decrease the stroke and lift it higher above the Crankshaft by editing the expression again to be: 1.5+.5*Sin(2*Crankshaft.Rot_X)

We will save more elaboration on this with the addition of a piston rod, etc. please see the tutorial The Parametric Engine.

 

Best Practice: Relating Translations

relations1

A simple parametric behavior: the red Box and blue Cylinder are always translated to the end of the gold Box.

If you find yourself connecting the Trans_X for one node and the Trans_X of another node to the same source, it is probably better to group the two nodes together with a Grouper and then relate the Grouper’s Trans_X to the source. This is analogous to parenting two GameObjects to an “Empty” GameObject in the Unity hierarchy window. While Archimatix can handle lots of relations, by using relation connections where a grouping would do, you will add more visual complexity to the NodeGraphWindow.

For example, the animation to the right depicts a parametric behavior whereby the red Box and the blue Cylinder are always positioned at the end of the gold Box. There are two ways we could encode this behavior:

archimatix-2016-09-07_10-09-53_pm

Setting translations for each node will lead to many redundant Relations.

Method 1: This method is not preferable, but happens commonly while building up a graph. The Trans_X of the Cylinder has been related to the width parameter of the rectangular plan of the gold Box with an expression of Cylinder.Trans_X=Rectangle.width/2. When the red Box was added to the graph, a similar relation was added between the gold Box and the red Box, as shown in the figure to the right. Now when we drag the Handle for the Rectangle width, the blue Cylinder and the red Box translate accordingly.

The down side of this is that we have two connections and we have to enter the same mathematical expression twice (for the Cylinder and for the red Box). If we want to change that relationship, we have to change it in two places. Also, the graph will quickly get cluttered if such translations are maintained with Relation connections all the time.

 

Grouping Node

Grouping nodes allows fewer Relations.

Method 2: Alternatively, we can feed the Cylinder and Box into a Grouper and then relate the Trans_X of the Grouper to the width of the Rectangle.

The behavior of our parametric model will be exactly the same, but now, if we wish to edit the expression in the relations, we are editing in only one place. Also, the graph will have fewer parametric relations, which tends to make the graph more legible.

 

 

 

Older posts

© 2017

Theme by Anders NorenUp ↑