Michael Auerswald

Photographer, Animator, IT Monkey

In Bloom

without comments

Just finished a new personal project, which offered me the oportunity to try out some new stuff:

Written by Michael

September 3rd, 2010 at 1:04 am

C4D – Make textures stick to mograph Text object

with 3 comments

This nearly drove me to insanity and back – but luckily some nice people on the mograph board had already worked out the answer. Basically, this is the problem: you can’t put a texture on a mograph Text object that will follow it. It will always behave like it was frontal/camera projected. You also can’t put a UVW tag on the object unless you make it editable – which would open a whole new can of worms as then you can’t use all the nice mograph effects any more, plus you have to deal with the UV map, which for a simple texture you may not want to. The solution is more of a workaround. It’s somewhat convoluted, but it works. Basically you drop you text into a Connector object which then is dropped into a Fracture object (see image).

Make sure to adjust the proper Phong mode in the connector object, otherwise your text’s corners might become rounded. You can either make the mograph text editable once so you end up with the spline and extrude object, or you manually create an Extrude Nurbs and drop the mograph text itself in.

(oh and as a side note: the “Stick Texture” tag does not work on mograph text either. Boo!)

Written by Michael

August 26th, 2010 at 8:41 pm

Posted in Vfx

Tagged with ,

Nuke / Renderpal: error in submit script

without comments

There seems to be a small error in the python script for the Nuke to Renderpal submit, at least when it’s running under OSX. The “IsWin” function is being called just like that: “If IsWin:” and so on. Unfortunately that doesn’t return the true/false we want. You need to replace all the “if IsWin:” with “if IsWin():”

Written by Michael

August 20th, 2010 at 1:00 pm

Posted in Blog

Tagged with , , ,

Py4D: Fibonacci Spiral

without comments

So, this Py4D Script is going to be a bit more complex. You probably know those Fibonacci spirals. I wanted to create one of those, including the squares that are being used to construct them, when you are using pen and paper. That’s definitely a job for a script, especially if you want to stay flexible in regards to the length of the spiral etc.

This is what we are aiming for:

And this is how we get there:
Read the rest of this entry »

Written by Michael

August 4th, 2010 at 9:10 pm

Posted in Vfx

Tagged with , ,

Py4D and COFFEE: Objects

without comments

This is a list I found here. It’s all quite Japanese, but instead of digging through all the header files, I decided not to reinvent the wheel here. There’s a wealth of information on those sites – if you can read them.

Offd FFD
Osds Hyper NURBS
Oatomarray Atom array object
Oinstance Instance
Oparticle Particle emitter
Ooiltank Oil-tank object
Ocapsule Capsule object
Ocamera Camera
Osplinecycloid Cycloid spline object
Osweep Sweep NURBS
Oheadphone Headphone
Ostage Stage
Ospline Spline object
Osplinedeformer Spline deformer object
Osplinerail Spline rail object
Oshear Shear deformer
Oturbulence Particle turbulence
Otube Tube object
Otwist Twist deformer
Odisc Disc object
Osplinetext Text spline object
Otaper Taper deformer
Otorus Torus object
Onull Null object
Opyramid Pyramid object
Ofigure Figure object
Oboole Boolean
Osplinecontour Contour spline object
Obezier Bezier NURBS
Osinglepoly Single polygon object
Opolygon Polygon object
Opolyreduction Polygon reduction object
Obone Bone
Omicrophone Microphone
Ometaball Metaball
Omelt Melt deformer
Olight Light
Oloudspeaker Loadspeaker
Osplinehelix Helix spline object
Owrap Wrap deformer
Orelief Relief object
Oloft Loft NURBS
Oattractor Particle attractor
Osplinecircle Circle spline object
Ocone Cone object
Ocylinder Cylinder object
Oextrude Extrude NURBS
Osplineflower Flower spline object
Olathe Lathe NURBS
Orotation Particle rotation
Oenvironment Environment
Ospherify Spherify object
Osphere Sphere object
Osky Sky
Obend Bend deformer
Ofriction Particle friction
Osplinearc Arc spline object
Oconplane Construction plane
Ospline4side 4-sided spline object
Osplinecogwheel Wheel spline object
Osplinecissoid Cissoid spline object
Ogravitation Particle gravitation
Ofloor Floor
Odestructor Particle destructor
Osplineformula Formula spline object
Oformula Formula deformer
Osplinestar Star spline object
Oplatonic Platonic object
Oselection Selection object
Oforeground Foreground
Osplinenside N-sided spline object
Osymmetry Symmetry object
Osplineprofile Profile spline object
Ofractal Fractal object
Osplinerectangle Rectangle spline object
Obackground Background
Oarray Array
Oexplosionfx Explosion FX object
Oexplosion Explosion deformer
Odeflector Particle deflector
Owinddeform Wind deformer
Owind Particle wind
Oshatter Shatter deformer
Oplane Plane object
Obulge Bulge deformer
Ocube Cube object

