Wings3d why erlang




















Other possible choices would have been Scheme or Lisp, but I don't know those languages nearly as well as I know Erlang. Although Scheme and Lisp can be used in a functional style, they can be used in an imperative style as well; the mix of imperative and functional style properly used could have had advantages.

An interesting language if I had started today would be Haskell. I have no intention of doing that. But feel free to start your own Wings-rewriting project.

What are the strengths of Erlang? Concurrency and support for Symmetric Multi Processing i. But Wings doesn't use that at all yet. Another strength is pattern matching.

That makes Erlang good for implementing complex 3D modeling commands and for implementing complicated telecom protocols and web servers. That Erlang is functional. A functional program is easier to test. Memory handling: It is easy to create dynamic data structures containing many small objects.

Dynamic typing. You don't have to declare any types; type errors will generate an exception at run-time. Since exceptions can be caught, it is possible to recover from most bugs i. Wouldn't it be great to have a printed list of all the defined hotkeys? This can be easily done by entering:. This could be a long list because it produces the hotkeys for each mode. But now you have the option to make a hardcopy to use as a handy reference.

Here's a format that is much better suited for printing the hotkeys list. The following code should open up a browser with the keys neatly listed in a table.

Here I used a recursive anonymous fun not to be confused with a function to do the work. You can easily find modules and functions by pressing tab in the console window. This will give you a list of modules. Enter the name of a module followed by a colon, then press tab to see a list of all the functions that the module exports. In the console, the tab key acts a completion helper. Most of the wings modules start with a "w". So type a "w" and press tab to see all the modules that start with that letter.

By using the tab you can easily type long functions without cut and paste. Many functions deal with the currently selected elements—vertices, edges, faces, or entire objects.

Wings is flexible enough that it allows you to select elements on more than one object simultaneously. Don't forget to take this into account if you want to limit your selection to a single object. This actually came up as I was writing the shortest path selector.

It didn't make much sense to select the shortest path as a series of edges between two vertices on two different objects because there are no edges connecting separate objects! Here's an example of how to get the selected elements. The current mode—vertex, edge, face, or body—determines the type of the elements in the variable Sel. Select any two vertices on a cube and paste in these lines:. Now points A and B are bound to the variables Pa and Pb. Note that Pa is not necessarily the first point selected.

Selections are not returned in the order that they were selected. Here's an example of how to get the selected faces. Select any number of faces on a cube and paste in these lines:. You'll get a list of lists of tuples. This is the object in raw format. It is possible write a complete exporter by using the shell and a few simple functions or Erlang Anonymous Fun s.

This code will export the first mesh to Wavefront OBJ, a common format. It will export the mesh data, but the materials and textures will be ignored. Why do you need this example if a full featured OBJ exporter is included with Wings?

Because this one is meant to get you started. I should mention that this example requires 0. Remember to quote the filename with single quotes. As an exercise, see if you can modify the code to automatically triangulate the model before exporting. Many wings functions simply take the state as input, modify it, then return the modified state as output. That sounds pretty simple, and it is. If you were clever enough, you could call one of these functions from the shell and modify objects.

Another large set of functions take the We record the W inged- E dge D ata S tructure as input, modify it, and return it. For a little insight on the WEDS format try this:. The above simply outputs dumps the winged-edge data structure to a file and then reads it back to you. This is useful if it's the first time you encounter this structure. Here's the output for a tetrahedron. Finally, the nicest and most elegant way to exit or quit Wings from the shell is to execute this simple function: q.

Now that you had a chance to code interactively, you will be more prepared to write your own functions and new features for Wings. I have tried to be as comprehensive as possible and this tutorial should give you a great head start on your journey to plugin writing.

Introduction This tutorial if for beginners and aspiring plugin writers who would like to know more about the internals of Wings.



0コメント

  • 1000 / 1000