Jump to content
  • Advertisement
Sign in to follow this  
Dixnet

Q:Managed DX9, Sprite.Draw, Billboarding?

This topic is 4733 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

--------English/Englisch------------- Hi All, has anyone used Sprite.Draw of Managed DX9 to build a billboarding-function or used it in any other way in 3D? I have the following two problems: 1.) I do not know how to configure the view matrix correctly. I use a identity matrix as world matrix and I implemented a fully functionally 1st Person 3D world with camera rotation by mouse, meshes etc. Everything works great that far, except billboarding. I like to use Sprite.Draw, because of its abillity to select regions from the bitmap-source (texture), its fast, and it should do it. But if I rotate my view, the Billboard-Sprite changes its position and comes nearer. What's my fault? Any Idea? Someone in this forum mend, its worth to try DX3D.SpriteFlags.ObjectSpace, and so I tried, but unfortunately the sprites behavior is as chaotic as it was before :-S 2.) There are two parameters in Sprite.Draw (Center and Position). What do they do? I tried different values, but it was impossible for me to position the Billboard Sprite at the correct place. If anyone has any experiences, oder knows a website where to look further (Microsoft MSDN is not very helpful in this case) or is able to post a code sample. That were great! Thank You all. So long, Holger A code sample is attached at the end of the text. (sorry for my english :-) --------Deutsch/German------------- Hallo Leuz, hat jeder von Euch schon mal mit dem Sprite.Draw von Managed DX9 die Billbord-Funktion benutzt? Ich habe folgende zwei Probleme: 1.) Ich schaffe es nicht die View-Matrix richtig anzugeben. Ich verwende als WorldMatrix einfach die Einheitsmatrix und übergebe schlicht die ViewMatrix (1stPerson-Kamerapos., berechnet über Maus die Drehung etc, läuft problemlos als 3D-Welt mit Meshes). Das Sprite sehe ich zwar auch, aber es verhält sich nicht richtig wie ein Billboard, sondern ändert die Position bei Kameradrehung (kommt auf die Kamera zu). Jemand in diesem Forum schrieb DX3D.SpriteFlags.ObjectSpace könnte ein Weg sein um die Position festzulegen. Doch irgendwie klappt das nicht und das Sprite verhält sich weiterhin chaotisch. 2.) Die beiden Vektoren-Parameter der Sprite.Draw (Center und Position). Welche Funktion erfüllen Sie? Ich habe damit experimentiert und kommen zu keiner sinnvollen Positionierung des Sprites. Wenn jemand einen Tip hat, wo es hierzu paar sinnvolle Infos, oder Codebeispiele gibt, wäre das klasse . Bei Microsoft (MSDN) gibts nämlich nix. Gruß, Holger Codebeispiel (Codesample), zur Frage:
     
Dim s As New Direct3D.Sprite(Device)
Try
  s.SetWorldViewLH(Device.Transform.World, Device.Transform.View)

  s.Begin(Direct3D.SpriteFlags.AlphaBlend Or  Direct3D.SpriteFlags.Billboard) ' Or DX3D.SpriteFlags.ObjectSpace
  s.Draw(AniTexture, New Rectangle(0, 0, 256, 256), New Vector3(x, y, z), New Vector3(x2, y2, z2), Color.White)
  s.End()
Finally
  s.Dispose()
End Try

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!