Saturday, May 3, 2014

Rigging for Unity's Mecanim Humanoid

Been making a movie for my 3D real time animation class. Figuring out how to rig things properly for animation took a lot longer than it should have, so here are some notes.



Unity has a simple animation system called Mecanim. Rigging with Blender is not hard. There is an automatic rigger in Blender called Rigify, but the rig can't be mapped properly to Mecanim's humanoid avatar.

So the simplest way is to just rig the T-pose mesh by yourself. Make sure that all the meshes are joined together (Shift-J) in Blender before rigging/ painting.

These are the bones:
Hip
=> Spine -> Chest
=> Thigh.l -> Shin.l -> foot.l
=> Thigh.r -> Shin.r -> foot.r

Chest
=> Neck -> Head
=> Shoulder.l -> upperarm.l -> forearm.l -> hand.l -> three bones each finger
=> Shoulder.r -> upperarm.r -> forearm.r -> hand.r -> three bones each finger

Refer to this tutorial if you haven't rigged things before, but note that you just need the bones stated above for Unity's Mecanim system. The finger bones are optional.

Then,
Parenting the mesh to the armature with Automatic weights should work fine.

In Unity, Mecanim should no be able to configure the humanoid avatar by itself. The only thing left to do is to adjust the muscles so that the model moves in a custom way. For example, you want a pig to be stiffer than a woman.

Saturday, April 19, 2014

Installing Octave on OS X 10.8

Couldn't find a post that worked for me. All the (will fail)'s are just in case of dependencies, if not you could probably just do these steps: 1, 4, 6, 5, 7.

1) brew update && brew upgrade

2) brew install gfortran (will fail)

3) brew install octave (will fail)

4)
wget https:/raw.github.com/Homebrew/homebrew-science/master/hdf5.rb
mv hdf5.rb /usr/local/Library/Formula
cd /usr/local/Library/Formula
brew install hdf5.rb

5) brew install octave (will fail)

5) brew install gfortran

5) brew install octave (will fail)

6)
wget https:/raw.github.com/Homebrew/homebrew-science/master/qrupdate.rb
brew install qrupdate.rb

7) brew install octave

Now we have everything installed, to run GNUPLOT (since OS X 10.8 has deprecated support for X11)

1) cd /usr/local/share/octave/site/m/startup
2) append "setenv ("GNUTERM", "X11")" to octaverc

Tuesday, December 3, 2013

Git for Windows publish branchfails...

On top of having to deal with Windows 8.1 on Virtual Box atop a Mac (i.e. slow), there's this thing where mid-sized Visual Studios solutions can't be pushed. My stuff is about 65 MB large...

So here's how to get around the "Can't publish branch" error. A "$ git push" won't help here...

