[Small App] Lister – Local note storage written in native JavaScript

Earlier this year I wrote a small app over a weekend, designed to be a chrome extension that would take notes and save them locally so that no snooping from a server or anything would happen. In order to do this I delved in the HTML5 localstorage API, to tell the truth this was back when I was a more inexperienced programmer, but it was the project with made me fall in love with it.

The app preview is available to see here. It’s possible to view the JavaScript in the web tools of your browser (right click > inspect) and under the sources tab. It uses some JQuery UI elements for styling but the base functionality will work without it. To make this a true Chrome extension I will have to create a manifest etc. but I think I will leave this as an exploration into my love for coding and commit it to my past for good.

Bent plane for subdivision modelling script WIP

While working with cylinders, it’s often necessary to cut holes or alter the geometry but that when subdivided, will cause a lot of distortion or pinching in the mesh. A common work around for this is to use a plane with a bend modifier/deformer, that bends 360 degrees to create a cylinder shape after the subdivision has already taken place. What if you started with a cylinder though?

The way I usually create a plane for bending when I have an existing cylinder, is to measure the diameter and multiply by pi to get the circumference, then I create a plane with the same width as the circumference and the same segments and move it manually. When working with guns, with barrel ports and cars with axles etc. it can become quite cumbersome. So I made a small script that generates the plane for you when you have a cylinder cap selected. It’s work in progress and has a few known issues so I won’t release it yet, but the base idea is working: With a poly selected, it will create a plane with the correct number of segments, with the appropriate modifiers and it will work in any orientation, so feel free to have some wild cylinder pointing in an abstract direction and use this script to create modified planes all aligned.

Debris – Global Game Jam 2015

Earlier this year, I had the privilege of taking part in Global Game Jam at the University of Hertfordshire and as this is a new blog, I haven’t talked about it yet. I was invited by my good friend who studies there so I travelled over on his request for my first ever game jam, us two and people I’d never met before. We organised ourselves into a team, a bunch of first years and a second year (and me a third year from a different university), who were very capable. By accident, I’d found myself somewhat close to being a leader of the group, but the creation was very much something we all agreed on, by this I mean I was holding the whiteboard marker and helping the direction. We knew game jams were going to be rough, we knew that whatever we were going to do would only be half well executed, it was our first game jam after all. Even so, we still chose to start the ambitious project: Debris, a game where the player is running out of oxygen in a procedurally generated asteroid field and trying to get to a space station for safety. My role was to be a technical artist & gameplay programmer of sorts.

Continue reading Debris – Global Game Jam 2015

Website Update & First PyMel script

My *splutter* lovely *ahem* face sits on the left side now, I’m not a narcissist I promise. I updated a lot since I put it live, I’m pretty happy with the way it’s going, if this was proper software development I’d say I’ve reached beta. I know that I need to add more content, this is my first text post in a little while, I’ve been having fun just fiddling with how the site works. If you’re interested in how WordPress is working for me, I love it! Plenty of plugin support and on the off chance I don’t find something I’m after, the code is documented well so it’s easy to build on existing functionality. I’m understanding why WordPress is one of the biggest CMS’.

The biggest update: I restructured the way that my art is displayed, it’s as a post type instead of a random page of images. I was originally updating them manually but now I’ve got galleries in place, thanks nivoBox (lightbox) & jetpack! I did some work in PHP, HTML & CSS to format the way posts appear in the Artwork page which looks pretty damn snazzy now if I do say so myself.

I do have one complaint that my images seem to be heavily compressed. I did some research and it may be a WordPress function doing it, I was pretty sure it only happened when I connected jetpack but not 100% about that. I’ll try my best to fix that soon as well.

In other news, I got setup in Maya for some Pymel scripting! I was originally just doing straight python, but from an OOP standpoint Maya’s python is alien and non-intuitive to me. Pymel has some overhead but I think clear readable code is important too, if I wanted the best performance I’d be writing a C++ plugin, it seems to be quick enough for most operations any way (feels faster than Maxscript? I’m probably imagining it).

To get myself up to scratch I wrote a small Maya script that centers & bottoms out the pivot pretty simple!

