Jan
22
2009
0

FYP Technology: Bonjour “Finished” and Basic TCP

Yesterday I set a goal for myself: get an arrow on the PC moving in synchronisation with the accelerometer in my iPod. It took a while but I finally got it working!

The most frustrating problem I had, which I wasted about an hour trying to fix, involved read accelerometer output from the sensor. No matter what I did, the callback just would not fire to give me the new readings. It turned out that the accelerometer callbacks just don’t fire in the iPhone Simulator! You have to run the code on a real device to get the readings. I already knew this but the penny was in freefall for a long time before it finally dropped.

As expected, writing for iPhone OS devices is much more enjoyable than writing for Windows. To set up a TCP/IP server on Windows you have to fill in a few structs (I hate how this is so standard in Windows API programming), create a socket, bind the socket, listen on the socket, accept a connection from the socket and then you can read and write. Using Bonjour with the iPhone SDK, I get a list of available services on the network, and when I want to use one, I just do getInputStream:outputStream: on the service (NSNetService) and I can now read and write to my heart’s content. I don’t even know what the hostname, port or transport is, and why should I? I really don’t care… all I want to do is say “I’ll take that device, hook me up”, and then start communicating.

I’m having a bit of trouble with lag, as expected, but I still haven’t set the thing up with multithreading; I’m just checking if there’s data to be read with select() every frame and grabbing it if it is. I expect that my synchronous reads aren’t keeping up with the stream so I’m falling a few frames back in time.

I’ll leave you with a N.E.R.D. song I heard late one night while flicking through the music channels and can’t get out of my head:

No comments »
Written by in: University |
Jan
21
2009
0

FYP Technology: Accelerometer Input and Service Discovery

When I checked my email this morning I saw that Apple had activated my iPhone Developer Program account. I set up my certificate, application, device, provisioning profile, and all that other code-signing junk, and got some sample code running on my iPod.

I played around with different values on the simple low-pass filter in the GLGravity demo to see how much it would take to get a clean reading from the accelerometer without sacrificing response time and it turns out the accelerometer is pretty noisy.

Here’s the callback which does the filtering:

- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration
{
	//Use a basic low-pass filter to only keep the gravity in the accelerometer values
	accel[0] = acceleration.x * kFilteringFactor + accel[0] * (1.0 - kFilteringFactor);
	accel[1] = acceleration.y * kFilteringFactor + accel[1] * (1.0 - kFilteringFactor);
	accel[2] = acceleration.z * kFilteringFactor + accel[2] * (1.0 - kFilteringFactor);
}

kFilteringFactor is a #define and accel is defined as a class variable:

UIAccelerationValue		accel[3];

kFilteringFactor was 0.1 by default but still still seems to give some jittery output so I ended up with 0.05 being a stable value. In the demo code, this callback is being called at 100Hz. I wonder if there’s a better way of cleaning up the inputs?

I also spent a bit of time with the Bonjour SDK today and have it ready to go on win32. I need to do more playing with it before it’s ready for the iPod, but I don’t anticipate any problems. Any difficulties I have will be with the UI code, not Bonjour. So far it seems to be working really well, and when I register a service on one computer it magically pops up on another without any issues. The biggest problem I had was with the TXT record format. Here’s the example where I finally understood what was going on:

------------------------------------------------------------------- 
| 0x0A | name=value | 0x08 | paper=A4 | 0x12 | Rendezvous Is Cool | 
-------------------------------------------------------------------

What’s happening there is that each entry in the TXT record has its length written to the byte before its first character. DNSServiceRegistrationCreate() does this for you on OS X but I haven’t seen it with the Bonjour SDK. By the way, the Bonjour “SDK” is a header file, a library file, and one (poorly commented) C and one Java example.

Tomorrow I hope to play more with the iPhone SDK, with the objective of getting the iPod’s accelerometer output displayed on the PC.

No comments »
Written by in: University |
Jan
20
2009
0

FYP Technology: Constraint Chains and Further Research

After playing around with the LittleBigPlanet level-editor with Niall, I wanted to see how well I could let a user tie objects together with a string/rope/chain.

