Author: RoaringTide (page 2 of 17)

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 eventually 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.

To get started, duplicate Archimatix/Scripts/Core/Generators/CustomNodeTemplate.cs. Change the node name, and edit the generate function and you have your own node!

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.

Meshing Examples

Lighthouse Base

Villa Romano

PlanSweepTube

JitterPlatforms

Older posts Newer posts

© 2019

Theme by Anders NorenUp ↑