Sunday, December 28, 2008

Using configure scripts to cross compile for Wii

Here's something I found while trying to compile ODE SVN for the Wii. It seems that most configure scripts aren't written to support powerpc-gekko targets, but I found a post on the devkitPro forums with an easy fix. You just have to add four lines to config.sub:
@@ -230,6 +230,10 @@
basic_machine=m68k-atari
os=-mint
;;
+ -gekko)
+ basic_machine=powerpc-eabi
+ os=-elf
+ ;;
esac

# Decode aliases for certain CPU-COMPANY combinations.

Now you can invoke the configure script with --host=powerpc-gekko and do some cross-compiling, as long as you have devkitPro set up with the binaries on your path.

Tuesday, December 23, 2008

Adding Wii as a platform

I've had the Wii Homebrew Channel installed for a while (I think I had previously loaded beta 8), but I never got around to setting up DevKitPro and playing with the libraries. Following some of the examples, I figured out how to set up video, load files from SD card, and load PNG images to one of the GX texture formats. After some work I got my Texture and Model classes to compile with libogc GX calls in place of the usual OpenGL ones.

At the moment I have way too many files that include the GL and SDL headers directly. I was planning to write a material/shader system that would keep all of that stuff behind abstraction layers, and supporting the Wii makes this a new priority. I may end up able to run the same core engine code on Windows, Linux, OS X, GameCube, and Wii. No idea yet on performance, but we'll see once I get ODE through the cross-compiler.

This is the crate model (models/crate.model and textures/crate.png) loaded from an SD card and displayed on my Wii. The bottom-right stuff is my Linux desktop on picture-in-picture.

Tuesday, December 16, 2008

Arrgh standards


The SCSI standards are really hard to read. For my project at work I'm trying to implement a USB mass storage device, which seems to require SCSI Primary Commands (SPC), SCSI Block Commands (SBC), and M ... something Commands (MMC). That's at least three standards documents, and they're all written like the damn IEEE Software Requirements Specifications we had to write for the one software engineering class I took. (I changed majors immediately afterward.) They explain just about everything in scary detail, but they never seem to answer the questions that pop into my head while I'm reading it. The info's there, but you have to read the whole damn thing before it makes any sense at all.

Monday, December 15, 2008

Trimeshes, kind of

I'm trying to implement support for ODE's trimesh geom, but it's not working too well. The trimesh data is exported by a Python plugin for Blender, much like the one I've been using to export models. Everything compiles and runs with no warnings or asserts, but I get stuff like this:



I've also noticed that ray-trimesh collisions are very unpredictable, which is bad since I use rays in all of the tools to trace along the player's "shoot" vector. Guess it's time to go digging through the ODE mailing list.

Tuesday, December 9, 2008

Green hair

I dyed my hair green today. Of course by "I" I mean "some friends who have a clue what to do with hair". It's so bright! The dye used was Special Effects Iguana Green purchased from Amphigory. I'm definitely sending them a picture.



Edit: Here's a picture with the Hat of Justice.

Saturday, November 29, 2008

ODE auto-disable and a Windows build

I got two things working today: ODE's auto-disable feature and a Windows build.

Auto-disable is great for performance when there are lots of objects just laying around doing nothing. Stacked objects tend to stay enabled just because they're wiggling slightly (worsened by my coarse 10 ms steps), but a once orderly stack strewn across the ground will usually be completely disabled within seconds.

The Windows build was the really hard part. I have Windows XP running in a VirtualBox VM (my host OS is Ubuntu). Installing MinGW and MSYS was easy enough, but I had to manually download and compile eleven source packages (including an updated GNU make) to get my code to compile and link. It doesn't help that the GL libraries have different names (opengl32 and glu32 vs. gl and glu), and that you need different complier switches to make everything happy. In the end, I got freetype, GLEW, libjpeg, libpng, ODE, SDL, SDL_image, SDL_ttf, libtiff, and zlib to configure, build, and install! The result is a monstrous 9.4 MB statically linked executable that should only depend on opengl32.dll, glu32.dll, and a few windows DLLs for the underlying SDL implementation.

Saturday, November 22, 2008

Tool chooser

I added a simple tool chooser to the HUD. When the HUD is instantiated it asks the ToolFactory for all of the tools' names and generates some textures. Moving the mouse wheel pops up the text menu and clicking selects a tool. It's not shiny yet, but it works well enough for now.




