Search the Community
Showing results for tags 'draw rectangle'.
Found 1 result
Hi! I'm trying to create unit (mesh) selection as it is in various strategy games(AoE, CnC (attached image) ...). After some exploring, I've came to the following, but there are a couple of steps I don't know how to do: 1. Hook to events (OK - trivial) 2. Draw lines using BABYLON.Mesh.CreateLines - at what position? Set LineMesh parent to camera? How to translate mouse position (scene.pointerX and Y) to world coordinates? Just draw rectangle and and set transformation matrix to identity (4x4)? Canvas 2d and 3d context can't be used together. 3. Once that is known, visible meshes are selected with octree (frustum plane is created and used for selection via octree.select method). But frustum plane can be very small and very close, or very big and far away (but this it's probably solved at step 2) I haven't really got to point 3. (got stuck at 2) so it's only my speculation. I'm open to suggestions if there are any better options . Explanation for attached image for non strategy game players: Green rectangle was drawn simply clicking in one corner and dragging. It's always orthogonal to camera view and at the same position (also based on camera) even if camera is moved or rotated. Its rendered above everything and every unit inside is selected. Thanks!