1. On Github for Windows, go to your repo
2. Open github in shell (there's a settings button on top right)
3. Check that remote already added
(i.e. try:
$ git remote add origin http://github.com//
Expected output: "fatal: remote origin already exists")
4. $ git config http.postBuffer 524288000
This increases the buffer size...
5. git push -u origin master
This should push your new repo.


It's quite late, which might explain all the trailing sentences.

Saturday, November 9, 2013

Ninja Crazy

Been making games for a class. The lecturer's from Microsoft so it's Windows 8 stuff, but other than that in terms of the game design, genre, concept etc. we're free to do anything we want.

So far of my first twenty games, here are my favorite one is this platformer, Ninja Crazy. It evolved from my first scrolling background SHMUP, Space shooter. It's a Windows 8.1 app (keyboard/ mouse/ touch support) written with DirectX and C++. Textures courtesy of the web.

Ninja crazy - a platformer


Basically you're a ninja on the run, but there's an infestation of crabs in your way, so you must kill or avoid them before they eat you up.
- When your HP drops, you'll flash red.
- You can shoot blue fireballs at the crabs.
- You can also jump and multi-jump (appoximately flying).
- To replenish Health, jump up to grab the apples.
Good luck!

Code is on github right now, but am kind of embarassed to show it because the OOD's quite ugly- it's very obvious that I was/ am still figuring out- in Space Shooter and Ninja Crazy- what's the best way to model a game object.

So I'll be refactoring my code, and for my next game, I want to have more static obstacles to jump and run on, more intelligent enemies (instead of arbitrarily positioning them and giving them different starting speeds to make it hard), and obstacles that spew fire that the ninja must avoid.

I also saw this Hyper Light Drifter on Kickstarter, and it's amazing. I would like to have such an exploratory game where there are many beautiful worlds of all kinds to explore. That would be awesome.

Monday, August 12, 2013

Post-DEFCON 21

So I went to DEFCON last week in Vegas, and it was great fun learning about all the ways software and hardware isn't safe. It's definitely different from SIGGRAPH (well obviously) in that the SIGGRAPH crowd is concerned with high math and creating art, whereas the DEFCON crowd are hackers in the traditional sense of the word. Both are pretty amazing. Hopefully I'll get to go to some convention next year as well.

Two of my favorite talks were about Femtocells and Schlage locks:

(1) 'I can hear you now - Traffic interception and Remote mobile phone cloning' by ISEC Partners on how they got root access to Verizon's Samsung femtocells and wrecked havoc with it. Femtocells are bible-sized cell towers for homes/ small enterprises that were invented to offload 3G connection. If your phone's on that provider and the femtocell's signal is stronger than the base station, your phone will automatically connect to the femtocell without user interaction.

Unfortunately, their security is pretty weak for how potent they are. Getting root access is easy, and your phone also gives its unique ID to the femtocell, which means that if this information is written to another cell, your phone is closed and an attacker could drop calls, get SMSs, listen in on your credit card/ SSN-getting conversations with some marketer. All without physical access to your phone.

Cloning is not the only thing. The femtocell itself can record your calls (one can decode the encrypted speech signals by grep-ping for the codec), capture your SMS packets, and smartphone data is plain text so since data middling is easy an attacker could show your a fake Chase login and get your username/password EASY.

(2) Key duplication for the high security Schlage Locks by the MIT locks club. Schlage locks are extremely resistant to picking because of the extra line of teeth running across the side of the key. So these lock hobbyists turned to key duplication. While manual cutting takes a practiced person with the right tools less than an hour, ordering a 3D printed key is much cheaper and more reliable. They wrote 100-lines of code which makes use of a modeling library such that your just have to note the teeth combination of the key you want to duplicate, feed it to a function, and out pops a 3D model of the key. Since 3D printers have sufficient precision nowadays, and are cheap ($1-3), it's a simple matter of filing an order online and waiting for the resulting model. They found that hard plastic was durable enough to open most Schlage locks.

Thursday, May 23, 2013

OpenCV setup for Mac

Homebrew makes setup easy.

This is for OSX 10.7+:
1) Install the latest XCode and its command line tools (must install separately).
2) Install homebrew
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
$ brew doctor
- make any fixes the doctor recommends
$ brew tap hombrew/science
- this gives you access to a group of science-related brew formulas
$ brew install opencv
- will probably install the latest mac-compatible OpenCV; as of this writing, the OpenCV version was 2.4.5

In XCode, if you set the correct Additional Library and Header paths in Build Settings, but still get linker errors when you try to compile OpenCV C++ code, in Build Settings edit the Standard C++ library to choose libstdc++ (GNU C++ standard library) instead.

Thursday, May 9, 2013

Automatic panorama

Coded in OpenCV 2.4.2 and C++. I initially tried to use OpenCV's Python wrapper, but the documentation was quite bad. So it was C++ instead, which was pretty fun. Like, in Python I'd just think of sticking an ArgumentParser for command line arguments, but in C++ it felt natural to write a recursive option parser. I decided not to use Matlab because (1) I don't have it on my laptop, (2) I wanted something I could play with later, or use easily.

The human eye naturally recognizes the relationship of points in two photographs. First I did manual landmarking (user clicks pairs of interesting points on the two images he/ she wants to stitch). To mosaic more than one image, do manual consecutive mapping for better results (the order that you put images together is important).

Automating manual clicking

Then with feature detector and extractors, I obtained descriptors of landmarks, and matched them. This was all done with the OpenCV library. However, it's findHomography function, where it finds the projective transformation from image 1's coordinate system to the other, was not very good. For non-planar surfaces, they would fail immediately.

So instead of using that, I implemented my own outlier/ inlier algorithms. It was really quite easy, but with some inaccuracies. It was also slower.