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 Online College Degrees on 16 de janeiro de 2017 - 4:22 pm

    Definitely believe that which you stated. Your favorite justification seemed to be on the net the easiest thing to be aware of. I say to you, I certainly get irked while people think about worries that they plainly do not know about. You managed to hit the nail upon the top and defined out the whole thing without having side effect , people could take a signal. Will probably be back to get more. Thanks

  2. #2 by Las Vegas SEO on 16 de janeiro de 2017 - 4:23 pm

    Very good info. Lucky me I discovered your website by chance (stumbleupon). I have book marked it for later!

  3. #3 by Rodger on 16 de janeiro de 2017 - 4:35 pm

    Si bien el estará concentrado en ti, debes crear una atmosfera agradable, puesto que aporta bastante a tu
    seguridad. http://ailbd.org/?option=com_k2&view=itemlist&task=user&id=921524

  4. #4 by GEICO for home insurance on 16 de janeiro de 2017 - 5:02 pm

    I’ve read some good stuff here. Certainly worth bookmarking for revisiting. I wonder how much effort you put to make such a fantastic informative website.

  5. #5 by alexander mcqueen outlet online on 16 de janeiro de 2017 - 5:18 pm

    Oh really? Wow I didnt know that! Thanks for sharing.
    alexander mcqueen outlet online http://www.alexandermcqueenoutlet.online

  6. #6 by hummingbird feeders on 16 de janeiro de 2017 - 5:24 pm

    I really enjoy the blog article. Fantastic.

  7. #7 by replica mcm backpack on 16 de janeiro de 2017 - 5:28 pm

    Excellent ideas throughout this post, I just added this to my RSS feed. Do you have any feedback on your most recent post though?
    replica mcm backpack http://www.mcmsale.store

  8. #8 by Online Graduate Schools on 16 de janeiro de 2017 - 5:29 pm

    The following time I learn a weblog, I hope that it doesnt disappoint me as much as this one. I imply, I know it was my option to read, however I truly thought youd have something fascinating to say. All I hear is a bunch of whining about something that you may fix when you werent too busy on the lookout for attention.

  9. #9 by car insurance quotes online compare on 16 de janeiro de 2017 - 5:36 pm

    What’s a great fun running a blog site to use with another person?

  10. #10 by coach factory outlet store online on 16 de janeiro de 2017 - 6:56 pm

    Id wish to thank you for the efforts youve got made in writing this post. Im hoping the exact same best perform from you within the potential also. Actually your inventive writing skills has inspired me to begin my personal BlogEngine weblog now.
    coach factory outlet store online http://www.bedcapdealers.com/coach/

  11. #11 by house plan gallery on houzz on 16 de janeiro de 2017 - 7:14 pm

    Great, thanks for sharing this post.Really looking forward to read more. Great.

  12. #12 by pandora birthday charm bracelet on 16 de janeiro de 2017 - 7:52 pm

    Enjoyed every bit of your article.Really thank you! Really Cool.

  13. #13 by ロレックス 偽物 ギャランティ 偽物 on 16 de janeiro de 2017 - 8:37 pm

    ウブロコピー腕時計品質NO.1
    2017秋冬最適ウブロコピー腕時計
    皆さん、こちらへどうぞ、ご注意くださいね。
    2017秋冬がソそろそろ来ますよ。
    皆様へのいい気持ちを与えることができるため、
    こういう季節に最適商品が登場しております。
    ウブロコピー,ウブロスーパーコピー,ウブロコピー時計,ウブロコピー代引き,ウブロコピー 時計通販,
    ウブロコピー時計販売弊店,は最低の価格と最高のサービスを提供しております。
    皆様は最高の満足を収穫することができます。
    ▲下記の連絡先までお問い合わせください。
    是非ご覧ください!
    ロレックス 偽物 ギャランティ 偽物 http://kopii.net/products/p1/7/1/index.htm

  14. #14 by ミュウミュウ 長財布 レディース 人気 腕時計 on 16 de janeiro de 2017 - 8:37 pm

    スーパーコピーブランド専門店
    ぜひ一度のスーパーコピーブランド品をお試しください。
    驚きと満足を保証できます。
    ご利用を心からお待ちしております。
    ミュウミュウ 長財布 レディース 人気 腕時計 http://bagshop78.com/brandcopy-m-32.html

  15. #15 by ロレックス オイスター 防水 on 16 de janeiro de 2017 - 8:38 pm

    ヴィトンコピーバッグ
    ルイヴィトンスーパーコピーバッグ モノグラム対応 激安 安心通販
    大人気のルイヴィトンスーパーコピーバッグの種類ご紹介です!
    弊社のルイヴィトンモノグラムバッグスーパーコピー品は生産工場から直接仕入れます から!
    だから安いです。本舗は専門のブランド コピー品小売屋でございます,よろしくお願い 申し上げます。
    ロレックス オイスター 防水 http://bagshop78.com/brandcopy-m-172.html

  16. #16 by term life insurance company RATINGs on 16 de janeiro de 2017 - 8:41 pm

    Wonderful website. Lots of useful information here. I am sending it to a few friends ans also sharing in delicious. And obviously, thanks for your effort!

  17. #17 by baritoneOn on 16 de janeiro de 2017 - 8:46 pm

    Great goods from you, man. I have keep in mind your stuff previous to and you’re just extremely wonderful. I actually like what you have acquired here, certainly like what you’re stating and the way in which you say it. You are making it enjoyable and you still take care of to keep it sensible. I cant wait to read much more from you. That is actually a great web site.
    baritoneOn

  18. #18 by Vay Nhanh 60s on 16 de janeiro de 2017 - 8:50 pm

    Simply wanna remark that you have a very nice website , I love the style and design it really stands out.

  19. #19 by annuity providers ratings on 16 de janeiro de 2017 - 9:24 pm

    Great line up. We will be linking to this great article on our site. Keep up the good writing.

  20. #20 by home designers in hattiesburg on 16 de janeiro de 2017 - 10:57 pm

    Really enjoyed this article post.Much thanks again. Really Cool.

  21. #21 by skype username resolver on 16 de janeiro de 2017 - 11:05 pm

    Wow, amazing blog layout! How lengthy have you ever been blogging for? you make blogging glance easy. The total look of your web site is wonderful, as well as the content material!

  22. #22 by jordan 12 for sale cheap on 16 de janeiro de 2017 - 11:09 pm

  23. #23 by Custom Car Interior on 16 de janeiro de 2017 - 11:16 pm

    How do I add the Google Analytics code to a Joomla website?

  24. #24 by cheap barbour jackets on 16 de janeiro de 2017 - 11:20 pm

    What I want to know is why I should care? I mean, not to say that what youve got to say isnt important, but I mean, its so generic. Everyones talking about this man. Give us something more, something that we can get behind so we can feel as passionately about it as you do.
    cheap barbour jackets http://www.tmearegion26.com/barbour/

  25. #25 by new balance outlet store on 16 de janeiro de 2017 - 11:30 pm

    Well I definitely enjoyed reading it. This tip procured by you is very effective for correct planning.
    new balance outlet store http://newbalanceoutlet.tmearegion26.com

  26. #26 by Business Law on 17 de janeiro de 2017 - 12:29 am

    Very good written article. It will be supportive to anyone who employess it, including myself. Keep doing what you are doing – looking forward to more posts.

  27. #27 by android apps for pc on 17 de janeiro de 2017 - 12:35 am

    As I website owner I think the articles here is rattling excellent, appreciate it for your efforts.

  28. #28 by android games free download on 17 de janeiro de 2017 - 12:49 am

    Appreciate it for this post, I am a big fan of this web site would like to proceed updated.

  29. #29 by home designers in hattiesburg on 17 de janeiro de 2017 - 12:50 am

    Thanks again for the blog article.Much thanks again. Keep writing.

  30. #30 by arcteryx vancouver outlet on 17 de janeiro de 2017 - 12:56 am

    Ive been meaning to read this and just never got a chance. Its an issue that Im very interested in, I just started reading and Im glad I did. Youre a fantastic blogger, 1 of the finest that Ive seen. This weblog certainly has some details on topic that I just wasnt aware of. Thanks for bringing this stuff to light.
    arcteryx vancouver outlet http://www.arcteryxsale.org

  31. #31 by wild g vibrator on 17 de janeiro de 2017 - 1:45 am

    usually posts some pretty fascinating stuff like this. If youre new to this site

  32. #32 by mulberry bags outlet on 17 de janeiro de 2017 - 2:31 am

    How do i extend the range on the Wireless N router? Weve an Xtreme N instant router (Dlink). I should extend the reach belonging to the wireless signal. I learn how to do it for a new G signal. I want to find out how to do it for an N transmission. Is it possible to use regular N routers while repeaters. If so, how to configure them. Thanks for any information.
    mulberry bags outlet http://www.mulberryoutletonlineeu.com

  33. #33 by pediatric dentists in baton rouge on 17 de janeiro de 2017 - 2:44 am

    Awesome post.Thanks Again. Keep writing.

  34. #34 by pc version free download on 17 de janeiro de 2017 - 2:54 am

    You have remarked very interesting points! ps nice site.

  35. #35 by Victorian front door in west London on 17 de janeiro de 2017 - 3:32 am

    There is noticeably a bunch to know about this. I feel you made certain nice points in features also.

  36. #36 by cheap ugg boots on sale on 17 de janeiro de 2017 - 3:57 am

    ive checked this cool site a few times now and i have to say that i find it quite good actually. continue doing what youre doing!
    cheap ugg boots on sale http://www.easyinboxmailer.com/boots-sale/

1 309 310 311
(não será publicado)