<< Prev Next >>


Curved Poly Inspector

The Curved Poly Behaviour has three parameters:

  • A Curved Poly Asset : some Curved Poly model stored in a file somewhere in the your project. The relationship between the Curved Poly Behaviour and the Curved Poly Asset is pretty the same as the one between MeshFilter and Mesh in Unity. The first is the behaviour attached to an object, the second is a recyclable geometry model which can be shared on more Curved Poly Behaviour at once.
  • A LoDs Asset : an asset containing a table of LoDs. LoDs Assets are discussed in the Tessellation Operator section
  • A LoDs Index : that is the index of the LoD to be used to tessellate the Curved Poly Asset among the ones available in the LoDs Asset. In the Inspector, you can control this with a choice containing the names of the LoDs.

Your GameObject will also have a MeshFilter and a MeshRenderer, they are automatically added together with the behaviour. The Curved Poly Behaviour assigns a new Mesh to the mesh Filter when the LoD change (either by changing the LoD asset of the LodIndex). For this reason you should never assign a Mesh manually. You should, instead, setup the MeshRenderer the way you like, first of all by selecting a good material. CurvedPoly - Shape Editor comes with a pair of materials called Normals Mat and Bisided Normals Mat, which are helpful to understand your shapes while you edit them. Both materials are base on a shader called NormalsShader which colors the surface of the mesh with a color based on normals coordinates (x component maps to red, y component maps to green, z component map to blue); such shader has 3 parameters:

  • Metallic : same as the one Unity Standard Shader. Helpful if you need to check how your shape would look with metallic effects.
  • Glossiness : same as the one Unity Standard Shader. Helpful if you need to check how your shape would look with glossy effects.
  • Bisided Normals [from 0 to 1] :choose smoothly if you need or not normals to be colored on both sides of each axis. For instance, when you assign 0 vertices facing the up direction will be green and the ones facing the down direction will be black; when you assign 1, vertices facing the up direction will be green and the ones facing the down direction will also be green.

The are aware that the Bisided Normals Mat will work only if you use the Unity Standard Pipeline. If you use one of the recent Pipelines (such as the Lightwave, the High Definition or the Universal one, or any custom pipeline not from Unity) it is not going to work. You can replace it with any material of course, it's only a material assigned to a Mesh Renderer. If you want to replicate the same effect of Bisided Normals Mat or Normals Mat for different pipelines, look for support at support.mushroomslabs.com

Shared Curved Poly Asset Data

Curved Poly Data is stored in Curved Poly Assets. You can assign the same Curved Poly Asset on more GameObjects, even with different LoD/Tessellation settings.

Note: If two GameObjects share the same Curved Poly Asset and the same LoD settings, they will also share the same computed Mesh; such meshes are kept inside the Curved Poly Asset and generated on demand, both in Edit and Play mode. For this reason, you should never exceed in the number of LoDs you are using at Run-Time.

Objects can’t be reshaped in Play mode. In Edit mode each Curved Poly Data will load an hidden editor object which responsible of all editing functions. GameObjects sharing the same Curved Poly Asset in the same Scene will access the same editor, so you can switch from one GameObject to the other to edit the content. The other GameObjects using the same asset will keep updating together. This is helpful if you plane to check how different LoDs will look on different Objects: create an aligned row of GameObjects with the same Curved Poly Asset, the same LoDs Asset and assign each one a different LoD; when you change something in the first GameObject with the Pointings or the Selection Operators you should see the changes applied on all the other GameObjects. If something goes wrong, try to click/select first each of the GameObjects: opening the inspector will force the editor to load their settings and will realign their data.

Fig. 1 A Curved Poly Asset shared among more Game Objects uses the same editor instance, but each Curved Poly can be assigned a different LoD.

Saving and Loading Assets

