The Pianist v1.0

After the easter break I decided to do a recording of every key on my Roland HP1300e digital piano (I used to play about 7-8 years ago). I also took some source shots of it on my Nokia N80. I took the shots in to work and ashepherd managed to whip up something fantastic very quickly 😀

Click the image below to be whisked over to the parks page on www.vastpark.com to have a go at it:

The Pianist

VietPark – Part 4: Implementation

Setting up the actual layout of the site in the VastPark Site Builder is very quick and easy, so I got our champion 3D modeller in the office to knock up some assets for me and I did just that.

Some of the ideas in the original mockup I’ve decided against, such as the walls. Instead its going to be a black space with the entities arranged in a similar way to how I previously wanted them.

Here’s are some screenshots that show the site in the builder:

VietPark - Alpha - Shot 1

VietPark - Alpha - Shot 2

And here is a code sample that shows how im making it all happen:

Clicking the flags:

Using the Flickr Plugin, this is fairly simple. First I search Flickr for my username and the tags for the images that I want to show for a particular example. The below code sample shows how to do the Saigon flag:

function OnClick(sender, entity)
	--create the flickr object and perform a search
	a = Flickr()	
	a:SearchUser('craigomatic', 'vietnam,saigon')	
	i = 1	
 
	--generate an entity for each search result using the MoveNext command
	while i < 6 do
		item = a:MoveNext()
		_GenerateEntity(item, i, entity.Position)
		i = i+1	
	end
end
 
--Create the function to generate an entity for each item
function _GenerateEntity(item, count,pos)
	--dimensions of the entity
	dim = Vector(0.2, 0.2, 0.01)	
	entity = GenerateBoxEntity(dim, pos)
	
	--add the OnClick events so each entity when clicked will go to the correct page
	entity.Script.ScriptDictionary[EventType.OnClick].Enabled = true;	
	--entity.Script.ScriptDictionary[EventType.OnClick].Payload = "function OnClick(sender, entity)\r\ndest = GetEntity('PicDest')\r\ninFocus = dest:GetCustom('focused')\r\nif(inFocus ~= nil and inFocus.Name ~= entity.Name) then\r\ninFocus:SetPosition(inFocus:GetCustom('basePos'), 250)\r\ninFocus:SetCustom('atBase', true)\r\nend\r\nif(entity:GetCustom('atBase') == true) then\r\npos = GetEntity('PicDest').Position\r\nentity:SetPosition(pos,125)\r\nentity:SetCustom('atBase',false)\r\ndest:SetCustom('focused', entity)\r\nelse\r\nDebug(entity:GetCustom('basePos'):ToString())\r\npos = entity:GetCustom('basePos')\r\nentity:SetPosition(pos,125)\r\nentity:SetCustom('atBase',true)\r\nend\r\nend"
	entity.Script.ScriptDictionary[EventType.OnClick].Payload = "function OnClick(sender, entity)\r\ndest = GetEntity('PicDest')\r\ninFocus = dest:GetCustom('focused')\r\nif(inFocus ~= nil and inFocus.Name ~= entity.Name) then\r\ninFocus:SetPosition(inFocus:GetCustom('basePos'), 250)\r\ninFocus:SetRotation(inFocus:GetCustom('baseRot'), 250)\r\ninFocus:SetCustom('atBase', true)\r\nend\r\nif(entity:GetCustom('atBase') == true) then\r\npos = GetEntity('PicDest').Position\r\nentity:SetPosition(pos,125)\r\nentity:SetRotation(Vector(0,0,0), 125)\r\nentity:SetCustom('atBase',false)\r\ndest:SetCustom('focused', entity)\r\nelse\r\npos = entity:GetCustom('basePos')\r\nrot = entity:GetCustom('baseRot')\r\nentity:SetPosition(pos,125)\r\nentity:SetRotation(rot, 125)\r\nentity:SetCustom('atBase',true)\r\nend\r\nend"
			
	e = GetEntity('frame'..count-1)
	destPos = Vector(e.Position.x,e.Position.y,e.Position.z)
	destRot = Vector(e.Rotation.x, e.Rotation.y, e.Rotation.z)
	
	--keep a record of where this entity first appeared at  
	entity:SetCustom('basePos', Vector(destPos.x, destPos.y, destPos.z))
	--and its rotation
	entity:SetCustom('baseRot', Vector(destRot.x, destRot.y, destRot.z))
	
	--tell it that its at the starting pos
	entity:SetCustom('atBase', true)  
  	entity.RenderEnabled = false
	
  	--look for the image, and apply it to the entity
  	if(item.MediumUrl ~= nill) then
    	tex = LoadTextureURL(count, item.MediumUrl) 
    	SetTexture(tex, entity)
 	end  	
	
	entity.RenderEnabled = true
 	startpos = Vector(pos.x,pos.y,pos.z)
 	entity:SetPosition(startpos,100)
	entity:SetScale(Vector(2,2,2),100) 
	Sleep(100)  
	entity:SetPosition(destPos, 500)
	entity:SetScale(Vector(7.5,7.5,7.5),500)
	entity:SetRotation(destRot, 500)
end

To view this site in action, visit www.vastpark.com and sign up to get access to download the browser. Once you have downloaded the browser, the link to view VietPark is: vp://vastpark/craigomatic/vietpark

Well thats it, version 1 of VietPark is up and running…so what do you think? Im already at work on version 2 which I’m pretty excited about. More details soon 😉