VietPark 1.5 Online
A new version of VietPark is now online, here’s what I’ve changed:
- The site now shows all of my photos rather than just 5 max
- Added smart caching system to prevent redundant queries to Flickr
- Added a loading animation
- Removed the movie clapper, it wasnt being used for anything just yet so was adding unnecessary size
- Removed the picture frames, instead im using the Slider plugin to display the images
Its starting to get closer to where I want it for version 2, which I had a few ideas about over here.
Check it out for yourself at vp://vastpark/craigomatic/vietpark and let me know what you think.
BTW, thanks to ashepherd for his efforts in making the assets for VietPark.
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:
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
VietPark – Part 3: The Design
With the mockup sketches in hand, I can now look at how the scripting will come into play.
My first design decision is to use Flickr as my photo storage area. The benefits of this are:
- VastPark supports Flickr natively through a plugin
- Flickr is free and nice to use
- I dont have to worry about the bandwith bill
My second design decision is to use a managed control system for this site. Rather that letting the user walk around the site at will Im going to restrict the movement to certain regions so I can better control their experience.
With these design decisions in place, I can now think about the triggers and events I’m going to need for this site. I’ll take a look at this on an entity-by-entity basis:
Flags
The flags are going to connect to Flickr and download a certain set of images according to my Flickr username and the tags I have applied to the pics. I want this to happen when the user clicks on the flag. I also want the flags to animate when the users mouse hovers over them.
Events
OnClick: Connect to Flickr and generate entities for each search result
OnHoverEnter: Play flag animation (looping) and apply the highlight shader
OnHoverLeave: Stop flag animation and remove the highlight shader
Movie clapper
When this is clicked on its going to cause the currently visible photos to begin a slideshow. Its animation will play while the mouse is over it and it will light up to show the user its clickable.
Events
OnClick: Begin slideshow for currently visible photos
OnHoverEnter: Play looping animation and apply highlight shader
OnHoverLeave: Stop animation and remove highlight shader
Notepad
Will allow the users to add a comment to my site.
Events
OnClick: Open my blog to the comments section for Vietpark (alternatively use the comments section on the VastPark Commons)
OnHoverEnter: Play looping animation and apply highlight shader
OnHoverLeave: Stop animation and remove highlight shader
Finally I need to think about site events. When the site first loads I want it to connect to my chosen comments website and download all of the comments and the user’s avatar that posted the comment and generate entities for each one in the site. This can all happen asynchronously. So in the SiteLoadEnd event, I’ll write some code to accomplish this.
Its been fairly brief, but I now have a simple design that I can take to the implementation stage.