Monday, September 16, 2019

graphics - Rendering 2d sprites into a 3d world?


In opengl how do I render 2d sprites in opengl given that I have a png of the sprite? See images as an example of the effect I'd like to achieve. Also I would like to overlay weapons on the screen like the rifle in the bottom image. Does anyone know how I would achieve the two effects? Any help is greatly achieved.


alt text


alt text



Answer




What you are looking for is called a billboard or projective sprite. A billboard is basically a quad that always faces the camera. If you don't need it to always face the camera then the code/math will be much simpler.


You can read more about how to implement them here:


http://www.lighthouse3d.com/opengl/billboarding/index.php3?billCyl


http://nehe.gamedev.net/data/articles/article.asp?article=19


http://www.flipcode.com/archives/Billboarding-Excerpt_From_iReal-Time_Renderingi_2E.shtml


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...