Delta Engine
»
Support
»
Rendering
»
2D interactive camera behavior
Joined: 9/15/2011(UTC) Posts: 2
Thanks: 1 times
|
Hi,
I've been playing around with DE a while now and tried to implement some sort of 2D camera behavior. Specifically the scene consists of 2D graphics with sprite-animation at variable positions. Now the camera should be controllable by the player to pan and zoom the scene. Now I'm not really sure what is the DE way to do this. I can draw Material2Ds, but it seems this only draws into [-1,1] area not influenced by the camera's view and perspective matrix. I guess only geometries' position/rotation/scale is influenced by the camera and simple Material2D.Draw only is more for static camera or HUD purposes. I could now translate and scale every Material2D by hand to accomplish a similar effect, but I wanted to ask if there may be another possibility. Also when using geometries/meshes, I cannot make use of the already implemented animation functionality in Material2D.
Any ideas or input would be much appreciated! Thanks in advance!
|
|
|
|
Medals:  Joined: 8/20/2011(UTC) Posts: 1,421 Location: Hannover
Thanks: 18 times Was thanked: 97 time(s) in 92 post(s)
|
You can either just draw normally and move the projection around with ScreenSpace.ViewProjection2D a bit, but optimizations might get in the way (you can comment them out in the Material classes). A better solution is to render in 3D like you would normally in a 3D application and use the camera top-down. There will be a bit more computation overhead, but you get depth buffer and sorting for free and frustum culling also helps with performance. Just render billboards and let the engine handle all optimizations for you: Code:
BillboardManager.Instance.Draw(material, position, size, rotation, color);
Alternatively you can also roll your own system and build your own geometry with GeometryData and Geometry. This is the most optimized approach and can make sense if you have tons of static billboards you want to render (thousands on screen), but it also would be the most work to test and optimize.
|
 1 user thanked Benjamin for this useful post.
|
|
|
Joined: 9/15/2011(UTC) Posts: 2
Thanks: 1 times
|
Thanks for your really quick reply! For now, the second solution works pretty good! Thanks for that! Already tried it out and it looks very nice! Didn't think of billboards and it's great uses! :) Thanks again!
|
|
|
|
Delta Engine
»
Support
»
Rendering
»
2D interactive camera behavior
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.