1 and 4 are my main wishes - I’m looking at this less as a “molecule viewer” and more as a toolkit. Anything abstracting away details is therefore welcome.
Also - momentum on the trackball controller would be nice, so if you give it a good spin, it coasts to a stop; it feels odd that it stops instantly when you let up, the iPad has trained me to expect things to coast to a stop unless I stop them.
BY THE WAY - if I haven’t made it clear before - this is pretty damn cool. Thank you.
Also - momentum on the trackball controller would be nice
I pondered that. You’re right that it’s “expected” on the iPad, it would also be quite fun. I have code for this in another project (the touch code on the wiki) so it wouldn’t be hard to add. I think in terms of implementing it, it would fit in most naturally once (7) has been done.
Maybe I’m taking abstraction a bit too far, but I’d really like my main program to be:
function setup()
touches = Touches()
viewport = Viewport() -- maybe pass some defaults here
shape = Shape("cube")
end
function draw()
Touches:draw()
viewport:draw()
shape:draw()
end
function touched(touch)
Touches:add(touch)
end
The vertex/edge data is just a couple of tables, no? It seems it would be easy enough to simply save them as strings of numbers, and parse them again. See http://lua-users.org/wiki/SplitJoin
There’s a big red circle in the top left. Touching that toggles between “view” mode and “edit” mode. In edit mode, tapping a node selects it, moving a node moves it and all selected nodes. Double tapping a node toggles the edges (ie removes those that exist and creates those that don’t) between it and all selected nodes. Tapping somewhere where there isn’t a node creates a new node. (Should provide a way to delete a node as I keep creating new nodes by accident).
This version is a fairly major update as I’m using the new clip capabilities to deal with the non-transitivity of edges overlapping (see picture in first post). Basically, when we draw a new piece (vertex or edge) then we go back through the previously drawn edges and see if any should be on top of the latest one. If so, we redraw the old edge but clipped so that only the bit over the new edge is seen. (It’s not completely ideal - there are some “edge effects” - but it’s pretty darned good, if I say so myself.)
I’ve also added the ability to specify a shape using valencies on the vertices. Each vertex is given an edge to the nearest other vertices up to its valency (and so long as those other ones have spare valency). This makes it much easier to specify something like, say, buckminster fullerene. The routine that specifies that is remarkably simple, considering the complexity of the molecule!
Predefined shapes now include:
Cube
Octahedron
Borromean “rings” (actually rectangles)
Four sticks (to demonstrate the non-transitivity of “is in front of”)
Two sticks (mainly for debugging)
“Chair” form of cyclic hexane
The shape that is shown when the program is run is actually a “merge” of the cube and the octahedron, demonstrating the mutual symmetries of the two.
It feels a bit sluggish because it is using the new routine for rendering edges. On some shapes, that isn’t necessary and can be turned off (actually, the default is for it to be off).
Need to work on the UI a bit, and severely comment the code (that’s the one bit of programming that I actively dislike doing in Codea so I’m waiting until next time my iPad is hooked up to my Linux machine and I can use Emacs).
WOW! It’s amazing! I’m not able to do that. I know many programming languages HTML, CSS2/3 Javascript/Ajax, PHP, Java and little C++, but I can not do that. Maybe I do not know about algorithms. (
I’ve done balls-and-sticks before - a few times. This SO BLOWS AWAY even my best efforts, I can’t even look at myself in the mirror. (Ah, who am I kidding? I love me.)
Next step is being able to define different types of vertices - we can pretend this is a molecule thing, and you’re differentiating hydrogen, oxygen, carbon, and so on, but know in the back of your mind I’m thinking planets (or stars) and hyperspace lanes.
What would you have the program do if you specified, say, 4 vertices? Where would it put them? You can already edit the shape and add or delete vertices.