Tuesday, February 28, 2012

Getting started with Minko [Tutorial] (Flash+FLEX+Molehill)


This is a tutorial aimed at setting up aerys Minko/FLEX - a process that is not detailed on the Minko website.
This is required before people can even begin to use the Minko Tutorials.

Last week I needed to do a very simple 3D project, the requirements were that it must run in a browser and not require additional plugins.
Since YouTube has driven people to keep up to date with their flash plugin, flash seemed a better candidate over HTML 5, since windows doesn’t seem to force update IE8 to IE9.
(IE 8 being the last modern browser to not support HTML 5).

Either way, I was going to have to learn this language pretty quickly. I have a strong background in C++, C# and JavaScript, so at least one of those would come into play. Flash's ActionScript is very much like JavaScript with some odd syntax.
This is a guide aimed at a non-flash-developer who wants to get working in 3D flash quickly.
There are several frameworks for 3D, they all use Molehill which is flash’s 3D rendering engine.
Some improve on the shaders and textures, others are entire engines. I settled on Minko because it looked extremely pretty and supported Jiglib - a physics library that I had used before.





For some reason, there are little to no tutorials or examples of how to get Minko working.
Firstly, because it’s flash, it does not mean that the projects must be loaded into Flash CS5.5, this was the first dead end I hit knowing nothing about flash development. I got some files and I had no idea how to compile them. I tried importing packages into Flash and executing them but I got errors upon errors every time. Some of the 3D examples I got didn’t even include .swf files which had me a bit baffled.
As it turns out, they required Flash Builder or some equivalent IDE to compile in. Good… we’re learning. Alongside that, this IDE requires FLEX. Flex is flash's open source SDK which adds many rich features.

This tutorial was written for Flash Builder 4.5 or equivalent and additionally is the only application in this tutorial that’s not free.
That’s not to say this tutorial won’t be useful for people using other tools (if they exist... the tools, not the people).

So let’s get compiling Minko then. We will try the Gravity demo.
Notice that the Dependencies are as follows:
minko
minko-lighting
minko-jiglibflash
minko-picking

This means were going to need to download all these files and throw them into the same folder.
You can find the link for the base Minko engine near the top of the page as a zip, but the rest are scattered around the page.

Go into the GitHub links and click the Download as Zip button near the top left.

Each of these files contains a src folder and some contain other folders next to the src folder (assets/libs).
Extract them all on top of each other so the src/libs/assets folders are overwritten.
Don’t worry about overwriting files here, they are all the same.
It should look like this.

Next, we need to get FLEX 4.6 (at least this version or it won’t work!)

Extract the contents of this to a tidy location (C:\Program Files (x86)\Adobe\FLEX).

Install the debug flash version in your browser. The screenshot shows the link for the Firefox version.
This debug version enables extra features for developers.

Run Flash Builder and we will begin to set up the project.
This bit is very important; choose the wrong thing here and you won’t compile anything.
Select File -> New -> ActionScript project.
1. Enter the name.
2. Deselect default location and point it to our folder that contains all our Minko stuff, src/libs/assets.
3. Select Web, not AIR.
4. Use specific SDK 4.6.0

a. To get this SDK to display in the list, you need to click Configure Flex SDKs...
b. Click Add and browse to the directory we put FLEX in before, it should find the correct name automatically if you extracted it correctly and the path is correct.
c. Ensure 4.6.0 is ticked and click OK.
5. Click Next

6. By default, "merged into code" should be selected. Ensure it’s that way.
7. Click Add SWC Folder and type in "libs" without the quotes and then click OK.
8. Ensure the Main application file is "Main.as", this might change depending on what you named the project.
9. Click Finish.

Before you compile you need to add a parameter to the flash otherwise you will get a "Context3D not available" error.
And you don’t want that...
Inside your Minko folder that you extracted the original files to, there should be a new "html-template" folder there that Flash Builder placed there.
Go inside and modify the index.html file (name might vary slightly).
Go through the code and look for the swfobject script. Below "params.allowfullscreen" add this:

params.wmode="direct";

Now do the same with the html file in the "bin-debug" folder (might be called Main.html for you).
This folder is normally updated with the html-template file, but it could take a few compiles for the update to take place so it's quicker and safer to do both.
DO NOT COPY THE FILE DIRECTLY, THEY ARE DIFFERENT.

Now that is done. Go back to Flash Builder and click Run (Green button top left).

If you get errors on compile you have done something incorrectly. The most common problem is missing files. This is because you extracted them wrong or had the directories pointing to the wrong places. If you are absolutely stuck, here is a file containing most if not all of the steps required to get Minko to compile. Now go start with the tutorials!


Thursday, January 20, 2011

Telnet-TV



This is a prototype application I wrote in C++. I came across the idea a few years ago, when I accidentally Telnet'd into a game server. I wrote the server to use winsock and didnt consider to check what application connected to its sockets, the server sent a mass of garbled text to the Telnet client. It sort of looked animated, and so I tried to write an app to stream scrolling images to Telnet. I forgot about it completely.
Recently I wanted to write some kind of obscure BBS type software and I remembered the old Telnet-TV attempt. The new one was written in 24 hours using some C++ snippets from the internet. It took about 12 Hours to encode the entire first episode of Peep Show, the episode is 60Mb in black and white, and 11Mb compressed. I ripped the audio as a low bitrate mp3 so I could get a dirty feel from it. Currently the server can broadcast coloured ASCII, but I find it lags a lot and is unwatchable. Colour doubles the filesize too. The video on its own can be streamed to another PC.
There are 2 programs involved in this process, the encoder and the streamer. The encoder scans frames of a video and saves them to a file. The encoder needs to know if it should take colour into consideration. The encoder writes 2 files, one is the raw data, the other is a file that keeps track of how much data is in each frame. I used this method to try and improve the colour frame rate in Telnet, there is a vast improvement, but its still unwatchable. The second program reads the files and listens for socket connections. It then streams content to the Telnet client thats connected, making sure to keep the appropriate frame rate.

