3Ducttapes(); Yvo von Berg | CG Toolsmith blog | C++, Python

Tycoon UE4 C++ Spiral demo

Taking the prototype further by adding multiple pieces, I’m applying the same technique I used in Max:

  1. I create a base actor which is the actual piece.
  2. That has an extra component which works like an anchor (locator at the end of each piece).
  3. I store the normal of the anchor component, the next actor in the row will ask the previous actor for it’s normal.

In this prototype I just add another offset in the other axis. (Quick hack so I can do some cool spirals and loops at least yay). That is going to be the next step, full directional control just like the deformer in Max.

Tycoon UE4 C++ circle demo

So my original goal starting this project was to create a port of my original tool that I made for 3Ds Max ( Tycoon ). That tool is basically an extension of the existing bend deformer in Max, for the Unreal version I had no existing deformer.

My first idea was actually to just deform a point in a circle, but I though it would be better or more flexible to investigate other methods first ( FFD, MVC and other deformation methods). But rotating the point seems to work fine, and really exact. I might use the FFD deformation if want to have more ‘dynamic/sculpting’ control, for this prototype I just want things to bend say exactly 90 degrees.

  FVector ATycoonActor::rot(FVector in, float angle) {
    float s = sin(angle);
    float c = cos(angle);
    float x = c*in.X - s*in.Y;
    float y = s*in.X + c*in.Y;
    return FVector(x, y, in.Z);
  }

If you haven’t seen the other tool: Tycoon - 3Ds Max custom bend tool release

FFD (Free Form Deformation)

Taking the concept I learned while researching the barycentric coordinates further by applying it to 3D cages. One algorithm I found that seems to work for what I’m trying to do is Free Form Deformation. That method is very common in a lot of 3D applications but I never took the time to figure out how it works under the hood.

C++ Barycentric coordinates

Doing research to find out how to approach a mesh deformer. I think I can use this to create a free form deformation (FFD) deformer: https://en.wikipedia.org/wiki/Barycentric_coordinate_system

How does it work

In order to deform a point within another shape, we have to remap the point in world space relative to the cage.

  1. Binding.

    In this example I use a triangle as the cage, the first step in the process is called ‘binding’, this will loop through all points in a mesh and calculate the coordinates in the cage, once we have those coordinates we can store them and access them later.

  2. Update the cage points.

    Change the position of the cage after doing the binding step.

  3. Apply new coordinates of the mesh based on the new cage points

     FVector cagePointC = VertexBuffer[0].Position;
     FVector cagePointB = VertexBuffer[1].Position;
     FVector cagePointA = VertexBuffer[2].Position;
    
     float u = barycentric_coordinates[0].X;
     float v = barycentric_coordinates[1].Y;
     float w = barycentric_coordinates[2].Z;
    
     float n = (u * cagePointC.X) + (v * cagePointB.X) + (w * cagePointA.X);
    

Maya blendshape converter

Quick script that I made while reading about how engines converts alembic caches into something that plays in real-time, I guess this happens under the hood when you drag n drop an alembic file with animation into the engine:

Super high lvl:

  1. Create a new skeletal actor instance
  2. Loop over each keyframe and assemble a ‘pose’ (or do every x interval)
  3. Do a diff between the poses and make new blendshapes for them
  4. Assemble everything into a normal skel asset + animation clip.

Wanted to see if I could create a script in Maya that does the same thing:

How it works

  1. Use a mesh as input, and duplicate this for a number of times
  2. Select all of them in the correct order and call cmds.blendShape(), this will all the blendshapes on the first object
  3. Create some animation by setting and keying the blendshapes

That was fun.