On May 11, 2011, at 3:41 PM, Russell Senior wrote:
> A long time ago, like in 2004, I used K3D in a project to visualize
> some 3D structure (a collection of cylinders). Back in those days
> (v0.4.x), it was fairly trivial to hack in some objects into an
> "empty" .k3d file. I know the endpoints of the cylinders x,y,z in
> world space, so I was able to set the radius, Zmin to 0, Zmax to the
> length, the position to one end's x,y,z and compute an orientation
> I've dredged up this project again, and am trying to prep for a
> presentation tomorrow where i'd like to do a live demo of how it lets
> me spin the structure around and inspect various parts, etc.
> Not surprisingly, nearly 7 years later, K3D's data format has changed
> and it doesn't like my old format files. I am hoping someone can tell
> me an expeditious way of getting my structure into a modern K3D
> (v0.8.0.2). I've seen the scripting stuff, maybe I can write my
> output into a script that builds the right thing? A pointer/example
> in the right direction would be most welcome.
Lots of water under the bridge - in the old days, a cylinder was a node that knew how to render itself; now, cylinders are a type of geometric primitive, just like polygons, so there's no one-to-one mapping from your old files to the new.
A few options come to mind: since you're already a fan of hacking on files, you might try the following:
* Start K-3D 0.8.
* Choose Create > Quadric > QuadricCylinder. This is a mesh source that creates individual cylinder primitives.
* In the QuadricCylinder properties, choose Output Mesh > Mesh Options > Save Mesh. Pick a filename.
* The file that you just saved contains just the mesh with a cylinder, not the whole document. Edit it to suit.
* To load your modified file into a document, choose Create > MeshReader > K3DMeshReader, and choose your modified file.
When you modify the saved mesh, you'll see that it is an XML file organized into a series of "tables", which each table containing zero-to-many arrays. The array names should look pretty familiar - you can add more cylinders to the file by adding values to the arrays.
A second option:
* Start K-3D 0.8.
* Choose Create > Mesh > MeshSourceScript.
* In the MeshSourceScript properties, choose Script > Load and pick the share/k3d/scripts/MeshSourceScript/cylinders.py script.
* Choose Script > Edit Script and modify the script to taste. For example, you could use the script to load your data from an external file, and create as many cylinders as-needed.