简体   繁体   English

OpenGL 纹理映射

[英]OpenGL Texture Mapping

I am new to game programming and graphics programming.我是游戏编程和图形编程的新手。 However, I eagerly wish to learn, so I have begun building a game engine with OpenGL.然而,我渴望学习,所以我开始用 OpenGL 构建一个游戏引擎。 I have implemented all of the basic graphical features, and now I want to add texture support for my triangle meshes.我已经实现了所有基本的图形功能,现在我想为我的三角形网格添加纹理支持。

The only tutorials I can find for texture mapping is for a single polygon - how do I define a texture that wraps around the entire mesh?我能找到的关于纹理映射的唯一教程是针对单个多边形的 - 如何定义环绕整个网格的纹理?

I am loading the meshes from .3ds files using lib3ds ( http://code.google.com/p/lib3ds/ ).我正在使用 lib3ds ( http://code.google.com/p/lib3ds/ ) 从 .3ds 文件加载网格。 Do .3ds file carry some texture coordinate data or something? .3ds 文件是否带有一些纹理坐标数据?

Here's a page showing an example of reading out the texture coordinates:这是一个页面,显示了读取纹理坐标的示例:

http://newsgroups.derkeiler.com/Archive/Comp/comp.graphics.api.opengl/2005-07/msg00168.html http://newsgroups.derkeiler.com/Archive/Comp/comp.graphics.api.opengl/2005-07/msg00168.html

However, not all 3ds files contain texture information - see warning in:但是,并非所有 3ds​​ 文件都包含纹理信息 - 请参阅以下警告:

http://www.groupsrv.com/computers/about186619.html http://www.groupsrv.com/computers/about186619.html

If your models are much more complex than cubes, you use a UV map to translate the 3-dimensional surface of your model into a flat image for texture mapping.如果您的模型比立方体复杂得多,您可以使用UV 贴图将模型的 3 维表面转换为用于纹理映射的平面图像。

Looks like this thread on gamedev has an example of how to extract what 3DS calls "texels" as well as materials.看起来gamedev上的这个线程有一个示例,说明如何提取 3DS 所谓的“纹素”以及材料。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM