Tagprogramming

Python in Blender

It was only a matter of time before I started my journey into scripting in Blender. Learning MEL (Maya’s Embedded Language) was one of the most powerful things any Maya 3D artist can do.  When it came go giving advice to students that were looking to break into the industry, learning scripting was the piece of advice that I could dish out with confidence. Even if you only learn a handful of functions, you can perform (what seem like) miracles.  Spend a day going through a set of introductory tutorials on scripting (Intro to Python in Blender, perhaps) and you’ll feel what I’m laying down here.

My time with MEL has lapsed and now I’m in Blender.  There is a confidence that I am experiencing, knowing that I am moving in the right direction. Putting energy into a language (python) and animation software (Blender) that will never be taken away (till an EMP takes out all electronics).

Resources

Blender 3D: Noob to Pro – Advanced Tutorials – Introduction – I am guilty of having not spent as much time in the Noob to Pro series as I should. I guess I get a bit sucked into videos sometimes, too often forgetting the speed and efficiency of text + images. This series is quick n dirty.

Blender 3D: Blending Into Python – Includes optimization guide, cookbook, APC, quickstart, reference, etc

Blender Cookie – Python + Blender – On this Youtube channel, this crew has demonstrated an ability to create quality video tutorials.

Blender.org – Advanced -> Scripting – RTFM!

Blender.org – API documentation – There’s also a link to download the contents in a ZIP file, for localized reference.

Nathan Miller’s Blender Python Notebook – The Proving Ground – Procedurally built architecture?  Includes sections on mesh definition, modifieers, math mesh, random mesh and “supershape 3D”?  Looks like a blast!

Vim Colors

First thing to do if I’m going to use Vim as my default text editor, is to get the colors looking good.

First, I’ve downloaed a theme (for example distinguished.vim) and placed it in my newly created ~/.vim/colors folder.

Next, I created a ~/.vimrc file and entered the following contents:

syntax on
colorscheme distinguished
set t_Co=256

Finally, if I type in tput colors into a terminal window, it tells me I have 8 colors. Even though my themes still appear to work in Vim, an error gets reported upon opening Vim.

To fix this error, I’ve edited my ~/.bashrc file and entered the following line.

export TERM=xterm-256color

Now tput colors reports 256 colors and Vim no longer reports an error when automatically loading my distinguished.vim file.

For those looking for a new Vim color theme, here’s a good place to look and another list of 10 good ones via VimNinjas.

I must admit though… colors still seem to be a bit wacky for me, as they don’t match the theme examples listed on the web page.

Vim – lighting fast text editor

It sounds like “lightning fast” is just another typical headline for viral Facebook post, which automatically makes me feel as if I’m not giving Vim enough credit.

I typically use basic text when writing on my pc, and I sometimes create light code or html. Since I originally used a Windows machine, I have used Notepad, Context, Notepad++, etc. After moving to Linux, I was usually operating in gedit. It wasn’t until recently till I started shopping for another solution. Since we’re talking about BASIC TEXT, I felt it was pretty critical to choose an open source tool. I don’t like the idea of using a closed source tool in order to help me speak.

I have spent a bit of time looking, testing and reading comment and I think I’ve got a pretty good hold on the text editor options out there. The same names pop up pretty frequently… though one editor has always stood out as being a legend in this area, though it does not have a GUI. Vi or Vim.

I’m a big fan of not having to jump onto the mouse constantly, especially after realizing the RSI that the mouse was causing me.

What is Vim? Alan Thomas does a great job of introducing Vim and looks at it through the lens of “sentences”, comparing the keystrokes to nouns, verbs, etc. He also includes some great example uses.

So now the learning begins. This experience is much like when I had to force myself to touch type. I was slower at typing for a few days, but after 3 days of practice, I was almost twice as fast of a typist as I was before I touch-typed. Initial investment is pretty low compared to the benefits!

First step was to force myself to get comfortable in using hjkl in order to navigate around the page. The first 3 levels of VIM Adventure helped with that.

Other Vim Resources

Learn Vim Progressively

Cheat Sheets
Vim common actions in catagories
Vim Quck Reference Card (PDF)
Best of Vim Tips

Like a Pro
Vim teaser quickly demonstrating some editing magic.
Ben Orenstein’s expert level vim talk (40 minutes) shows how deep you can get.
vimcasts.org/episodes/archive

Why learn Vim?
Best way to master
Is it worth the effort?
7 reasons Vim is your text editor

More Interactive Ways To Learn
OpenVim’s tutorial
Sitting at a Linux computer and want muscle memory to assist your text editing? As Alan reminds us, just type this in a terminal window:
vimtutor

Vector Math for 3D Graphics and Animation

2014-01-27 09.32.05First, I’m not a “graphics programmer”. I do quite a bit of scripting (Maya’s MEL scripting language) and enter dozens of expressions (Houdini), but have never compiled a single line of C++.

