VR mobile developer??
So billboarding in games development was something that always used to frighten me. I understood you were supposed to make an object always face the screen, but I didn't know an easy way to do that. I mean, we're you supposed to somehow calculate all the rotations needed by glRotatef() to make a picture always face you?
Anyway, eventually I found a solution with some online help that made the whole thing really easy, and I couldn't find it anywhere else, so I just thought I'd share.
Basically, you just take the current rotation matrix and invert it. Pretty simple! So here's some sample code to do that.
GLfloat modelview; GLfloat tempModelView; glGetFloatv( GL_MODELVIEW_MATRIX, modelview ); glGetFloatv( GL_MODELVIEW_MATRIX, tempModelView ); modelview = tempModelView; modelview = tempModelView; modelview = tempModelView; modelview = 0.f; modelview = tempModelView; modelview = tempModelView; modelview = tempModelView; modelview = 0.f; modelview = tempModelView; modelview = tempModelView; modelview = tempModelView; modelview = 0.f; //if you'd like, plug the position of the object into the transformation matrix, here I'm drawing a sun modelview = sunPosition.position; modelview = sunPosition.position; modelview = sunPosition.position; modelview = 1.f; glPushMatrix(); glMultMatrixf(modelview); renderFlare(0.8f,0.8f,0.6f,1.f,5.f); //render the billboard glPopMatrix();
So a friend also asked me how I drew the lasers in our upcoming game Ensign 1. These really aren't anything special, and still need some work. Still, the basic idea is that these objects should be drawn facing the direction they are traveling, but their up vector should be pointing into the line of site of the viewer. Iunno if I explained that right, but anyway, here's the code I used to do it.
Basically you generate the forward, up, and right vectors for this object. And you need to ensure that the up vector is completely orthogonal to the forward vector.
glDepthMask(GL_FALSE); Vector up,forward,right; forward = lasers[index].velocity; forward = forward*6.f; up = lasers[index].position - parentModel->position; up -= forward * forward.dot(forward,up); //ensure up vector is orthogonal to forward vector up.normalize(); right = up.cross(forward,up); right.normalize(); right = right*1.f; GLfloat modelView; modelView = right; modelView = right; modelView = right; modelView = 0.f; modelView = up; modelView = up; modelView = up; modelView = 0.f; modelView = forward; modelView = forward; modelView = forward; modelView = 0.f; modelView = lasers[index].position; modelView = lasers[index].position; modelView = lasers[index].position; modelView = 1.f; glPushMatrix(); glMultMatrixf(modelView); glEnable(GL_BLEND); lasers[index].Draw(viewerPosition); glDisable(GL_BLEND); glPopMatrix(); glDepthMask(GL_TRUE);
Some more tricks would might be that, when the up vector here is very small, the laser might appear flat, you might actually purposely add some forward vector to it to give it some depth. I haven't tried this myself yet though.
No blogs were found matching the criteria specified. We suggest you try the blog list with no filter applied, to browse all available. Join now to share your own content, we welcome creators and consumers alike and look forward to your comments.
I'm less of a studio and more of a guy with with a dream to turn his game ideas into reality! I work with a few different people here and there. Made...
No groups were found matching the criteria specified. We suggest you try the group list with no filter applied, to browse all available. Start a group and help us achieve our mission of showcasing the best content from all developers. Join now to share your own content, we welcome creators and consumers alike and look forward to your comments.
Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.
Secret of Harrow Manor promo test, You can get the key for Steam testing your game? on my YouTube channel
here is my channel Youtube.com
If you want a proper Zombie(ish) game you might want to try out Killing Floor, I was hoping RR to be more of a Survival (scavange/barricade/survive) game then a coop game and I think thats more what they are going for...
Afterall they are making a freeroam open world zombie survival :'D
Hey just curious, was this zombie game comment meant to be for me? How'd you know I love zombie games!!?
For zombie games I have project zomboid now :)
Yep, that's exactly how were planning RR to be :D
And there'll be a large map!