Adventures in Shade 03: Cameras and Picking!

By | September 3, 2014

Today I got ray-plane intersection, bounding-box-based picking, and pan-able cameras working!

Dungeons in Shade consist of many convex polygons linked together. For example: A room might consist of a square (or a hex!) and a corridor between rooms might consist of a longer rectangle. I implemented the logic to project a ray onto one of those convex polygons, allowing me to click within the polygon to move our hero to a position in the dungeon cell. Thank you high school linear algebra!

Next off, I implemented bounding-box-based picking. Meshes have model-space bounding boxes. Not sure if I'll add bounding spheres into the mix - I'll probably do that whenever I composites bounding volumes. With the same rays from earlier, I can naively test every object in the scene for intersection - I haven't implemented any optimizations (ie: spatial partitioning) yet.

Finally, I reimplemented the camera (previously static view and projection matrices) - cameras are now entities like objects in the scene! Cameras have a Camera Component which exposes View and Projection matrices. The Position-Oriented Camera Component implementation even sources from the Position and Orientation components, so in code, moving a camera looks like moving any other entity.

Moved Hero, Panned Camera, and Positive Bounding Boxes!

Panned Camera and Positive Bounding Boxes!Lime box: Your character.
Red boxes: Enemies.
Crate: Will be mimic/treasure-chest-like.
White Wireframe: Positive Bounding Box

Picking uses positive hitboxes (seen by the enlarged bounding boxes) following the internet's reasoning. To do this, I simply expanded the hitbox of a pickable object's mesh by 10%-20%.

Camera panning took forever to implement, mostly because I spent 2am-4am trying to figure out why my camera was a bit off... turns out I'd written Math.Atan(10/4) instead of Math.Atan(10.0f/4.0f)... doh! I'm still undecided on Shade's camera system - Mabinogi's fixed-on-player camera felt extremely limiting, yet it did allow for intuitive free rotation. Such a system also frees the spacebar for jumping, which you can't do (as a movement command) in League of Legends. I might end up with a smart/dynamic camera system (ie: pan weighted towards you and the enemies you're targeting) or a more "creative" configuration (ie: mouse buttons 4/5 to center) - only time will tell!

View this post's commit (a7060586) on github

Michael "ItzWarty" Yu

Loading Facebook Comments ...

Leave a Reply

Your email address will not be published. Required fields are marked *