24 May 2013

Fun With Phones......

It's been a few weeks since my last post... it's busy times again but all work and no play makes Mat a Dull boy so I set myself a quick technical exercise... model and render my headphones.

I know, if the subject was any more exciting and I could cause my self an injury right..... Ok, it was the first thing I picked up when I decided to set myself a task.

Anyway, modelling and rendering.... pretty straight forward really, I threw in a bit of Mudbox sculpting for the headphone pads but apart from that it was very quick, straight forward and fun.

It's nice to set yourself challenges every now and then, no pressure to get it done just zone out and enjoy the practice.

Here's some pictures....

A nice jaunty angle, I think I might have overdone the depth of field here but hey, I'm the client here and I'm happy with it!!

Close up of the label, I decided to use geometry for the badges rather than bump maps, it's worked out quite nicely really.

 Another close up, this time of the hinge, what's the point in adding detail if you don't render it eh!

I rather like this shot, it sort of looks like it belongs in an advert.

Anyway, that's that... I don't really feel as though I pushed myself with this little project but I did learn some stuff along the way. I definitely need to brush up on my composition skills and remember to adjust the depth of field on the rendering camera... or at least write a script to do it for me!!

1 May 2013

Fibionacci - Curves & Coding

I was asked by an artist friend if I could make a Fibionacci spiral that they could use in their 3D work or more precisely a button that when pressed would create one..... challenge accepted!

I'm no coder but I know a little MEL (Maya's native language) and I also like a good problem to solve so I set right to it by finding out the the equation for the Golden Spiral which turns out to be....

X(t) = sin(t*pi)*exp(t)
Y(t) = cos(t*pi)*exp(t)
Z(t) = exp(t)

I assumed X,Y and Z are translate coordinates and that t = time so I used the equation, where testLoc is the name of the locator, in an expression that I attached to a locator and it worked a treat.

testLoc.translateX = sin(time*3.14159)*exp(time);
testLoc.translateY = cos(time*3.14159)*exp(time);
testLoc.translateZ = exp(time);

I applied a motion trail to the locator to visualise it's path and was actually surprised a how well it had worked, figured the job was a good'un and that my artist friend would be happy making spirals until the cows came home. Unfortunately motion trails, while being an awesome animation tool, are not particularly useful for much else and so it was back to the drawing board.

I had a couple of otpions to choose from....

1 - The possibility of making a CV curve from the motion of an object that had the expression applied.
2 - Could I write a self contained script that would create a CV curve without the need for the expression.

I figured that the fewer steps that the end user had to consider to get the spiral would be the best option and so I decided to go for the self contained script rather than the expression/script combination that I believed the first option would entail.

The problem with scripting is that it isn't time based in the same way as expressions are. An expression will be calculated per frame as the animation plays whereas a script is considered when it is applied and not during playback. Being as time is a key element of the spiral equation I had to work out how to apply time in a script.

In a moving image sequence, time can be calculated by dividing the frame number by the frames per second and so using a loop, limited by the number of frames in the animation, to create an integer representing the frame number and querying the playback speed of the scene I was able to create a time value which I could apply to the spiral equation. That was the hardest part, the rest was pretty straight forward.

When run, the script initially creates a minimum value CV curve with four coordinates then queries the length of the animation and rebuilds the curve to have the same amount of control vertex as there are frames in the scene. The control vertex are then redistributed according to the spiral equation (with the calculated time) and Bob's your uncle, you've got a Fibionacci spiral shaped CV curve that you can use as a motion or extrude path in whatever cosmic animation you're planning to make.

Here's a link to the script, just copy and paste the text into Maya's script editor and execute it for spirally goodness. If you want to you could put a button on your custom shelf by selecting the text in the script editor and dragging it, while holding the middle mouse button, to the shelf, enjoy :)

CLICK FOR SCRIPT - Creative Crash