Post

 Resources 

Console

Home | Profile | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 VBGamer
 VBGamer
 pseudo-billboarding question

Note: You must be registered in order to post a reply.

Screensize:
UserName:
Password:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkInsert EmailInsert Image Insert CodeInsert QuoteInsert List Spell Checker
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

   Insert an File
Check here to include your profile signature.
Check here to subscribe to this topic.
    

T O P I C    R E V I E W
Chango Posted - Aug 13 2006 : 5:33:40 PM
Hello,

In my current programming efforts, having done several 2d games in the past, I am attempting to create a very basic 3d engine. It can already do a lot of things such as loading and manipulating .x files in 3d space, .x file animation, simple lighting, and it has a simple point sprite based particle system. However, I am having some trouble implementing a solution for using billboards.

What I want to do is have a rectangle out in 3d space that always directly faces the camera and orients itself so that whatever texture is on there will always face 'up' in relation to the view of the camera. I already have the code to create and draw the rectangle; I'm just having trouble finding the correct math functions to orient the rectangle to the camera's view.

For example, right now the code in my angle finding Sub looks more or less like this:

a = CameraRotation
b = CameraVerticalPitch
Object.Direction.x = b
Object.Direction.y = -a
'Object.Direction.Z = ?

This causes the rectangle to rotate correctly around the world's 'Y' axis, and interestingly rotates it correctly around the world's 'X' axis as long as the camera is directly lined up with the 'Z' axis (when it’s at the default start position of [0,0,40]). However, when the camera moves out of alignment with the 'Z' axis, and has a vertical pitch that isn’t zero, the object keeps rotating around the world's 'X' axis. This, of course, produces unacceptable results.

I think the answer lies in how to rotate the rectangle around the worlds 'Z' axis. I've already tried 'Object.Direction.Z = b * Sin(a)' and gotten results that were close in that the rectangle will face the camera, but still have it rotating around in an odd way.

I've already gone through the billboarding tutorial from directx4vb and found that it doesn’t really contain the solution to my problem. Unfortunately, one of the Subs it uses contains the equivalent of the line 'temp = (vN.x / (r * Sin(Object.Direction.x))).' Unfortunately, if the rectangle object has a direction of zero, it causes a crash (because as you all obviously know, one can't divide by zero).

If anyone has any ideas or suggestions, I would be very appreciative.

Thanks,

Chango
4   L A T E S T    R E P L I E S    (Newest First)
Chango Posted - Sep 10 2006 : 7:55:56 PM
Success! I have finally gotten my billboards to work properly.

Thank you for all your help.

-Chango
Almar Posted - Aug 25 2006 : 4:43:13 PM
Just use the D3DXMatrixInverse /Inverte or so function I think. Or, I believe you can multiply your matrix with an inversion matrix, but you'll have to look that up on google. :)
Chango Posted - Aug 21 2006 : 11:21:34 PM
That sounds interesting. Do you know how I might code such a thing in VB? Or more specifically, how would I find the inverse of my view matrix in VB?

I coded something similar to the example in the link you provided, only I used the regular view matrix instead of the inverse. It provided interesting results, but unfortunately is still incorrect. (the quad seemed to rotate around the camera's position instead of staying stationary)

Thanks.
Almar Posted - Aug 18 2006 : 1:52:49 PM
I think you can just transform (multiply) your vertices using the inverse view matrix, and have it work pretty well? That's what I use in my game.

http://www.flipcode.com/cgi-bin/fcarticles.cgi?show=63904

VBGamer © Go To Top Of Page
This page was generated in 0.08 seconds. Snitz Forums 2000

Copyright © 2002 - 2004 Eric Coleman, Peter Kuchnio , et. al.