3D Billboards On Windows Phone 7


Billboards are one of the most used “primitives” in rendering, principally in mobile environments where whe dont have GPU power avaliable to render millions of real triangles.

In this post i will show how to implement Cylindric and Spherical billboards using the simple XNA SpriteBatch.

The result is not cool/fast as using shaders, but is more than enough.

To begin, we show our simple class that represents any type of billboard.

public class Billboard3D
{
        public Billboard3D(Texture2D tex, Vector3 pos, Vector2 scale)
        {
            this.Texture = tex;
            this.Position = pos;
            this.Scale = scale;
        }

        public Vector2 Scale;
        public Texture2D Texture;
        public Vector3 position;
}

Here we show the code to render the Axial Billboard (Cylindric).
For the example, we constrained it to the Y axis (most common – Vector3.Up), you can change it the way you want. (you can put this as a parameter in Billboard3D class)

            Vector3 position = CAMERA_POSITION;

            foreach (var item in Billboards)
            {
                basicEffect.World = Matrix.CreateConstrainedBillboard(item.Position, position, Vector3.Up, null, null);

                basicEffect.View = activeView;
                basicEffect.Projection = activeProjection;

                spriteBatch.Begin(0, null, null, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);
                spriteBatch.Draw(item.Texture, Vector2.Zero, item.Texture.Bounds, Color.White, 0, new Vector2(item.Texture.Bounds.Center.X, item.Texture.Bounds.Center.Y), item.Scale, SpriteEffects.None, 1);
                spriteBatch.End();
            }

The basicEffect variable is an instance of the classic XNA Basic Effect class.
The next code shows how to render a Spherical Billboards (will always look to the camera).
There are some magic convertions cause the coordinate space of the basic effect and the SpriteBatch are different.

Matrix invertY = Matrix.CreateScale(1, -1, 1);

            basicEffect.World = invertY;
            basicEffect.View = Matrix.Identity;
            basicEffect.Projection = activeProjection;

            spriteBatch.Begin(0, null, null, DepthStencilState.DepthRead, RasterizerState.CullNone, basicEffect);

            foreach (var item in Billboards)
            {
                Vector3 viewSpaceTextPosition = Vector3.Transform(item.Position, activeView * invertY);
                spriteBatch.Draw(item.Texture, new Vector2(viewSpaceTextPosition.X, viewSpaceTextPosition.Y), item.Texture.Bounds, Color.White, 0, new Vector2(item.Texture.Bounds.Center.X,item.Texture.Bounds.Center.Y), item.Scale, SpriteEffects.None, viewSpaceTextPosition.Z);
            }               

            spriteBatch.End();

There are others ways of drawing billboards on wp7 like creating teh vertices by hand every frame and render using RenderUserPrimitive function.

We always have pros and cons in all approaches, i prefer this =P

This technic can also be used to render Text in 3D, just change the spritebatch draw function to the equivalent draw text function.

