简体   繁体   English

如何在SFML或OpenGL中将纹理正确映射到凸多边形上?

[英]How do I map a texture correctly onto a convex polygon in SFML or OpenGL?

I want to represent my Objects as textured convex Polygons. 我想将我的对象表示为带纹理的凸多边形。 For the most part those will just be rotated rectangles but i want to support convex shapes too and thats where the problems arise. 在大多数情况下,这些只是旋转的矩形,但我也想支持凸形,这就是问题所在。

I worked with Blender a while ago and there you could unwrap the 3D-Objects and explicetely tell Blender which vertex of the Shape has which Position on the Texture. 我之前与Blender一起工作过,在那里您可以打开3D对象的包装,并明确告诉Blender Shape的哪个顶点在Texture上的哪个位置。

Would it maybe be better to just request the Texture to have the size of the bounding Rectangle of the Shape so I can just apply the texture with SFML? 仅要求Texture具有Shape的边界Rectangle的大小可能会更好,这样我就可以使用SFML应用该Texture?

PS: Im sorry i cant post pictures to clarify my question. PS:对不起,我不能张贴图片来澄清我的问题。

or OpenGL 或OpenGL

In OpenGL, typically you'll have two (or more!) vertex attributes: position and texture coordinate. 在OpenGL中,通常会有两个(或更多!)顶点属性:位置和纹理坐标。 That's basically saying which vertex of the Shape has which Position on the Texture . 基本上是说Shape的哪个顶点在Texture上的哪个位置

That's what SFML has to be doing internally, and since its Open-Source, you might just peek inside and see if your "bounding rectangle" idea has a chance of working (my guess is that it indeed does). 这就是SFML 在内部做的事,因为它的开源,你可能只是偷看里面,看看你的“边框”的想法有工作的机会(我的猜测是,它的确如此)。

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

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