Here’s how I implemented it:

  • A raycast picks a rigid body and gets a position in worldspace where it hit, and a second raycast picks the second body and wordspace position of the hit.
  • These worldspace co-ordinates are then translated to local space, extended a bit so they’re a little bit away from the surface of the bodies.
  • A chain of links is then constructed in place between the bodies, with their correct positions and orientations. The number of links is decided by the distance to be covered.
  • Each link gets a small sphere representing it. Maybe a spline curve is better if it’s a string? Or maybe a cylindrical mesh with a skeleton for a rope? Or if it’s a chain, individually rendered 3D links? Or would a billboard for each link be better? I like that last one actually…

What I need to add/change:

  • Ensure that the path along which the chain is to be constructed is not obstructed by other bodies.
  • Make the chain lighter… right now it’s quite heavy, and I have to figure out how to maintain stability without having to make it so heavy.
  • Increase stability when constraining a body to fixed geometry.
  • Figure out how to create a stable chain between two bodies decided by a user. One could be hugely heavy, and the other too light, which would cause problems. Or both two light or too heavy for the chain. Interesting problem.

I spent a lot of time last night researching Windows device drivers. I’m thinking of writing a virtual joystick driver so an iPhone OS device could be used as a generic controller for any game which supports DirectInput joysticks. I found some good information on writing device drivers, but that’s only a device driver; I need to figure out how to create a virtual joystick too, I believe. From my reading, it seems that Windows will load a device driver when it needs it (which makes sense), but without a new device being discovered, Windows won’t go loading any drivers.

