openglreadobj

所属分类:3D图形编程
开发工具:Visual C++
文件大小:675KB
下载次数:318
上传日期:2010-08-09 08:20:09
上 传 者wbj891001
说明:  能够载入obj格式的三维模型,并且包含纹理贴图
(load obj)

文件列表:
Code\OGL\ToonTex\ARBMTex.h (3904, 2000-08-01)
Code\OGL\ToonTex\brush1.tga (196652, 2000-08-01)
Code\OGL\ToonTex\brush2.tga (196652, 2000-08-01)
Code\OGL\ToonTex\chess.mtl (163, 2000-08-01)
Code\OGL\ToonTex\chess.obj (28458, 2000-08-01)
Code\OGL\ToonTex\default.shd (320, 2000-08-01)
Code\OGL\ToonTex\donut.mtl (163, 2000-08-01)
Code\OGL\ToonTex\donut.obj (62674, 2000-08-01)
Code\OGL\ToonTex\head.mtl (165, 2000-08-01)
Code\OGL\ToonTex\Head.obj (38317, 2000-08-01)
Code\OGL\ToonTex\LoadOBJ.cpp (11991, 2000-08-01)
Code\OGL\ToonTex\LoadOBJ.h (910, 2000-05-25)
Code\OGL\ToonTex\loadtex.cpp (2892, 2000-08-01)
Code\OGL\ToonTex\loadtex.h (1162, 2000-06-25)
Code\OGL\ToonTex\MainFrm.cpp (8532, 2000-08-01)
Code\OGL\ToonTex\MainFrm.h (2727, 2000-08-01)
Code\OGL\ToonTex\MathDefs.cpp (9435, 2000-01-24)
Code\OGL\ToonTex\MathDefs.h (3303, 2000-08-01)
Code\OGL\ToonTex\OGLView.cpp (29909, 2000-08-01)
Code\OGL\ToonTex\OGLView.h (3786, 2000-08-01)
Code\OGL\ToonTex\point1.tga (196652, 2000-08-01)
Code\OGL\ToonTex\point2.tga (196652, 2000-08-01)
Code\OGL\ToonTex\resource.h (4071, 2000-08-01)
Code\OGL\ToonTex\RES\MAINFRAM.BMP (1078, 1997-09-20)
Code\OGL\ToonTex\RES\Toolbar.bmp (1142, 1997-09-06)
Code\OGL\ToonTex\RES\ToonTex.ico (1078, 2000-01-25)
Code\OGL\ToonTex\RES\ToonTex.rc2 (399, 2000-08-01)
Code\OGL\ToonTex\Skeleton.cpp (8677, 1999-10-20)
Code\OGL\ToonTex\Skeleton.h (7540, 2000-08-01)
Code\OGL\ToonTex\sketch1.tga (196652, 2000-08-01)
Code\OGL\ToonTex\sketch1.tga.icon (12580, 2000-08-01)
Code\OGL\ToonTex\sketch2.tga (196652, 2000-08-01)
Code\OGL\ToonTex\sphere.mtl (167, 2000-08-01)
Code\OGL\ToonTex\sphere.obj (59132, 2000-08-01)
Code\OGL\ToonTex\StdAfx.cpp (204, 1999-10-20)
Code\OGL\ToonTex\StdAfx.h (987, 1997-09-06)
Code\OGL\ToonTex\strokes1.tga (196652, 2000-08-01)
Code\OGL\ToonTex\strokes2.tga (196652, 2000-08-01)
Code\OGL\ToonTex\ToonSet.cpp (1502, 2000-08-01)
... ...

3D Real-time Cartoon Rendering Textured Update August 2000 ---------------------------------------------------------- v. 2.0 This demo makes use of multi-texture hardware support in OpenGL to add texturing to the cartoon renderer. It was featured in the July 2000 issue of Game Developer Magazine. The idea is that the simple cartoon shading from February isn't too much detail. I would like to add a texture pass as well. I could have simply used multi-texture to modulate the cartoon shade with the texture but to make things more interesting, I am using two base textures. The cartoon shade table now has an alpha component for each shade. This is used to select between the two base textures. When ARB_multitexture is supported, the renderer will make two multi-texture passes. Pass 1. The object is drawn with the "dark" texture modulated by the cartoon shade. Blend is set to glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA) and alpha test is set so it only draws when the alpha component is 0.0f. Pass 2. The object is drawn with the "light" texture modulated by the cartoon shade. Blend is set to glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) and alpha test is set so it draws when the alpha component is > 0.0f. Discussion: The alpha test prevents overdraw and z-fighting. It could be done without the alpha test or even with alpha values other then 0 and 1. It may be interesting to have the two passes smoothly blend together rather then a cut. One new hardware (such as the ATI Radeon) that supports 3 texture multitexture, all these passes could be done in a single pass. Once I get a Radeon, I will give it a try. Each model is in an OBJ file. The two textures are designated in the .MTL file for each OBJ. The Pass 1 texture is the map_Kd and Pass 2 is map_Ks. To try different textures, just change the MTL text file. Since OBJ format varies a bunch, you may need to massage the file or my code to get your models in. It only handles triangle models right now for ease of code. Next, I want to work on good ways for automatically generating those sketch style textures so that they follow the model contours. v. 1.0 This is the sample application that accompanies the February 2000 Game Developer magazine. It is meant as a demonstration of a method for Non-photorealistic cartoon rendering. The February issue didn't really do any cartoon shading so there wasn't much to do. Just the silhouette lines. Lots of people wanted the app before the March issue though so I am releasing it. But since you haven't seen the March issue yet, you won't know about the shading method. So, here it is in a nutshell: I use a 1D texture as a non-linear shading function. The dot product of the light vector and the surface normal is used to calculate which entry to grab out of that table. This gets rid of the Gouraud shaded look and allows me to be very flexible on the shading. For this demo, there are 32 entries in the shade table. This may not be enough precision for some shaders. If you look at the "gradient.shd" which is a smooth gradient, you will see the banding. This is also because the bilinear filtering is turned off also. If it was on, the shader wouldn't look like a Toon. You can edit the .SHD files and create your own settings. They are simple text files. Model files are Wavefront OBJs. I get the model base color from the Diffuse color in the MTL file. Use settings to change the line color, width and light direction variables. Anti-Alias may really slow things down on some OpenGL implementations. This anti-aliases the sihouette lines. Manipulating the View --------------------------------------------------------------------- LMB to Rotate view in X and Y LMB+SHIFT to Rotate in Z RMB to Translate in Z RMB+SHIFT to Translate in X and Y --------------------------------------------------------------------- Stuff you can do to improve: Add support for multiple materials and then add in material lines. Add blending with a texture. --------------------------------------------------------------------- Write to me if you have problems or questions and check the web site or Game Developer's web site for updates. Jeff Lander jeffl@darwin3d.com www.darwin3d.com/gamedev.htm ----------------------------------------------------------- I know this code could be optimized for maximum performance but it was written to be a clean example without a lot of tricks. It should be easy to learn and build from. Here are the details. I compiled the code with Visual C++ 5.0. It has been tested with Microsoft OpenGL, SGI OpenGL, Permidia 1 and 2 OpenGL Drivers, Riva 128 (New Beta OGL Drivers), AccelGalaxy, and Symetra Ultra FX Pro. It should run on any OpenGL fully complient driver. This DOES NOT include the mini-QuakeGL driver for 3DFX Voodoo or Voodoo 2. 3DFX Voodoo and Voodoo 2 OpenGL do not support OpenGL in a window so will not work with this application.

近期下载者

相关文件


收藏者