Explore Bodiam Castle - Please!

Bodiam Castle is one of England’s finest but it is at the centre of a debate over whether castles were fortresses or just country houses. A graduate student of mine has come up with a way to try to test how the castle was intended to be used by tracking how people move through a model of the castle.

This is the result: http://www.thomasav.com/bodiam/bodiam.php

It would be a tremendous help to his research if you could take 5 minutes to take a run through the model.

The link takes you to a front page which is a form asking for a name (or your handle, or whatever you want to call yourself) and then into the castle model itself. Nothing but the name is recorded. The site isn’t trying to gather any other information at all.

The model is very basic, as is its implementation within Unity. It is simply meant to be a 3d projection of the plan of the building, just to test how the architecture guides you through. One interesting feature, though, is that it logs the player’s position in 3d which will then allow him to build up a composite of traces through the space to analyse most commonly taken paths. This has applications elsewhere, and I’m hoping to develop this further on other projects.

The spiral stairs are loads of fun. But don’t fall into the moat. Seriously.

Feedback is appreciated. Keep in mind this is very basic, though!

I like these simple forms, and the spiral stairs. The mouse sensitivity is for my experience too high.

And I know now, what you mean with moat oO.

Is it possible to see the results of the visitor analyse (since it’s really cool feature)?

Falling into the water makes you drop forever. Why not lay out a level beneath it, so you can’t fall too far, and can get back out again?

I thought it was alright… It could obviously be refined in terms of texturing, but not bad. There’s one thing that bugs me in the castle though. The hallways a little too narrow when you want to get to a different room from another room. It feels like I’m an elephant trying to fit into a house or something. Just saying, but take it however you want. :smile:

Done, I hope my walkthrough helped.

Many thanks to everyone who has run through the model so far. It has been a huge help to my student.

Also, many thanks for the encouraging response and for the helpful feedback. We’ll try to build a reset function so that when you fall into the moat you’ll be set safely back on dry land. Also, will tone down the mouse sensitivity. Textures and model could be much better. That’s going to take the most time, however, so it’s something for version 2. Any hints on dealing with textures for so many rooms? How do they do this in games like Prince of Persia? In one version we had about six 2048 baked textures and it reduced the framerate to a slideshow.

We’re also working on posting some of the results, as they are quite interesting. Ideally, I’d like to do this in Unity. I think Eric’s Vectrosity is the perfect solution. Have to find the time to play with this, though.

Attached is an image of the first few runs through the model. The path in blue is our Head of Department.

Many thanks again, and, if you haven’t run through the castle recently, drop by. It would be a big help to my student.

– Anthony

Reuse textures where possible, avoid making them as high as 2048 if you can help it, lower is fine, tiling repeatable helps a lot too, decals to help break up repeating artifacts, separate lightmap (allowed to be higher res if used over multiple surfaces).

Also turn on Trilinear and up the Aniso level of your textures so they’re not so blurry at a distance and angle.

Thank you for improvements you’re planing to do!
Wow, as far as I see, it’s very neat feature with visit protocolling. How did you constructed it?

Thanks for your kind words, kosmopol.

Loggin visitor paths is really easy. We log one 3d position every second. These are logged by an external javascript function on the webpage using ExternalCall. Every ten seconds the batch of ten 3d positions is sent off to the server which appends them to a csv file on the server via php. There’s one file for each visit, the file being named based on the name the visitor supplied on the entry page and a timestamp.

That’s it. I can post the scripts if you’re interested, but I don’t claim they are particularly optimised as we threw this functionality together pretty quickly.

You could do this in many ways, depending on your needs. We needed just the 3d point info for visitor paths in csv form so we could feed these into CAD for offline analysis. But you could log anything you wanted and visualise it any way you want. Ethically, of course, you should make sure you inform the visitor what is being logged.

We’re planning on adding another section to the site where visitors can go to view their own path and the paths of others using another webplayer - so we’ll have to feed these csv files back into the webplayer from the server at runtime. Which should be fun…

Thanks for your interest!

Thank you for explanation, dear amasinton.
And I would be glad to see this script. Of course, the players should be informed about the logging of their movements. But this system is really great for evaluation of the own generated worlds, to watch, where people are mostly interested to go. I think, this evaluation can even bring two ways of enhancement:

either

  1. enhancement of the areas the visitor are mostly visiting (for better experience of these mainstream visits)

or
2) enhancement of all another areas for keeping the world in balance

(I’m thinking about worlds with freedom of movements across these levels).

So, thank you in advance :slight_smile:

I walked through.
In my opinion I think castles were built to be big fancy homes. If you look at the structure of castles they dont look like it was not intended to be usedas a a fort as it dosnt have many defendible positions.
Maybe castles were used a safe house for people in the civil war which made the illusion which they are particially forts…

Hi Epic, I agree with you, to a point, on castles just being big, fancy homes. If you look at Bodiam, it looks fortified (the real castle had ultra-modern gun loops at the gatehouse, murder holes in the gates, flanking towers, a big moat, etc) but when you look further you see that many of these features don’t work in practice. But, if you look at some of Edward I’s castles in Wales, such as Harlech, you’ll see very functioning military fortress installations which were used as such many times. So, the debate continues, which is part of the fun…

