Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#4.0
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 Smile | :) Smile | :)
 
------------------------------------------------------
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
Posted 18-Jan-11 11:00am
Comments
Marcus Kramer at 18-Jan-11 16:53pm
   
+5 for the question. I don't have any kind of an answer for you, but I like the question.
Thomas.D Williams at 19-Jan-11 2:59am
   
Thank you all for the feedback. Once I come up with a solution to this problem I can post source up here for those interested. :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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!
  Permalink  
Comments
Thomas.D Williams at 19-Jan-11 2:52am
   
This link is very useful for extracting the part of the image that is being used as a texture. This is accomplishes the first part of what needs to be done. It just now needs to map it to 3d points (I have already calculated there 2d representation of them). It should be a bit like the warp transform tool in Photoshop.
 
Thank you for your help. Very useful :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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
  Permalink  
Comments
Thomas.D Williams at 19-Jan-11 2:56am
   
Very useful links. I shall look through them later once I have done my Maths exam :p I only consider it third party in the sense DirectX has dropped c# support in VS 2010. Very annoying as I wanted to learn DirectX (Still learning to program really).
 
Thank you for the links. I'm sure i'll put them to good use :) :)
Espen Harlinn at 19-Jan-11 5:47am
   
Glad to be of some help, and thanks for voting

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 200
1 PIEBALDconsult 150
2 BillWoodruff 148
3 Jochen Arndt 135
4 DamithSL 130
0 OriginalGriff 5,695
1 DamithSL 4,506
2 Maciej Los 4,007
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,190


Advertise | Privacy | Mobile
Web03 | 2.8.141216.1 | Last Updated 18 Jan 2011
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100