{"id":712,"date":"2009-09-06T23:38:59","date_gmt":"2009-09-06T13:38:59","guid":{"rendered":"http:\/\/www.vectorstorm.org\/?p=712"},"modified":"2009-09-11T15:47:04","modified_gmt":"2009-09-11T05:47:04","slug":"selecting","status":"publish","type":"post","link":"https:\/\/www.vectorstorm.com.au\/2009\/09\/06\/selecting\/","title":{"rendered":"Selecting"},"content":{"rendered":"

\"SelectingABuilding\"<\/a>This is a little ugly, but functional. \u00a0Today, I implemented polygon-accurate picking of buildings, players, and monsters. \u00a0That is, the cursor now moves over and reacts to these objects rather than ignoring them. \u00a0I also implemented a mechanism by which the cursor can find out not only where it’s bumped into something, but also precisely what that object is. \u00a0In this screenshot, I have just selected a quest building that’s off in the distance, while new subscribers (blue cubes) are entering the world from the starting position in the foreground.<\/p>\n

Today I also implemented a “DrawOutline” function on the vsBox3D class, which just draws the edges of an axis aligned bounding box; \u00a0that’s what I’m using to draw the outline around the building in the distance. \u00a0I’m not really convinced that that’s the right way to hilight a building, but at least it can show you what’s currently being selected. \u00a0Actually drawing glowing lines along the vertices of the building sounds like a good idea, but it could turn into an awful lot of lines, once the buildings are being fully procedurally generated, instead of just being the simple blocks that I’m using now. \u00a0Alternately, I could change the material of the building; \u00a0draw it in a different color, or with an extra animated light or something. \u00a0Really, I suppose that’s a visual thing that I can work out later; \u00a0right now I’m trying to make the game’s UI work at all; \u00a0being pretty can come later. \u00a0:)<\/p>\n

I always forget how tricky it is to make this sort of 3D picking code work; \u00a0particularly in a project like this one, where there are lots of different objects being expressed in a lot of different coordinate systems. \u00a0There were lots of finicky little bugs where if you pointed at a player, but there was a building somewhere behind the player, the cursor would prefer to point at the building rather than at the player, due to a subtle bug in the coordinate conversions. \u00a0Time consuming to track it all down! \u00a0But I think it’s all working properly, now.<\/p>\n

Next thing is going to be the “Remove Building” functionality, which shouldn’t be difficult at all to hook up; \u00a0figuring out which building the mouse is pointing at in a 3D scene was the hard part. \u00a0Now that I know that, it should be pretty trivial to remove the building. \u00a0But I’m going to leave that for tomorrow.<\/p>\n","protected":false},"excerpt":{"rendered":"

This is a little ugly, but functional. \u00a0Today, I implemented polygon-accurate picking of buildings, players, and monsters. \u00a0That is, the cursor now moves over and reacts to these objects rather than ignoring them. \u00a0I also implemented a mechanism by which the cursor can find out not only where it’s bumped into something, but also precisely…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[24,25],"tags":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/po9WK-bu","_links":{"self":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/712"}],"collection":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/comments?post=712"}],"version-history":[{"count":0,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/posts\/712\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/media?parent=712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/categories?post=712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vectorstorm.com.au\/wp-json\/wp\/v2\/tags?post=712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}