kosmopol, here are the scripts:

This is the javascript, externalPosLogger, attached to a controller object in-game which logs a position every second and passes it to another javascript function called cacheVals running in the browser page:

var playerObject : Transform;

InvokeRepeating("logPoint", 1, 1);

function logPoint () {
	var pointPosition = playerObject.position;
	var posx = pointPosition.x.ToString();
	var posy = pointPosition.y.ToString();
	var posz = pointPosition.z.ToString();
	var posAll = posx + "," + posz + "," + posy;
	Application.ExternalCall ("cacheVals", posAll);
}

Now here’s the javascript function in the external page that receives the positions from Unity. This function or set of functions uses some Ajax/jquery stuff so that the page doesn’t have to reload in order to update - it’s mainly used for the status monitor which you may have noticed working away under the game window on the page - the Sending, Sent! thing.:

		var vals = new Array();
		var maxCache;
		var pending;
		
		// Number of entries to trigger AJAX request
		maxCache = 10; 
		
		
		function cacheVals (val) {
			vals.push (val);
		
			if ((vals.length >= maxCache)  (pending != true)) {
				$.post ("masterpage.php", { 'xyz': vals }, function (msgBack) {
					if (msgBack = '1') {			
						vals = [];
						pending = false;
						$('#ajaxStatus').text ('Sent!');
					}
					else {
						$('#ajaxStatus').html ('Error :-(
' + msgBack);
						pending = false;
					}
				})
				pending = true;
			}
			else {
				$('#ajaxStatus').append ('.');
			}
			
			if (pending)
				$('#ajaxStatus').text ('Sending!');
		}

And this is all governed by the masterpage.php PHP script running as its own page but including the actual login, maze, and logout pages. This is the master key that glues everything together and allows Unity to write csv files to the server. This script and the one above were built by our partner David Harker, BTW:

<?php

session_start();

usleep (100);

define ('FILE_START', 'placetostorefiles/mazepath');
define ('FILE_EXT', '.csv');
define ('MAX_FILESIZE', '10000');

// name of form field with 123,456,789 etc.
$ipfield = 'xyz';
// list of field IDs in order
$split_fields = array ('x', 'y', 'z');

if (isset ($_POST['logout'])) {
        session_destroy ();
//        echo "reload page!";
        include ("logoutpage.inc");
}
elseif (isset ($_SESSION['username']) AND (isset ($_POST[$ipfield]) )) {
//if (isset ($_SESSION['username'])) {
	// get values first
	
	// ok to record values
	$filename = FILE_START . $_SESSION['username'] . "_ts" . $_SESSION['timestamp'] . FILE_EXT;


//print_r ($_POST);
//die();
	
	// Split input
	$in = (is_array ($_POST[$ipfield])) ? $_POST[$ipfield] : array ($_POST[$ipfield]);
	foreach ($in as $n => $xyz)
		$split[$n] = explode (",",$xyz);
	foreach ($split as $vnum => $arr_xyz)
		foreach ($split_fields as $pos => $fname)
			$save[$vnum][$fname] = numinput ($arr_xyz[$pos]);
	$outt = array ();
	foreach ($save as $n => $arr_f)
		$outt[] = implode (",",$arr_f);
	$append = implode ("\n", $outt);
	// create CSV file if we need to 
	if (!file_exists ($filename))
		file_put_contents ($filename, implode (",", $split_fields));
	
	echo (append_to_file ($append, $filename)) ? '1' : '0';
}
elseif (isset ($_POST['username'])) {
	$_SESSION['username'] = preg_replace ("/^[^a-z]|[^a-z0-9]/i", '', strtolower ($_POST['username']));
	$_SESSION['timestamp'] = time();
	include ("castlepage.inc");
}
elseif (isset ($_SESSION['username'])) { // user has reloaded page, give them maze since we know username already
	include ("castlepage.inc");
	
}
else {
	include ("loginpage.inc");
}


function append_to_file ($append, $filename) {
	if (!$fh = fopen ($filename, 'a'))
		return FALSE;
	fwrite ($fh, "\n" . $append) or die ("Can't write to file: $filename !");
	return fclose ($fh);
}

function numinput ($mi) {
	return (is_numeric ($mi)) ? (round ($mi, 3) + 0.00) : FALSE;

}


?>

Hope that is helpful!

Also, updated the webplayer.

Now the mouse sensitivity is lower, so it’s not as squirrely .

Also, when you fall into the moat now, you only fall for a second or two before being reset back on dry land, near where you fell in. The transition is a bit abrupt, but it works. Most of the time…

Working with Vectrosity now to see if we can show all users’ maze paths in another webplayer when the Logout button is pressed. I’ll let you know when we get this working

Thank you for script! I will try to understand it now :slight_smile:

And the castle improvements are really nice: the mouse sensitivity and moat reset is very comfortable now.