Crystal Space
 Welcome, Guest. Please login or register. October 18, 2017, 12:54:27 am 1 Hour 1 Day 1 Week 1 Month Forever Login with username, password and session length
Search:     Advanced search
9063 Posts in 2051 Topics by 77077 Members
Latest Member: Rudolfnwakae221
 Pages: [1]
 Author Topic: Planar texture mapping  (Read 2301 times)
eventhorizon5
Jr. Member

Posts: 53

 « 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

 « 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

 « 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]
Jump to:

Page created in 5.451 seconds with 15 queries.