(08-17-2013 08:20 AM)Zervox Wrote: Well, you can always send him your integration work if you feel like it when you're done, that is what I did with my recast implementation, atleast it worked as a intergration sample even if he didn't copy it. ; )
I'd very much too like to see the end results of this, too bad you can't say the name of the library yet. ; )
I did some tests with Umbra and EE and it worked very well, although Umbra has so much in it and I couldn't share integration samples, nor is it easy to get rights to implement it as a module for a Engine.
Interesting you mention Umbra since that was the other option but I wanted to have a look at this library first since the licensing for Umbra is pretty expensive :/
So I am pretty sure I've got the vertex and index data sorted using MeshBase using the following (the sample world I created for the project contains hundreds of tavern objects):
Code:
Game::ObjParamsPtr tavern = Game::Objs("Obj/Static/Tavern/0.obj");
if(tavern) {
EE::Mesh& fullMesh = tavern()->mesh()->joinAll(false,false,false); // get vertex/index data for parts of the mesh
Int* idx = reinterpret_cast<Int*>(fullMesh.parts[0].base.tri.ind()); // occlusion lib takes arrays of values
Int idxCnt = fullMesh.parts[0].base.tri.elms()*3; // 3 elements per index
Flt* vtx = reinterpret_cast<Flt*>(fullMesh.parts[0].base.vtx.pos()); // occlusion lib requires vertex position only
Int vtxCnt = fullMesh.parts[0].base.vtx.elms()*3; // 3 elements per vertex pos
// MeshUpdate for the occlusion library takes a Mesh handle which is unique, we have to create one per mesh of every game object and associate with it basic data about the mesh resource. We only need to supply vertex positions and indexes, nothing else. This function looks similar to some DX DrawPrimitive functions; the last parameter is a 'stride' or 'step' between the vertex positions in the 'vtx' data.
MeshUpdate(Mesh, EPT_TRIANGLES_INDEXED, &idx[0], idxCnt*sizeof(Int), EIT_U32, &vtx[0], vtxCnt*sizeof(Flt), 3*sizeof(Flt));
Basically the library wants unique handles for every game mesh because we then have to create instances of it for the library to use and determine what to cull. We create instances based on what objects are loaded/being drawn in the Esenthel game world.
To create the instances, we have to supply 4x4 matrices that represent the objects position. I wrote a quick and dirty function that maps a Matrix4 to a Flt array. I couldn't find a function to do this in Esenthel SDK?
Here's part of the code that does it:
Code:
Matrix& m = Statics[i].matrix(); // get tavern matrix
Matrix4& M = Matrix4(m); // make a 4x4 mat out of it
Flt mat[16]; Matrix4ToArray(M, mat); // map Matrix4 elements to array. [0] to [3] contain 'right' axis, [4] to [7] contain 'up' axis, [8] to [11] contain 'forward' axis and [12] to [15] contain position.
Pretty sure that is working correctly, camera code still not certain about because occlusion library works directly with DX library and I find it difficult to understand how to do the same in Esenthel. Projection transform code I posted earlier, View transform I tried using the Cam matrix, but is that used for transforming objects from world to camera space or is it simply the cameras orientation?