Editor Scripted Meshes

I’m looking into writing a sort of unique heightmap library, and I’m curious about what classes I’d be mucking with in the process of creating a subsurf model within the editor, and adding/subtracting data to the vertices of the heightmap…

The editor class documentation is a little sparse here.

If I understand what you want to do, you would probably be making use of the Mesh API to generate the geometry and the editor classes would mainly be for the user interface. Can you give any more detail about how you envisage creating/editing the heightmap data in the editor?

Alright, I got pretty far on this last night before I had to go into work.

I’ve got two different systems in the works right now, when I hit a snag on one, I move on to the other.

The first, is an Editor subclass, which handles what I’m calling a LatheBrush. The LatheBrush is a 2-dimensional collection of points and edges.

The Lathebrush itself uses a custom Editor script to allow the user to click and drag on control points on the Lathe Brush.

I’m using the Handles class to draw lines between each vertice on the path, and then dots on the vertices in the 3d space, and a third pass draws dots at the midpoint of each edge. This works exactly like a standard 3d modeling tool.

I want to make it so that the player can click on these handles and drag them around in the editor, but I can’t find a class that allows me to detect mouse clicks on these handles. Can someone point out to me how this works? I activate edit mode by clicking on a button in the inspector, but any time I click on a handle, it’s going to lose focus on the object in the inspector by default. Is there some built-in behavior that I’m missing? Or am I going to have to create a special class to handle the selection, and movement of these handles within the Editor GUI?

As for the terrain system, I’m using something very similar. I’m creating terrain pages by clicking on one of four arrows that are drawn when you select either a face or an edge. When a vertex is selected, the only option is to collapse it into another vertex that it is connected to using similar arrows.

Interior faces are automatically deleted. Most of this is working, but again, the issue is the selection of faces, edges, and buttons… I’ve got everything drawing properly, but no dice on the buttons. I’d really like to draw filled shapes or textured 3D shapes in the world space, but I’m not sure of how to make it so that these shapes can be clicked on, since they are being drawn each frame…

I’m having some trouble envisioning how the built-in terrain painting system works. The best way I can think to do this, is to raycast to the mesh, and modify the vertex heights accordingly. (Of course, the my height calculation is going to be much more complex, involving the averaging the distance between each point and whatnot, but whatever.) How do the built in terrain shaders work, and how many different terrain textures can they support on one heightmap at a time?

Another question I had, was if it was possible to create a realtime 3D viewport in the inspector, or in an Editor Window? Kind of like the model viewer? Or is that a rendertexture? I’d like to manage some things via an external editor, seeing as a lot of my content is going to be databased content, and I’d like to be able to query, update, and drop items from the database, and view them in 3D while I do so.

I was also wondering about 3D Objects on the HUD. Would I have to pass data directly to GL to do that?

Thank you for the late answer, I was giving up on asking, and I got most of what I was wondering about done, by doing a combination of searching the forums, and using completely unrelated answers to stumble on the right ones, and reading and re-reading the reference material.

I would like to note, that my first experiment with mesh creation in the editor went horribly.

First, I didn’t know I had to invalidate the old layout, and update it. I ended up just sort of pounding my head into the keyboard as I created a plane without ever having told the mesh to update, and thus display itself.

I did, however, discover a few things:

  1. How to add menus and commands to the editor.
  2. How to add windows, and create custom contents in the editor.
  3. To never, ever, ever use the handles class outside of the OnEditorGUI function.
  4. How to draw lines and shapes in the GUI.
  5. That drawing debug lines are worthless.
  6. numerous other things.

I think I’m starting to get it, but the description of how most of the GUI stuff interacts has a little bit less “oomph” to it than the rest of the reference. Most of it is pretty sensibly layed out, but that freaking Editor and GUI stuff is just completely arcane, and needlessly spread between classes.