The first time you create a Curved Poly Behaviour, a new Curved Poly Asset is generated in the editor, but its data is not saved in the project. So, you can shape your model, but if you close the editor or change scene you will lose everything. There are a few actions you can take to save/load your model in/from a valid Curved Poly Asset.

  • Import : pressing the import button will load the list of all available Curved Poly Asset in your project. After choosing one, the content of your current Curved Poly Asset will be overwritten with the content of the selected one. This action will not affect the asset your are copying from in any way.
  • Save : pressing the Save button saves the content of your Asset in its assigned file. If you didn’t previously assign a file, you will be asked to generate one first. If you press ok, the editor will generate a new Curved Poly Asset at the default path Assets/CurvedPoly/User, with a default name, but you can move it in the Project Panel where you want and rename it the way you like. You don’t need to save a Curved Poly Asset when you work on other GameObjects in the scene, because the editor will keep your data until it’s destroyed by either closing the scene or closing Unity.
  • Ctrl+S (File > Save Scene) : when you save the scene, your edited Curved Poly Assets will be automatically saved. Only if you have selected a GameObject with a Curved Poly Asset and its content has not been assigned a real asset file, you will prompted to accept to generate a new one.
  • Save New :pressing the Save New button generates a new Curved Poly Asset, copying in it the data of the one you are working on. The Asset will be a perfect copy and will have its own new editor instance.
  • Change the Curved Poly Asset with the inspector: when you change the Asset in the inspector, the Editor will also perform a Save action on the previous one before switching them.
  • Create a Curved Poly Asset in the Project Panel first: you can also create a new Curved Poly Asset in the Project Panel for instance in the Assets menu with Create > CurvedPoly > CurvedPolyAsset. Then you can assign it to your GameObject Curved Poly Behaviour. After this, you will have an empty shape and you will need to perform an Import to have something to work on.

Do Import, Don't Duplicate

There are many ways to create a Duplicate of a Curved Poly Asset. One option is to load the asset on a new Curved Poly, then use the Save New option. Or you can create a new Curved Poly, Import the one you want to duplicate and save it with Save. You could also duplicate it in the inspector, but in that case Curved Poly will make a slightly different work: the duplicate may be broken into more parts when the original model has texture coordinates.

There is a reason. As explained in the next section, Curved Poly uses two data formats, one for real time operations and one for editing. The real time format is simplified compared to the editing one. When you use Unity Duplication in project explorer, only the real time format will be duplicated (while, for instance, Import will create a copy of both of them). Then, if you try to edit the Curved Poly Asset, the edit format will be generated from scratch and it will miss important informations from the original model.

Editing Data

There is a second asset saved together with the Curved Poly Asset when you press Save.

  • the Curved Poly Asset stores all the informations required to regenerate tessellated meshes in Play Mode (and, generally, at execution time). Data has a compressed format and it's hidden in the inspector.
  • the Curved Poly Editor Asset ( the script name is MLab.CurvedPoly.eHPN.Data.EditablePolygonsNetData ) contains the same data (in an uncompressed format) and all the additional informations which are only necessary in edit mode.

A few things about the Curved Poly Editor Asset:

  • All the Curved Poly Editor Assets are saved at path Assets/CurvedPoly/User/Editor by default.
  • I keep a reference to the GUID of the Curved Poly Asset in the the Curved Poly Editor Asset, so you can move the Curved Poly Asset where you want and I will be able to find its editing counterpart. Also: I will keep the Curved Poly Editor Asset renamed with a name which is calculated on the location of the Asset. For instance, if you move the asset at path Assets/Examples/CP/MyCurvedPolyAsset the other asset name will be Assets/CurvedPoly/User/Editor/Examples_CP_MyCurvedPolyAsset (Basically I take the path and replace the character ‘/’ with the character ‘_’). Names are aligned when you perform a Save action on the asset, so you may experience some misalignment before pressing the Save button again on the Inspector or if you don't save the asset at all.
  • If you move the Curved Poly Asset to another project alone, a new Curved Poly Editor Asset will be generated in the new project, and your custom editing data will be lost. You can manually move both the assets in the new project to find back your settings.

