Jump to content
  • Advertisement
Sign in to follow this  
nataku17

OpenGL drawing wiremesh to textured

This topic is 3226 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

i'm still pretty new to openGL and i have to make a game for uni using it. the idea i came up with is a Tron like lightbike game. what i would like to do is have the bikes appear to be loading up when the game starts so the player will see the wiremesh appear and then get textured but to be honest i am not sure how to go about that. one way i was thinking would be to texture the model with an animation but i don't know if thats even possible. i'm not really asking for someone to write the code for me i would just like to know if this is something i can do with openGL and what techniques i would need to use. thanks =)

Share this post


Link to post
Share on other sites
Advertisement
Sure, you can do whatever you want with code

If you want to draw the mesh in wireframe, then set the wireframe polygon mode before drawing the mesh:

http://www.gamedev.net/community/forums/topic.asp?topic_id=295289

I don't know exactly what you mean by "and then get textured", but if you want to have the object "fade in" from fully transparent to fully opaque, then draw the mesh to a texture, and then alpha blend that texture onto the scene. Animate the alpha value used to blend from 0.0 (transparent) to 1.0 (opaque) over some amount of time to have it 'fade in'

Share this post


Link to post
Share on other sites
that sounds like a good way to do it thanks, it's also stuff i already know how to do =)

i don't really know how to word what i wanted it to look like exactly =/ it would be kinda like you have the mesh for the bike and then the texture would start at the back of the bike and move towards the front over a period of time. so half way through the back of the bike would be fully textured while the front would still be wireframe

Edit: i didn't really know what to look for but i found out about using multiple textures the give the appearence of animation, thinking if using that may do what i want

Share this post


Link to post
Share on other sites

To do that, when drawing the textured version of the bike, you can do a test in the shader to kill the current fragment

The most straightforward way I can think of is to add vertex colors to your mesh. Say, color the red channel of each vertex with a value between 0.0 and 1.0, with 0.0 at the back of the bike and 1.0 at the front. Then, in your fragment shader you can test the vertex color of the current fragment and discard it if it's greater than some threshold

The threshold then becomes a value you animate between 0.0 and 1.0 and this way you can simulate a 'sweeping in' effect of the textured bike

Share this post


Link to post
Share on other sites
From what you just described I'd say you might want to look into clipping planes. I've never actually used them before, but I can give you a brief explanation about how I think you would do it.

Say if you wanted the front half of the bike to be wireframe and the back half to be a full mesh, you could try something like this:

(assuming the center of the bike is at exactly (0,0,0) and the bike is pointing down the positive Z-axis)

1) Tell openGL to use a clipping frame that will cull the back half of the bike. (I think the equation for which would be (0,0,1,0))
2) Draw bike in wireframe mode
3) Tell openGL to use a clipping frame that will cull the front half of the bike. (0,0,-1,0)
4) Draw bike as mesh with texturing/shaders/etc.

Obviously you can specify an arbitray plane, but it was easier to figure out the plane equation at the center and facing down the z-axis. [smile]

To animate the transition point, you would need to change the value of the last number in the equation (a.k.a. d). This should give you a sudden change between wireframe and mesh mode.
Hope that helps.

Share this post


Link to post
Share on other sites
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!