titaniumbunker.com

Evil geniuses and world domination are 2 of our goals... we also like Dr Who

Just Loaded : PhonySession

no comment
phony_logo_thumb.png

PhonySession – now on nuget.org

In a previous post I wrote about needing to fake up a HTTP Context for testing a controller and I hinted that perhaps I would create a NuGet package to make this easier. Well I am happy to announce that I have done just that.

NuGet?

NuGet is an open source package manager for Visual Studio and .NET.  Developers can take code that they use and package it for distribution from the Nuget Gallery.  This allows other developers an easy way to reference and include functionality from libraries.  Want to a a unit testing framework to your library? reference if from Nuget.  Visual Studio projects support the concept of automatically refreshing dependancies from Nuget when loading, and Nuget Packages can have a defined set of dependancies.  I developed PhonySession partly because I wanted a framework I could potentially reuse, and also as an exercise in packaging my .NET library for Nuget.

PhonySession is a nuget package that can be added to a test project allowing a developer to ‘fake up’ a HTTP context, allowing controllers to be tested without needing to stand up servers.  Setting up the context is easy.  PhonySession uses other NuGet packages, and the dependency management system will automatically add these dependencies to any project that PhonySession is added to.

phonySession-Depends.png

PhonySession dependency graph

Using PhonySession

As always code is the key – so here’s an example of setting up a HTTP context, and adding a file from an embedded resource.

var fakeHTTPSession = new TitaniumBunker.PhonySession.FonySession();
            fakeHTTPSession.AddFileUpload(new PhonyUploadFile("Screensjot.jpg", GetResourceAsStrream("TestAPI.img100.jpg"), "JPG"));
            prodcontroller.ControllerContext = fakeHTTPSession.BuildControllerContext(prodcontroller);
            prodcontroller.Url = new UrlHelper(fakeHTTPSession.BuildRequestContext());

This code fragment :

  1. Creates an instance of the Product Controller – the controller we want to test
  2. Creates an instance of the FonySession object
  3. Adds a file to that session object
  4. Sets the controllers context to the output from BuildControllerContext
  5. Sets the controllers URL property to a new URL Helper object.

So the eagle-eyed amongst you might notice that when I create a PhonyUploadFile, that I specify “JPG” as it’s MIME type, and that the correct MIMETYPE should be “image/jpeg”.  My tests don’t check the MIME type – there’s no reason I couldn’t check the MIME Types – I just don’t think there’s much benefit in testing that, as the file upload functionality is not something provided by my application, rather something provided by the framework.

 

It’s not perfect – there are a couple of names that I should change (fonysession?) but from a functionality point of view it all works.  It may not support 100% of all test requirements (I wrote this for a controller testing a particular issue) and it might be that this framework will have to grow to include other functionality.

PhonySession is hosted on GitHub here and is licensed under an MIT Licence.

 

Icon Credits : “Disguise” logo by Helen Tseng is licensed under CC BY 3.0 US – downloaded from https://thenounproject.com/term/disguise/24240/

Building LA: adding some buildings

no comment

Having  previously created the landscape of LA and placed the model of the chinese theater. for a flythrough for the intro of Pied Pipers Production of Singin’ in the rain.Next thing I did was to make some rain

Makin’ it Rain

to make the rain effect, I created a simple particle flow system and altered its settings to look like it was falling like rain. I then built a simple raindrop and then made the particle system reference this one raindrop . I turned off  random rotation so the raindrops are heading straight down. Particle systems are expensive in terms of redraw and update speed so I will hide it untill I need to render it.

makingLA2_6

A single raindrop

 

 

 

 

 

 

 

I then placed a camera in the scene, set up some controls for it and after a bit of trial and error , made the beginings of what could be an interesting camera move.Here’s roughly what I had:

I then went on a download spree over on 3D warehouse, looking at the collections of models in LA and Hollywood checking against the map to find buildings next to the Chinese theatre. Then I got some more generic buildings and come cars

Changin’ the Format

here’s the next problem. 3D ware house has files in sketchup format, which if you remember from last time, I don’t have sketchup. but 3D warehouse also has the option to download in google earths model format – .KMZ

I renamed each of the .kmz files to .zip before extracting to new folders. Each folder has a collada file and a folder of directories. Luckily 3DS Max will import .dae files

Except when it doesn’t.  these files simply crashed 3DS Max. So I tried a different approach. I fired up a copy of Blender and imported the .dae file it loaded so I exported out to .fbx

makingLA2_1

El Capitan Theater in Blender

 

 

 

 

 

 

after a little of trial and error,  I managed to get a model into 3DS Max ! behold the El capitan theatre!

makingLA2_2

The same El Capitan Theater model in 3DS Max

 

 

 

 

 

 

hmmm. Looks a little strange. lets take a look at the 3D model in the browser again:

The El Captian model in 3d warehouse

The El Captian model in 3D warehouse

 

 

 

 

 

 

Yeah it looks like as part of the dae import, it welds/deletes faces and/or verts seems Dae importer is not very well supported in blender so, back to the drawing board. This time I tried to import the .dae into Maya and straight back out to fbx and back into 3DS Max

makingLA2_4