Written by Michael

August 4th, 2010 at 3:51 pm

Posted in Vfx

Tagged with , ,

Py4D: Hello Cube

without comments

To get things going, here`s a quick example of how to generate a cube from scratch. This lets you generate most kinds of objects, although some, like splines and polygon objects, have their own constructor (more later…).

First of all, here’s the source code:

import c4d
from c4d import symbols as sy
 
def main():	
	cube = c4d.BaseObject(c4d.Ocube)
	cube.SetName("MyShinyNewCube")	
	cube[sy.PRIM_CUBE_LEN] = c4d.Vector(50,50,50)
	cube.SetPos(c4d.Vector(25,25,25))
	cube.SetScale(c4d.Vector(1,2,1.25))
	cube.Message(c4d.MSG_UPDATE)
	doc.InsertObject(cube)

Let’s go through this step by step.

import c4d
from c4d import symbols as sy

Import c4d makes the functions from the c4d available to you in your script. You still have to reference them with the prefix c4d. though. So it’s not “Vector”, but “c4d.Vector” so Python knows we’re referring to the Vector as it is defined in the c4d module. So far so good. The second line imports the symbols module, which in itself is part of c4d. You could refer to it just as well by typing c4d.symbols.whatever, but it’s a bit more convenient to instead just type sy.whatever. The symbols that we are talking about are defined in the header files of the Cinema 4D SDK. They represent variables that can be read and written to. Those are the various fields that can be seen in the attribute editor on the Cinema 4D UI. We’ll use one of those in a bit. You can find those header files by searching your Cinema 4D program folder for a subfolder called “res” (there will be than one). Then have a look at the definitions in there – you can use these to find out what kind of data you can manipulate for each object.

def main():	
	cube = c4d.BaseObject(c4d.Ocube)

So here we just create a cube. A cube is of the object typ “Ocube”. BaseObject is the base class for all objects. Some objects offer additional functionality, so they extend the BaseObject class, like the SplineObject. Here’s a list.

	cube.SetName("MyShinyNewCube")	
	cube[sy.PRIM_CUBE_LEN] = c4d.Vector(50,50,50)

The SetName() just does what it says. You just pass it a string and it becomes the name you’ll see in the Object Manager. Much more interesting is the second line. This is one of those symbols I was talking about before. PRIM_CUBE_LEN contains a vector, which in turn defines the x, y and z cube length (same as in the Object tab of a cube’s attribute editor in the GUI). This is, for all I know, the only way to influence certain parameters of an object, there’s no “setsize” function etc.
To find out the name of a field, the easiest way is to just drag and drop the label of that field in the UI into a text field like the Console window. It’ll give you the internal name of that field, which you can use to refer to it. However, this will be in Maxon’s COFFEE format! So you can’t use that label directly in Python. For example, the above will look something like #PRIM_CUBE_LEN!VECTOR_X or similar. Python does not like this one bit. It’s probably the easiest to just read out the value of those fields in the UI (via the print command) and that should give you some indication of the data type contained. So, PRIM_CUBE_LEN you’ll notice, returns a Vector. So that’s what we are going to feed it.
If you can’t figure out the python-friendly name, theres an alternative as well. Each of these strings has a numeric value too, again to be found in the header. cube[sy.PRIM_CUBE_LEN] as it turns out is identical to cube[1100]. Same thing. This cries out for some commenting though, otherwise you’ll never remember what value does what.

	cube.SetPos(c4d.Vector(25,25,25))
	cube.SetScale(c4d.Vector(1,2,1.25))

On we go with some rather straightforward functions. SetPos sets the center position of our cube (the pivot position). SetScale sets the scale (default is 1,1,1). So in our case, our 50x50x50 cube will become some oblong shape.

	cube.Message(c4d.MSG_UPDATE)
	doc.InsertObject(cube)

The message tells the cube to redraw (update) itself in the viewport. Especially when you modify vector points you need to do this to see the immediate result on screen. InsertObject() is the final step, it actually inserts the cube, which so far only existed within python, into the Cinema 4d document. At this point it will appear in the Object Manager. If you pass it a second object as a parameter, it will parent your cube into that (so, if you create lots of objects, you would first create a bunch of Null objects, for example, and then group your other objects under those).

And that’s that. I hope this helped to give a first idea of how things work. I found the documentation of both the SDK and Py4D so lacking (especially as there are virtually no examples), that even this rather basic script took quite a while to figure out. Could just be me though ;)

Written by Michael

August 4th, 2010 at 3:38 pm

Posted in Vfx

Tagged with , ,

Py4D: Getting Started

without comments

After installing Py4D just add the new Py4D Tag to any of your objects. If you want to modify a certain object with your Python script, you should probably add the tag to that object, as you can refer to it directly from the script that way (of course you can as well use Nulls to manage your scripts and keep them separate from the geometry and then just find the object you want to work in from within the script).

Here’s a super simple example:

import c4d
 
def main():
    obj = op.GetObject()
    print obj.GetName()

All this does is that it will give you the object’s name in the Python console. It does however show a few things that are important to know:

    import c4d

The first line in every Py4D script (or one of the first at least). It imports the c4d module and makes all the nice functionality available that’s documented here. Without, there’s really not all that much you can do in Cinema 4D…

    obj = op.GetObject()

Every Py4D script automatically contains two variables that are being assigned during initialisation: doc and op. Just like in a COFFEE script, doc refers to the BaseDocument that the script has been called from. op on the other hand refers to the Py4D tag itself! By calling the tag’s GetObject() function, we receive the object that the tag has been assigned to in return. Thus, we can now call functions that work with the actual object.

    print obj.GetName()

Not very impressive, I know. All this does is return the name of the object to the console. Still, it proves that we can indeed access the tag’s parent object.

Written by Michael

August 4th, 2010 at 9:44 am

Posted in Vfx

Tagged with

Py4D blogging

without comments

I’m starting to work more with Py4D and C.O.F.F.E.E., but the entire C4D SDK etc. documentation leaves a lot to be desired… getting your head around certain things, especially how to get started, is bloody torture. So, as much to help others as to simply documents things for myself, I’ll start to blog some code snippets, maybe tutorials and random thoughts about C4D scripting. If you know any interesting links with more info, please let me know so I can link to them from here as well.

Written by Michael

August 4th, 2010 at 9:26 am

Posted in Vfx

Tagged with , , ,

Pinhead

without comments

Pinhead

I was planning on creating a nice animation – but a single frame took 3,5 hours on my dual core, so I decided it would be a bad idea…

Written by Michael

July 16th, 2010 at 8:42 am

Posted in Vfx

Tagged with

Reforming Logo

without comments

Written by Michael

June 29th, 2010 at 10:30 pm