Add a Pay Pal “Buy Now” Button

Posted by on Jan 25, 2011 in code, how to | No Comments

If you have a PayPal account, go here to set up Buy Now, Cart, Donate buttons.


OK, now give me a dollar!



OK, a penny?

HTML create new line

Posted by on Jan 11, 2011 in code, how to, web, wordpress | No Comments

To create white space between paragraphs in a post etc in WordPress.

<br />&nbsp;

How to create a mouse-over image for a wordpress post

Posted by on Jan 11, 2011 in code, how to | No Comments

This comes from a nice tutorial that you can find here at: More Than A Maths Teacher.

You will need to add a javascript file to the root folder of your current wordpress theme. Code is below. Note the the images I used for the mouse-over are named image.png and image_over.png. For this particular script to work, your images must be names image.png and image_over.png ( “image” stands for whatever you want, and can be replaced). If you want to use another file format, than png, you must edit the code.

jQuery(function($) {
$(document).ready(function() {

		// Preload all rollovers
		$(".hoverlink img").each(function() {
			// Set the original src
			rollsrc = $(this).attr("src");
			rollON = rollsrc.replace(/.png$/ig,"_over.png");
			$("<img>").attr("src", rollON);

		// Navigation rollovers
		$(".hoverlink a").mouseover(function(){
			imgsrc = $(this).children("img").attr("src");
			matches = imgsrc.match(/_over/);

			// don't do the rollover if state is already ON
			if (!matches) {
			imgsrcON = imgsrc.replace(/.png$/ig,"_over.png"); // strip off extension
			$(this).children("img").attr("src", imgsrcON);

		$(".hoverlink a").mouseout(function(){
			$(this).children("img").attr("src", imgsrc);


Nextyou will need to add the following code to your head.php file, somewhere between the tags.

       wp_enqueue_script('hoverlink', get_bloginfo('template_directory').'/rollover.js');

Finally use this format to the post to add the images:

<div class="hoverlink">
<a href=""><img src="" border="0" alt="mouse-over" width="200" height="100" /></a></div>

How to learn PHP

Posted by on Jan 5, 2011 in code, how to | No Comments

1. Download and install XAMPP (free). You will need to run this software (or similar) to enable an Apache web server on your computer. In other words you need this to run PHP scripts.
2. Download and install Eclipse PDT All In Ones / Eclipse PHP Package (free). This is a development environment, a text editor and other tools, with which to create your PHP scripts.
3. Launch XAMPP. Start Apache, and MySQL.
4. Launch Eclipse. You will need to choose the “workspace”. The workspace is where you will save your php files. Generally you will want to use XAMPP’s htdocs folder. Found in the application folder where XAMPP resides. While XAMPP is running you will be able to launch your php scripts in a web browser by navigating to http://localhost/myScript.php
4. Find a book or tutorials. Start learning.

CG Rain Drops

Posted by on Dec 23, 2010 in animation, code, dynamics, Maya | No Comments

Splashes created in Real Flow, and instanced to Maya Particles.

Ripples created with a dynamic fluid texture.

float $colU = particleShape1.collisionU;
float $colV = particleShape1.collisionV;

if ($colU > 0) {
int $xpos = fluidTexture2DShape1.resolutionW * $colU;
int $ypos = fluidTexture2DShape1.resolutionH * $colV;
setFluidAttr -xi $xpos -yi $ypos -at density -ad -fv 0.6 fluidTexture2DShape1;

Syntax Highlighter Evolved for WordPress short codes

Posted by on Dec 12, 2010 in code, web, wordpress | No Comments

Syntax Highlighter Evolved “short codes” or brush aliases for “brushes” brushes.

Ex:  for c code.

Maya particle instancing with real flow rain drops

Posted by on Nov 26, 2010 in code, dynamics, Maya, MEL | One Comment

Create animated instances geometry at a particle collision.

For my raindrop splash, I am using an animated sequence of geometry, created in realflow (70mb). The realflow bin sequence is a single node after it is imported to Maya, it needs to be converted (duplicated) to a sequence of Maya nodes, multiple nodes. Use the following MEL script to convert the bin to multiple nodes.

//Select your realflow imported bin
string $bin[] = `ls-sl`;
//this is set up to to "convert" (duplicate) the bin from frame 1 - 100. Set the frame range that you want to convert below.
for( $index = 1; $index <= 100; $index++ )
currentTime $index;
select $bin[0];
select -cl  ;

Now you should have a sequence of separate meshes, each representing a frame of your instanced animation. These will be loaded into the “particle instancer” to allow for animation at the point where each particle collides.

Create a collision event for your particle
1. Select particle and collision object and go to Menu : Particles > Make Collide
2. Set a particle collision event for your selected particle. Particles > Particle collision event editor. Set: event type to “emit”. Set: inherit to 0. Set: 1 particle emitted per collision. Set: Original Dies.
3.Press the create event button. A new particle object will be created.

Instance the geometry to the newly created particle.
1.Go to Menu>Particles > Instancer options
2. Load your sequence of separate meshes into the “Instanced Objects” section. Make sure that your particleShape is NOT loaded into the create instancer as an instanced object as it will try and instance itself.
3. Set: particle object to instance to : particleShape2 or whatever the particle object that was created by the collision event.
4. Select the newly created particle object shape. In the attribute editor, set: the lifespan of the particle to the duration of you splash object geometry sequence (number of individual nodes). The lifespan is in seconds…so you will need to do the math to get your frame count..

Tracking the position of a particle collision.

Posted by on Nov 23, 2010 in code, dynamics, Maya, MEL | No Comments

Rough guide:

  1. Create planes, one above the other, scale to 10 units square, and place in positive unit space.
  2. Select the top plan. Make it emit particles: Particles > Emit From Object >options (select “surface” as emitter type).
  3. Make particles and ground plane collide. Select the particles, Shift-select the plane, then select Particles > Make Collide.
  4. Select particlesShape, add CollisionU and CollisionV attributes. Set the lifespan attribute to LifespanPP only.
  5. Create a locator called loc.
  6. Create a dynamic expression with the code below.
float $colU = particleShape1.collisionU;
float $colV = particleShape1.collisionV;

if ($colU > 0) {
	loc.translateX = ($colU*10);
	loc.translateZ = ((1 - $colV) * 10);

Scene file.

determining the bounding box of a Maya object

Posted by on Nov 22, 2010 in code, how to, Maya, MEL | No Comments
float $boboArray[] = `polyEvaluate -b pCube1`;

for a default cube, this will return : // Result: -0.5 0.5 -0.5 0.5 -0.5 0.5 //, the units returned correspond to the 6 coordinate locations of the cubes vertices.

float $boboArray[] = `polyEvaluate -b pSphere1`;

for a default sphere, this will return : // Result: -1 1 -1 1 -1 1 // , the units returned correspond to the coordinate locations of the a cube that is “fitted” to the sphere’s bounding box.

Collision Detection in Maya

Posted by on Oct 13, 2010 in code, Maya, MEL | 2 Comments

Based on this tutorial. You will need to download and source this script.

I added attributes to the cubes: .col1(int), .theCol_u(int), and .vel(float) to watch for collisions, “unique” collisions (see the tutorial), and the velocity of the cube, respectively.

Two expressions are created for each cube, each rigidBody. The first is created to watch the dynamic rigid body collisions, and the velocity of the rigid body.

// variables
string $myRigidBody = "rigidBody1";
int $contactCount;
int $uniqueContactCount;

//check velocity
vector $theVelocity1 = `getAttr rigidBody1.velocity`;
float $velCheck1 = ($theVelocity1.x + $theVelocity1.y + $theVelocity1.z);
float $absVel = `abs $velCheck1`;

pCube1.vel = $absVel;

// get $contactCount
$contactCount = `getAttr($myRigidBody+".contactCount")`;

// compute theCol_u
if ($contactCount > 0)
  string $array[] = `rigidBody -q -contactName $myRigidBody`;
  string $flatArray[] = flattenStringArray($array);
  $uniqueContactCount = size($flatArray);
  $uniqueContactCount = 0;

// set interface attributes
pCube1.col1 = $contactCount;
pCube1.theCol_u = $uniqueContactCount;

The second expression affects a shader, based on the collision and velocity values collected by the expression above.

int $theTime = `currentTime -query`;
if ($theTime > 0)
	if (myLam1.incandescenceR >.05)
		myLam1.incandescenceR = myLam1.incandescenceR -.075;
		if (pCube1.vel > 0.2)
			if ( pCube1.theCol_u >=1)
				myLam1.incandescenceR = 2.5;
			myLam1.incandescenceR = 0;
Load More