I did, however, find some sample code in the DDK (Windows’ Driver Development Kit) for creating a virtual HID driver, but could not figure out how it was doing that. I think it may be HID-specific functionality which won’t help with DirectInput-compatible joysticks :( Looking at Microsoft’s UMDF (User-Mode Driver Framework), it looks like Microsoft is getting serious about making a usable driver framework, but this technology still seems quite new. On Microsoft’s official product page it’s all about UMDF in Windows 7! Though I’ve read that UMDF drivers are XP-compatible…

I also researched iPhone OS development a little more, submitted my Apple Store order for the Standard iPhone Developer Program so I can run my own code on my iPod, and found some good sample code that does some of the stuff I’m hoping to implement (WiTap for using Bonjour, GLGravity for reading accelerometer input).

No comments »
Written by in: University |
Jan
19
2009
0

FYP Technology: Sound

Yesterday I spent a lot of time trying to get audio up and running. It took quite a while as most of the Ogre-based libraries are either dead or don’t have a lot of developers.

OgreAL, the first one I tried, turned out to be pretty much dead, and didn’t have a binary release, only a source release that was for an old version of Ogre. Not wanting to port it to the new version, I gave OgreOggSound a try, which is quite similar, but with support for only two types of file (Ogg and wav).

It took a while, but after wrestling with some strange problems that I still don’t understand, I have it working. Thinking of ways of associating sounds with the graphical/physical environment now. I’m thinking of using a config file to associate certain types of bodies and certain types of motion with certain sounds.

It was fun to try a technique that I noticed being used in games before: changing pitch slightly on repetitive sounds to make it sound a little more interesting. I got a bump sound, and when a contact point is added to a box, the sound is played, but with a pitch multiplied by a random real number between 0.8 and 1.2.

No comments »
Written by in: University |
Jan
18
2009
4

FYP Technology Change

I got tired of Irrlicht pretty quickly, with my frustration mainly coming from the poor pipeline support. Today I moved over to Ogre3D and things started moving really quickly!

Here’s what my pipeline looks like now:

  • Everything is modelled in 3ds Max 2008.
  • Havok Content Tools 3ds Max plugin is used to create rigid bodies, constraints and all that other physics goodness.
  • Use OgreMax to generate a .scene (XML file describing the scene nodes), and corresponding .mesh and .material files (actual entities and associated materials).
  • Use Havok Content Tools exporter to generate a .hkx file, containing the physics data for the whole scene.

What I’ve tested exporting:

  • Meshes (boxes and a CSG-hollowed 6-sided cyclinder)
  • Materials (only created by setting diffuse colour in 3ds Max, no textures)
  • Lights (directional, white)
  • Rigid bodies (static box, static mesh with MOPP, dynamic boxes)
  • Constraints (limited hinge with high torque)

And here’s what happens at runtime:

  • Load up the .scene with the DotSceneInterface Ogre addon when the application starts.
  • Load up the .hkx with the Havok SDK once the Ogre scene is done.
  • Iterate through all Havok rigid bodies, find associated Ogre entities, and set up a vector of associations.

Before every frame, I run through the vector and update the positions and orientations of all Ogre entities according to their associated Havok rigid bodies. I’m probably going to use Havok’s userdata on rigid bodies to keep pointers to the Ogre objects, or maybe use a hashmap if I think the userdata might be useful in some other context later (I don’t think I have redundancy with the userdata… I’ll need to see whether or not OgreMax really exports it). Once I have immediate random access to rigid bodies’ corresponding graphical entities, I can only update active (moving or possibly moving) entities which will save a lot of work when things start getting bigger.

Development is really made easy by Havok’s excellent pipeline and testing integration. The 3ds Max exporter allows you preview your seen in a 3D window, with all the physics you designed working properly. If you use a lot of custom actions it won’t be perfect, but not having to load your own graphics engine to see how it works really speeds things up and lets you catch problems in the design much earlier.

As far as testing goes, the Visual Debugger hooks in to your application through a TCP/IP port when it runs and shows you the physics in its own graphics engine. A mouse-picking ‘viewer’ means that you can interact directly with objects in your game (and of course, your game’s graphics will reflect the interaction).

Here‘s a clip of a test involving all exported elements listed above:

4 comments »
Written by in: University |
Jan
13
2009
4

FYP Technologies

Here’s a list of some of the technology I’ve been getting to grips with for the FYP:

Frameworks/Libraries:

Content Creation:

Irrlicht can load Quake3 BSP maps, and not only is Quake 3 map editing the only map editing I ever got really proficient at, but it’s a handy format in that it can give me fully-textured and light-mapped models to be loaded up. I intend on using Q3 BSPs for static geometry and then using 3ds Max to create dynamic objects to be dropped in, and any characters I might need.

I’m just trying to decide what to do with the Irrlicht/Havok overlap. For example, which library’s vectors to use in generic cases? I’m familiar with Havok’s and the utility classes for vectors are cool, but Irrlicht’s has direct access to vector elements and operator overriding to allow you add and multiply vectors with standard mathematical operators (I understand Havok’s lack of operator overriding is a design decision but I like to have it). I wonder if Irrlicht’s vectors support SIMD operations? Lots of interesting research going on right now!

4 comments »
Written by in: University |
Jan
01
2009
0

Cultural Differences Evidenced Through Augmented Reality Advances

A pretty well-known piece of research on AR (Augmented Reality) is ARQuake. This came frp, the University of South Australia, and involves killing monsters which are rendered so as they appear to exist around you in reality. The video below goes a little something like:

Player opens a door and uses a machine gun to kill all the monsters inside Player opens a door and kills the monster with the machine gun Player opens another door and kills another monster Player opens a fourth door and kills loads of monsters Player switches to bloody axe and starts hacking into more monsters behind him

Recently, a Japanese company got their hands on ARToolkit and released the following software, which is probably the best-known Japanese AR software. It’s a virtual anime maid wife. Here are some of the things she comes out with in the video:

“Wow, is this my master’s room?” mindless mumbling and humming “Is there something on your mind..?” “Hey! Watch where you’re touching me!” various embarrassed squeals as the “master” touches her “What are you doing all of a sudden?!” (as the “master” knocks the broom out of her hands and changes her from a maid outfit to pink lingerie) more embarrassed squealing while he keeps changing her clothes between swimsuits and various underwear and furry outfits crying “That’s horrible! Why would you do this sort of thing!? … oh! Is this a present?? Wow!! Cute!!” dances around with teddy-bear while in her underwear “I got something really nice~~!♪*

T-Rex bursts through a door and starts trying to kill her “Woooaah!! Dangerous! Don’t come in! That was a close call…”

No comments »
Written by in: Uncategorized |

Powered by WordPress | Theme: Aeros 2.0 by TheBuckmaker.com