[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ] [ Search: ] Creating a Furmesh Mesh

Written by Alexandru - Teodor Voicu, voicualexandruteodor@gmail.com.

This section describes how to create a Furmesh mesh.

What is Furmesh?

A ‘Furmesh’ mesh object (see section Furmesh Mesh Object) is a generic triangle mesh object used for rendering both fur and hair. Furmeshes also support animation via (see section Furmesh Animation) and advanced shaders via (see section Furmesh Material).

Furmeshes have different performance when used on static objects or dynamic objects, and so they can be used both for rendering long hairs (having complex animations, based on bullet physics) and for rendering furs, on bigger surfaces, but having just simple animations or being static.

Due to the high volume of geometry, furmeshes don't support any kind of shadows.

Furmesh objects always have to be created through a factory. So, first you create the actual furmesh factory and then you create one or more instances from that factory. Furmesh factories can be created from furmesh types or from map files.

Creating a Furmesh in a Map

Here is an example of how to create a furmesh for Krystal model in a map file:

<meshfact name="krystal_furmesh_factory">

Having the furmesh object defined as:

<meshobj name="krystal_furmesh_object">
      <copy />

The densitymap and the heightmap are textures that can be defined as well in a map (library) file, by:

  <texture name='krystal_skull_densitymap'>
  <texture name='krystal_skull_heightmap'>

However, this only sets the properties for a furmesh. Creating the actual geometry can be done only programmatically, because other interfaces, for the furmesh animation and for the furmesh material have to be specify first.

Creating a Furmesh Programmatically

Here we create the actual furmesh programmatically, after setting the furmesh properties:

// Load some fur
rc = hairTest->loader->Load ("/lib/krystal/krystal_furmesh.xml");
if (!rc.success)
  return hairTest->ReportError ("Can't load krystal furmesh library!");

csRef<iMeshWrapper> krystalFurmeshObject = 
if (!krystalFurmeshObject)
  return hairTest->ReportError ("Can't find fur mesh object!");


iSector* sector = hairTest->engine->FindSector("room");

if (!sector)
  return hairTest->ReportError("Could not find default room!");



csRef<iMeshObject> imo = krystalFurmeshObject->GetMeshObject();

// Get reference to the iFurMesh interface
furMesh = scfQueryInterface<CS::Mesh::iFurMesh>(imo);


furMesh->SetMeshFactorySubMesh(animesh -> GetSubMesh(1)->GetFactorySubMesh());
furMesh->GenerateGeometry(hairTest->view, hairTest->room);



In order to not use map files at all, we can create the furmesh factory and furmesh object, programmatically, as well:

csRef<iMeshObjectFactory> imof = furMeshType->NewFactory();

csRef<iMeshFactoryWrapper> imfw = 
  hairTest->engine->CreateMeshFactory(imof, "hair_factory");

csRef<iMeshWrapper> hairMesh = hairTest->engine->
  CreateMeshWrapper (imfw, "hair_mesh_wrapper", hairTest->room, csVector3 (0));

csRef<iMeshObject> imo = hairMesh->GetMeshObject();

csRef<CS::Mesh::iFurMeshState> ifms = 

// Get reference to the iFurMesh interface
furMesh = scfQueryInterface<CS::Mesh::iFurMesh>(imo);

Include Files

The include files useful for this section are:

#include <imesh/furmesh.h>

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated using texi2html 1.76.