Todd's profileTodd's spacePhotosBlogListsMore Tools Help

Blog


    November 16

    Font to Texture application

    I've been working on a game in XNA, and one of the things I need to create is a very flexible control library (labels, textbox, buttons, etc.).  The first of these must be the label so I can display some text.

    Although XNA comes with text output functions, I needed more precision, performance and flexibility for text output.

    The first step is to decide how to display text.  Do you convert font glyphs to triangles and render the text as true 3D?  What about creating a vector font? I decided that what I needed for most applications was high performance '2D' text that I could use for my upcoming control library - and that meant at the very basic level: using 'Quads' for each character and texturing the quads. 

    Later on, in the control library, I can use many performance enhancements to render the labels.  For example, if the text doesn't change, we can render the text once using multiple quads, then render that to the label's 'panel'.  This way, we can simply use one quad for any string of static text.  Anyway, there are many ways to do it with various tradeoffs.

    This is a screen shot of the application I am writing in Windows Forms (.Net 3.5 on Visual Studio 2008):

    image

    This application gives you many text output options, which I won't go into here :)  But I'm designing it such that it is very flexible.

    Here is a directory listing in Vista that shows some of the characters generated:

    FontToTexture2

    I've got a few things to add yet and of course, the obligatory code cleanup and stuff that you always put off at the very end :D

    Looking forward to getting some text into my game.  But first, I've got to write a text library, a control library, then... ummm well I better get back to work.

    Enjoy :)

    -Todd

    November 11

    My new Condo in Singapore!

    Well, due to the quickly rising rents in Singapore, I decided I needed to buy a place before the property prices became so high that they would become unaffordable.  Since most property was already above S$1000 PSF (Per Square Foot), I was forced to look in 'other' areas in Singapore.  One of those areas is called "Geylang" popular for being a legal red light district (yes, that's right, I said LEGAL in SINGAPORE) :)  Geylang is also famous for its multitude of food cafes everywhere - and the food is just excellent.  Geylang comes alive after 8PM and doesn't stop until early morning (I'm talking about the crowds in the food cafes).

    Anyway, my most excellent real estate agent found me a most excellent condo in the heart of Geylang (in the family area, away from all of the girls).  It was going for 444 PSF, occupied the entire floor of the building (no neighbors on the sides), has a terrific draft (windy), and just so much more.  So I sprung for it.  After about a month of renovation, here are the final pictures of what it looks like inside:

    Main living room: (the floors are teak wood with dark walnut semi-gloss finish.  Walls are painted with 'dune white' paint.  Ceiling is plain white.  The blinds throughout the place are semi-see through, except in the bedrooms where they are opaque.)

    Living areaLiving area

    Living area: TV Living area towards rooms

    Kitchen (I had this completely refurbished since the former owner completely 'destroyed' it due to some reason I can't mention here.  Suffice to say, the kitchen is all new.  I put in 3 independent stove units.  Notice the grill in the middle :)  All of the stuff is Ariston, the sales lady loved me.  New fridge, stove, oven, sink, hob, etc.  Espresso maker is Krups.)  Oh, the kitchen is VERY breezy which is great in Singapore because it's usually pretty hot and humid.  So you always get a great breeze when you are cooking.

    Camera 11 NOV 2007 086 Camera 11 NOV 2007 089

     Camera 11 NOV 2007 088 Camera 11 NOV 2007 109  

    Bedroom 1 & 3 (Guest/weight room, entrance to Master)

    Camera 11 NOV 2007 094 Camera 11 NOV 2007 097

    Bedroom 2 (Computer room running Windows Vista 64-bit dual monitor and Ubuntu Gutsy.  Once Windows Server 2008 ships, I'll be setting up a server rack for testing my game in progress - watch for a future blog on that :)

    Camera 11 NOV 2007 075  Camera 11 NOV 2007 077

    Nuclear bomb shelter room - notice the 1 foot thick concrete walls, the 5 lock pins in the door, and the two air ports covered by a 1/4" steel blast shield (air gets through on the side of the blast plate).  Ok, so it's not a nuclear bomb shelter, but it is a "civilian defense shelter".  It has full cable/ethernet/power/lighting inside.  Could make a great server room...

     Camera 11 NOV 2007 116 Camera 11 NOV 2007 117

    View from master bedroom and the living area balcony.  Pool is awesome and it's not used much.  There is a BBQ pit down there too.  The best thing about this place (besides being in the middle of night life) is the VENDING machine down there which carries your favorite soda which is essential when you need to get some coding done and you're all out of something to drink.

    Camera 11 NOV 2007 096 Camera 11 NOV 2007 103 Camera 11 NOV 2007 104

    Well that's it for now on the new place.

    So far, I'm VERY much enjoying it here.  It's nice to own your own place and not pay sky high rent.  My mortgage payments are less than half of what I was paying in rent.  Not bad :)  Oh, and this place is larger than the place I was renting and is on the 5th floor vs. being stuck on the ground floor.

    There is still more I want to renovate, but I'll get to it later.

    Hope you enjoyed the tour!

    -Todd

    November 09

    LED Lighting

    On my living room table:

    My regulated power supply with my Fluke scope on top, soldering iron to the far lower right, breadboard with ‘old’ LEDs (for comparison with the power LEDs on the instruction manual in lower center of image.).

    The LED packaging is just to the right of my cell phone – contains 5 LEDs per strip that I bought. 

    clip_image002

    Power LEDs up close and mounted on an oversized heat sink (notice how very small they are… less than 3mm x 5mm package size!!!) and they put out 100 lumens of light each (compared to about 1700 lumens for a 100 watt incandescent bulb).

    So you’d need around 17 of these super small LEDs to make the same amount of light as a 100 watt ‘normal’ light bulb.  Each of these LEDs uses about a watt of power each, so 17 x 1 watt is 17watts for the equivalent light output of a 100 watt bulb.

    Notice the Singapore ‘dime’ near the mounted LEDs on the heatsink for a size comparison.  The wire I used to attach was very small gauge bell (magnet) wire I think of 24 gauge or something… (it looks big in the picture but was the only size small enough that I had that would solder to the extremely small solder pads on the LEDs).

    I mounted the LEDs using an epoxy + accelerant.  The backside of the LEDs contain a non-electric copper patch for heat transfer (you can actually pump up to an amp through each LED if you so choose – they run normally on 350ma).  In tests, even when running an amp through each LED, the heatsink wouldn’t even get warm… and the LEDs didn’t get warm either… so these are some efficient LEDs!!

    clip_image004

    Ok, and now a picture with all other lights out of the picture:  I didn’t use any flash on the picture, and used normal exposure.  So the room is being lit by only the power LEDs using a total of about 4 watts (3 white + 1 red power LED).  Normally I wouldn’t use the red, but just wanted to see what it looked like :)

    So really, you could do this with 3 watts of power.

    clip_image006

    To get an idea of how small these really are, take a look at the packaging next to my cell phone in comparison:  there are 4 of these LEDs still left in the packaging tape (used for automated surface mount).  Each power LED (Luxeon Rebel Lumiled) costs about US$6.60 in small quantities for the ‘cool white’ color, about $4.40 in larger (250+) quantities.  And by the way, ‘cool’ here doesn’t mean ‘cool’ as in me, it refers to the color temperature of light, such as cool, neutral, or warm light.

    So you get about 100 lumens of light for about $4.40.  Multiply by 17 to get a normal 100 bulb light output (of around 1700 lumens), and you come up with about $75 dollars for just the LEDs… never mind the current regulation systems and such.

    Of course, you will only be using about 17 watts instead of 100 watts, and if you live in a hot climate where air-conditioning is used a lot, that is an additional savings because air-conditioners don’t have to compensate for added heat generated by the ‘waste’ heat of a normal incandescent output.

    So you save money on energy in two ways:  the cost of the energy to power the bulb (17 vs. 100 watts) and the less amount of energy to power the air-conditioner (in the day-time).

    Of course, you could also choose to light rooms more brilliantly and cut energy instead… for example you could triple the light in a given room and still save on energy costs.

    clip_image008

    It was a long day and night to get all of this working.  Had to go buy a regulated power supply (and other electronics related stuff :) so I could adjust current in small steps, and the guy that had the only (high quality) one didn’t accept credit cards (don’t even ask), so I had to go walk to an MRT station to find an HSBC ATM because my stupid HSBC ATM card can ONLY be used in HSBC ATMs (grrr) in the pouring rain using a cheap china-made umbrella that broke halfway through and cut me and my hand got cut in various places and started to bleed and then I was cursing china-made products all the way back to his shop.  But I kept it to myself – sort of.

    Needless to say, I MADE him give me a 15% discount for all of my troubles.

    And since he was so nice, I bought a LUX meter from him too :) It’s pictured in the very first picture in this email in the sort of upper left of the image (it looks like a remote control with a while ball stuck in it at the top).  LUX meters measure light output which let me measure the efficiency of LEDs at various power levels.

    Interestingly, the lower the power you give them, the more efficient they become… which is exactly the opposite of what happens when you lower the power (or dim) an incandescent bulb – they get even LESS efficient – turning less than 5% of the power you give them to light… the rest gets wasted as heat.  In low power situations, the LEDs were giving me almost 130 lumens per watt, and ‘normal’ lights about 5 lumens per watt – it’s that different.  The absolute best fluorescent lights are about 100 luments/watt – however, typically used fluorescent lights only give out about 40-65 lumens/watt.

    Well that’s it for now, hope this was interesting.  Now you know what keeps me up late at night (besides installing the latest Microsoft betas).  Next step is to get a PCB board fabricated that has about 10 of these in a circular patter (so that I can use a lens over them) and package them easily.

    -Todd

    XNA cube renderings

    Well, just fooling around with XNA and took this screenshot:

    For the folks on IRC EFNet #xna :)  We were talking about BOX wars with cubes and... errr...  ummm never mind.

     xna - Copy

    This is a screen shot from a game engine I'm putting together.  This rendering is of 500,000 cubes at a 120 degree angle camera view.  Normal viewing angles are typically less than that. The 120 angled view gives a sort of 'fish eye' view and is responsible for the cubes at the edges looking 'warped'.

    You can notice the 'fake HDR' or the bloom on the letters and lines on the textured cubes giving them sort of a 'glow' look.

    I wasn't really going for FPS, I was after the ratio of CPU usage vs. GPU usage of the rendering engine.  For example, how many objects can I instance vs. the amount of complexity for each object (# of polygons, pixel shader complexity, etc.).

    Anyway, this was simply a snapshot of some of the work I was doing.  I've since made some progress of which I'll post soon.

    -Todd

    November 08

    My first Spaces post

    Well, this is my first post to Spaces.  Just downloaded the new "Live" messenger, and it was actually an installer package for the entire Microsoft Live 'suite'.  It included some nice applications, and this one "Live Writer' was one of them.

    Being an employee and placing all of my trust in Microsoft :)  I just decided to download all of them since they were free.

    I am quite amazed at the level of quality of this software and the integration to the Internet that they all have (hence the 'Live' terminology).  It set up my 'Spaces' account automatically, and now I can write blogs quite easier, or so I will find out.

    If you want to try out this stuff, which so far I can recommend even though I haven't played around with it for that long :), the link is here: http://get.live.com

    It's also easy to uninstall and doesn't seem to leave many remnants behind as other 'uninstallers' do!

    Well... OK... here goes... going to hit the "Publish" button and see what happens... I guess if you see this on Spaces it worked!  3...2...1... PUBLISH!!!!