, ,

  1. #1 by Samurai Katana on 28 de setembro de 2016 - 10:01 pm

    Je vous remercie ! Il est juste comme décrit et expédition rapide !

  2. #2 by Discover More Here on 28 de setembro de 2016 - 10:07 pm

    marriage counselor kingsport tn

  3. #3 by super fast reply on 28 de setembro de 2016 - 10:30 pm

    marriage counsel app

  4. #4 by Naginata Sword on 28 de setembro de 2016 - 11:06 pm

    wonderul et rapide

  5. #5 by sakabato weapon on 28 de setembro de 2016 - 11:16 pm

    bonne affaire, chargeur rapide, utiliserait encore …. A + A + A +

  6. #8 by electric actuator suppliers on 29 de setembro de 2016 - 2:04 am

    Here are a few of the sites we recommend for our visitors

  7. #9 by tworzenie stron www kurs online on 29 de setembro de 2016 - 2:34 am

    Very interesting information!Perfect just what I was searching for! “Charity is injurious unless it helps the recipient to become independent of it.” by John Davidson Rockefeller, Sr..

  8. #10 by smart hoverboard for sale on 29 de setembro de 2016 - 3:27 am

    Marine goes down are that happen to be for homes coast dogs.

  9. #11 by samurai sword blade on 29 de setembro de 2016 - 5:40 am

    Absolutely great item, quick shipping and excellent communication. A+++

  10. #12 by katana blade on 29 de setembro de 2016 - 5:48 am

    Super fast shipping, perfect thank you. A++++

  11. #13 by Shinken katana on 29 de setembro de 2016 - 6:43 am

    Merci pour la livraison rapide .

  12. #14 by japanese tanto on 29 de setembro de 2016 - 6:52 am

    Tr猫s exp茅diteur rapide ! !

  13. #15 by singapore permanent resident on 29 de setembro de 2016 - 8:38 am

    Nice post. Thank you.

  14. #16 by helpful resources on 29 de setembro de 2016 - 8:56 am

    marriage counsel columbus ohio news

  15. #17 by recipes on 29 de setembro de 2016 - 9:01 am

    we like to honor lots of other online web pages on the net, even when they arent linked to us, by linking to them. Underneath are some webpages worth checking out

  16. #18 by nike outlet uk on 29 de setembro de 2016 - 9:15 am

    The carriage near the palace is not how long, began to move on, but the little red and may have lost sight of.

  17. #19 by kala jadu on 29 de setembro de 2016 - 9:54 am

    please pay a visit to the internet sites we follow, such as this a single, because it represents our picks in the web

  18. #20 by adidas yeezy boost 350 where to buy on 29 de setembro de 2016 - 9:58 am

  19. #21 by Air Jordan 12 Wool on 29 de setembro de 2016 - 10:39 am

  20. #22 by Backyard zip line kits sale on 29 de setembro de 2016 - 11:01 am

    549016 406700Greetings! Quick question thats completely off topic. Do you know how to make your site mobile friendly? My weblog looks weird when viewing from my iphone. Im trying to find a template or plugin that might be able to fix this problem. If you have any recommendations, please share. Appreciate it! 848444

  21. #23 by Felipe Del on 29 de setembro de 2016 - 11:48 am

    Thanks for your time so considerably for your impressive and wonderful guide. I will not be reluctant to endorse your web sites to any individual who need to receive direction on this dilemma.

  22. #24 by Wypożyczalnia Podnośników Nożycowych Poznań on 29 de setembro de 2016 - 1:27 pm

    hello!,I really like your writing very a lot! proportion we keep in touch more approximately your article on AOL? I need an expert on this area to resolve my problem. Maybe that’s you! Having a look forward to peer you.

  23. #25 by Wolfgang on 29 de setembro de 2016 - 1:27 pm

    Círculo com laço com cetim e também strass faz maior sucesso entre as
    meninas, e resta muito legal com os looks usados à noite. http://2Deabril.com/?option=com_k2&view=itemlist&task=user&id=744082

  24. #26 by kdf podatki rok podatkowy w niemczech on 29 de setembro de 2016 - 2:42 pm

    What i do not understood is in truth how you are now not really a lot more smartly-liked than you might be right now. You’re so intelligent. You recognize thus significantly on the subject of this topic, produced me for my part imagine it from numerous various angles. Its like men and women aren’t involved unless it is something to accomplish with Lady gaga! Your individual stuffs excellent. All the time take care of it up!

  25. #27 by Samurai swords on 29 de setembro de 2016 - 2:48 pm

    AAA + + + Seller ! Expédition rapide superbe ! Aimez la chaussure! !

  26. #28 by Japanese Swords on 29 de setembro de 2016 - 2:49 pm

    Bon temps de réponse de recevoir des colis.

  27. #29 by Entdecken Sie mehr hier on 29 de setembro de 2016 - 4:37 pm

    Und wenn Europa eine faire Lastenverteilung findet, wird es dazu auch nicht kommen.

  28. #30 by singapore permanent resident on 29 de setembro de 2016 - 4:56 pm

    Great post!

  29. #31 by swords on 29 de setembro de 2016 - 6:09 pm

    Merci pour l’exp茅dition rapide & livraison; recommandent vendeur! Chaussure mignonne de commutation !

  30. #32 by apply pr on 29 de setembro de 2016 - 8:16 pm

    Great post!

  31. #33 by boxing trainer Seattle on 29 de setembro de 2016 - 8:19 pm

    46621 514689Bookmarked. Please also discuss with my web site. 230501

  32. #34 by Wakizashi Sword on 29 de setembro de 2016 - 8:26 pm

    Expédition rapide et grande chaussure !

  33. #35 by Leif Peals on 29 de setembro de 2016 - 8:49 pm

    Canon Camera

  34. #36 by Mickie Brickles on 29 de setembro de 2016 - 8:51 pm

    poswiadczenie dziedziczenia Wroclaw

  35. #37 by Mirta Gilomen on 29 de setembro de 2016 - 9:25 pm

    9/29/2016 @ 20:24:17 In my estimation, ploobs.com.br does a excellent job of dealing with subject matter of this type. While often intentionally controversial, the material posted is in the main thoughtful and challenging.

  36. #38 by Davis Gurke on 29 de setembro de 2016 - 10:18 pm

    annonces legales en ligne

  37. #39 by Hugh Ferrick on 29 de setembro de 2016 - 10:21 pm

    Modern sofas

  38. #40 by rams rush jersey on 29 de setembro de 2016 - 11:45 pm

    The last master will look forward to approval pertaining to processing. As soon as approved it really is moulded in si rubber if you use a vacuum. This is often the mould just for re-creating often the professional. One time reproductions tend to be complete they may be colored or executed in accordance with the design and style.

  39. #41 by nike outlet uk on 29 de setembro de 2016 - 11:54 pm

    He went to the table and sat down, holding the lower jaw at the same recovery dress unusual Phoenix, however, if only to teach her a lesson, you are not so boring to show this, say, is what I can do for you

  40. #42 by nike outlet uk on 29 de setembro de 2016 - 11:54 pm

    The carriage was quick to run, and the car was under a spell, so it was not a bumpy.

  41. #43 by christian louboutin outlet real on 30 de setembro de 2016 - 12:58 am

  42. #44 by vpn 购买 on 30 de setembro de 2016 - 1:50 am

    I believe this is among the so much significant info for me. And i’m satisfied reading your article. But wanna observation on few basic things, The web site taste is perfect, the articles is truly nice : D. Good task, cheers

  43. #45 by 国内 vpn on 30 de setembro de 2016 - 2:55 am

    Hello! Someone in my Myspace group shared this site with us so I came to check it out. I’m definitely loving the information. I’m book-marking and will be tweeting this to my followers! Fantastic blog and outstanding design.

  44. #46 by vpn 中国 on 30 de setembro de 2016 - 2:56 am

    I have been browsing online more than 3 hours today, yet I never found any interesting article like yours. It’s pretty worth enough for me. Personally, if all site owners and bloggers made good content as you did, the net will be much more useful than ever before.

  45. #47 by nike outlet uk on 30 de setembro de 2016 - 5:53 am

    Oh! Really need people ah. Rich people’s children’s idea is really not the same as ordinary people ah! Luo eyes shook his head and took his two things to be put on the back, and once again went to the woods to find those rabbits.

  46. #48 by google marketing services on 30 de setembro de 2016 - 6:32 am

    442218 735674Glad to be one of many visitants on this awing internet site : D. 335865

1 194 195 196
(não será publicado)