Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon

8. February 2012

 

The last week or so I’ve been looking at using Node for server side game programming and I have been quite impressed.  I have found a few things quite frustrating ( the documentation is extremely sparse and tooling support is… iffy ) but code wise everything has worked about exactly how I expect it.

 

That said, I ran into my first glaring bug and it is an annoying one.  In my current code, I want to write out some memory to file when my code exits, I imagine a fairly common event.  At first it seems like a remarkably simple thing to do.  Every node application has a process object, and process has an exit event.  Therefore handling on exit should be as simple as:

 

process.on('exit', function () { //handle your on exit code console.log("Exiting, have a nice day"); });

 

*Should* being the operative word.  Reality is, this doesn’t work.  The event simply does not fire on CTRL+C.   Hmmm.  So I decide to throw process.exit() at the end of my script and BAM, the on exit event is fired.  So it appears that contrary to the documentation, the CTRL+C event doesn’t raise an exit event, or so I thought.

 

Alright, no big deal, I’ll just trap the SIGINT event raised from CTRL+C and handle exit then.  Ohh… that didn’t work out well.

 



C:\Users\Mike\workspace\NodeDev\src>node server.js

node.js:218
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: No such module
    at EventEmitter.<anonymous> (node.js:403:27)
    at Object.<anonymous> (C:\Users\Mike\workspace\NodeDev\src\server.js:5:9)
    at Module._compile (module.js:434:26)
    at Object..js (module.js:452:10)
    at Module.load (module.js:353:32)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:472:10)
    at EventEmitter._tickCallback (node.js:209:41)



Hmmm…

 

So off to Google I go!  After a few minutes I discover this tidbit.  Basically it’s a known issue, SIGINT isn’t raised on Windows and they claim it isn’t possible, which considering Python handles it just fine, I find a bit difficult to believe.  So, it is a currently unsolved issue, but hopefully it will be resolved in the future.

 

Considering that CTRL+C is the defacto way to shut down Node, I really hope this is resolved soon.  In the meanwhile, does anyone out there know an effective workaround?

 

 

Update

 

Stack Overflow came to my rescue on this issue.  User pimvdb posted this work around:

 

var tty = require("tty"); process.openStdin().on("keypress", function(chunk, key) { if(key && key.name === "c" && key.ctrl) { console.log("bye bye"); process.exit(); } }); tty.setRawMode(true);

 

It feels like a bit of a hack, but then, I suppose it is!  Hopefully this issue gets fixed in node eventually, but for now, here is an effective workaround.

Programming

8. February 2012

 

logo

A couple days back, PlayN developers posted a handy little tablet showing what the current development status is for each supported platform.  The iOS support seems to be coming along nicely, but as you can see, there is still some work to be done.



  Java HTML5 Android iOS Flash
Analytics Stub Comp Stub Stub Stub
Assets Comp Comp Comp Part Comp
Audio Comp Comp Part Stub Comp
Graphics Comp Comp Comp Part Part
Json Comp Comp Comp Comp Comp
Keyboard Comp Comp Comp Stub Comp
Log Comp Comp Comp Comp Comp
Mouse Comp Comp N/A N/A Stub
Net Comp Comp Comp Stub Stub
Pointer Comp Comp Comp Comp Comp
RegExp Comp Comp Comp Stub Stub
Storage Comp Comp Comp Comp Comp
Touch N/A Comp Comp Comp Stub

Key:

  • N/A - not applicable to this platform (i.e. mouse on mobile).
  • Stub - non-functional placeholder implementation.
  • Part - partially implemented with some missing pieces.
  • Comp - fully implemented.

Also see the Roadmap.

 

 

Very cool news.  One of the items on the roadmap is better documentation, something I really look forward to.  Supporting iOS is definitely a huge deal, especially for Java developers that don’t want to go within a thousand feet of Objective C but want to be able to target the massive iPhone/iPod/iPad market, while still supporting desktop, Android and web targets.

News

8. February 2012

 

 

As I mentioned in my earlier review, all the links for Hexagon’s documentation are currently broken.  Since then, I have noticed a fair bit of search engine traffic  of people looking for documentation, for good reason too… this program is downright confusing!

 

I have noticed that although all of the links to Daz3D.com are broken and you can’t use the help menu in Hexagon itself, the help files are actually installed on your computer!  Go to the folder you installed Hexagon 2.5 to, in my case it was C:\Program Files (x86)\DAZ 3D\Hexagon2\docs.  Inside should be the PDFs you are looking for.

 

In case you cannot find them, I will make them available here ( hopefully this is ok… ).

 

Keep in mind, these are the manuals for Hexagon 2.1 and appear to be about 6 years old!  That said, it’s better than nothing!

 

 

Hexagon 2.1 US Manual (PDF, 11MB)

Hexagon 2.1 US Keyboard Shortcuts (PDF 1/3MB)

Art

6. February 2012

 

 

As I recently mentioned Daz3D have made Hexagon, Bryce and Daz Studio all available for free for a limited time.  As a Blender user, until they finally ship BMesh, I am always in the market for a good modeler with effective COLLADA support.  So at a price of 0$ I figured I would try out Hexagon 2.5.  This is not a complete review, not even close, think of this more as a “These are the things I ran into that made me decide to not waste any more time on Hexagon” review.  Obviously, it doesn’t have a happy ending, which is a shame.

 

 

First off, it is a remarkably capable modeler, almost every feature you could want is in there… somewhere.  Feature-wise, it actually spanks Blender handily, with support for n-gons, good boolean supports, surfacing, etc.

 

First a look at the interface:

 

image

 

At first glance it’s pretty clean.  Properties and scene graph on the right, a tool shelf ALA Maya across the top and a mish mash of visibility buttons across the bottom across the bottom.  Then this is where things start to show the sloppiness as well.  Consider this expanded icon:

 

image

As you can see from the tool tip, this control “Activates actual lighting” and when you click it, that toolbar folds out.

 

 

Any guesses what any of these icons means?  Cause, I’ll tell you, I don’t have a bloody clue either!  None of them have mouse over tool tips, so you are stuck trying to figure it out from the icons…  good luck with that.

 

Don’t worry, there is always the help files to sort things out…   or wait, is there?

 

 

Here comes big and I mean BIG strike number two.  The help, yeah, there is none!



Of course, there is a Help menu, and as you can see, the options look pretty encouraging imageover all but they do nothing!


You click Help->Documentation or Help->Tutorial and you are brought to Daz3D’s website.  At first it appears that it is going to bring you to a documentation page, but then you are redirected back to the Front page.  Yay.


Alright, so the help hyperlink is broken, no big deal right, just surf to the help manually in your browser?


Ah good idea, let’s try that!

So you go to Support->Wiki from the front page manual.  Then select Hexagon on the left hand side and click the Hexagon documentation link.

image

 

 

 

Ooooh, this looks encouraging!  Hexagon 2.1 Manual in English, it’s an earlier version but better than nothing, lets click that!

 

image

 

 

Oh my!  Amateur hour continues.  So, no help, I guess you are on your own figuring things out and, well…  good luck with that.  The interface is downright confusing.

 

Take view navigation for example.  Other than Blender, the 3D world has become pretty standardized on how to navigate in 3D, so lets see how it works in Hexagon.  To pan your view, hold down your middle mouse button.  Ok so far.  To zoom in your view, use the scroll wheel.  Ok, pretty standard.  To Dolly/Rotate your view you….

 

Um….

 

You…  well apparently you use the arrow keys.  Yep, by default there is no mouse mode to actually orbit the camera!   Of course, there might be, put to hell if I can find it with a complete lack of documentation!   Of course, a little googling later and I discovered the answer… It’s a preference and it’s by default OFF! Huh?  Why?  Seriously, why?

 

For those following along at home, its pretty easy to resolve. Go to the Edit Menu->Preference Editor.  Under the User Interface tab, click Misc then select Dolly around selection center, like so:

 

image

 

 

Can you seriously tell me a reason why this wouldn’t be enabled by default?  It’s a small thing, but it is infuriating until fixed.  It’s a problem that exists for no reason, and those are always the worst kinds of problems.

 

 

There are a few thousand examples like this, all around, it’s like death from a thousand paper cuts.  Like features are added or removed with no thought to being a cohesive tool.  Lets take a look at the tools panel for an example:

 

image

 

Second Life???  HUH?  Why exactly is Second Life getting such important placement, or even placement at all?  Now *this* is the type of thing you make optional in the Preference Editor!  Now take another look back at the shelf and answer me this… where you do think you would go to say… split an edge?  If you said anything except Vertex modeling, you are wrong.  Now lets take a look at that process…  How do you split an edge?  Using a tool named Tessellate, that expands down with various options, lets take a look at that next!

 

image

Lovely eh?

 

So, not only do you not have documentation, you also do not have tooltips so its basically anyone’s guess which icon you actually want to press.

 

But wait, there is a description of each icon below the shelf!  Oh wait… the expanded toolbar obscures the description text!

 

 

 

 

Again, a small niggling thing, but 5 minutes in QA should have caught this.  Again, it’s like people keep adding features with no thought to how they fit or should work.  Even worse, you have items that simply don’t exist in the panel, but only via menu.  For example, there is a utilities panel, and a tools->Utilities menu, but WELD can only be accessed via the menu! Or how about the “Lines” menu that has 5! items called arc!  I’m not kidding… look:

 

image 

 

 

Then there is the lack of polish that if you switch to a different part of the tools panel with a menu expanded, it doesn’t close.  You have to switch back to Vertex modeling, click Free Tessellate again to get rid of the menu, otherwise it’s stuck there forever. There are tons of little things like that with the UI, that make the UI toolkit they used just feel… sloppy and frankly, slow.

 

 

Speaking of slow, I am running Hexagon on a 12GB i7 machine purchased 3 weeks ago and it can be downright sluggish.  This is especially true when it comes to sub-division surfaces.  The finally

 

 

 

It’s all such a shame, as reality is, there is a great program underneath the surface here.  I didn’t give this program a lot of time; I didn’t have to.  The glaring problems are exactly that, glaring.  I encountered a good dozen “WTFs?” in less than half an hour and within three or four hours with this program I realized it had nothing to offer me that Blender/Wings didn’t already do better.

 

 

If there was documentation available ( a big huge mistake, especially when they new they were going to have a giant influx of new users with the promotion ), it might be worth fighting through the stupidity, but there isn’t and it’s not really worth it in the end.

 

 

Product Link: Hexagon 2.5

 

It’s free for the remainder of February, so there is no need to take my word for it, check it out yourself.  Be aware though, once you sign up, Daz is a little spam happy.  Since signing up this weekend, I believe I have received 5 emails, in addition to the receipt and serial number emails you get initially.  A word of advice to Daz, first off, it’s really cool you have made your applications available freely and I hope you see an uptick in your market sales as a result; but dial it back on the volume of emails or you are going to be blocked as SPAM and ignored by the users you are trying to attract!

Art

2. February 2012

 

 

 

Not sure the catch, if there is one, but this is a pretty epic deal on face value, hard to beat free!  I just finished the checkout process and as you can see, it really is free:

 

Your order contains:

DAZ Studio 4 Pro                                 1 @ $429.95   = $429.95
Bryce 7 Pro                                      1 @ $249.95   = $249.95
Hexagon 2.5 - Download...      Hexagon - Bo... 1 @ $149.95   = $149.95
Tax:                                                           $0.00
Shipping:                                                      $0.00
Discount:                                                     -$829.85
Paid via Gift Cert/Voucher/other credit:                      ($0.00)
Total:                                                         $0.00

=========================================================================

 

You have to sign up, and they will confirm your email address, so use a real one.

 

Oh, and their servers are getting absolutely hammered right now, so have some patience.  For those wondering, these are real applications and those are their real prices, so this is quite a bargain and time limited to my understanding.

 

As to the applications:

 

Daz Studio Pro

 

 

DAZ Studio 4 Logo

DAZ Studio is a feature rich 3D figure customization, posing, and animation tool that enables anyone to create stunning digital illustrations and animations. DAZ Studio is the perfect tool to design unique digital art and animations using virtual people, animals, props, vehicles, accessories, environments and more. Simply select your subject and/or setting, arrange accessories, setup lighting, and begin creating beautiful artwork.

With DAZ Studio 4 you can...
  • Create custom 3D characters and avatars
  • Produce illustrations for books, comics, and graphic novels
  • Make your own CG movies
  • Quickly make your own editorial artwork
  • Create graphic design elements
  • Design virtual environments with animated fly-throughs

 

 

So, basically it sounds like Poser, not sure how much this one use would be but worth checking out for free. 

 

 

Bryce 7

 

 

Bryce 7: The First Name in 3D Landscapes

Discover why Bryce has earned its place as the favorite 3D modeling and animation package of so many for so long. Bryce 7 Pro combines powerful features with a smart and simple user interface to make the creation of digital landscapes easier and more realistic than ever. Bryce 7 Pro proves that the only limit to creation is your own imagination.

 

 

 

Bryce I’ve used in the past, it used to be a rather one of a kind package, although now it’s functionality is often included in game engines like UDK.  Anyways, it allows you to easily build and render landscapes and terrain easily.  The results are actually rather amazing too.  This is surely a tool to add to your arsenal, especially for free!  The Pro version exports to Callada, so can easily be slotted into your workflow.

 

 

Hexagon 2

 

 

Hexagon delivers all the tools a graphic artist needs to create detailed 3D models ready for final render. Packed with features such as; DAZ Studio Bridge, sculpted primitives, freehand modeling brushes, micro-displacement modeling tools, comprehensive UV-mapping modules, advanced 3D paint, and instant ambient occlusion. Hexagon provides you with all the options of expensive competitor software, but at an affordable price.

 

 

 

Basically it’s a modeling package, I have absolutely no experience with this application, but again the price is right.

 

 

Oh, and your “purchase” gives you Mac and PC binaries!

 

 

 

In a world of 3000+$ graphic apps, this is an offer too good to ignore!  So, go check it out before it expires!

Art

Month List

Popular Comments

Gaming for the blind? Easily text to speech enable your console text adventure.
Subscribe to GameFromScratch on YouTube Support GameFromScratch on Patreon


30. May 2012

 

There was an interesting ( to me anyways… ) topic on Reddit today about making games that are accessible to the blind or visual impaired.  After thinking about this for a little bit, I though that there might be a remarkably easy way to add text to speech to a console based game.  Turns out I was correct.

 

 

The following is a C# app that makes heavy use of the .NET System.Speech libraries, however it does appear to be available in Mono, so it should work across platforms.

 

In the end the process is remarkably simple, all I am doing is redirecting Console.Out ( StdOut ) to my custom class, which converts the text to speech.

 

Let’s take a look, this code is across two classes.  One is our exceedingly simple game:

 

using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AudibleTextAdventure { class Program { private static StdoutToSpeech speechOut; static void Main(string[] args) { speechOut = new StdoutToSpeech(); Console.SetOut(speechOut); Console.WriteLine("You are standing in an open field west of a white house, with a boarded front door."); Console.WriteLine("There is a small mailbox here."); bool done = false; while (!done) { Console.Clear(); Console.WriteLine("What would you like to do?"); string currentCommandString = Console.ReadLine().ToLower(); string [] tokens = currentCommandString.Split(new char[] { ' ' }); string currentCommand = tokens.First(); switch (currentCommand) { case "volume": { if (tokens.Length > 1) { if(tokens[1].ToLower() == "up") speechOut.VolumeUp(); if(tokens[1].ToLower() == "down") speechOut.VolumeDown(); } break; } case "quit": done = true; Console.WriteLine("Thank you for playing, Goodbye"); break; case "help": Console.WriteLine("Sorry, you are beyond help"); break; case "changevoice": speechOut.NextVoice(); break; default: Console.WriteLine("I don't know the work \"" + currentCommand + "\""); break; } } } } }

 

 

Most of that code is the skeleton of our “game”.  The majority is just getting and displaying strings as well as parsing and handling the commands our game accepts. The only lines of any real consequence here are:

speechOut = new StdoutToSpeech(); Console.SetOut(speechOut);

 

Here we declare our StdoutToSpeech object we are about to define in a second, and replace the standard output stream with it.  Now lets look at StdoutToSpeech:

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Speech; using System.Media; namespace AudibleTextAdventure { class StdoutToSpeech : System.IO.TextWriter { static System.Speech.Synthesis.SpeechSynthesizer synthesizer; static SoundPlayer soundPlayer; static System.IO.TextWriter origOut; static int currentVoice = 0; static List<System.Speech.Synthesis.InstalledVoice> voices; public StdoutToSpeech() { // Grab a reference to Stdout before it's overridden origOut = Console.Out; synthesizer = new System.Speech.Synthesis.SpeechSynthesizer(); // Will bork if no voices found voices = synthesizer.GetInstalledVoices().ToList(); synthesizer.SelectVoice(voices.First().VoiceInfo.Name); // Slow it down a bit synthesizer.Rate = -1; synthesizer.Volume = 5; soundPlayer = new SoundPlayer(); } public override void WriteLine(string value) { // We still want text to show... origOut.WriteLine(value); using (System.IO.MemoryStream mem = new System.IO.MemoryStream()) { synthesizer.SetOutputToWaveStream(mem); synthesizer.Speak(value); soundPlayer.Stream = mem; soundPlayer.Stream.Position = 0; soundPlayer.PlaySync(); } } public void VolumeUp() { if (synthesizer.Volume < 10) { synthesizer.Volume++; this.WriteLine("Volume increased"); } } public void VolumeDown() { if (synthesizer.Volume > 0) { synthesizer.Volume--; this.WriteLine("Volume reduced"); } } public void NextVoice() { currentVoice++; if (currentVoice >= voices.Count) currentVoice = 0; else { synthesizer.SelectVoice(voices[currentVoice].VoiceInfo.Name); this.WriteLine("Voice changed"); } } public override Encoding Encoding { get { throw new Exception("If you are trying to use this as text, you are in for a world of hurt!"); } } } }

 

In our constructor we create our System.Speech.Sythensis.SpeechSynthesizer, set a voice, default speed and volume for it.  We also instantiate our SoundPlayer which is going to actually play the sound file our synthesizer um… synthesizes.

 

The key to this class is that it inherits from System.IO.TextWriter, this is the only type that we can set standard out to.  Our class must implement the Encoding:Get method, which if anyone actually called would cause all kinds of problems, so we throw an Exception if it is actually called. In the constructor we take a snapshot of the original standard out, so we will still be able to print to text.

 

Otherwise most of the work happens in our WriteLine overload.  First we print out to the original standard out, otherwise our command prompt would become audio only!  Next we create our memory stream that our synthesizer is going to record to.  We then render whatever speech was printed via a Console.WriteLine() call, set it as the active stream and play it using our soundPlayer.  We using PlaySync() to make sure it finished playing before continuing execution.  You could use Play(), but it would only render the most recent sentence if a couple lines where written at once.   Also note, we only overrode WriteLine(string), so if you do Console.Write, Console.WriteLine(char[]) or any other version, nothing will happen.  If you want to support more versions, you need to implement.

 

Otherwise the rest of the code provides a simple interface for increasing and decreasing volume, as well as changing between voices.  Keep in mind though, if you are using Vista or Windows 7, you probably only have on voice installed.  You can however add additional voices ( including different languages ), I download one from here for example ( copy the dlls to your debug folder if you get an error ).

 

 

Now when you run the application, you can use the following commands:

quit – exits the “game”

volume up – increases the voices volume

volume down – decreases the voices volume

help – displays a help string

changevoice – changes to the next installed voice, if you have any.

 

 

Obviously in a real game you would do substantially more.  In a real game you would also add a great deal more error checking too, as this is just a proof of concept I slapped together!  Obviously use at your own risk, as I offer no warranty.  Then again, I never offer a warranty…

 

 

And here it is in action:

Text to speech adventure in action

Programming ,

blog comments powered by Disqus

Month List

Popular Comments