Wednesday, 10 November 2010

Painting the Fear and Loathing Fish

slowly going insane...

Spent the last 3 hours painting seamsless textures and bone weights (this ones an FK only rig... I'm running out of time).  At least the fish can now deform into shapes like this, and blow bubbles thanks to instanced metaballs on a particle system emitting from his cigarette!  He has a nice irradescent glow which changes colour as he turns round courtesy of blender's underused 'magic' texture mapped to the reflection channel.  Animation starts tomorrow!

Tuesday, 9 November 2010

Fish Modelling

Hunter S Thompson Herring
4 hours modelling

Great White Shark
3 hours modelling
(incl 1 hour of teeth vertex pushing!)
2 hours texture painting
(incl 1 hour of messing around with Photoshop 3D)
2 hours rigging and weighting

Some half cooked models I built in a rush for this weeks anim exercise (fishes with character).  The shark's got a nice spline IK rig (a spline for the back and for each of the big flippers), but thanks to blender's outgrown deps graph, it has more than twice the number of bones it would need in maya.  At least the modelling and texture painting in blender kicks the socks off maya.


Saturday, 6 November 2010

Python Boids in 3D



I'd only tested my code out in 2D up till now, even though I'd been coding all the vector maths in a way I hoped would work in 3D.  I ran a simulation above and to my pleasant surprise it worked perfectly first time.  Sadly trying to shrinkwrap/constrain the boids to a surface (a mesh marking the limits of where they are allowed to wander) I ran into a new bug in blender.  Its in the tracker, fingers crossed that by the next time I have a moment to work on the code all will be resolved!

Escape Route Searching in Python Boids






Yey! after some more coding this morning I got escape route searching working.  In this example the boids just give up when they collide as there are no controllers (or boid brains) yet to tell them to do anything other than that.

Friday, 5 November 2010

Boids in Python



Coding boids in blender's python API might seem like a lot of unnecessary work, but when the built in simulation system doesn't offer quite the options you need there really isn't much choice!  At least there's the hope that the python prototyping I'm doing might inspire a competent coder to leap to the mantle and take on the hard work.  Boids generally work in 3D space without stable collisions and don't have the ability to be constrained to a surface/mesh (ie a mesh offset from the ground plane which represents the translational limits of say their torso/root bone).  On the tube project we'll soon be starting work on a scene which requires a large scale crowd simulation.  Over the last 4 days I've put down the foundations of an almost-stable collisions system in python with some basic flock awareness.  More importantly I've implemented some important optimisations which make slow python less painful than it otherwise would be.  Black specks on a grey background might look pretty boring, but this is a big milestone (almost) successfully reached in implementing my half typed up design docs!

Mood Change Walk

First attempt at a mood change walk with the Ludwig Rig (and some special FK/IK adaptations) in blender 2.5.  Background flies are boids with a vortex field.



Talking of boids I've been working on some python code for boid like crowd simulations, the difference being they're slightly less flock like, constrained to a 'ground' geometry and they can't collide or pass through each other.

Thursday, 4 November 2010

Week 4 Line Test and Maya

Week 4 - pushing and pulling and last week's bouncy ball with a mesh deform to vertex color based shader I coded in MEL.




code...

int $numberOfVertices[]=`polyEvaluate -vertex pSphere1`;
string $neighbouredges[];
string $neighbourverts[];
float $edge_start_original[3];
float $edge_end_original[3];
float $edge_start_deformed[3];
float $edge_end_deformed[3];
float $diff_original[3];
float $diff_deformed[3];
float $total_length_original;
float $total_length_deformed;
float $stretch_amount[];
int $edges[];
int $i=0;
for($i=0;$i<$numberOfVertices[0];$i++)
 {
 //find neighbour edges
 $neighbouredges=`polyInfo -ve pSphereShape1.vtx[$i]`;
 string $buffer[];
 int $num_tokens = `tokenize $neighbouredges[0] $buffer`;
 $num_tokens-=2;
 for ($k=0;$k<$num_tokens;$k++)
  {
  $edges[$k]=(int)$buffer[$k+2];
  }
 //now convert the edges to lengths

 $total_length_original=0;
 $total_length_deformed=0;
 for ($l=0;$l<$num_tokens;$l++)
  {
  $neighbourverts=`polyInfo -ev pSphereShape1.e[$edges[$l]]`;
  tokenize $neighbourverts[0] $buffer;
  int $verts[2];
  $verts[0]=(int)$buffer[2];
  $verts[1]=(int)$buffer[3];

  //get edge lengths
  $edge_start_original=`xform -ws -q -t pSphereShape1Orig.vtx[$verts[0]]`;
  $edge_end_original=`xform -ws -q -t pSphereShape1Orig.vtx[$verts[1]]`;
  $edge_start_deformed=`xform -ws -q -t pSphereShape1.vtx[$verts[0]]`;
  $edge_end_deformed=`xform -ws -q -t pSphereShape1.vtx[$verts[1]]`;
  $diff_original[0]=$edge_end_original[0]-$edge_start_original[0];
  $diff_original[1]=$edge_end_original[1]-$edge_start_original[1];
  $diff_original[2]=$edge_end_original[2]-$edge_start_original[2];
  $diff_deformed[0]=$edge_end_deformed[0]-$edge_start_deformed[0];
  $diff_deformed[1]=$edge_end_deformed[1]-$edge_start_deformed[1];
  $diff_deformed[2]=$edge_end_deformed[2]-$edge_start_deformed[2];
  $total_length_original+=sqrt(pow($diff_original[0],2)+pow($diff_original[1],2)+pow($diff_original[2],2));
  $total_length_deformed+=sqrt(pow($diff_deformed[0],2)+pow($diff_deformed[1],2)+pow($diff_deformed[2],2));
  }
 $stretch_amount[$i]=($total_length_deformed/$total_length_original);
 }

//find max and min
float $max_stretch=-1;
float $min_stretch=-1;
for($i=0;$i<$numberOfVertices[0];$i++)
 {
 if($max_stretch==-1 && $min_stretch==-1)
  {
  $max_stretch=$stretch_amount[$i];
  $min_stretch=$stretch_amount[$i];
  }
 if($max_stretch<$stretch_amount[$i])$max_stretch=$stretch_amount[$i];
 if($min_stretch>$stretch_amount[$i])$min_stretch=$stretch_amount[$i];
 }

for($i=0;$i<$numberOfVertices[0];$i++)
 {
 if($min_stretch!=$max_stretch)$stretch_amount[$i]=($stretch_amount[$i]-$min_stretch)*(1/($max_stretch-$min_stretch));
 else $stretch_amount[$i]=0;
 polyColorPerVertex -colorR $stretch_amount[$i] pSphereShape1.vtx[$i];
 polyColorPerVertex -colorG $stretch_amount[$i] pSphereShape1.vtx[$i];
 polyColorPerVertex -colorB $stretch_amount[$i] pSphereShape1.vtx[$i];
 }