Welcome Guest! To enable all features please Login or Register.



Go to last post Go to first unread
Offline starkapps2  
#1 Posted : Monday, September 19, 2011 12:02:50 PM(UTC)

Joined: 9/15/2011(UTC)
Posts: 2

Thanks: 1 times

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!

Wanna join the discussion?! Login to your forum accountregister a new account. Or Connect via Facebook Twitter Google

Offline Benjamin  
#2 Posted : Monday, September 19, 2011 2:17:47 PM(UTC)

Medals: Admin

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:


				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.
thanks 1 user thanked Benjamin for this useful post.
starkapps2 on 9/19/2011(UTC)
Offline starkapps2  
#3 Posted : Monday, September 19, 2011 3:08:04 PM(UTC)

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!
Rss Feed  Atom Feed
Users browsing this topic
OceanSpiders 2.0
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.

Powered by YAF.NET | YAF.NET © 2003-2023, Yet Another Forum.NET
This page was generated in 0.044 seconds.