Click here to Skip to main content
15,893,663 members

Drawing an image to a triangle

Thomas.D Williams asked:

Open original thread
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 :) :)

------------------------------------------------------
C#
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
Tags: C# (C# 4.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900