El Capitan Theatre, converted via Maya

 

 

 

 

 

 

Ok, that’s looking good. Let’s go ahead and put some buildings in there!

Buildin’ the town

I dropped in some generic looking buildings on Hollywood Boulevard, built some very simple buildings ( literally cubes with  texture maps on them) in there and made a starry night sky dome.

Then I found a model T ford on 3D Warehouse. I downloaded , got rid of the open bonnet, and merged the objects to make 4 new object, the car body, the back wheels, and 2 front wheels

I then modelled 2 low poly cones and fitted them to the headlamps. These cones were given a gradient in their diffuse and opacity channels to make them fade out. In effect faking the light cone you see in headlamps in fog

Model T Ford with headlamps

Model T Ford with headlamps

 

 

 

 

 

 

 

I then patented all this to a dummy, I made copies of the dummy and animated them driving down Hollywood Boulevard.

Paintin’ the town

The opening is in black and white, So I decided that I would have to tweak all the textures, I made an action Photoshop to convert an image to grayscale and ran it as a batch on a copy of the textures (if I ever want to swap them back then it should be easy)

the only building I am going to worry about is Graumans chinese Theater itself. It’s current textures are promoting the film ‘300’ so I need to change it to promote the film in the script.

Lightin’ the lights

Lighting this set was hard, mainly because I suck at lighting. The first thing I did was make a large blue spotlight toward the top of the skydome . This represents the moonlight

I Created some large omni lights at the edges of the planes and set them to white with -1 intensity which sucked the colour out of the scene, darkening the edges of the map when the cameras moving you hopefully won’t notice the square edges of the landscape.

I then stuck a series of lights on each car ( in hindsight I should have lit the cars first then animated them)  I put a couple of low intensity omni lights in front of the car and a free spot to represent the headlights.

I found a Streetlamp model from 3D warehouse and created a couple of lights an omni light for the glow and a spot pointing downwards. These were patented to a dummy. I was then able to mass duplicate 20  down Hollywood boulevard

A streetlamp lit rigged and ready to duplicate

A streetlamp lit rigged and ready to duplicate

 

 

 

 

 

 

A lot of the buildings in my section of Hollwood Boulevard have lit signs .I will mke those textures be self illuminated.

Next up, Balancing Textures and animating the camera move

 

 

 

 

 

 

Building LA

no comment

I have been asked to create a series of video projections for The Pied Pipers Musical Theatre Group’s upcoming production of Singin’ in the Rain. Since I won the NODA national poster competition I have been pretty busy. At the moment, everyone wants me to design backgrounds that are to be projected for 3 different shows.

Singing in the Rain is first- after getting some information from BAWDS I was able to work out a frame size.

First challenge:  The director wanted a fly-through  through 1920’s LA to the Graumans Chinese theatre.

Well it looks like SketchUp Make could solve this problem.  I could use it to generate terrain and place buildings accurately – or so I thought.

Thing is, right now, I don’t use windows at home. I have an ancient Mac mini, so I tried installing SketchUp Make on that.  Latest version installed, only to tell me when starting that the OS was the wrong version and so it wouldn’t run- thanks apple

Linux doesn’t have a version, so I tried to install SketchUp under WINE. this installed and ran (sort of) but there was no 3D view. So in desperation I contacted Mike who had a windows laptop and was able to extract chunks of landscape and the Hollywood sign and Chinese theatre to a number of .3ds files.

First up – let’s make the land.

Opening up a copy of 3ds max one lunchtime, I was able to import the landscape.  As part of that, mike had very acurately placed the hollywood sign for me. I also had 30 or so chunks of land

3D terrain Data for Hollywood

Terrain Data extracted from SketchUp

Opening Photoshop I loaded the textures into a large file and using the 3D view as a guide, arranged the textures together:

unfiltered landscape

Hollywood Textures

Then I went through each layer cropping the footer display to create a large texture that could be mapped onto all the planes at the same time.

LaLand

Texture when cleaned up

Back in max, I combined all the landscape planes together and then made another plane above the land with roughly the same density as the merge plane object. I then applied a Conform spacewarp to the object and suddenly my new plane was fitting snugly over the Holly wood hills

making LA_3

Combining the landscape planes

I now had a single surface with no co planar polygons. I made a snapshot this mesh and deleted the faces and vertices that hadn’t been affected by the conform operation.

making LA_4

Single surface generated from the terrain data

Slap the text ure on and VOILA!

making LA_5

Texturing the landscape

It’s not 100% but its a lot quicker than manually editing and welding thousands of verts and performing countless STL checks

a quick render:

making LA_6

Rendering the Hollywood hills

And I was ready to swap out the HOLLYWOOD sign for the earlier HOLLWOODLAND sign. I fudged it a bit but it still looks pretty good:

making LA_7

Hollywoodland sign

Next Up I will add the Chinese Theatre, and then populate the Rest of LA with generic buildings

Unit Testing your controllers

1 comment
Thomas thought that testing the controller would be a good thing.

Thomas thought that testing the controller would be a good thing.

I’m working on a home project at the moment – it’s an MVC/Entity Framework based project, and I have been stumped for the past 3 weeks on something – How can I test it?


Read more..

Categories

Archives

Tags