Crystal Space
Welcome, Guest. Please login or register.
September 23, 2014, 07:47:20 pm

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


View Profile WWW
« on: May 17, 2009, 10:02:03 pm »

Hi - I recently started working with genmeshes for parts of my app (most of it uses thing meshes, and I can't really switch off of them yet due to technical reasons), and I'm having trouble figuring out how to correctly map a texture onto a quad.  I'm creating a tesselated quad, and once I apply the material (which uses the density texture mapper), the texture is shifted (where the center of the texture is at the edges of the polygon, and the edges of the texture are in the center).  I'm mostly familiar with the Thing factory state's SetPolygonTextureMapping function.

Part of my code:
Code:
CS::Geometry::TesselatedQuad wall (csVector3(x2, altitude, z1), csVector3(x1, altitude, z1), csVector3(x2, altitude + height, z2));
CS::Geometry::DensityTextureMapper mapper(1);
wall.SetMapper(&mapper);
wall.Append(mesh->GetFactory());
csRef<iMaterialWrapper> mat = engine->GetMaterialList()->FindByName(texture);
mesh->GetMeshObject()->SetMaterialWrapper(mat);

Examples are attached (a pic of the thing mesh with the up/down arrows, and then the gen mesh with the same textures, each arrow is a mesh)

-eventhorizon


* 1.jpg (8.44 KB, 238x206 - viewed 279 times.)

* 2.jpg (7.54 KB, 217x258 - viewed 265 times.)
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: May 19, 2009, 07:54:25 pm »

You cannot easily do what you want using the DensityTextureMapper. You'll have to use a TableTextureMapper instead. That way you have full control over the texel coordinates at the four corners of your quad.

Greetings,
Logged
eventhorizon5
Jr. Member
**
Posts: 53


View Profile WWW
« Reply #2 on: May 20, 2009, 05:38:25 am »

You cannot easily do what you want using the DensityTextureMapper. You'll have to use a TableTextureMapper instead. That way you have full control over the texel coordinates at the four corners of your quad.

Yeah I saw that but for some reason didn't try messing around with it (since there was even less info about it).  I just tried it out now, and figured it out in maybe 5 minutes Smiley

-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.263 seconds with 15 queries.