This is a stack of 100 crates. I am not deactivating motionless objects (yet), so they are all fully active and generating lots of contacts each step. The CPU usage was about 90% when I took the first shot below. I switched to the Move tool and ripped out one of the bottom ones, and they scattered beautifully with no slowdown. The Open Dynamics Engine is pretty nice.

Thursday, November 20, 2008

Tools updated

I had some time today (not really, but I pretended that I did), so I rewrote the tool system the way it should have been done. Gone are arrays of function of pointers, replaced with a Tool class which is the base of the classes TableTool, DeleteTool, and MoveTool. The Table and Delete tools are like the old ones, but the Move tool is new and interesting. It's basically a clone of gmod's physics gun's primary fire. Click and drag to move objects. It is currently possible to use the arrow keys to spin it in the air, but I'm going to make this mouse controlled at some point.

I made another model because I was getting bored with just the tables. At the moment the two objects' collision models and mass distributions are hard coded. One of my next goals is to come up with a simple text format for those two and load them in from files (it's already doing this for the display models). I also need to get trimesh collision models working.

Here's a colorful picture:

Friday, November 14, 2008

Enumeration!

Thanks to this website I got Windows to accept the driver INF. After implementing two more USB standard device requests I can do this:



\o/

Thursday, November 13, 2008

Success! The configuration descriptor was malformed.



Now I just have to figure out what "The required section was not found in the INF." means. It's basically a copy-paste from Microsoft WinUSB documentation so I don't know what's going on.

Windows seems to read the string descriptors three times while enumerating the device, with longish pauses between. It doesn't complain about it to the user, but the device is identified as "USB Device" before the Found New Hardware wizard pops up. I think the string descriptors could be all wrong but Windows doesn't think it's important enough to abort.

USB

(posted from work)

I'm playing around with an Altera DE2 board which has an ISP1362 USB controller chip. The idea here is to get Windows to accept the board as a real USB device so I can transfer lots of data into and out of the FPGA accelerated encryption engine. The results so far are negative but entertaining:

Sunday, November 2, 2008

Table gun

Based on recent [lack of] progress I've put the floatsinspace project on hold for a while. It's tricky to deal with multiple physics spaces when I still haven't written the basics, so I made a new project folder (called "mod" for +1 Creativity) and started over. The goal with this one is to get an entity system, player movement and interaction, and Wire kind of stuff working. If it goes really well I will use it as a base for some tests with networked play and we will kill Garry's Mod and probably rule the world (waaay out there though).

I put in some basic player movement a few weeks ago. The player is represented by a capsule object (a cylinder with hemispheres on the ends) and is moved by applying equal and opposite forces to the "ground" (whatever is below the player) and the player itself. It works, but I got bored with walking around and jumping so I thought a weapon/tool system would be a good next addition.

The code for the tool system is a complete mess (polymorphism by arrays of void* and lots of reinterpret_cast) but it will work until I rewrite it as an object hierarchy. The first set of test tools I created were a table making tool and a deleter. The table maker spawns tables (roughly like the one my monitor sits on) wherever you are looking. The deleter deletes stuff.

Here's a picture of the table maker in action (BAMF! Look at that table!):


The underlying system is about as simple as it can be right now. I'm using the Open Dynamics Engine as both a physics engine and collision system. The world state is stepped at 100 Hz and the renderer goes as quickly as it can without exceeding 60 FPS or the speed of the simulation. Performance seems to be okay even with lots of tables in weird positions.

This was going at 60 FPS (good sign that performance won't suck too much):


The two problems I'm seeing right now are some interobject penetration and some stacking instability. Dropping a table on another at a right angle results in the falling table shoving through the stationary one and they end up stacked in the wrong order. The table top is only 2 cm thick so this will probably be less of a problem for collisions between big things, but it means I may have to up the physics step rate. Uniform stacks of a few tables are no problem but they wobble if you stand perfectly still on them. Again, this might be helped by increasing the physics step rate but there are definite limits to doing that. I was originally testing with a 1 kHz step rate which looked good until I realized how slow it got with more than ten objects in existence.

Old blog

This is my second blag thing. I have an old account on LiveJournal (http://mvanbem.livejournal.com/), but it's kind of annoying to use so this will be the one I update. If you're bored you can come here to read about what I've been programming while bored.


Hey, uploading images is easy. LiveJournal doesn't look like it lets you do that without a paid account. (looks like animated GIFs don't work, though)