Crystal Space
Welcome, Guest. Please login or register.
October 20, 2014, 12:43:23 pm

Login with username, password and session length
Search:     Advanced search
9010 Posts in 2044 Topics by 8755 Members
Latest Member: Pererajerl
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Planar texture mapping
« previous next »
Pages: [1] Print
Author Topic: Planar texture mapping  (Read 1550 times)
eventhorizon5
Jr. Member
**
Posts: 53


View Profile WWW
« on: December 26, 2009, 06:32:47 am »

Hi,

I've recently been working on trying to implement generic planar texture mapping for objects in my simulator, and am wondering if anyone here knows the right way to do it (the way I originally did it was very wrong).

Basically I'm trying to take a polygon of any shape (and any direction), and calculate a square around the polygon to use as the texture mapping coordinates.  My original way was to calculate the extents of the polygon (min and max vertex values) and use that to construct the square's coordinates (with X and Z flipping based on the direction of normals), but obvious problems start happening when the Y portion of the normal vector is not 0 (since the extents no longer correlate with the plane that the polygon's on), so now I'm trying to figure out if I could use the polygon's plane to determine the planar corners (top left, top right, bottom right).  Has anyone tried doing things like this?  Thanks

-eventhorizon
Logged
res
Develazyoper
CS Developer
Full Member
*****
Posts: 206


View Profile Email
« Reply #1 on: December 28, 2009, 05:21:07 pm »

Lighter2 has to solve the same problem (there for mapping lightmaps); what it does is to take the largest component of the normal of a polygon and using the _other_ two components for the projection.
Logged
eventhorizon5
Jr. Member
**
Posts: 53


View Profile WWW
« Reply #2 on: December 29, 2009, 04:34:30 pm »

Lighter2 has to solve the same problem (there for mapping lightmaps); what it does is to take the largest component of the normal of a polygon and using the _other_ two components for the projection.

Thanks - that seems to have worked.

-eventhorizon
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 5.321 seconds with 16 queries.