Showing posts with label 3d. Show all posts
Showing posts with label 3d. Show all posts

Sunday, March 4, 2012

Episode 6 - Camera controls and exceptions

Implementing camera controls for Board Game Machine

Worked on some camera controls for our upcoming (multi player, multi device) board games simulator Board Game Machine . Control mechanisms demonstrated in the video below:
  • 90 degree spherical (elliptical) rotation of the camera position to view each side of the game board
  • Continuous vertical rotation of the camera position to get the desired view angle onto the board
  • 90 degree camera rolling when the camera is facing straight down

Notice (or rather, please do not notice) how there is a myriad of debugging text on the screen (the video is recorded straight from the dedicated development tool), and how the graphics are still very much in development.

Making Eclipse stop on Null Pointer Exception (and friends)

By default, debugging an exception in your Android application goes something like this:
  1. Watch the IDE stop into an empty page somewhere in the Dalvik code (no source code available unless you installed the full Android sources) with a rather meaningless call stack.
  2. Hit F8 to continue running.
  3. Look at LogCat to find out what was actually wrong. Find the red lines in the log, scroll down until you find the "caused by" line, doubleclick, and finally be transported to the offending line in your code.
I just learned you can force Eclipse to actually behave like a sane IDE by performing the following simple steps:
  1. From the menu, select Run, Add Java Exception Breakpoint
  2. Find NullPointerException (or whatever exception you are debugging)
  3. Verify Suspend On Caught Exceptions is checked. Click OK.
The debugger will now immediately break (suspend) where the exception occurs. Like, you know, every other (proper) debugging environment on the planet. I'm kinda stumped as to why they didn't make this the default debugging behaviour, but at least you can configure it to work properly.


Mobile client for DMSforSharePoint

Since after a fair bit of swearing and cursing I've got SOAP + NTLM up and running now (hurray, detailed blog post on that topic later), ít's time to develop a little prototype of a mobile client for our SharePoint-based DMS, DMSforLegal / DMSforSharePoint. Here is the first screenshot of this work in progress:

 
Misc

- The Android game engine now plays sound & music through some convenient manager objects. This was really easy to get up and running on android (thanks, MediaPlayer and SoundPool!). Still unsure about the best engine design for handling sound effects, but we'll see how it works out.

Sunday, January 29, 2012

Episode 2 - Death of a Hard Drive

This week, out of the blue, the hard disk in my trusty Vaio decided to die on me in several subtle ways. So in between the figuring out why the heck it kept locking up, heavy cursing, reinstalling my work environment on my travel laptop, and nightly tours of the house walking off the little cries of my 3-week old youngest daughter... I've not exactly been very productive.

The good news is my little Dell Inspiron on-the-train laptop, despite having the whole cardboard look-and-feel going on, is happily running my Delphi XE2 environment. Even the shoddy HD 4225 is more or less handling the trivial 3D stuff I'm throwing at it. For now it seems I'm sorted.

Rounded cube
For our Board Game Machine implementation of Maria, we needed simple cubic pieces. As with many real life objects, the pieces have a nice little rounded bevel going on at the edges.

After a fair bit of fiddling around with the geometry generation code, the final result looks quite acceptable in the prototyping app: 


From comparing the screenshot to the real deal, it is immediately clear that (apart from a higher resolution texture of the game board), a realistic visualisation of the game pieces will require:
  • A wood-like texture on the block, perhaps a subtle normal map to accentuate the wood grains would suffice
  • Fading, glossy reflections on the game board
  • Very subtle shadows directly under the block, mostly to enhance contrast.

Misc
- Added a debugging setting to the 3D engine that renders all vertices as 4.0 sized points. A real must-have when painstakingly handcrafting geometry from vertices and indices, as I can now debug vertex and index buffer setup individually.

- Tried to use Crinkler to link & compress a trivial FPC application, with minimized system "rtl"units. So far no luck, can't get the linker to resolve DLL binding symbols.

Thursday, January 19, 2012

Episode 1 - Reflections and more

2012, Week 3 - No matter how passionate a coder you are, at some point in your life you'll find that your home programming hours have become so scarce and far between that it becomes hard to keep the flow going of whatever hobby projects you are working on (and your are working on hobby projects, right?). 

For me, detailed planning and structuring really kill motivation if I know my next opportunity to put another half hour into it is at least a week away. So now I'm trying something new: I'm just going to write down whatever I'm working on this week, add some imagery, and hopefully when rereading it'll look enough like I'm actually Getting Things Done to keep me going.

Skybox
Added convenient SkyBox support to the office 3D engine, which I also use to do at-home 3D prototyping. Currently only supports a cubemap texture, for this example I've used one of the great sets by Emil 'Humus' Persson. I used the DirectX Texture Tool from the SDK to stitch the texture together into a single cubemap, which took a surprising amount of processing time to do its job and then spit out a huge 98mb cubemap. I'll sure I'll get around to fixing that huge file size later, but for now it works... and it sure seems to load quickly enough.


Reflection & Refraction
Time to get some basic shaders up and running. Did a basic reflection shader, then a basic refraction shader. Rather unsure about picking the "best" refraction ratio, settled for something that results in the standard "backdrop looks upside down when seen through a sphere" look.

Finally, I combined the two shaders into one and included a tint color. It only colors the refraction bit, not the reflection. Not entirely correct, but in general it gives the look I was after, and isn't that what graphics programming is all about?
Misc
  • Started a new test project that should give me some legroom to do some experiments. Revived support for full frame rate vsync timing in the 3D engine, because the fixed rate timer was getting in the way of kkapture capturing... or so I thought. Turned out to be the aweful high resolution uncompressed AVI video playback on my laptop.
  • Worked out a very awkward way of recording YouTube video using kkapture to do the uncompressed capture, VirtualDub do stitch the AVI segments back together, and finally x264 to compress into MP4. At least two of the components in this workflow refuse to be properly automated from the command line, but for now it works.
  • Played around with the Protrekkr playback source, planning to research options for getting it to run with Delphi, perhaps through the Agner.org Object File Converter?
  • Played around with kkrunchy, verified that for <64kb C++ applications it does indeed run circles around any other cruncher. Need to figure out how to get it to properly pack a Delphi application.