I was never a big fan of math, especially algebra (grammar = yuck), though I did breeze through my Geometry class. I survived a decade working in the 3D animation industry working as a rigger, technical artist and production technology lead and only implemented a little triangle math only a handful of times. *note: This does NOT mean you should skip out on getting a proper understanding of Euler rotation orders and gimbal lock, if you want to be a good character TD.

Though no one needs to understand 3D math in order to become a 3D artist, even some digital sculptors realize the importance of a little trigonometry. Having an elementary 3D math base gives an artist a better understanding of the ‘why”s.

So, since I don’t remember too much of my high school math and never took a single trigonometry class (I’ll blame the education system), I eventually realized that if I was going to produce anything jaw-dropping, I was going to need to study up a bit…

…and luckily the internet has the answers!

Where to start?
There is a boatload of free online courses available to those willing to learn from text and videos, but mathematics is a massive world and it’s difficult to figure out where to start. For those that have completed highschool (maybe even just 10th grade) and are interested playing with some bit of 3D code, here’s some items I found quite useful. Keep in mind that most 3D animation software packages will include tools (commands, expressions, functions, etc.) that will do the math for you. Remember to search the documentation!!

vectors
If you have a line, what direction is it pointing? If you have an object in space, what direction is it moving? This is your vector. The length (aka “magnitude”) of a vector can tell you it’s speed. A normalized vector is always 1, and is useful to apply to other operations. You can subtract two vectors and you’ll get another vector which tells you the direction from one vector to another. More examples with images on MathIsFun.com.

cross product (aka vector product)
a × b = |a| |b| sin(θ) n
I have two vectors and I want to find another vector that is perpendicular (90 degress) to these two vectors. The cross product of the two vectors will help. It’s useful if I have a plane and I need to know the surface normal to the plane. For those using particles, this tells us the direction that particles would travel if we are emitting from the middle of a surface. BUT, be careful, the direction of this newly calculated vector depends on what order you specified a & b. This is where the dot product comes in very handy! More cross product details on MathIsFun.com.

dot product
a · b = |a| × |b| × cos(θ)
If you have two vectors, the dot product will tell you if the vectors are moving in the same general direction (greater than 0) or moving in two completely different directions and will never intersect the same plane (less than 0). If you have just used the cross product to find a perpendicular vector (like a surface normal), you can use the dot product to see if the if it’s facing the right direction (up?). More info on MathIsFun.com.

For video explanations, Khan Academy has a great section on vector dot and cross products or trigonometry and precalculus if you already have a basic understanding of geometry.

Here’s a list links to more information on vector math:

So what’s next?  Perhaps some matrix calculations? Maybe linear algebra via MIT’s online course or N.J. Wildberger (known for “rational trigonometry”).

Finally, checkout this list of free technical online courses, including programming.

Thanks to Les for the inspiration to catalog my findings.

Technical Online Courses for Free

codecademy.com – Walks you through programming languages like jQuery, Javascript, HTML/CSS, Python, Ruby and PHP.
Online Math Learning.com
Interactive Mathematics
CosmoLearning – Subjects include math, science, economics, law, medicine, etc.
coursera.org – Learn from 595 courses, from our 108 partners.
academicearth.org – Online college courses from Carnegie Mellon, Yale, Stanford, etc.
MIT’s Open Courseware
codebymath.com – learn math while coding
code.org – Tutorials for beginner programmers and also includes links to other training games like Code Combat(Javascript), Code Avengers, Lightbot, Grok Learning, etc.
N.J. Wildberger’s Math Foundations and Algebraic Topology series, or his popular Rational Trigonometry (to avoid sine and cosine).
FAQ for computer graphics algorithms
There’s lots of stuff out there, as demonstrated w/ “20 great math sites for students and teachers” .

Web Programming with Python

Going to go super geek for a moment here, but I will keep this very short.

I know that I need to be versed in web programming, because nearly everything that I have done, either personal or project related, ends up on the web in some format. I’m realizing that WordPress, Drupal, Joomla or other content management software solutions will not give me the flexibility that I need.

I’m turning to Python, due to it’s simplicity, use of PERL style regular expressions (w00t) and (most importantly) it’s integration in nearly every 3D animation package that’s out there.  Is Python programming for the web going to be more of a pain than just utilizing Ruby or PHP?  Maybe, but there’s always frameworks, like Django.

Without further adieu, here’s a blog, made in 8 minutes.

Simple Electronics w/ LEDs

Ever since I touched down on the playa back in 2010, I’ve had a project in mind that would utilize LEDs.  The tricky part was trying to figure out a way to control them in complex ways.  It seems that this Arduino hardware platform is a good place to start. Minibloq is a visual programming tool that looks non-intimidating.  Gotta love visual programming.

© 2024 Jer's Life

Theme by Anders NorenUp ↑