Crystal Space
Welcome, Guest. Please login or register.
October 10, 2015, 05:07:17 am

Login with username, password and session length
Search:     Advanced search
9092 Posts in 2100 Topics by 10381 Members
Latest Member: Teresanarek
* Home Help Search Login Register
  Show Posts
Pages: [1] 2 3 4
1  Crystal Space Development / Support / Re: Texture mapping functions on: August 08, 2010, 07:33:38 pm
There are some mapping tools for genmeshes, see CS::Geometry::TextureMapper. I'm not experienced in them, so I can't say if they can be useful for you, maybe you will need to implement a new mapper.

That's actually what I'm using (TableTextureMapper) which only allows a list of UV coordinates for each polygon vertex.

2  Crystal Space Development / Support / Texture mapping functions on: August 07, 2010, 07:43:46 pm
I'm finally trying to move the rest of my simulator app off of thing meshes and onto genmeshes.  This is about the first issue I'm having (the 2nd one has to do with polygon cuts, but I think I know how I'll do that).

My app currently doesn't use any static 3D models, and generates everything on the fly.  About 1/3 of it is using genmeshes already.  The Thing mesh system (specifically iThingFactoryState) had numerous texture mapping convenience functions, mainly this implementation of SetPolygonTextureMapping (the one I use):

virtual bool iThingFactoryState::SetPolygonTextureMapping  ( const csPolygonRange &  range, const csVector3 &  p1, const csVector2 &  uv1, const csVector3 &  p2, const csVector2 &  uv2, const csVector3 &  p3, const csVector2 &  uv3 )

With that function, a list of 3 abstract vertices along with their UV mappings are specified, and the important part is that they're abstract - they don't have to match up with actual polygon vertices (extra math is done to calculate the full mapping matrix with values adjusted to the actual vertex positions).  With the newer Genmesh system, the only way (as far as I know) to perform manual texture mapping is to specify a list of UV coordinates for each vertex, which becomes a problem when you're dealing with abstract coordinates like I mentioned before (ones that don't match up with any polygon coordinate, but are readjusted by the mapping functions).  Does anyone know if there are functions to help perform this kind of texture mapping with the genmesh system?  Right now I'm thinking that I'll have to somehow use the calculation code from the old thingmesh system, but I don't know if it'll work properly with genmeshes.

3  Crystal Space Development / Support / Re: walktest-problem on: January 02, 2010, 03:19:36 am
The walktest runs, but very inadequatly, with very low framerates. Hope anyone can help!

Are you sure you have accelerated 3D drivers installed?  Type "glxinfo" on a console and make sure that your machine's not using the indirect renderer.

4  Crystal Space Development / Support / Re: Planar texture mapping 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.

5  Crystal Space Development / Support / Planar texture mapping on: December 26, 2009, 06:32:47 am

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

6  Crystal Space Development / Support / Re: Polygon z-fighting issues on: December 11, 2009, 08:09:29 pm
Z-fighting is a technical limitation you have to work with. CS 1.9 gives you some more flexibility as you can control the perspective matrix with it manually (and hence choose a matrix with a more limited depth range, but better 'separation' at distance) but fundamentally the problem won't go away.

Thanks for that info - yesterday I made an internal coordinate rescaler to deal with that problem, and it worked (at least with the distant positions that are currently used - currently rescales at a 5:1 ratio, the 1 being a single GL coordinate unit).  One issue I've noticed with high ratios is that the frustum culling seems to go crazy - I tried finding a way to change/rescale the view frustum, but couldn't find anything.  I'm attaching a pic showing what things look like at a 100:1 ratio (everything near the camera is clipped).

7  Crystal Space Development / Support / Polygon z-fighting issues on: December 10, 2009, 05:18:19 am

I'm having an issue with polygons z-fighting when they're placed at positions usually further than 1500 units in any direction, with the camera always at the same distance from the polygons (this is not related to view distance).  In an example test, two polygons are spaced 0.01 units apart (let's say the camera's 10 units away from them), and if they're centered at 0,0,0, they look fine.  But if you move both their mesh and the camera to an X position of 1500 for example, the polygons start overlapping, seemingly due to some sort of position rounding.  This doesn't seem to be related to the internal vertex compression (unless compression is performed each time the meshes are moved).  I'm thinking of possibly changing the unit scale to deal with this issue (right now 1 3D unit is 1 foot - should probably use something like 10 meters instead).  Has anyone else experienced this issue?

8  Crystal Space Development / Support / Re: Rendering text to a texture on: September 08, 2009, 11:20:49 pm
Never mind - I figured it out.  It was mainly the way I was creating the texture, but also had to do with 2 bugs in CS (one seems to have been recently fixed in SVN, and I'm about to report the 2nd one with a patch).

9  Crystal Space Development / Support / Re: Rendering text to a texture on: August 26, 2009, 05:28:18 pm
I finally started working on this, and here's the code I have so far.  I'm trying to do everything within a single function, instead of using csProxTexture.  The first block containing LoadTexture is within another function, in case you're wondering why the code searches for the texture right after that (so it's intentional).  The goal is to write text onto a loaded texture, but for now I'm testing it by trying to draw a line.

if (!loader->LoadTexture(name, filename))
ReportError("Error loading texture");
return false;

csRef<iTextureWrapper> tex = engine->GetTextureList()->FindByName(name);
if (!tex)
return false;

if (!g3d->BeginDraw (CSDRAW_2DGRAPHICS)) return false;
g2d->DrawLine(1, 1, 100, 100, g2d->FindRGB(255, 255, 255));

