# Articles

### Fractal thing Posted by Naelstrof on January 11, 2017

A guy at my work had an (original?) fractal idea, he had no computer knowledge so he asked me to make this cute little app for him. It makes some pretty cool pictures if you let it run long enough.

You can find the program here: https://github.com/naelstrof/FractalThing

### FOV Calculations Posted by Naelstrof on January 21, 2016

Working on a space station 13 clone with a friend, I had the challenge of developing FOV. The term FOV in top-down RPG games usually refers to determining which tiles are visible.

My first idea was to just raytrace from the player, marking every tile hit visible. So I ripped out the Bresenham algorithm and traced to every tile on the perimeter of the screen. This method seemingly works great!

There's two problems though, column shadows have gaps, and walls get random splotches of shadows as well.

You can see that the Bresenham lines increment at the perfect time to dodge the column, making some unrealistic shadows.

There's just not enough rays to hit every part of the wall, and it's unfeasible to just add more rays...

There's other FOV calculation methods other than ray tracing, but most of them are convoluted and confusing, and so I devised my own solutions to fix these artifacts.

## Wall Gaps Solution

This problem was a little more complex, I understood that if any part of a perfectly flat wall is visible: the whole wall would be visible. I first had to develop a tool that could interpret if a group of wall tiles is a wall, and which direction that wall is facing. To do this I realized I just need the hit-normals of the casted rays. In most other games, when you do a ray-trace you recieve a hit-normal so you can tell what kind of surface it hit. In a 2D game about spess men, it's a little more complex since "walls" are a pretty arbitrary concept with 2D tiles. For example a single solid tile wouldn't be a wall, it would be a column. Do two tiles in a row make up a wall? Do three tiles in a corner configuration make up two walls? To solve this what I did was when a ray hits a solid tile, it checks adjacent tiles and put them in a flag like this:

``````o = center
8
2o1
4
``````

So if the flag is `3` then it would indicate we have 3 tiles in a straight line. While `5` would indicate a SE corner tile. From there it's pretty easy to set up a switch statement to handle hit normal calculations separately.

With this new powerful tool, it's fairly simple to detect when a wall is hit. The normal just has to be pointing in a cardinal direction to know we hit a "wall". You can see it in action from the blue lines in all of the images.

From there we can trace the wall, marking every tile visible until we hit a corner, an already visible tile, or if the wall ceases to be visible due to obstructions (a quick raytrace back, offset by the hitnormal can do this for us) fixing our wall gaps!

Seems like it would be really inefficient, but because a wall trace often terminates immediately, it hardly makes a difference in speed.

## Column Gaps Solution

Lua as two values that evaluate as false: false and nil. I abuse this feature to mark certain tiles as "forbidden", disallowing them to be marked visible for the current frame. With my hit normal tool, it's pretty simple to set tiles behind columns as forbidden. Which fixes our column gaps!

With that my FOV calculations work pretty well, and it was fun to work on.

### Installing Autodesk Maya 2015 On Arch Linux Posted by Naelstrof on January 21, 2016

You should never ever want to do this. Blender does everything you could want. However if you're stuck in a college class that requires you to use Maya like me, then read on you poor poor soul.

## 1

First of all, you'd need a PKGBUILD to get started. They've been eradicated from the internet for whatever reason-- dead links and empty AUR searches. Fortunately somebody posted a PKGBUILD on a pastebin, it was a tad broken but worked for my purposes. You should make a folder called maya2015 somewhere safe and put the PKGBUILD within it.

~/maya2015/PKGBUILD

You can see a few commented lines. They were originally install scripts that came with the AUR package, but obviously they're missing from grabbing it from pastebin. I was able to get Maya to work without them.

``````cd ~/maya2015
makepkg
sudo pacman -U *.xz
``````

It should get Maya in neat little packages and install them for you.

## 2

After installation we have to run a dumb service installation script to set up certain folders that other parts of Autodesk looks for. Afaik it doesn't do anything but create a folder but you'll have to run the following anyway:

``````sudo /opt/Autodesk/Adlm/FLEXnet/bin/install_fnp.sh
``````

## 3

You should now have the capacity to "activate" the product. To do so will vary, but for the typical college student with a standard standalone licence you'll use the following command as root:

``````sudo /usr/autodesk/maya2015-x64/bin/adlmreg -i S <product key> <product key> 2015.0.0.F <serial like 900-0000XXX> /var/opt/Autodesk/Adlm/Maya2015/MayaConfig.pit
``````

Yes you have to put the product key twice, both the serial and product key should be emailed to you by Autodesk. If you mess up you might have to remove the key to try again, reinstalling works fine for that.

## 4

If you noticed "activate" was in quotes earlier, and that's because Maya still has to phone home to activate itself. This must be done as root as well (ugh!), however it has 100% chance to fail anyway.

``````sudo /usr/autodesk/maya2015-x64/bin/maya2015
``````

This will be OK though because we can use an activation request code maya provides to activate it online. However there's one little issue with this-- It fails to display the request code!

Ok so it's not as bad as it seems. You'll have to go to https://registeronce.autodesk.com/prodreg/, and fill out the information the best you can (You'll probably have to insert correct addresses and phone-numbers or else it will fail). Once it asks for the request code, make sure Maya 2015 is open and on the activation code page shown above. You should find the request code file located at /tmp/MAYA2015en_USLongCode.xml!

It should let you download an activation code response file, and it should successfully activate Maya 2015 for real!

## 5

Now the big challenge is running Maya itself. Running it as a user seems to cause it to hang, so again-- sigh-- we'll have to run it as root.

``````sudo maya
``````

Woo! It should start up, but with another issue... Maya's gui and text are invisible! Google searches didn't come up with anything, but with a little tinkering I figured it out. For whatever reason Maya fails to make some files in normal users folders, while root is incapable of running QT applications properly. So to fix it I just copied root's maya files over and chowned them.

``````sudo cp -R /root/{Adlm,maya,xgen} ~
``````

And now I can run maya as a normal user, and it works 100% (as far as I can tell)!

### Slop Shader Support Posted by Naelstrof on July 07, 2015

It was inevitable.

### Slop Hardware Acceleration Posted by Naelstrof on June 20, 2015

Added hardware acceleration to slop (OpenGL!) which means I can add coolio things like magnifying glasses.

I developed some algorithms to optimally push rectangles out of other rectangles using only math which was pretty fun.

Zooming in really far makes text look like they have a severe case of chromatic aberration.

For those of you who use slop, could you help me test this feature at https://github.com/naelstrof/slop/tree/experimental? Just do

``````git clone git@github.com:naelstrof/slop.git
cd slop
git checkout experimental
cmake ./
make
./slop --opengl --magnify
``````

and tell me what you think at naelstrof@gmail.com, thanks!

Views: 2331