Better billboarding in Papervision3D

The Papervision3D wiki has an example for making billboarded sprites with just three extra lines of code. Trouble is, it doesn’t really work. Anyone who’s tried it may have noticed that when the planes get too close to the camera, or if the camera rotates around it’s z-axis at all, the planes start rolling instead of staying vertical.

The problem is that the lookAt method defaults to using the world y-axis as “up” for the billboards, which isn’t usually correct. Of course we don’t really care about the world y-axis with billboards. We just want them to be vertical in the camera. Here’s some code that does it.

// calculate the camera vertical in world coordinates
var up : Number3D = new Number3D(0, 1, 0);
Matrix3D.rotateAxis(camera.transform, up);

// billboard is the plane you want to billboard.
billboard.lookAt(viewpoint, up);
billboard.roll(180);
billboard.pitch(180);

Tags: , , , , , , ,

Comments (1)

Protected: An annual ritual

This post is password protected. To view it please enter your password below:


Enter your password to view comments

Last Easter

This is what I started to write last April.  Apparently LJ has a draft saving feature now.  Unfortunately, I didn’t finish it, and it’s not worth finishing now.

It’s been awhile. I don’t feel like covering everything that’s happened just now, so instead I’ll just outline what I earned during Easter.

  1. Catholic Easter mass takes forever

    My sister received full communion into the Catholic church the night before Easter, so I got a cool, three for one bonus: Easter mass, confirmations, and baptisms. Sweet! I can’t tell you how excited I was, but the three (four?) hour ceremony exceeded all my expectations.

  2. There are kids who don’t enjoy hunting for eggs on Easter

    This is the first Easter that Connor is aware of, and my niece was with us too, so we had a lot of fun getting ready.

Comments (1)

Easy Scientific Notation In LaTeX

I use LaTeX for all my physics homework and lab reports, and I’ll be using it for a master’s thesis in the next few years, so I’m constantly adding to my library of LaTeX commands to save some typing. Here’s a good one when you need to use scientific or engineering notation. Put the following in the document preamble (before \begin{document}):

\providecommand{\e}[1]{\ensuremath{\times 10^{#1}}}

Then, typing

The [111] crystal planes are 3.2\e{-10} m apart.

gives you:

The [111] crystal planes are 3.2×10-10 m apart.

whether or not you’re already in a math environment. If the exponent is just one number, you can omit the braces, like this: 3\e8 m/s. Cool, huh?

(Of course, for 10-10 m you can just use Angstroms, \AA. If you’re in a math environment, use \text{\AA}, or else the circle won’t line up with the A. That is, if you’re okay with non-SI units.)

Tags: , , , , , ,

Comments (6)

Bold vectors in LaTeX

Vectors can be typeset in LaTeX with the command \vec, which decorates the argument with a little arrow. This was cute at first, but it doesn’t look very good, especially in fractions. Textbooks use bold face for vectors, so here’s how to do that in LaTeX.

\let\oldhat\hat
\renewcommand{\vec}[1]{\mathbf{#1}}
\renewcommand{\hat}[1]{\oldhat{\mathbf{#1}}}

This also makes unit vectors (typeset with \hat) bold.

Tags: , , , , , ,

Comments (5)

Silly Jessica Simpson Game, Pizza Hut Codes

I don’t get it, but my wife loves the celebrity gossip, so when all this stuff about Jessica Simpson started coming out I whipped up this little game to make her laugh. It’s an homage to an old Mac game I haven’t seen in years called “Slick Willie.” I’m also keeping track of Pizza Hut’s sweepstakes codes here. Have fun.

Click on “more” to play the game.

[Read the rest of this entry...]

Tags: , ,

Comments (2)

wxCL, SBCL, and Windows

wxCL is a GUI package for Common Lisp that uses wxWidgets, and it seems to look pretty good on Windows and Linux, and the code is sufficiently lispy. Exactly what I’m looking for, except it’s in alpha. Serious, seeping wound alpha.
I haven’t gotten it working on Linux yet, but it works on Windows. The asdf-install included in SBCL 1.0 for Windows doesn’t work, and asdf doesn’t work with Windows links, so here is what I ended up doing. First, I unpacked the wxcl archive to ~/.scbl/site. This is where asdf-install would put it. Then I copied the function sysdef-source-dir-search from the current asdf-install release to installer.lisp in SBCL’s version. Finally, I add that function to asdf:*system-definition-search-functions* so ASDF can find stuff in .sbcl/site.

Tags: , , ,

Leave a Comment

Mathcad 13 with Wine, first attempt

The professor for my electricity and magnetism class wants me to use Mathcad instead of Maple, so I bought the student version. I’ve been using it on my Windows laptop for a week or so, but it would be nice to be able to run it on my desktop. The Wine compatibility lists show good results with earlier versions of Mathcad, so I thought it might work out. Unfortunately, it requires the .NET framework, which requires IE 5, which I’m not going to install just yet. Damn.

Tags: , ,

Leave a Comment

Flash 9 in Linux

Those of you in the know already know that Adobe recently released Flash 9 for Linux. An official, honest to god, up to date version. The best part? It actually works.

I’ve had problems with Flash since I switched to Linux, because I foolishly chose the AMD64 version of Kubuntu. After messing around with a 32-bit chroot for awhile, I finally discovered Swiftfox, a version of Firefox compiled to use 32-bit libraries but optimized for, and compatible with, 64-bit systems. I could watch Flash movies again. Sound didn’t work, but who needs to hear them anyway? Oh, and since Macromedia never released Flash 8 for Linux, there were more and more SWF’s that I couldn’t watch. And it crashed the browser a lot.

Okay, so it totally sucked.

Even so, I was pretty disappointed after I upgraded to Swiftfox 2 and found that Flash stopped working. Imagine my surprise when I clicked on the missing plugin button and saw that Flash 9 was available. I knew Flash 9 for Linux was out, but I’ve never had the plugin search feature actually work correctly. Then, right before my eyes, Flash 9 installed, the page reloaded, and the SWF started playing. With sound. “Thus Spoke Zarathustra” came on the radio, the sun broke through the clouds of winter storms, and a chorus of angels heralded, or trumpeted, or whatever it is that choruses of angels do.

It’s almost as if big companies are starting to take Linux seriously.

Tags: , ,

Leave a Comment

Snow Crash

I just finished the book Snow Crash by Neal Stephenson. Yes, for the first time. It had some interesting ideas; not “they might be true” interesting, but “what if they were true” interesting. The idea that all our major religions are based on stories about exceptionally remarkable people which have evolved into more grandiose tales over millenia of oral tradition is probably not far from the truth. Just looking at something like Iliad it’s obvious how quickly an oral tradition can embelish extraordinary deeds until they’re superhuman. Add to that the modifications stories undergo as they’re filtered through the ever shifting styles and zeitgeist of the people telling them, and the tendency for people to rely on supernatural explanations when natural explanations fail them, and we can almost see the skeleton on which our religious myths have been built.

I also liked the idea of an ancient language which arose from our brain structures. Interesting to think of the consequences that would have on linguistic research, but it doesn’t seem too likely.

The ending of the book was disappointing, since almost nothing was resolved with any of the characters. We don’t even know who lived and who died. It desperately needed an epilogue. I was also rather disappointed with the three or four chapters which consist entirely of Hiro explaining everything that was going on. That part felt like the end of a Scooby Doo episode, right before they say, “Well, that about wraps it up. There’s just one more thing. Let’s see who the monster really is. Why, it’s old man Wilfred!!” Neal Stephenson seems to be a good writer sometimes, but at times he simply fails.

Tags: , ,

Leave a Comment