BrownBot Logo BrownBot Head

Cel Shaded Dirchies

3:51 pm Filed under: Dirchie Kart,XNA

I had been holding off doing a full cel shaded effect for Dirchie Kart, it’s been done before and I was hoping to come up with something more original.

I figured it suits the graphic style so much I’d better have a look… It looks so good particularly with the vertex animations that it’s definitely got to stay.

CellShadedXNA

WCF Callback Events in WPF Client and Console applications

11:06 pm Filed under: Uncategorized

WCF-WPF-Client-update-sampl Managed to pulled off some clever code today, got my callback events raised by a WCF service to safely manipulate the underlying ObservableCollections of my WPF client.

I’m sure it’s nothing that hasn’t been done before but I think my solution was quite graceful so I’ve put together a sample for people to use, something other than a chat program.

The image to the left shows 6 WPF clients with the same list of “BatchIDs” (ObservableCollection<string>), manipulating the list on any client re-arranges the list on the other clients.

Potential big concurrence issues I know but my implementation will only have one client with edit permissions, the others will have a read only view.

You can see the server which holds a master list of BatchIDs in the bottom left and a console client above it which simple lists out the sequence of BatchIDs when an update is received by the clients.

When one of the WPF clients completes a move within the list it sends it’s the sequence of BatchIDs up to the server, which in turn updates it’s master list and sends the list via callbacks down any other clients currently connected.

The WCF Contract is as follows:

[ServiceContract(SessionMode = SessionMode.Required, CallbackContract = typeof(IProductionReportingServiceCallback))]
public interface IProductionReportingService
{
    [OperationContract(IsOneWay = false, IsInitiating = true, IsTerminating = false)]
    bool Join(string name);

    [OperationContract(IsOneWay = false, IsInitiating = true, IsTerminating = false)]
    void NotifyBatchSeqenceUpdate(string[] batchIDSequence);

}

public interface IProductionReportingServiceCallback
{
    [OperationContract(IsOneWay = true)]
    void UpdateBatchSequence(string[] batchIDSequence);
}

the Join() is simply there for the server to store a callback for the client (List<IProductionReportingServiceCallback>), the NotifyBatchSequenceUpdate() is for clients to upload a new sequence.

The IProductionReportingServiceCallback is pretty self explanatory, it’s the callback sent down to the clients from the server.

 

I won’t bother explaining the implementation, you’ll have to look at the code and comments to work that out, but you use it as follows:

In your Main Window of your WPF app create the DuplexChannel so you can send a receive messages.

public staticProductionReportingServiceCallbackEventRaiser ProdRepSvcCallbackEvents;
public staticIProductionReportingService ProdRepSvc;

publicWindow1()
{
    // We pass in the Dispatcher here so the events come back to us on the UI thread
  
ProdRepSvcCallbackEvents = newProductionReportingServiceCallbackEventRaiser(Dispatcher);

    DuplexChannelFactory<IProductionReportingService> ProdRepSvcCF = newDuplexChannelFactory<IProductionReportingService>(
                                                  ProdRepSvcCallbackEvents,
                                                  newNetTcpBinding(),
                                                  newEndpointAddress(“net.tcp://localhost:9080/DataService”));

    ProdRepSvc = ProdRepSvcCF.CreateChannel();
    ProdRepSvc.Join(Environment.MachineName + “: WPFClient”);

    InitializeComponent();
}

We have the Service and Callback event wrapper as static so we can call/subscribe to them anywhere in the app like so:

Send up a new sequence

Window1.ProdRepSvc.NotifyBatchSeqenceUpdate(_batchList.ToArray());

Subscribe to the callback event

Window1.ProdRepSvcCallbackEvents.OnBatchSequenceUpdated += new EventHandler<UpdateBatchSequenceEventArgs>(OnBatchSequenceUpdated);

You can download the complete (server & client console class lib and WFP client) VS2008 project here (40k) enjoy!

Announcing Dirchie Kart

5:18 pm Filed under: Dirchie Kart,XNA

With the announcement that Microsoft are going to sell the XNA community games over XBox live I figure it’s time to reveal the super secret skunkworks XNA project I’ve been working on.

DirchieKart1

Up to 1 to 4 player split screen, co-op or competitive cart action on XBox or PC. Most of the graphics are just place holders at the moment, but I’ve got some pretty good tech going on in the shaders that open the door to some game play ideas.

Every object in the game can:

  • Be animated by one of many vertex shader routines.
  • Have the amplitude and frequency of this animation individually controlled.
  • Have it’s a colour saturation manipulated (from grey scale to colour).
  • Mask out areas of the texture to a colour (ie specific parts can change colour).

DirchieKart2

Game modes I want to include:

  • Paint the town, where everything starts gray scale and you have to paint the level with your Dirchies colour (maybe have a specific colour that you have to collect first).
  • Race…standard Kart affair but with more bad guys.
  • Battle, you need to keep your Dirchie meter above zero (Dirchie meter indicated to other players by your saturation level)
  • Survival, help each other reach the end of a level filled with bad guys.
  • DDR, Dirchie Dance Revolution, something where you collect notes or something that make the level dance… I dunno.

The other thing I want to introduce is a award/punishment/vote system so you can bag each other out at the end of each round.

If you’ve got any suggestions for game modes, weapons or awards/punishments leave me a comment.

Dipping a toe into the WCF pond

2:58 pm Filed under: C#

Spent the day in WCF yesterday, plenty of reading and then hacked up a couple of different samples I found around the web into a basic but functional client server test.

What I set out to achieve was write a simple service that clients could connect to and receive a callback from, previously I’ve done this by having the client poll a server on a timer which is really inefficient. The screen shot below shows the server console on the left spewing out updates every 100 milliseconds and the 5 clients on the right instantly receiving the message.

image

Not all that impressive but it does seem pretty robust with the clients able to connect and disconnect at will, it’ll do the job I want it for anyhow.

Online Colour Wheel

8:42 pm Filed under: Uncategorized

ColourWheelFor anyone out there doing some design, be it a user interface, greeting card or painted master piece, the colour wheel is an invaluable tool for picking colours.

I was mucking about this morning cleaning up some rough edges in the UI design app I’m working on and stumbled across this great web based colour wheel.

I find it a great way to explore the colour spectrum looking for a list of complimentary colours.

As a bonus for the code monkeys out there that like to see there hexadecimal colours in code rounded out (ie #FFFF2255, I bet you also only ever set your stereo volume to numbers devisable by 2 or 5)  it limits the pallet to only round values.

As a bonus I also stumbled across this informative article on colour theory, handy for understanding how to use the colour wheel.

Toon Animation Shader

5:16 pm Filed under: XNA

Didn’t sleep too well last night, my mind was racing after an intense afternoon in HLSL (High Level Shader Language) developing a new shader I had thought up over the weekend.

I’m thinking about putting together an entry for the new XNA Dream-Build-Play competition. One of the feedback concepts I dreamt up was to pack the area with static characters and objects which start off black and white, these animate and gain colour the better you perform.

Being a one man team there’s no way I’m going to be able to animate all these objects in max, so I came up with a vertex shader to do it, a few sin waves and matrix calcs later it was all working (I say that but it pushed my matrix math and HLSL skills to the limit).

You have to use your imagination with these static images but imagine the coloured ones bopping and swaying in time to some music.

ToonAnimation1 ToonAnimation2

Powered by WordPress