This is all done before Prepare() is run, but the supposedly modified texture isn't changed from this code (on Windows at least).  On Linux, the app crashes later on when trying to render the texture.  I've also tried switching engine contexts, which doesn't help.  Is there something I'm doing wrong here?

10  Crystal Space Project Development / Feature Requests / Mesh-based SplitWithPlane support on: May 20, 2009, 06:51:05 pm
Here's a tricky one - my project (Skyscraper, is currently stuck on Thing meshes (really just for walls and floors; objects are not affected and I'll eventually be migrating those to genmeshes) due to a Cut function I made that creates holes in polygons by simply chopping up each poly into 5 pieces, discarding the 5th (which results in 4 polygons, and a hole), and then remapping the texture across the resulting 4 polygons.  This is vital because, for example, if you create an elevator shaft in my app, first you'll have all of the floors/ceilings for each level already in place, and then the Cut function will automatically cut holes vertically in every polygon within the shaft's area, making room for the shaft.  This is by design, since buildings are written in a scripting language I designed, and I've tried to minimize the overall complexity (so for a square-shaped floor, you'd only have to specify a single polygon, instead of creating dozens of polygons to fit around all of the shaftwork, stairwells, etc, since all of that is done automatically).  This is also done with doors (including elevator doors), since a wall is created, and then later on when a door is placed, a hole is cut in the area for the door.

That stuff is fairly simple because the polygons are basic and non-triangulated.  But in order to move to genmeshes, I'd need to make (or have someone make) a mesh-based variant of the csPoly3D::SplitWithPlane functions, which is what my Cut function uses.  I was thinking over some of it recently, and the main problem is that I'm not good (yet) with working with triangulated objects.  Basically for a split, either the triangles at the edge of the plane would have to be modified and retriangulated, or the function would have to determine the edge vertices of the full-size triangulated polygon (or meshed polygon? don't really know what that would be called) and would cut and retriangulate the entire thing.  This isn't that urgent right now (since Thing meshes are working great, even though they've been dropped in the CS trunk), but I was wondering if anyone has thought about this or has tried doing anything like this yet.

Here's an old pic from July '07 when I first got my Cut function working, showing a vertical cut.

11  Crystal Space Development / Support / Re: Genmesh texture mapping 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

12  Crystal Space Development / Support / Re: Run? on: May 20, 2009, 05:23:26 am
Crystal Space is a 3D graphics and game engine that can be used by software written in mainly C++ and/or Python.  If you're looking for a map editor or graphical-based game designer, you won't find it here.  To learn how to use it, look over the manual, and also look over the code of some of the sample applications that come with it.

13  Crystal Space Development / Support / Genmesh texture mapping 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:
CS::Geometry::TesselatedQuad wall (csVector3(x2, altitude, z1), csVector3(x1, altitude, z1), csVector3(x2, altitude + height, z2));
CS::Geometry::DensityTextureMapper mapper(1);
csRef<iMaterialWrapper> mat = engine->GetMaterialList()->FindByName(texture);

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)

14  Crystal Space Development / Support / Re: iMeshDrawCallback issues on: May 11, 2009, 05:00:40 am
I just found that the issue was fixed in 1.4 (I was using 1.2.1, which explains why I was confused about the class declaration).

15  Crystal Space Development / Support / iMeshDrawCallback issues on: May 08, 2009, 04:18:03 am
I'm trying to create a mesh draw callback using the iMeshDrawCallback struct, and am having issues - I don't know if it's supposed to be declared in a standard SCF implementation or not, since it's declared with "public iBase" instead of "public virtual iBase" in CS's mesh.h.  I can't really find any code online that uses this (I found one thing, but it does everything in a completely different way).

Here's what I've made:

header file:
struct iDirectionalCallback : public virtual iBase
SCF_INTERFACE(iDirectionalCallback, 0, 0, 1);

class DirectionalCallback : public scfImplementation2<DirectionalCallback, iDirectionalCallback, iMeshDrawCallback>
DirectionalCallback(iBase* base);
virtual ~DirectionalCallback();
virtual bool BeforeDrawing(iMeshWrapper *spr, iRenderView *rview);


DirectionalCallback::DirectionalCallback(iBase* base) : scfImplementationType(this, base)




bool DirectionalCallback::BeforeDrawing(iMeshWrapper *spr, iRenderView *rview)
return true;

So when creating a test object using these data structures:
csRef<iDirectionalCallback> a = scfCreateInstance<iDirectionalCallback>("DirectionalCallback");

error C2259: 'DirectionalCallback' : cannot instantiate abstract class
        due to following members:
        'void iBase::IncRef(void)' : is abstract
        c:\cs\include\csutil\scf_interface.h(118) : see declaration of 'iBase::IncRef'
        'void iBase::DecRef(void)' : is abstract
        c:\cs\include\csutil\scf_interface.h(120) : see declaration of 'iBase::DecRef'
        'int iBase::GetRefCount(void)' : is abstract
        c:\cs\include\csutil\scf_interface.h(122) : see declaration of 'iBase::GetRefCount'
        'void iBase::AddRefOwner(void **)' : is abstract
        c:\cs\include\csutil\scf_interface.h(131) : see declaration of 'iBase::AddRefOwner'
        'void iBase::RemoveRefOwner(void **)' : is abstract
        c:\cs\include\csutil\scf_interface.h(133) : see declaration of 'iBase::RemoveRefOwner'
directional.cpp(33) : error C2594: 'initializing' : ambiguous conversions from 'DirectionalCallback *' to 'iBase *'

If iMeshDrawCallback is removed from the SCF type declaration, then it works.  Any ideas on how this should be set up?

Pages: [1] 2 3 4
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 9.288 seconds with 15 queries.