There are a few sections that I found a little interesting. Of course the imports, it was my first time working with Maya’s xform finding it in Pymel was a breeze, it’s straight up Transform in this case. Now as for the structure, Python is a mostly new language for me as I’ve only studied it a little bit & I wanted to mess around with the native language a little bit so of course I defined a function for a single task. Python seems to be coming from a C++ angle in the sense that hoisting things that aren’t defined yet gets a bit broken, while I was making this I didn’t realise this though because I was calling then defining like in JavaScript. Weirdly enough the Python interpreter didn’t produce any runtime errors at first but it produced weird and inconsistent results confusing me for a short while, soon enough runtime errors came in thick and fast and soon it was impossible to run certain Maya cmds. So I restarted Maya, restructured it and haven’t had an issue since. That’s one to watch for though.

For the code itself it’s pretty simple, the main loop iterates through all the objects the user has selected and identifies if it meets the type ‘transform’, if so it’ll trigger the cntrBtm() function. There’s a big reason for the loop itself, of course the user may not have selected a transform so the script will throw a Python error, in the same vein I first noticed this when I created an object. In Maya when you select and existing object you will by default grab the transform, when creating an object the transform isn’t the selected object which threw me for a loop for a moment (excuse the pun). In the function, we have a pvt variable being declared as the result of getBoundingBoxInvisible(ws=True) which returns a list of the bounding box’s limits. For example, if we draw a 1 meter3 cube, centered on world 0, then getBoundingBoxInvisible(ws=True) would return -0.5m, -0.5m, -0.5m, 0.5m, 0.5m 0.5m. The results are ordered as xmin, ymin, zmin, xmax, ymax, zmax, Maya’s height is measured along the Y axis so ymin will give us the lowest point of the mesh.

The variable xyz does something similar, it returns a list of co-ordinates for the current rotatePivot (rotate pivot is shared with the translate). Python is a 0+ index language which means that we count lists starting at zero. 0 = milk, 1 = sugar, 2 = eggs… So all we have to do now is change the xyz variable so that it’s second item ‘xyz[1]’ is equal to the ymin value which also happens to be at ‘pvt[1]’. Done! Just throw that into a setPivots command.

As far as scripts go this one was pretty tame but was really fun to get started with PyMel so I’ll be working on more in the future.


Side note: I just realised my favicon (image in the tab) looks like a jellyfish instead of the letters 3D, jelly fish are cool so it’s a happy accident.

The last executed function I used in my script was wrong. It reset the transform when it shouldn’t have, I must admit that coming over from Max I’m still getting used to Maya, though I should have caught this sooner as it works pretty much the same way. I could probably just query the pivot position too instead of reaching for transforms, but it was a good dive into that area at least. It works across all selected objects same as before.


Hiding Selected Component Display in Maya

Late one night while fiddling with Autodesk Maya’s crease tools I realised how mildly annoying it was for the creased edge to block the users view of the effect it was having. It makes it harder than usual to tell how hard of soft the edges are, so I set about making a solution.

After a short while of researching whether it’s possible to stop Maya from displaying the selected component’s wire it turns out it may not be possible. It’s easy to disable the wide crease edge but the thin edge will still show. Select an edge and it will be orange (or custom colour, not transparent) no matter what. I couldn’t find anything through the interface nor the cmds documentation but I will be having another look because it seems like it should exist.

So a little bit irritated, but not defeated, I came up with a simple solution. If nothing is selected, nothing distracting will display! So I wrote up this little snippet of Python:

When executed this script will store the users selection in a variable then clear it & hide everything that can be distracting. When executed again, it will return the users selection & show everything again. It has it’s limitations, such as when the user selects other stuff while everything is toggled off, I’ll probably implement some selection locking or run a detect for a new selection.

I realise that this is a hacky, incomplete and very inadvisable way of doing things but at least now I can toggle the display on a hotkey, though I can’t actually manipulate anything while it’s in effect. It’s kind of silly really, conclusion? I’ve taken this as an experiment move on and cut this out of workflow, at this point it’s better to adopt crease sets or just deselect and reselect manually.