There is a second location where Curved Poly looks for the Curved Poly Editor Asset. Such location is a folder named Editor inside the folder the Curved Poly Asset resides. So for instance, if you have your Curved Poly Asset at path Assets/Examples/CP/MyCurvedPolyAsset, the Curved Poly Editor Asset will be searched at path Assets/Examples/CP/Editor before checking the default Assets/CurvedPoly/User/Editor folder. So you can move the editing assets from the default location to a subfolder of your assets folder, which is useful when you need to move files from your project to another.

Another important editor feature of Curved Poly Editor Assets is locking, which is used for instance by our Curved Poly Primitives. You can lock a Curved Poly Asset (making it a custom primitive) by renaming its Curved Poly Editor Asset, adding the special string model0 at the end of the name. In this way, any attempt to save the Curved Poly Asset will be blocked with a warning message.

Fig. 2 A warning message, happening when you try to overwrite a primitive.

For instance, all the Primitives of Curved Poly - Shape Editor (find them at Assets/CurvedPoly/Assets/Primitives ) have theirs editing assets (find them at Assets/CurvedPoly/Assets/Primitives/Editor) renamed with the special model0 string.

Curved Poly Statistics

This panel is part of the Inspector and it shows the count of vertices, curves and polygons your Curved Poly Asset is made of.

(new!) Now the panel will show separated statistics for the Edit Model and the Runtime Model. It also shows the number of geometries

Mesh Statistics

This panel is part of the Inspector and it shows the count of vertices and faces (Triangles) of the last Mesh your Curved Poly Behaviour put in the MeshFilter. This is useful because Mesh Statistics change when you change LoD, and you may be interested to know how much vertices and triangles you are using at RunTime. You also have two additional buttons here, you need to use carefully:

  • Remove Curved Poly: this action will remove the Curved Poly Behaviour from the GameObject, keeping the Mesh in the MeshFilter. This is helpful if you want to use Curved Poly - Shape Editor as a Mesh Generator, but you don’t care to use it at Execution/Play Time.
  • Recalculate Normals: this action uses Unity RecalculateNormals method to update the Mesh Normals. Curved Poly normals are usually good and you should not perceive any significant difference after normal recalculation. That said, the Curved Poly normals evaluator is still not perfect and there are a few situations in which you may feel there’s something wrong. So, here is your alternative. That said, Curved Poly Editor will rewrite normals again the first time you change something. For this reason, there are only two ways to exploit Recalculate Normals:
    • As a Check, to verify if something is going wrong. Most of the times you will have bad normals in the model because there’s something wrong with the model handles or with the elasticity settings. If, after applying Remove Curved Poly, the bad normals are still there, than you should try to work on your model with the Pointings Operator and pointing your handles one by one. Usually you can get better results by working on the Handles Length or Weight.
    • Before using Remove Curved Poly, if you are planning to remove the Curved Poly Behaviour and you think that RecalculateNormals can give you a better result, go for it.

History

Curved Poly - Shape Editor has its own History storing a reference to any change you make on the model. When you use Unity Undo or Redo actions on a Curved Poly Behaviour, the Editor will keep such History system aligned with Unity one.

At the same time, a maximum of ten actions you performed on the model will be listed in the Inspector. When you Undo, undone actions will have their font-color changed from black to gray, in order to help you understand at which step you are in the history. In this version of Curved Poly - Shape Editor only the last ten actions stored in the history will be shown, so if you Undo more times you will not be able to see undone actions in the Inspector.

Moreover: since the Editor is shared between Curved Poly Behaviours having the same Curved Poly Asset, also the History is shared and you will be able to see the actions you took also while Inspecting other GameObjects.

(new!) Now the panel will show a control to choose the maximum number of elements stored in curved poly history. Lower the number down if you think that curved poly is using too much of the editor memory.

LoDs

You can edit the LoDs asset also in the Curved Poly Inspector. This is helpful when you are learning Curved Poly Editing for the first time. However, you should use this carefully because changing a LoDs asset within the Curved Poly Inspector will affect any other Curved Poly Behaviour using that LoDs asset, even the ones not being in the actually selected scene.

Update : this is an additional button, not present in the LoDs inspector, which allows you to update manually your Curved Poly Mesh after you have finished changing a LoDs tessellation data.




<< Prev Next >>