Archive

Author Archive

Achieving smooth transparency and glowing

August 13th, 2010 Eddie Long No comments

Generally when you want something to flash on and off in a smooth fashion you have a duration that you want an icon to fade in and out at. You then tend to have a timer that increments up to the fade value and when it hits the fade value begins to decrement again down to zero. See the code below for an example of this in action

static const f32 totalFadeTime = 4.0

if (m_fadeUp)
{
	timer += delta;
	if (m_timer > m_revealTime)
	{
		timer = m_revealTime;
		m_fadeUp = false;
	}
}
else
{
	timer -= delta;
	if (timer < 0.0f)
	{
		timer = 0.0f;
		m_fadeUp = true;
	}
}

const f32 alpha = timer / totalFadeTime;

icon->SetAlpha(alpha);

The approach above uses linear interpolation so the fade looks quite even and bland. To get a nicer smooth fade you can use sin or cos alongside the linear value to give you a smoother looking effect. This is because of the curve of cos is not linear cos curve. Add the following lines to achieve this effect:

const f32 alpha = timer / totalFadeTime;
const f32 newAlpha = (cosf(TwoPi * alpha) - 1.0f) * -0.5f;
icon->SetAlpha(alpha);

Unfortunately I don’t have an example of this on hand to show but I does the trick nicely.

Categories: C/C++ Tags:

Just a test

July 31st, 2010 Eddie Long Comments off

testing FB and twitter posts

Categories: C/C++ Tags:

Tumbleweed

July 31st, 2010 Eddie Long No comments

It’s been quiet around here lately. I’m going to try to make an effort to blog here a bit more, it will mostly be about my SingStar coding experiences!

Categories: C/C++ Tags:

S-Video out with Snow Leopard, beware!

March 30th, 2010 Eddie Long No comments

Hi there,

I recently upgraded to Snow Leopard and was shocked to see that Apple have not kept up support for DVI to S-Video output. The output on screen appears in greyscale and poor quality. Even with restarting I had the same problem. The latest patch for Snow Leopard doesn’t seem to have anything to fix this problem so I was left with no alternative but to revert back to Leopard or lose my TV in my room, no thanks. Also upon upgrading I lost some widgets I used such as MenuMeters and my replacement for the time stopped working also.
Luckily I had a backup with Time Machine from a few days ago which could be restored!

Beware of Snow Leopard!

EDIT: I’ve just upgraded again and these issues appear to be fixed, damn right!

Categories: Mac Tags: ,

New site content

December 15th, 2009 Eddie Long No comments

Hi all,

I’ve just uploaded two new two new projects to the site.

The first is a little physics simulation I did last week.

The second is an application framework for DirectX that provides a basic scene along with camera setup and manipulation, logging, mesh loading and rendering support and direct input support.

You can get them in my downloads section of the site.

Cheers,
Eddie

Categories: C/C++ Tags:

Really annoying ActionScript error

December 12th, 2009 Eddie Long No comments

Hi,

I’ve been working with ActionScript for the first time and created a really simple class with a couple of getters and setters and wanted to instantiate the class and use a few setters.

So the original class was:

package MyPackage
{
	import mx.core.UIComponent;

	public class AClass extends UIComponent
	{
		public function AClass()
		{
			super();
		}

		public function get AValue():Number
		{
			return _aValue;
		}

		public function set AValue(_newAValue:Number):void
		{
			_aValue = _newAValue;
		}

		private var _aValue:Number;
	}
}

That looks fine right?

So in my class I call
import MyPackage.AClass at the top of the file.

Next in another class I called

var myClass:AClass = new AClass();

myClass.AValue(20.0);

I figured that this looked fine, you want to call the function AValue with the value 20.0 passed in. However I was getting the cryptic error:

1195: Attempted access of inaccessible method AValue through a reference with static type MyPackage:AClass

Took me a while to figure this one out I thought I had defined the functions incorrectly or wasn’t importing the class right. However the solution is a simple one. When you use get and set you are essentially saying that you can use the assignment operator but for some weird reason you can’t call the functions directly.
So the solution was to do:

var myClass:AClass = new AClass();

myClass.AValue = 20.0;

Use the assignment operator instead of calling the set function directly.

Categories: Flex Tags:

Site update

November 25th, 2009 Eddie Long No comments

Hello all,

Well I’ve spent the last few days updating my site, hopefully all the downloads now work with Visual Studio 2005 and the most recent DirectX.

I’ve not got a chance to actually clean up the code yet so don’t expect miracles!

Please let me know if you find anything broken!

Cheers,
Eddie

Categories: Uncategorized Tags:

Quieten XCode’s output to the console

August 6th, 2009 Eddie Long No comments

Hi,

During some iPhone dev i noticed that the console on my macbook had many entries like:

Xcode(19838,0xb0103000) malloc: free_garbage: garbage ptr = 0x319a380, has non-zero refcount = 1
Xcode(19838,0xb0103000) malloc: free_garbage: garbage ptr = 0x31bf6e0, has non-zero refcount = 1
Xcode(19838,0xb0103000) malloc: free_garbage: garbage ptr = 0x3263da0, has non-zero refcount = 1
Xcode(19838,0xb0103000) malloc: free_garbage: garbage ptr = 0x3274eb0, has non-zero refcount = 1
Xcode(19838,0xb0103000) malloc: free_garbage: garbage ptr = 0x319a380, has non-zero refcount = 1
Xcode(19838,0xb0103000) malloc: free_garbage: garbage ptr = 0x31bf6e0, has non-zero refcount = 1

These messages I found out are not actually anything to do with my program, I thought I was doing something wrong and not freeing up resources. It is actually the internal workings of XCode which is automatically freeing up resources. Knowing this, I decided to turn off these annoying console outputs and found this XCode project which basically gobbles up output from XCode in the same mould as above.

Just compile the project and it will install the QuietXCode plugin to ~/Library/Application Support/Developer/Shared/Xcode/Plug-ins. Restart Xcode and fire up the console and you’ll see an inital output of:

06/08/2009 19:34:32 Xcode[5147] <QuietXcode> loaded successfully

You should no longer see the annoying output!

Categories: C/C++ Tags:

How to watch Hulu videos from anywhere(i.e. outside of the US!)

March 24th, 2009 Eddie Long No comments

Hey all,

Very quick post, very handy little entry on Lifehacker – how to watch videos on Hulu from anywhere. For someone like me who wants good quality TVs without searching around for ages then Hulu is for you. I’ve tried it on my Mac (Leopard) and it works a dream.

Lifehacker link

Categories: Mac Tags:

Making iTunes work on Windows XP Pro 64 bit

March 24th, 2009 Eddie Long No comments

Hi,

Very quick post just to link to a useful blog post. At work I’m using Windows XP Pro 64 bit and wanted to be able to sync up my iPod with the latest podcasts but found that Apple haven’t released a version that supports 64 bit OSes besides Vista and Macs. After some searching I found this great blog post, I skipped the CD burning section and it worked just fine. Check it out here for a tutorial to get iTunes installed and working.

Categories: Windows Tags: