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:
touches = Touches()
viewport = Viewport() -- maybe pass some defaults here
shape = Shape("cube")
I agree. ideally, main() (er, draw() that is) should fit on one page.
I’m trying very hard with the Font/Keyboard stuff to be:
f = HersheyRomanSimplex()
k = Keyboard()
and then just draw em.
Keyboard should probably take an argument for what font to use, thinking about it.
It’s funny how we think alike but on different levels (or actually dimensions ) I had half started a 2D valence bond program.
Andrew, would it be possible to add a function that would allow to draw 3D functions using a mesh?
Okay, 1 4 6 7 are now done. The code is as a
.codea file on my website at the above link (the other files are old, I’ll update them later).
Also, a “flick” will set the shape rotating.
With the swipes for translating, a two-fingered swipe translates before translating and a three-fingered one translates after.
Once we get a decent data serialiser, after moving the vertices then it would be nice to be able to save the new data.
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
Yes, that would work. I’ll look into it. Thanks!
(I must take a longer look at that lua-users.org site. Just about every “how do I do X in lua” search that I do ends up there.)
New version, now with more refined shape editing.
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).
Still to do: saving and loading shapes.
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:
- 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).
Latest version is terrific, Andrew. Very impressive.
I, for one, am deeply disappointed.
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.
Next step is being able to define different types of vertices
Vertices can already have their own colour, radius, and valency, overriding the defaults. Ditto edges. What else would you like?
Wholly crap! How did I miss this! As always, I like to give ideas. Possibly, you could define the number of vertices?
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.
Oh… Sorry. Feel free to submit it. You can submit one price of code in each section in my compitition. I like it.
I really wanted to check this out but looks like the link is dead.