将图像绘制为三角形 [英] Drawing an image to a triangle

查看:100
本文介绍了将图像绘制为三角形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

背景::
我目前正在使用c#.Net创建3D建模引擎,而未使用任何第三方库(例如DirectX或OpenGl).到目前为止,我已经构建了一个引擎,该引擎支持创建新对象,灯光,运动和物理(考虑到限制:p,到目前为止,我认为这是非常令人印象深刻的).但是我碰到了一点迷路.我无法将图像映射到三角形.

问题::
我的引擎从数组中存储的3d三角形生成了3个屏幕点.我可以简单地在两点之间画线以生成网格,但是我希望能够将给定的纹理扭曲到该三角形的边界.给定的纹理由图像和它将作为图像源的不同三角形的3个点组成.我该怎么办?

感谢所有帮助我解决挑战的人:) :)

-------------------------------------------------- ----

Hi all,

Background::
I am currently in the process of creating a 3D modelling engine using c#.Net without the use of any 3rd party libraries like DirectX or OpenGl. So far I have built an engine that supports the creation of new objects, lights, movement and physics (which I think is pretty impressive so far considering the restrictions :p). However I have hit a bit of a stumble. I cannot map an Image to a triangle.

Question::
I have 3 screen points generated by my engine from a 3d triangle stored in an array. I can simply draw lines between the points to generate a mesh but I would like to be able to put a given texture warped to the bounds of this triangle. The given texture is made up of an Image and the 3 points of a different triangle it will source of the image. How can I accomplish this?

Thank you to all who help me solve my challenge :) :)

------------------------------------------------------

Graphics Drawer;  //Graphics Object
Image TextureImage;  //Image to draw source
Point[] PointsOnImageToSource;  //triangle on source image we want drawn
Point[] PointsOnScreenToDraw;   //Triangle in 2D space where texture needs to be drawn

//TODO - Draw triangle to screen

推荐答案

因为您尚未指定是否要将图像投影到三角形或图像的三角形部分,请参见此处:http://msdn.microsoft.com/en-us/library/aa457087.aspx [
如果您可以清除此问题,那么如果您对我的答案"发表评论并修改您的问题,以便其他人可以立即理解阅读您的帖子,那就太好了.

谢谢!
Since you''ve not specified if you want a projection of an image to the trianlge or just a triangular section of your image see here: http://msdn.microsoft.com/en-us/library/aa457087.aspx[^]

You''d have to elaborate a bit on what you mean by "map an image to a triangle".

If you can clear this up, it would be nice if you leave a comment to my "answer" and also modify your question so other that read your post will immediately understand.

Thanks!


DirectX或OpenGl包含在Windows中,不应视为第三方.

将图像映射到3d空间中的三角形以在2d设备上进行渲染.我无法给您快速解答.

如果您不介意花很多时间写代码-
http://away3d.com/ [ http://irrlicht.sourceforge.net/ [ ^ ]还附带了一个基于软件"的渲染器.

irrlicht软件渲染器在速度方面令人印象深刻.

问候
Espen Harlinn
DirectX or OpenGl are included with Windows, and should not be considered 3rd party.

Mapping an image to a triangle in 3d space for rendering on a 2d device. Not something I can give you a Quick Answer to.

If you don''t mind wading trough a lot of code - http://away3d.com/[^] provides one solution to yur problem - look at the pre flash 10 version.

irrlicht http://irrlicht.sourceforge.net/[^] also comes with a "software" based renderer.

The irrlicht software renderer is pretty impressive in terms of speed.

Regards
Espen Harlinn


这篇关于将图像绘制为三角形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