Thursday, September 30, 2010

Annoying windows updates

So there I was playing StarCraft 2 in a ranked match and my PC suddenly shut down.
It was those damn Windows Updates messages that give you a five minute ultimatum before restarting, but gives you an option to postpone it if you were lucky enough to catch it.
For whatever reason, I didn't see the notification, I was fullscreened and it didn't tab me out.
Anyway, here is a registry file for Windows 7 that will prevent it from shutting down your PC. You will still get the warning message and your PC will still update and download updates as normal, but it will never force restart on you.

Download
Just download the zip, and run the reg file inside to apply the fix.

Wednesday, September 15, 2010

Wardriving and GPS Tracking

It’s not a new idea by any means, but I decided to try to wardrive and GPS track my findings with the equipment I had at my disposal.
Namely a laptop that can run Aircrack and a Nokia N95 with built in GPS.
The laptop took me a long time to set up, Months fiddling with a closed source Intel driver setup, and eventually a method of compiling a custom kernal with the promiscuous drivers installed. I wanted to use my n95 as an external Bluetooth device so I could use a sophisticated tracking suite and run it all off Linux. But alas, the very drivers that allow me to use promiscuous Wi-Fi, hinder my Bluetooth chip, which is integrated into my Wi-Fi card. So a little research later, I found a free java based (GPSED) software that can track positions and store the data on the memory card. Unfortunately, the format it saved the files to was almost proprietary. Luckily I can convert the .gpsed files to the more common GPX files with www.gpsvisualizer.com. Meanwhile, kismet stores sniffing data in csv format, so that was perfect. The CSV contaions lots of juicy data such as the time when an SSID is first discovered, the name, mac, security type and tons more info.

I did a small trial run with the laptop and the phone running in parallel and got enough data to write a quick C# app. The app takes the data from both and tries to match up the closest times for the discovery of Wi-Fi and the plotted GPS points. Its quite accurate, even without filtering (linear interpolation etc.). It takes these coordinates and plots them on Google maps using the JavaScript API, Each point is named after the Wi-Fi SSID. However it would be very simple to allow the user to preview the full information by clicking on the SSID.
I did a 20 mile drive and got some data, but the chart looked wrong. Turns out my phone was in GMT+1 while my laptop was in GMT+0. So I added a Time correction option to compensate (For quick reference; my one hour offset was 3600 Seconds). All I did before my trip, was to stop and activate the N95 Tracker and the Wi-Fi sniffer, and make sure that I came to a full stop when I Deactivated both of them.

Finally I decided to do a real test with the program (which you can see in the video below). I took the laptop and phone across country for a near 2 hour drive. From Enniskillen to Newry. My GPX file (Tracking Data) ended up being 661KB, and my CSV file (SSID Data) was 94KB.



The programs name is Koitus, why? Because I was told to call it that. The sloppy source code is available as a Visual Studio 2008 Solution if you email me requesting it. The data was gathered legally and I am by no means responsible for the misuse of the information in this blog post. Let me remind you, it is illegal to even connect to many wardriven access points.

" Don't look. Don't touch. Don't play through.

In other words, 1) don't examine the contents of a network; 2) don't add, delete, or change anything on the network, and 3) don't even use the network's Internet connection for Web surfing, email, chat, FTP, or anything else."
~ Jeff Duntemann's Drive-By Wi-Fi Guide

Archos 605 Web Browser Hack

I used a simple DNS redirect allowing me to use the Content Portal to browse similar to the built in Opera web browser.
It’s pretty easy to change your DNS settings on a windows machine by editing your hosts file.
But on an Archos, it’s a different matter. With the Archos GFT3 root hack, its possible not only to modify the aliases, but to completely hack full webrowser functionality.
As far as normal DNS hacks go, there are 2 solutions available. Install a small Linux based DNS system, or get custom firmware for your router.
I fortunately am using a Netgear WNR834B which allows me to install the Talisman operating system. I would recommend of course openWRT if you can use it.
The procedure was very simple; I redirected all outgoing communications from archos.euronews.com to my server.

On my server I put some PHP code in to detect if the Archos had connected and if it had, print out a form for it to fill in.

The form has one Google search box and a box at allows you to put in HTML code.

The disadvantage of this is mobility, the Archos will only every work this way behind the router.
However you can set up your own Linux DNS server and have your Archos point to it and redirect you to Google.
Overall this shows some bad design decisions on Archos's behalf. Notice how I redirect Euronews instead of the main Archos portal, There is a prevention method implemented, just not very well.
When the browser connects to the Archos portal it sends the GUID. The code below displays the ID and write some forms for the Content Portal to derail from the portal.


The Archos portal validates the ID and sends a confirmation string.
If we redirected the portal, and didn’t send the string (which we don’t know how to generate) then the Content Portal would fail to operate.
None of the other sites worry about the validation, so it allows you to derail from the portal if one redirects to an external site.