Backtracking on a year's work of cleaning swamps comes with the added dubious advantage of having even more work to do in order to set down the results such as they are for potential pickup (maybe!) sometime in the near or even not so near future. So I took a few deep breaths, checked the full compilation and versions of everything, read through the main changes all again and unloaded the main gist of it all in a readme file that might come in handy at a later time1. My initial plan was to pack it all up and let it be really but since I did already the work of disentangling the CrystalSpace (CS) way of programmatically creating the whole map and a lot of the stuff in it, I might as well publish the prototype code as ugly as it is, what can it hurt anyway.
As the freshly baked readme file says, this prototype client is an attempted switch from legacy ps code to:
- SMG communication protocol as opposed to PS's net/messages.h approach. Status: working registration of new account and exchange of Serpent keys for both ways communication + all lower level required functionality of the protocol (e.g. packing/unpacking, encryption/decryption, message types, queues). Existing (in EuCore, which is client's lib for communication with the server and data acquisition, essentially SMG Comms + data acquisition skeleton) implementation for message types that are fully defined so far: keys management (rsa and serpent packaged messages), file transfer and request.
- Compiling with gprbuild (gnat) as opposed to current dependency on jam/ftjam. Status: working for client and eucore lib (though CS not ported to gprbuild) with the caveat that a few plugins haven't yet been moved to gprbuild as well (mainly because they were anyway slated for removal e.g. bgloader aka PS's background loader thing).
- On the fly loading of graphics (from clientcache/ for now for testing purposes) as opposed to the bgloader plugin delayed loaders that expected the whole WORLD to be known upfront and never changing. Status: removed the original "preloading" and caching of all sorts, as well as the whole "art" dir; existing working prototype loaders2 integrated into the client code (aka in use) for sectors, factories, meshes of various sorts, textures, materials (including shader variables setting). Some of the prototype loaders test successfully the intended reliance on EuCore (Ada code) for data acquisition as well as on the fly loading of local files from any specified location (as opposed to predefined world.zip file in a set location). No world file needed or used anymore; no preloading/delayed loading (bgloader is not called anymore, nor expected although the code is left in src/plugins/common/bgloader); disabled also the part that was expecting the full list of all art assets including shaders to be known upfront and loaded before even getting into the game at all.
- Simplified start of the client meaning getting directly into game + using the EuCore lib (Ada implementation of SMG Comms as well as RSA TMSR, config file reading, key generation, read/write keys to binary files on disk etc). Status: working and tested, quick launch of the game and straight load of the world as known from client's own local cache; removed dependency on net/ (though the code remains in src/common/net) and working offline client that doesn't require ping-pong with the server for anything. All attempted communications with the server happens from EuCore only and it's decided on by EuCore too since it is driven by the data acquisition needs, regardless of the GUI part itself. This version of the client is currently able to run standalone (ie no server really needed anywhere) and it will show a naked char that can be moved around (though none of the animations are loaded so that the char will remain stiff while gliding across the world).
- Removed preloading of 2D assets too (the interface itself, hence PAWS). Status: PAWS (widgets and therefore all buttons and windows inside the game) IS working but some windows may not be visible as they are not loaded (they have a LONG and INTRICATE codependency relation going on so it was cut at the root for starters); there is a tested prototype loader for icons (2D) but it's currently not called from any of the running code (mainly because the issue to sort out first here is related to purging preloaded ideas from PAWS and PAWS windows themselves since currently it all cascades if one tries to load one single window). Notably, the Quit button works (if it's invisible nevertheless) and the confirmation dialog window is one of the few that actually shows.
- Reading of config from Ada and from an .ini file as opposed to Planeshift's multiple and multi-stratified configs. Status: working and tested for various data types; allows comments as well.
Caveats of this prototype client:
- This version will BLOCK (waiting to read from /dev/ttyUSB0) if there's no FG (or other source of bits) connected and working on /dev/ttyUSB0 - this is because reading from FG is currently BLOCKING as implemented in EuCore lib
- The prototype implementations of various effects (e.g. rain, fire, snow) are currently commented out. They work as previously illustrated but I took them out at the moment as I was focusing on figuring out the shaders and their linking with materials and textures.
- The look of the terrain (aka the colours really) as well as the looks of various effects seems to depend on the exact environment where the code runs. I had the same code resulting in brown rain as well as nicely twinkling rain, depending on where I ran it. This was not fully investigated mainly for lack of time but it prompted the deeper dig into shaders as apparently the "nicer" aspects are mainly achieved through shader(s) use currently.
- The path & names of .bin key files are hardcoded and checked at runtime - depending on which keys are present and which ones are missing, the EuCore lib may try to generate new keys and/or send messages to the server to request an account/registration/etc.
- While the .gpr file works to build the client code, the EuCore lib is linked dynamically and has to be built separately (see its own gpr file). Moreover, the .gpr file relies on CRYSTAL and CAL3D environment variables to be set to the locations of CS and Cal3D respectively so it can include their headers as needed. At runtime, LD_LIBRARY_PATH still has to point to CS and Cal3d as well as EuCore's locations.
- There are 3 libs that are not yet ported to gprbuild (mainly as they were either slated for removal or otherwise not yet high enough on the priority list to get done): soundmanager.so, celgraph.so and bgloader.so
- The tests for EuCore in eucore/tests have their own project that needs to be built separately.
As to the code, it's ugly prototypes and messy and all that but anyway, perhaps best to start with the "basic" versions of Getters I wrote for CS's "factories" of meshes, hoping that I could perhaps simplify a bit the full thing on this side. To understand what I'm talking about here: to create anything at all in CS, you'll need first the "factory" for that type of thing since the idea is that it's more efficient this way; which it is, sure, but only if you ever want to create a lot of very-similar-things in the same place like that, which happens ~never and so, as a result, all this does is that ~every thing you create ends up with its additional unique factory too!
Add to the above the maddening fact that CS uses strings - and it's CPP code so strings are a pain at all times, of course - as IDs for everything so you have to search for factories as well as for objects by their *name*. Oh, and each factory is created through a call that requires also the *name* of the SCF plugin that provides the type of... factory you are after. Think of it: since you have factories to create "same sort of" objects, it follows that the factories themselves represent already types of objects, right? Sure, but why not have then also types of factories to make things more... hm, interesting? So there we go, there are also types of factories and plugins that implement (or not) those types and it's true that in general there's only one plugin for each type but don't let that stop you from having the oh-so-useful-mechanism for having more than one type because there's now no real cost to all this, no, none at all, right? Fine, first let's set those plugin names to something shorter at least and give the "types" some numbers too, I like numbers:
#define DEFAULT_CULLER "crystalspace.culling.dynavis"
#define GENERIC_PLUGIN "crystalspace.mesh.object.genmesh"
#define CAL3D_PLUGIN "crystalspace.mesh.object.sprite.cal3d"
#define TERRAIN_PLUGIN "crystalspace.mesh.object.terrain2"
#define PARTICLES_PLUGIN "crystalspace.mesh.object.particles"
#define EMITTER_PLUGIN "crystalspace.mesh.object.particles.emitter"
#define EFFECTOR_PLUGIN "crystalspace.mesh.object.particles.effector"#define TERRAIN_RENDERER "crystalspace.mesh.object.terrain2.bruteblockrenderer"
#define TERRAIN_DATAFEEDER_SIMPLE "crystalspace.mesh.object.terrain2.simpledatafeeder"
#define TERRAIN_DATAFEEDER_THREADED "crystalspace.mesh.object.terrain2.threadeddatafeeder" //alternative data feeder available in principle
#define TERRAIN_COLLIDER "crystalspace.mesh.object.terrain2.collider"#define TEXTURE_FIRE "crystalspace.texture.type.fire"
#define TEXTURE_PLASMA "crystalspace.texture.type.plasma"
#define TEXTURE_WATER "crystalspace.texture.type.water"#define FACTORY_NONE 0
#define FACTORY_GENERIC 1
#define FACTORY_CAL3D 2
#define FACTORY_TERRAIN 3
#define FACTORY_PARTICLES 4
Using the above, an example3 of a "Getter" method that will retrieve an existing factory from the engine or otherwise create it and return it, if it doesn't exist already:
csRef
EuLoader::GetFactoryTerrain(char *factName) {
//terrain of a sector
csReffactWrapper = 0; //check if the factory exists already
factWrapper = psengine->GetEngine()->FindMeshFactory(factName);if (factWrapper != 0)
return factWrapper;//create a basic factory of this type (aka using the plugin corresponding to this "type")
//boolean last argument is "addtolist" so yes, it should add it to list
factWrapper = psengine->GetEngine()->CreateMeshFactory(TERRAIN_PLUGIN, factName, true);return factWrapper;
}
Similar Getter method for a texture, using the given name as path too since one string is anyway enough of a mess in there, no need for two. The loader thing is simply CS's way of reading an image file, since the texture here is simply assumed to be an image (.png, .bmp, .jpg, .dds are all supported):
csRef
EuLoader::GetTexture( char *texName ) {
csReftex = 0; //first check if the engine already has it loaded
tex = psengine->GetEngine()->FindTexture(texName);
if (tex != 0)
return tex; //found it so return and be done with it.//texture not found, so load it
csRefloader = csQueryRegistry (psengine->GetObjectRegistry());
if (loader == 0)
Err::NonfatalError("EuLoader::LoadTexture failed to find the iLoader plugin of CS!\n");
else
tex = loader->LoadTexture(texName, texName); //NB: the "name" is same as the full path!return tex; //either way, the result is still in here
}
The equivalent for a Material is potentially more dubious because on one hand CS *anyway* wraps all textures into materials with the same name and on the other hand, a material also holds shader variables of all sorts, with the basic texture set as a "shader variable" itself! Moreover, shader variables can have different data types, what joy. So this one is not all that basic: it queries the client's data cache (via that SMG object) to retrieve all shaders and variables for this material and applies them as they come:
csRef
EuLoader::GetMaterial( char *matName) {
csRefmatWrapper = 0;
csRefmat = 0; //first check if the engine already has it loaded
matWrapper = psengine->GetEngine()->FindMaterial(matName);
if (matWrapper != 0)
return matWrapper; //material found so return it
//material not found, so create it;
//NB: "texture" in xml is ANYWAY made into a shader var at load time!
mat = psengine->GetEngine()->CreateBaseMaterial(0);
//add it to the engine's list of materials
matWrapper = psengine->GetEngine()->GetMaterialList()->NewMaterial(mat, matName);//set shaders and corresponding textures and/or shader vars
csRefstringSet = csQueryRegistryTagInterface (psengine->GetObjectRegistry(), "crystalspace.shader.variablenameset");
csRefstrings = csQueryRegistryTagInterface (psengine->GetObjectRegistry(), "crystalspace.shared.stringset");
// csRefloader = csQueryRegistry (psengine->GetObjectRegistry());
uint32_t sindex = 1;
//for shaders to set on this material
char stype[MAX_STR_LEN+1];
char sname[MAX_STR_LEN+1];
unsigned int stypelen = MAX_STR_LEN;
unsigned int snamelen = MAX_STR_LEN;
while (psengine->SMG.GetShader(matName, sindex, stype, &stypelen, sname, &snamelen)) {
stype[stypelen] = '\0';
sname[snamelen] = '\0';
csStringID st = strings->Request(stype);
csRefss = GetShader(sname);
if (ss != 0)
mat->SetShader(st, ss);
//next shader, if any
sindex = sindex + 1;
//reset the lengths!
stypelen = MAX_STR_LEN;
snamelen = MAX_STR_LEN;
}
//shader vars, if any
char sVarName[MAX_STR_LEN+1];
unsigned int sVarNameLen = MAX_STR_LEN;//texture type shader vars
char sTexName[MAX_STR_LEN+1];
unsigned int sTexNameLen = MAX_STR_LEN;
sindex = 1;
while (psengine->SMG.GetShaderVar(matName, sindex, sVarName, &sVarNameLen, sTexName, &sTexNameLen)) {
sVarName[sVarNameLen] = '\0';
sTexName[sTexNameLen] = '\0';
csRefstex = GetTexture(sTexName);
if (stex != 0) {
csRefshaderVar;
CS::ShaderVarStringID strID = stringSet->Request(sVarName);
shaderVar.AttachNew( new csShaderVariable );
shaderVar->SetType(csShaderVariable::TEXTURE);
shaderVar->SetName(strID);
shaderVar->SetValue(stex);
mat->AddVariable(shaderVar); //as iMaterial extends directly iShaderVariableContext, this can be added here.
}
else
Err::NonfatalError("EuLoader::GetMaterial can't find the texture for a material\n");
sindex = sindex + 1;
sVarNameLen = MAX_STR_LEN;
sTexNameLen = MAX_STR_LEN;
}//float type shader vars
float v1, v2, v3, v4;
sindex = 1;
while (psengine->SMG.GetShaderVar(matName, sindex, sVarName, &sVarNameLen, &v1)) {
sVarName[sVarNameLen] = '\0';
csRefshaderVar;
CS::ShaderVarStringID strID = stringSet->Request(sVarName);
shaderVar.AttachNew( new csShaderVariable );
shaderVar->SetType(csShaderVariable::FLOAT);
shaderVar->SetName(strID);
shaderVar->SetValue(v1);
mat->AddVariable(shaderVar); //as iMaterial extends directly iShaderVariableContext, this can be added here.
sindex = sindex + 1;
sVarNameLen = MAX_STR_LEN;
}
//vector2 type shader vars
sindex = 1;
while (psengine->SMG.GetShaderVar(matName, sindex, sVarName, &sVarNameLen, &v1, &v2)) {
sVarName[sVarNameLen] = '\0';
csRefshaderVar;
CS::ShaderVarStringID strID = stringSet->Request(sVarName);
shaderVar.AttachNew( new csShaderVariable );
shaderVar->SetType(csShaderVariable::VECTOR2);
shaderVar->SetName(strID);
shaderVar->SetValue(csVector2(v1, v2));
mat->AddVariable(shaderVar); //as iMaterial extends directly iShaderVariableContext, this can be added here.
sindex = sindex + 1;
sVarNameLen = MAX_STR_LEN;
}//vector3 type shader vars
sindex = 1;
while (psengine->SMG.GetShaderVar(matName, sindex, sVarName, &sVarNameLen, &v1, &v2, &v3)) {
sVarName[sVarNameLen] = '\0';
csRefshaderVar;
CS::ShaderVarStringID strID = stringSet->Request(sVarName);
shaderVar.AttachNew( new csShaderVariable );
shaderVar->SetType(csShaderVariable::VECTOR3);
shaderVar->SetName(strID);
shaderVar->SetValue(csVector3(v1, v2, v3));
mat->AddVariable(shaderVar); //as iMaterial extends directly iShaderVariableContext, this can be added here.
sindex = sindex + 1;
sVarNameLen = MAX_STR_LEN;
}//vector4 shader variables
sindex = 1;
while (psengine->SMG.GetShaderVar(matName, sindex, sVarName, &sVarNameLen, &v1, &v2, &v3, &v4)) {
sVarName[sVarNameLen] = '\0';
csRefshaderVar;
CS::ShaderVarStringID strID = stringSet->Request(sVarName);
shaderVar.AttachNew( new csShaderVariable );
shaderVar->SetType(csShaderVariable::VECTOR4);
shaderVar->SetName(strID);
shaderVar->SetValue(csVector4(v1, v2, v3, v4));
mat->AddVariable(shaderVar); //as iMaterial extends directly iShaderVariableContext, this can be added here.
sindex = sindex + 1;
sVarNameLen = MAX_STR_LEN;
}
return matWrapper; //the result is in matWrapper at all times
}
Using the above, a prototype method that creates a sky as a sphere with the fixed "starry" image painted on the inside, since your world is - of course! - all inside of the sky dome, in this grand vision of computer graphics4. Note that both the texture and the location (aka sector) of the sky are hardcoded in this hasty prototype:
bool EuLoader::GetSky() {
char skydomef[] = "skydomef";
//factory wrapper
csReffactSkyWrapper = GetFactoryMesh(skydomef); //a *generic* mesh factory, used for ALL non-moving objects if (factSkyWrapper == 0) {
Err::FatalError("FAILED TO GET GENERIC FACTORY WRAPPER TO MAKE THE SKY!\n");
return false; //this should never happen....
}
//geometry HAS to be set on the factory state as the meshstate lacks the needed methods...
//...and to get the factory state, first need the factory rather than the wrapper, arghhh
csReffactSky = factSkyWrapper->GetMeshObjectFactory();
csReffactClouds = factCloudsWrapper->GetMeshObjectFactory();
if (factSky == 0) {
Err::NonfatalError("Sky/Clouds failed to find iMeshObjectFactory valid for created factory\n");
return false;
}//and since anyway can't really have several objects here, set the MATERIAL on factory as well....ugh.
char skyMatName[] = "stars.png";
csRefskyMat = GetMaterial(skyMatName); //this WILL load/create needed texture too, if it does not exist already
if (skyMat == 0) {
Err::NonfatalError("EuLoader:GetFactory failed to find material for sky\n");
return false;
}
factSky->SetMaterialWrapper(skyMat); //sets the material for the whole factory i.e. default for objects created from this factory//generic settings
factSky->GetFlags().SetBool(CS_FACTORY_STATICSHAPE, true); //default static for genmeshes; non-static should use CAL3D!
factClouds->GetFlags().SetBool(CS_FACTORY_STATICSHAPE, true); //default static for genmeshes; non-static should use CAL3D!
//defaults: compress = false; auto_normals = false; auto_normals_nocompress= false
//if compress state->Compress();
//if auto_normals state->CalculateNormals(!auto_normals_nocompress);//factory state
csReffactStateSky = scfQueryInterface (factSky); //create sky dome geometry
using namespace CS::Geometry;
csVector3 center (0, 0, 0);
int rim_vertices = 16;
bool toponly = false; //make FULL sphere, not only top half; default=false
bool reversed = true; //so it's visible from INSIDE, yes; default=false
bool cylmapping = false; //no cylindrical texture mapping; default=false
csEllipsoid ellips;
ellips.SetRadius(csVector3(2500,2500,2500));
ellips.SetCenter(center);
//this should directly generate the vertices,texels,normals and triangles + set vertex colors to black
factStateSky->GenerateSphere(ellips, rim_vertices, cylmapping, toponly, reversed);/* alternative way to the above neater GenerateSphere? :
csDirtyAccessArraymesh_vertices;
csDirtyAccessArraymesh_texels;
csDirtyAccessArraymesh_normals;
csDirtyAccessArraymesh_triangles;
Primitives::GenerateSphere (ellips, rim_vertices,
mesh_vertices, mesh_texels,
mesh_normals, mesh_triangles, cylmapping,
toponly, reversed, 0);
AppendOrSetData (factState, mesh_vertices, mesh_texels,
mesh_normals, mesh_triangles);
*///directly here instead of calling "GeneralMeshBuilder::CreateMesh" that does exactly this;
//see cs/libs/cstool/genmeshbuilder.cpp//sector - should get this either as param or from smg....TO DO
csRefs = psengine->GetEngine()->FindSector("Rotces");
if (s == 0) {
//this should NOT happen as the sector should call/create contained entities, not the other way around.
Err::NonfatalError("EuLoader: failed to find the sector for the sky!\n");
return false;
}//objects (?)
//apparently: it's really the triangles and/or render buffer stuff i.e. the "raw" values that just aren't right (it WORKS with a generated ellipse...)
char skyn[] = "skyn";
csRefskyMeshWrapper = psengine->GetEngine()->CreateMeshWrapper (factSkyWrapper, skyn, s, csVector3 (0)); //z buffer and priorities
skyMeshWrapper->SetZBufMode(CS_ZBUF_USE); //DO read so that the zbuffer gets updated...ugh;only write to the z-buffer but do not read
skyMeshWrapper->SetRenderPriority(psengine->GetEngine()->GetObjectRenderPriority());psengine->GetEngine()->PrecacheMesh(skyMeshWrapper); //hmm?
return (skyMeshWrapper != 0 );
}
For an example, the test made with the moon, effectively creating an object in the world directly through the list of vertices and texture coordinates (as taken from its existing xml file otherwise, don't look weirdly at me when you get to that huge list of vertices, they have been there all the time):
csRef
EuLoader::GetMoon() { csRef
fact;
csRefstate;
csReftype; type = csLoadPluginCheck
( psengine->GetObjectRegistry(), GENERIC_PLUGIN, false);
if (!type)
Err::FatalError("EuLOADER: can't find crystalspace.mesh.object.genmesh plugin\n");fact = type->NewFactory ();
state = scfQueryInterface(fact); //material
char matname[11] = "waves.dds";
csRefmat = GetMaterial(matname);
if (mat == 0)
Err::FatalError("EuLOADER: can't find material waves.dds");
fact->SetMaterialWrapper(mat);//renderbuffer: position
const float posElems[] = {-24.46479416,4.86635208,16.66710281,-20.80559731,4.13849306,21.21320534,-21.21320534,0.00000000,21.21320343,-24.94408798,0.00000000,16.66710663,-20.80559731,4.13849258,-21.21320343,-24.46479607,4.86635256,-16.66710663,-24.94409180,0.00000000,-16.66710663,-21.21320343,0.00000000,-21.21320343,-27.18382263,5.40720034,11.48050213,-27.71638680,0.00000000,11.48050308,-16.34685135,3.25159287,-24.94409180,-16.66710663,0.00000000,-24.94409180,-28.85818863,5.74025345,5.85270882,-29.42355728,0.00000000,5.85271072,-11.25990391,2.23973608,-27.71638680,-11.48049831,0.00000000,-27.71638680,-29.42355919,5.85271168,0.00000358,-30.00000000,0.00000000,0.00000226,-11.25990868,2.23973703,27.71638870,-5.74025154,1.14180899,29.42355728,-5.85270977,0.00000000,29.42355728,-11.48050308,0.00000000,27.71638680,-5.74024439,1.14180756,-29.42355919,-5.85270309,0.00000000,-29.42355919,-28.85819244,5.74025393,-5.85270500,-29.42355919,0.00000000,-5.85270643,-16.34685326,3.25159311,24.94408607,-16.66710663,0.00000000,24.94408798,-27.18382263,5.40720034,-11.48049831,-27.71638680,0.00000000,-11.48049831,-10.60659599,4.39340019,-27.71638680,-15.39839554,6.37822866,-24.94409180,-16.34685135,3.25159287,-24.94409180,-11.25990391,2.23973608,-27.71638680,-27.71638489,11.48050785,0.00000358,-27.18381882,11.25991058,5.85270882,-10.60660172,4.39340210,27.71638870,-5.40719748,2.23973894,29.42355728,-5.40719128,2.23973608,-29.42355919,-5.74024439,1.14180756,-29.42355919,-27.18381882,11.25991058,-5.85270500,-15.39839745,6.37822914,24.94408607,-25.60660172,10.60660458,-11.48049831,-19.59844398,8.11794472,21.21320534,-23.04533005,9.54569340,-16.66710663,-23.04533005,9.54569244,16.66710281,-19.59844208,8.11794472,-21.21320343,-25.60660172,10.60660458,11.48050213,-15.39839554,6.37822866,-24.94409180,-17.63813210,11.78542995,-21.21320343,-20.74024582,13.85819817,-16.66710663,-23.04533005,9.54569340,-16.66710663,-19.59844208,8.11794472,-21.21320343,-23.04533005,15.39840508,11.48050213,-20.74024582,13.85819626,16.66710281,-23.04533005,9.54569244,16.66710281,-25.60660172,10.60660458,11.48050213,-13.85818863,9.25975227,-24.94409180,-24.46478844,16.34685707,5.85270882,-27.18381882,11.25991058,5.85270882,-9.54568291,6.37822866,-27.71638680,-24.94408607,16.66711426,0.00000358,-27.71638489,11.48050785,0.00000358,-9.54568672,6.37823105,27.71638870,-4.86634779,3.25159669,29.42355728,-4.86634254,3.25159264,-29.42355919,-24.46478844,16.34685707,-5.85270500,-27.18381882,11.25991058,-5.85270500,-13.85818958,9.25975323,24.94408607,-15.39839745,6.37822914,24.94408607,-23.04533005,15.39840508,-11.48049831,-25.60660172,10.60660458,-11.48049831,-17.63813210,11.78542995,21.21320534,-19.59844398,8.11794472,21.21320534,-19.59844017,19.59844971,-11.48049831,-20.80558968,20.80560303,-5.85270500,-14.99999523,15.00000477,21.21320534,-11.78542042,11.78543091,24.94408607,-17.63812828,17.63813782,-16.66710663,-17.63812637,17.63813782,16.66710281,-14.99999428,15.00000477,-21.21320343,-19.59844017,19.59844971,11.48050213,-11.78541756,11.78542995,-24.94409180,-20.80558777,20.80560303,5.85270882,-8.11793423,8.11794472,-27.71638680,-21.21319962,21.21320915,0.00000358,-8.11793709,8.11794853,27.71638870,-4.13848686,4.13849735,29.42355728,-4.13848305,4.13849211,-29.42355919,-6.37821770,9.54569435,-27.71638680,-9.25973988,13.85819817,-24.94409180,-16.66710091,24.94409561,0.00000358,-16.34684372,24.46479797,5.85270882,-6.37821913,9.54569721,27.71638870,-3.25158596,4.86635780,29.42355728,-3.25158310,4.86635208,-29.42355919,-16.34684372,24.46479797,-5.85270500,-9.25974178,13.85819912,24.94408607,-15.39839363,23.04533958,-11.48049831,-11.78541756,17.63813972,21.21320534,-13.85818386,20.74025345,-16.66710663,-13.85818291,20.74025345,16.66710281,-11.78541660,17.63813972,-21.21320343,-15.39839363,23.04533958,11.48050213,-9.54567719,23.04533386,16.66710281,-8.11793327,19.59844971,21.21320534,-8.11793232,19.59844971,-21.21320343,-9.54567909,23.04533386,-16.66710663,-10.60659409,25.60660934,11.48050213,-6.37821627,15.39840508,-24.94409180,-11.25989437,27.18382645,5.85270882,-4.39338970,10.60660553,-27.71638680,-11.48049545,27.71639252,0.00000358,-4.39339066,10.60660839,27.71638870,-2.23972821,5.40720701,29.42355728,-2.23972631,5.40719986,-29.42355919,-11.25989437,27.18382645,-5.85270500,-6.37821770,15.39840698,24.94408607,-10.60659409,25.60660934,-11.48049831,-5.74023724,28.85819435,-5.85270500,-5.85270023,29.42356491,0.00000358,-3.25158167,16.34685898,24.94408607,-2.23972559,11.25991631,27.71638870,-5.40718985,27.18382835,-11.48049831,-4.13848162,20.80560493,21.21320534,-4.86633825,24.46479797,-16.66710663,-4.86633682,24.46479797,16.66710281,-4.13847971,20.80560493,-21.21320343,-5.40718985,27.18382835,11.48050213,-3.25158072,16.34685898,-24.94409180,-5.74023724,28.85819435,5.85270882,-2.23972535,11.25991249,-27.71638680,-1.14179850,5.74026012,29.42355728,-1.14179790,5.74025249,-29.42355919,0.00001179,16.66711044,-24.94409180,0.00001201,21.21320724,-21.21320343,0.00001425,29.42355728,5.85270882,0.00001022,27.71639252,11.48050213,0.00001067,11.48050690,-27.71638680,0.00001022,30.00000381,0.00000358,0.00001089,11.48050880,27.71638870,0.00001033,5.85271788,29.42355728,0.00000944,5.85271120,-29.42355919,0.00001425,29.42355728,-5.85270500,0.00001089,16.66711426,24.94408607,0.00001022,27.71639252,-11.48049831,0.00001022,21.21320724,21.21320534,0.00001246,24.94408798,-16.66710663,0.00001425,24.94408798,16.66710281,4.86636257,24.46479416,-16.66710663,5.40721035,27.18382835,-11.48049831,4.86636448,24.46479416,16.66710281,4.13850212,20.80560303,21.21320534,4.13850355,20.80560303,-21.21320343,5.40721035,27.18382835,11.48050213,3.25160384,16.34685707,-24.94409180,5.74026585,28.85818863,5.85270882,2.23974657,11.25991058,-27.71638680,5.85272074,29.42356110,0.00000358,2.23974705,11.25991440,27.71638870,1.14181888,5.74025917,29.42355728,1.14181662,5.74025249,-29.42355919,5.74026585,28.85818863,-5.85270500,3.25160384,16.34685898,24.94408607,2.23974514,5.40719986,-29.42355919,4.39341021,10.60660362,-27.71638680,11.25992203,27.18381882,-5.85270500,11.48051453,27.71638680,0.00000358,6.37823963,15.39840508,24.94408607,4.39341116,10.60660553,27.71638870,10.60661411,25.60660553,-11.48049831,8.11795330,19.59844780,21.21320534,9.54570103,23.04533005,-16.66710663,9.54570293,23.04533005,16.66710281,8.11795425,19.59844780,-21.21320343,10.60661411,25.60660553,11.48050213,6.37823963,15.39840126,-24.94409180,11.25992203,27.18381882,5.85270882,2.23974848,5.40720558,29.42355728,9.25976276,13.85819435,-24.94409180,11.78543854,17.63813782,-21.21320343,16.34686470,24.46478844,5.85270882,15.39840889,23.04533386,11.48050213,6.37823772,9.54569054,-27.71638680,16.66711807,24.94408798,0.00000358,6.37823963,9.54569340,27.71638870,3.25160551,4.86635590,29.42355728,3.25160146,4.86635113,-29.42355919,16.34686470,24.46478844,-5.85270500,9.25976372,13.85819817,24.94408607,15.39840889,23.04533386,-11.48049831,11.78543854,17.63813782,21.21320534,13.85820389,20.74024582,-16.66710663,13.85820484,20.74024582,16.66710281,17.63814163,17.63813019,-16.66710663,19.59845543,19.59844780,-11.48049831,17.63814545,17.63812828,16.66710281,15.00001144,15.00000191,21.21320534,15.00001144,15.00000000,-21.21320343,19.59845543,19.59844780,11.48050213,11.78543854,11.78542328,-24.94409180,20.80560684,20.80559158,5.85270882,8.11795330,8.11794281,-27.71638680,21.21321487,21.21320343,0.00000358,8.11795616,8.11794376,27.71638870,4.13850594,4.13849545,29.42355728,4.13850117,4.13849115,-29.42355919,20.80560684,20.80559158,-5.85270500,11.78544044,11.78542900,24.94408607,4.86636066,3.25159168,-29.42355919,9.54570103,6.37822628,-27.71638680,24.46480179,16.34684753,-5.85270500,24.94409752,16.66710281,0.00000358,13.85820866,9.25974941,24.94408607,9.54570389,6.37822676,27.71638870,23.04534531,15.39840126,-11.48049831,17.63814735,11.78542519,21.21320534,20.74026108,13.85818958,-16.66710663,20.74025917,13.85818672,16.66710281,17.63814545,11.78542328,-21.21320343,23.04534531,15.39840126,11.48050213,13.85820580,9.25974751,-24.94409180,24.46480179,16.34684753,5.85270882,4.86636591,3.25159431,29.42355728,15.39840889,6.37822390,-24.94409180,19.59845352,8.11793995,-21.21320343,27.18382835,11.25990295,5.85270882,25.60661507,10.60660267,11.48050213,10.60661316,4.39339828,-27.71638680,27.71639252,11.48049927,0.00000358,10.60661507,4.39339828,27.71638870,5.40721416,2.23973656,29.42355728,5.40720892,2.23973536,-29.42355919,27.18382835,11.25990295,-5.85270500,15.39841461,6.37822628,24.94408607,25.60661507,10.60660267,-11.48049831,19.59845543,8.11794090,21.21320534,23.04533958,9.54568481,-16.66710663,23.04533768,9.54568291,16.66710281,20.80560875,4.13848925,21.21320534,16.34686661,3.25159049,24.94408607,24.46479988,4.86634684,-16.66710663,27.18383598,5.40719891,-11.48049831,24.46479797,4.86634541,16.66710281,20.80560684,4.13848877,-21.21320343,27.18383598,5.40719891,11.48050213,16.34686470,3.25158882,-24.94409180,28.85820007,5.74024677,5.85270882,11.25991917,2.23973489,-27.71638680,29.42356491,5.85270643,0.00000358,11.25992298,2.23973417,27.71638870,5.74026775,1.14180732,29.42355728,5.74026108,1.14180708,-29.42355919,28.85820007,5.74024677,-5.85270500,30.00000381,-0.00000313,0.00000358,29.42356300,-0.00000447,5.85270882,11.48051643,-0.00000156,27.71638870,5.85272551,-0.00000101,29.42355728,5.85271931,0.00000000,-29.42355919,11.48051453,-0.00000067,-27.71638680,29.42356300,-0.00000447,-5.85270500,16.66711998,-0.00000201,24.94408607,27.71639824,-0.00000134,-11.48049831,21.21321487,-0.00000179,21.21320534,24.94409370,-0.00000313,-16.66710663,24.94409180,-0.00000402,16.66710281,21.21321106,-0.00000179,-21.21320343,27.71639824,-0.00000134,11.48050213,16.66711617,-0.00000291,-24.94409180,20.80560684,-4.13849258,-21.21320343,24.46479797,-4.86635256,-16.66710663,27.18383408,-5.40720034,11.48050213,24.46479797,-4.86635303,16.66710281,16.34686279,-3.25159431,-24.94409180,28.85819626,-5.74025536,5.85270882,11.25991917,-2.23973608,-27.71638680,29.42356110,-5.85271168,0.00000358,11.25992203,-2.23973727,27.71638870,5.74026680,-1.14180923,29.42355728,5.74026108,-1.14180696,-29.42355919,28.85819626,-5.74025536,-5.85270500,16.34686661,-3.25159431,24.94408607,27.18383408,-5.40720034,-11.48049831,20.80560684,-4.13849306,21.21320534,25.60661125,-10.60660362,-11.48049831,27.18382645,-11.25991058,-5.85270500,19.59845352,-8.11794376,21.21320534,15.39840889,-6.37823009,24.94408607,23.04533386,-9.54569054,-16.66710663,23.04533386,-9.54569054,16.66710281,19.59844971,-8.11794376,-21.21320343,25.60661125,-10.60660362,11.48050213,15.39840698,-6.37822866,-24.94409180,27.18382645,-11.25991058,5.85270882,10.60661316,-4.39339924,-27.71638680,27.71638680,-11.48050308,0.00000358,10.60661411,-4.39340115,27.71638870,5.40721321,-2.23973846,29.42355728,5.40720844,-2.23973489,-29.42355919,9.54570007,-6.37822676,-27.71638680,13.85820007,-9.25975037,-24.94409180,24.94408798,-16.66710663,0.00000358,24.46479607,-16.34685516,5.85270882,9.54570103,-6.37822866,27.71638870,4.86636400,-3.25159550,29.42355728,4.86635971,-3.25159097,-29.42355919,24.46479607,-16.34685516,-5.85270500,13.85820389,-9.25975227,24.94408607,23.04534149,-15.39840126,-11.48049831,17.63814163,-11.78542614,21.21320534,20.74025345,-13.85819244,-16.66710663,20.74025154,-13.85819244,16.66710281,17.63813972,-11.78542614,-21.21320343,23.04534149,-15.39840126,11.48050213,13.85820007,-9.25975037,-24.94409180,15.00000763,-15.00000000,-21.21320343,17.63813782,-17.63813210,-16.66710663,19.59845352,-19.59844780,11.48050213,17.63813400,-17.63813210,16.66710281,11.78543091,-11.78542614,-24.94409180,20.80559731,-20.80559731,5.85270882,8.11795139,-8.11794281,-27.71638680,9.54570007,-6.37822676,-27.71638680,21.21320343,-21.21319962,0.00000358,8.11795235,-8.11794472,27.71638870,4.13850307,-4.13849545,29.42355728,4.13849926,-4.13849020,-29.42355919,4.86635971,-3.25159097,-29.42355919,20.80559731,-20.80559731,-5.85270500,11.78543472,-11.78542900,24.94408607,19.59845352,-19.59844780,-11.48049831,15.00000954,-15.00000000,21.21320534,15.39840698,-23.04533386,-11.48049831,16.34685326,-24.46479034,-5.85270500,11.78543186,-17.63813210,21.21320534,9.25975704,-13.85819626,24.94408607,13.85819626,-20.74024582,-16.66710663,13.85819530,-20.74024582,16.66710281,11.78543091,-17.63813210,-21.21320343,15.39840698,-23.04533386,11.48050213,9.25975609,-13.85819340,-24.94409180,16.34685326,-24.46479034,5.85270882,6.37823582,-9.54569054,-27.71638680,16.66710663,-24.94408035,0.00000358,6.37823582,-9.54569340,27.71638870,3.25160289,-4.86635494,29.42355728,3.25160027,-4.86634970,-29.42355919,4.39340830,-10.60660267,-27.71638680,6.37823200,-15.39839935,-24.94409180,11.48050404,-27.71637917,0.00000358,11.25990868,-27.18381882,5.85270882,4.39340734,-10.60660458,27.71638870,2.23974562,-5.40720367,29.42355728,2.23974419,-5.40719748,-29.42355919,11.25990868,-27.18381882,-5.85270500,6.37823343,-15.39840126,24.94408607,10.60660839,-25.60660362,-11.48049831,8.11795044,-19.59844398,21.21320534,9.54569435,-23.04532814,-16.66710663,9.54569244,-23.04532623,16.66710281,8.11794758,-19.59844398,-21.21320343,10.60660839,-25.60660362,11.48050213,4.13849735,-20.80559731,-21.21320343,4.86635590,-24.46478844,-16.66710663,5.40720463,-27.18382645,11.48050213,4.86635447,-24.46478653,16.66710281,3.25159764,-16.34685135,-24.94409180,5.74025345,-28.85818481,5.85270882,2.23974466,-11.25990868,-27.71638680,5.85271311,-29.42354965,0.00000358,2.23974323,-11.25991058,27.71638870,1.14181626,-5.74025631,29.42355728,1.14181614,-5.74025059,-29.42355919,5.74025345,-28.85818481,-5.85270500,3.25159836,-16.34685516,24.94408607,5.40720463,-27.18382645,-11.48049831,4.13849926,-20.80559731,21.21320534,0.00000687,-16.66710663,24.94408607,0.00000754,-11.48050499,27.71638870,0.00000530,-27.71638680,-11.48049831,0.00000307,-29.42354965,-5.85270500,0.00000843,-21.21320343,21.21320534,0.00000665,-24.94408035,-16.66710663,0.00000620,-24.94407845,16.66710281,0.00000665,-21.21320343,-21.21320343,0.00000530,-27.71638680,11.48050213,0.00000642,-16.66710281,-24.94409180,0.00000307,-29.42354965,5.85270882,0.00000933,-11.48050308,-27.71638680,0.00000486,-29.99998856,0.00000358,0.00000832,-5.85271358,29.42355728,0.00000944,-5.85270786,-29.42355919,-5.74024677,-28.85818100,5.85270882,-5.40719318,-27.18382263,11.48050213,-2.23972583,-11.25990868,-27.71638680,-3.25158405,-16.34685135,-24.94409180,-5.85270309,-29.42354202,0.00000358,-2.23972797,-11.25991058,27.71638870,-1.14179957,-5.74025536,29.42355728,-1.14179730,-5.74024963,-29.42355919,-5.74024677,-28.85818100,-5.85270500,-3.25158453,-16.34685326,24.94408607,-5.40719318,-27.18382263,-11.48049831,-4.13848162,-20.80559540,21.21320534,-4.86634207,-24.46478653,-16.66710663,-4.86634207,-24.46478271,16.66710281,-4.13848352,-20.80559540,-21.21320343,-9.54567909,-23.04532242,-16.66710663,-10.60659599,-25.60660172,-11.48049831,-9.54567909,-23.04532051,16.66710281,-8.11793232,-19.59844208,21.21320534,-8.11793327,-19.59844017,-21.21320343,-10.60659599,-25.60660172,11.48050213,-6.37821770,-15.39839363,-24.94409180,-11.25990009,-27.18380928,5.85270882,-4.39338923,-10.60660267,-27.71638680,-11.48049355,-27.71636963,0.00000358,-4.39339113,-10.60660362,27.71638870,-2.23972821,-5.40720177,29.42355728,-2.23972464,-5.40719604,-29.42355919,-11.25990009,-27.18380928,-5.85270500,-6.37821913,-15.39839745,24.94408607,-3.25158024,-4.86634779,-29.42355919,-6.37821674,-9.54568958,-27.71638680,-16.34684372,-24.46478081,-5.85270500,-16.66709518,-24.94406891,0.00000358,-9.25974083,-13.85819054,24.94408607,-6.37821913,-9.54569054,27.71638870,-15.39839363,-23.04533005,-11.48049831,-11.78541374,-17.63813210,21.21320534,-13.85818005,-20.74024200,-16.66710663,-13.85817909,-20.74024010,16.66710281,-11.78541660,-17.63813019,-21.21320343,-15.39839363,-23.04533005,11.48050213,-9.25973892,-13.85818672,-24.94409180,-16.34684372,-24.46478081,5.85270882,-3.25158477,-4.86635256,29.42355728,-11.78541374,-11.78541756,-24.94409180,-14.99999046,-14.99999523,-21.21320343,-20.80558395,-20.80558395,5.85270882,-19.59843826,-19.59844208,11.48050213,-8.11793232,-8.11794090,-27.71638680,-21.21318817,-21.21318626,0.00000358,-8.11793423,-8.11794186,27.71638870,-4.13848448,-4.13849211,29.42355728,-4.13847923,-4.13848829,-29.42355919,-20.80558395,-20.80558395,-5.85270500,-11.78541660,-11.78542137,24.94408607,-19.59843826,-19.59844208,-11.48049831,-14.99999046,-14.99999809,21.21320534,-17.63811874,-17.63812447,-16.66710663,-17.63811874,-17.63812256,16.66710281,-20.74023438,-13.85818481,-16.66710663,-23.04532623,-15.39839554,-11.48049831,-20.74023438,-13.85818291,16.66710281,-17.63812447,-11.78542233,21.21320534,-17.63812447,-11.78541946,-21.21320343,-23.04532623,-15.39839554,11.48050213,-13.85818291,-9.25974178,-24.94409180,-24.46477699,-16.34683990,5.85270882,-9.54568005,-6.37822533,-27.71638680,-24.94406700,-16.66708946,0.00000358,-9.54568291,-6.37822580,27.71638870,-4.86634350,-3.25159192,29.42355728,-4.86633825,-3.25158954,-29.42355919,-24.46477699,-16.34683990,-5.85270500,-13.85818386,-9.25974560,24.94408607,-5.40718555,-2.23973346,-29.42355919,-10.60659313,-4.39339733,-27.71638680,-27.18380356,-11.25989723,-5.85270500,-27.71636200,-11.48048782,0.00000358,-15.39838982,-6.37822247,24.94408607,-10.60659409,-4.39339733,27.71638870,-25.60659409,-10.60659599,-11.48049831,-19.59843445,-8.11793995,21.21320534,-23.04531288,-9.54568100,-16.66710663,-23.04531288,-9.54568005,16.66710281,-19.59843445,-8.11793613,-21.21320343,-25.60659409,-10.60659599,11.48050213,-15.39838696,-6.37821913,-24.94409180,-27.18380356,-11.25989723,5.85270882,-5.40719223,-2.23973489,29.42355728,-16.34683800,-3.25158548,-24.94409180,-20.80558586,-4.13848591,-21.21320343,-28.85816956,-5.74024248,5.85270882,-27.18381500,-5.40719318,11.48050213,-11.25989914,-2.23973393,-27.71638680,-29.42353058,-5.85269690,0.00000358,-11.25990105,-2.23973370,27.71638870,-5.74024439,-1.14180589,29.42355728,-5.74023771,-1.14180613,-29.42355919,-28.85816956,-5.74024248,-5.85270500,-16.34684372,-3.25158787,24.94408607,-27.18381500,-5.40719318,-11.48049831,-20.80558777,-4.13848925,21.21320534,-24.46477509,-4.86634493,-16.66710663,-24.46477509,-4.86634302,16.66710281,0.00000603,-0.00000903,30.00000000,-5.85270309,0.00000000,-29.42355919,0.00000978,0.00000000,-30.00000000,4.13849926,-4.13849020,-29.42355919,3.25160027,-4.86634970,-29.42355919,2.23974419,-5.40719748,-29.42355919,1.14181614,-5.74025059,-29.42355919,0.00000944,-5.85270786,-29.42355919,-1.14179730,-5.74024963,-29.42355919,-2.23972464,-5.40719604,-29.42355919,-3.25158024,-4.86634779,-29.42355919,-4.13847923,-4.13848829,-29.42355919,-4.86633825,-3.25158954,-29.42355919,-5.40718555,-2.23973346,-29.42355919,-5.74023771,-1.14180613,-29.42355919};
unsigned int bufPosLen = sizeof(posElems) / sizeof(posElems[0]);
unsigned int compCount = 3;
unsigned int elemCount = bufPosLen / compCount;
csRefbufPos = csRenderBuffer::CreateRenderBuffer((size_t) elemCount, CS_BUF_STATIC, CS_BUFCOMP_FLOAT, compCount);
bufPos->CopyInto(posElems, elemCount); //this is the only available method to copy apparently the data from memory/pointer and into the buffer....
state->AddRenderBuffer("position", bufPos);//renderbuffers: normal
//TO DO TO CHANGE retrieve the contents of the buffer from SMGData
const float normElems[] = {-0.81731617,0.16257210,0.55275124,-0.69649345,0.13852352,0.70403147,-0.71013522,0.00000000,0.70403147,-0.83333844,0.00000000,0.55275124,-0.69649345,0.13852352,-0.70403147,-0.81731617,0.16257210,-0.55275124,-0.83333844,0.00000000,-0.55275124,-0.71013522,0.00000000,-0.70403147,-0.90697956,0.18039490,0.38053530,-0.92474133,0.00000000,0.38053530,-0.54899746,0.10919522,-0.82863855,-0.55977052,0.00000000,-0.82863855,-0.96215707,0.19138157,0.19391461,-0.98098695,0.00000000,0.19391461,-0.38041323,0.07565539,-0.92168951,-0.38785973,0.00000000,-0.92168951,-0.98077333,0.19507432,0.00000000,-1.00000000,0.00000000,0.00000000,-0.38041323,0.07565539,0.92168951,-0.19708854,0.03918577,0.97958314,-0.20096439,0.00000000,0.97958314,-0.38785973,0.00000000,0.92168951,-0.19708854,0.03918577,-0.97958314,-0.20096439,0.00000000,-0.97958314,-0.96215707,0.19138157,-0.19391461,-0.98098695,0.00000000,-0.19391461,-0.54899746,0.10919522,0.82863855,-0.55977052,0.00000000,0.82863855,-0.90697956,0.18039490,-0.38053530,-0.92474133,0.00000000,-0.38053530,-0.35834834,0.14841151,-0.92168951,-0.51713616,0.21420942,-0.82863855,-0.54899746,0.10919522,-0.82863855,-0.38041323,0.07565539,-0.92168951,-0.92385632,0.38267159,0.00000000,-0.90633869,0.37540817,0.19391461,-0.35834834,0.14841151,0.92168951,-0.18564409,0.07690664,0.97958314,-0.18564409,0.07690664,-0.97958314,-0.19708854,0.03918577,-0.97958314,-0.90633869,0.37540817,-0.19391461,-0.51713616,0.21420942,0.82863855,-0.85436565,0.35389262,-0.38053530,-0.65605640,0.27173680,0.70403147,-0.76989043,0.31888792,-0.55275124,-0.76989043,0.31888792,0.55275124,-0.65605640,0.27173680,-0.70403147,-0.85436565,0.35386211,0.38053530,-0.51713616,0.21420942,-0.82863855,-0.59044158,0.39451277,-0.70403147,-0.69289225,0.46296579,-0.55275124,-0.76989043,0.31888792,-0.55275124,-0.65605640,0.27173680,-0.70403147,-0.76891387,0.51374859,0.38053530,-0.69289225,0.46296579,0.55275124,-0.76989043,0.31888792,0.55275124,-0.85436565,0.35386211,0.38053530,-0.46540728,0.31098360,-0.82863855,-0.81566823,0.54499954,0.19391461,-0.90633869,0.37540817,0.19391461,-0.32248908,0.21549119,-0.92168951,-0.83144629,0.55555892,0.00000000,-0.92385632,0.38267159,0.00000000,-0.32248908,0.21549119,0.92168951,-0.16708884,0.11163671,0.97958314,-0.16708884,0.11163671,-0.97958314,-0.81566823,0.54499954,-0.19391461,-0.90633869,0.37540817,-0.19391461,-0.46540728,0.31098360,0.82863855,-0.51713616,0.21420942,0.82863855,-0.76891387,0.51374859,-0.38053530,-0.85436565,0.35389262,-0.38053530,-0.59044158,0.39451277,0.70403147,-0.65605640,0.27173680,0.70403147,-0.65388960,0.65388960,-0.38053530,-0.69365519,0.69365519,-0.19391461,-0.50212103,0.50212103,0.70403147,-0.39579454,0.39579454,0.82863855,-0.58925140,0.58925140,-0.55275124,-0.58925140,0.58925140,0.55275124,-0.50212103,0.50212103,-0.70403147,-0.65388960,0.65388960,0.38053530,-0.39579454,0.39579454,-0.82863855,-0.69365519,0.69365519,0.19391461,-0.27426985,0.27426985,-0.92168951,-0.70708334,0.70708334,0.00000000,-0.27426985,0.27426985,0.92168951,-0.14209418,0.14209418,0.97958314,-0.14209418,0.14209418,-0.97958314,-0.21549119,0.32248908,-0.92168951,-0.31098360,0.46540728,-0.82863855,-0.55555892,0.83144629,0.00000000,-0.54499954,0.81566823,0.19391461,-0.21549119,0.32248908,0.92168951,-0.11163671,0.16708884,0.97958314,-0.11163671,0.16708884,-0.97958314,-0.54499954,0.81566823,-0.19391461,-0.31098360,0.46540728,0.82863855,-0.51374859,0.76891387,-0.38053530,-0.39451277,0.59044158,0.70403147,-0.46296579,0.69289225,-0.55275124,-0.46296579,0.69289225,0.55275124,-0.39451277,0.59044158,-0.70403147,-0.51374859,0.76891387,0.38053530,-0.31888792,0.76989043,0.55275124,-0.27173680,0.65605640,0.70403147,-0.27173680,0.65605640,-0.70403147,-0.31888792,0.76989043,-0.55275124,-0.35386211,0.85436565,0.38053530,-0.21420942,0.51713616,-0.82863855,-0.37540817,0.90633869,0.19391461,-0.14841151,0.35834834,-0.92168951,-0.38267159,0.92385632,0.00000000,-0.14841151,0.35834834,0.92168951,-0.07690664,0.18564409,0.97958314,-0.07690664,0.18564409,-0.97958314,-0.37540817,0.90633869,-0.19391461,-0.21420942,0.51713616,0.82863855,-0.35386211,0.85436565,-0.38053530,-0.19138157,0.96215707,-0.19391461,-0.19507432,0.98077333,0.00000000,-0.10919522,0.54899746,0.82863855,-0.07565539,0.38041323,0.92168951,-0.18039490,0.90697956,-0.38053530,-0.13852352,0.69649345,0.70403147,-0.16257210,0.81731617,-0.55275124,-0.16257210,0.81731617,0.55275124,-0.13852352,0.69649345,-0.70403147,-0.18039490,0.90697956,0.38053530,-0.10919522,0.54899746,-0.82863855,-0.19138157,0.96215707,0.19391461,-0.07565539,0.38041323,-0.92168951,-0.03918577,0.19708854,0.97958314,-0.03918577,0.19708854,-0.97958314,0.00000000,0.55977052,-0.82863855,0.00000000,0.71013522,-0.70403147,0.00000000,0.98098695,0.19391461,0.00000000,0.92474133,0.38053530,0.00000000,0.38785973,-0.92168951,0.00000000,1.00000000,0.00000000,0.00000000,0.38785973,0.92168951,0.00000000,0.20096439,0.97958314,0.00000000,0.20096439,-0.97958314,0.00000000,0.98098695,-0.19391461,0.00000000,0.55977052,0.82863855,0.00000000,0.92474133,-0.38053530,0.00000000,0.71013522,0.70403147,0.00000000,0.83333844,-0.55275124,0.00000000,0.83333844,0.55275124,0.16257210,0.81731617,-0.55275124,0.18039490,0.90697956,-0.38053530,0.16257210,0.81731617,0.55275124,0.13852352,0.69649345,0.70403147,0.13852352,0.69649345,-0.70403147,0.18039490,0.90697956,0.38053530,0.10919522,0.54899746,-0.82863855,0.19138157,0.96215707,0.19391461,0.07565539,0.38041323,-0.92168951,0.19507432,0.98077333,0.00000000,0.07565539,0.38041323,0.92168951,0.03918577,0.19708854,0.97958314,0.03918577,0.19708854,-0.97958314,0.19138157,0.96215707,-0.19391461,0.10919522,0.54899746,0.82863855,0.07690664,0.18564409,-0.97958314,0.14841151,0.35834834,-0.92168951,0.37540817,0.90633869,-0.19391461,0.38267159,0.92385632,0.00000000,0.21420942,0.51713616,0.82863855,0.14841151,0.35834834,0.92168951,0.35389262,0.85436565,-0.38053530,0.27173680,0.65605640,0.70403147,0.31888792,0.76989043,-0.55275124,0.31888792,0.76989043,0.55275124,0.27173680,0.65605640,-0.70403147,0.35389262,0.85436565,0.38053530,0.21420942,0.51713616,-0.82863855,0.37540817,0.90633869,0.19391461,0.07687613,0.18564409,0.97958314,0.31098360,0.46540728,-0.82863855,0.39451277,0.59044158,-0.70403147,0.54499954,0.81566823,0.19391461,0.51374859,0.76891387,0.38053530,0.21549119,0.32248908,-0.92168951,0.55555892,0.83144629,0.00000000,0.21549119,0.32248908,0.92168951,0.11163671,0.16708884,0.97958314,0.11163671,0.16708884,-0.97958314,0.54499954,0.81566823,-0.19391461,0.31098360,0.46540728,0.82863855,0.51374859,0.76891387,-0.38053530,0.39451277,0.59044158,0.70403147,0.46296579,0.69289225,-0.55275124,0.46296579,0.69289225,0.55275124,0.58925140,0.58925140,-0.55275124,0.65388960,0.65388960,-0.38053530,0.58925140,0.58925140,0.55275124,0.50212103,0.50212103,0.70403147,0.50212103,0.50212103,-0.70403147,0.65388960,0.65388960,0.38053530,0.39579454,0.39579454,-0.82863855,0.69365519,0.69365519,0.19391461,0.27426985,0.27426985,-0.92168951,0.70708334,0.70708334,0.00000000,0.27426985,0.27426985,0.92168951,0.14209418,0.14209418,0.97958314,0.14209418,0.14209418,-0.97958314,0.69365519,0.69365519,-0.19391461,0.39579454,0.39579454,0.82863855,0.16708884,0.11163671,-0.97958314,0.32248908,0.21549119,-0.92168951,0.81566823,0.54499954,-0.19391461,0.83144629,0.55555892,0.00000000,0.46540728,0.31098360,0.82863855,0.32248908,0.21549119,0.92168951,0.76891387,0.51374859,-0.38053530,0.59044158,0.39451277,0.70403147,0.69289225,0.46296579,-0.55275124,0.69289225,0.46296579,0.55275124,0.59044158,0.39451277,-0.70403147,0.76891387,0.51374859,0.38053530,0.46540728,0.31098360,-0.82863855,0.81566823,0.54499954,0.19391461,0.16708884,0.11163671,0.97958314,0.51713616,0.21420942,-0.82863855,0.65605640,0.27173680,-0.70403147,0.90633869,0.37540817,0.19391461,0.85436565,0.35386211,0.38053530,0.35834834,0.14841151,-0.92168951,0.92385632,0.38267159,0.00000000,0.35834834,0.14841151,0.92168951,0.18564409,0.07690664,0.97958314,0.18564409,0.07690664,-0.97958314,0.90633869,0.37540817,-0.19391461,0.51713616,0.21420942,0.82863855,0.85436565,0.35386211,-0.38053530,0.65605640,0.27173680,0.70403147,0.76989043,0.31888792,-0.55275124,0.76989043,0.31888792,0.55275124,0.69649345,0.13852352,0.70403147,0.54899746,0.10919522,0.82863855,0.81731617,0.16257210,-0.55275124,0.90697956,0.18039490,-0.38053530,0.81731617,0.16257210,0.55275124,0.69649345,0.13852352,-0.70403147,0.90697956,0.18039490,0.38053530,0.54899746,0.10919522,-0.82863855,0.96215707,0.19138157,0.19391461,0.38041323,0.07565539,-0.92168951,0.98077333,0.19507432,0.00000000,0.38041323,0.07565539,0.92168951,0.19708854,0.03918577,0.97958314,0.19708854,0.03918577,-0.97958314,0.96215707,0.19138157,-0.19391461,1.00000000,0.00000000,0.00000000,0.98098695,0.00000000,0.19391461,0.38785973,0.00000000,0.92168951,0.20096439,0.00000000,0.97958314,0.20096439,0.00000000,-0.97958314,0.38785973,0.00000000,-0.92168951,0.98098695,0.00000000,-0.19391461,0.55977052,0.00000000,0.82863855,0.92474133,0.00000000,-0.38053530,0.71013522,0.00000000,0.70403147,0.83333844,0.00000000,-0.55275124,0.83333844,0.00000000,0.55275124,0.71013522,0.00000000,-0.70403147,0.92474133,0.00000000,0.38053530,0.55977052,0.00000000,-0.82863855,0.69649345,-0.13852352,-0.70403147,0.81731617,-0.16257210,-0.55275124,0.90697956,-0.18039490,0.38053530,0.81731617,-0.16257210,0.55275124,0.54899746,-0.10919522,-0.82863855,0.96215707,-0.19138157,0.19391461,0.38041323,-0.07565539,-0.92168951,0.98077333,-0.19507432,0.00000000,0.38041323,-0.07565539,0.92168951,0.19708854,-0.03918577,0.97958314,0.19708854,-0.03918577,-0.97958314,0.96215707,-0.19138157,-0.19391461,0.54899746,-0.10919522,0.82863855,0.90697956,-0.18039490,-0.38053530,0.69649345,-0.13852352,0.70403147,0.85436565,-0.35386211,-0.38053530,0.90633869,-0.37540817,-0.19391461,0.65605640,-0.27173680,0.70403147,0.51713616,-0.21420942,0.82863855,0.76989043,-0.31888792,-0.55275124,0.76989043,-0.31888792,0.55275124,0.65605640,-0.27173680,-0.70403147,0.85436565,-0.35386211,0.38053530,0.51713616,-0.21420942,-0.82863855,0.90633869,-0.37540817,0.19391461,0.35834834,-0.14841151,-0.92168951,0.92385632,-0.38267159,0.00000000,0.35834834,-0.14841151,0.92168951,0.18564409,-0.07690664,0.97958314,0.18564409,-0.07690664,-0.97958314,0.32248908,-0.21549119,-0.92168951,0.46540728,-0.31098360,-0.82863855,0.83144629,-0.55555892,0.00000000,0.81566823,-0.54499954,0.19391461,0.32248908,-0.21549119,0.92168951,0.16708884,-0.11163671,0.97958314,0.16708884,-0.11163671,-0.97958314,0.81566823,-0.54499954,-0.19391461,0.46540728,-0.31098360,0.82863855,0.76891387,-0.51374859,-0.38053530,0.59044158,-0.39451277,0.70403147,0.69289225,-0.46296579,-0.55275124,0.69289225,-0.46296579,0.55275124,0.59044158,-0.39451277,-0.70403147,0.76891387,-0.51374859,0.38053530,0.46540728,-0.31098360,-0.82863855,0.50212103,-0.50212103,-0.70403147,0.58925140,-0.58925140,-0.55275124,0.65388960,-0.65388960,0.38053530,0.58925140,-0.58925140,0.55275124,0.39579454,-0.39579454,-0.82863855,0.69365519,-0.69365519,0.19391461,0.27426985,-0.27426985,-0.92168951,0.32248908,-0.21549119,-0.92168951,0.70708334,-0.70708334,0.00000000,0.27426985,-0.27426985,0.92168951,0.14209418,-0.14209418,0.97958314,0.14209418,-0.14209418,-0.97958314,0.16708884,-0.11163671,-0.97958314,0.69365519,-0.69365519,-0.19391461,0.39579454,-0.39579454,0.82863855,0.65388960,-0.65388960,-0.38053530,0.50212103,-0.50212103,0.70403147,0.51374859,-0.76891387,-0.38053530,0.54499954,-0.81566823,-0.19391461,0.39451277,-0.59044158,0.70403147,0.31098360,-0.46540728,0.82863855,0.46296579,-0.69289225,-0.55275124,0.46296579,-0.69289225,0.55275124,0.39451277,-0.59044158,-0.70403147,0.51374859,-0.76891387,0.38053530,0.31098360,-0.46540728,-0.82863855,0.54499954,-0.81566823,0.19391461,0.21549119,-0.32248908,-0.92168951,0.55555892,-0.83144629,0.00000000,0.21549119,-0.32248908,0.92168951,0.11163671,-0.16708884,0.97958314,0.11163671,-0.16708884,-0.97958314,0.14841151,-0.35834834,-0.92168951,0.21420942,-0.51713616,-0.82863855,0.38267159,-0.92385632,0.00000000,0.37540817,-0.90633869,0.19391461,0.14841151,-0.35834834,0.92168951,0.07687613,-0.18564409,0.97958314,0.07690664,-0.18564409,-0.97958314,0.37540817,-0.90633869,-0.19391461,0.21420942,-0.51713616,0.82863855,0.35386211,-0.85436565,-0.38053530,0.27173680,-0.65605640,0.70403147,0.31888792,-0.76989043,-0.55275124,0.31888792,-0.76989043,0.55275124,0.27173680,-0.65605640,-0.70403147,0.35386211,-0.85436565,0.38053530,0.13852352,-0.69649345,-0.70403147,0.16257210,-0.81731617,-0.55275124,0.18039490,-0.90697956,0.38053530,0.16257210,-0.81731617,0.55275124,0.10919522,-0.54899746,-0.82863855,0.19138157,-0.96215707,0.19391461,0.07565539,-0.38041323,-0.92168951,0.19507432,-0.98077333,0.00000000,0.07565539,-0.38041323,0.92168951,0.03918577,-0.19708854,0.97958314,0.03918577,-0.19708854,-0.97958314,0.19138157,-0.96215707,-0.19391461,0.10919522,-0.54899746,0.82863855,0.18039490,-0.90697956,-0.38053530,0.13852352,-0.69649345,0.70403147,0.00000000,-0.55977052,0.82863855,0.00000000,-0.38785973,0.92168951,0.00000000,-0.92474133,-0.38053530,0.00000000,-0.98098695,-0.19391461,0.00000000,-0.71013522,0.70403147,0.00000000,-0.83333844,-0.55275124,0.00000000,-0.83333844,0.55275124,0.00000000,-0.71013522,-0.70403147,0.00000000,-0.92474133,0.38053530,0.00000000,-0.55977052,-0.82863855,0.00000000,-0.98098695,0.19391461,0.00000000,-0.38785973,-0.92168951,0.00000000,-0.99996948,0.00000000,0.00000000,-0.20096439,0.97958314,0.00000000,-0.20096439,-0.97958314,-0.19138157,-0.96215707,0.19391461,-0.18039490,-0.90697956,0.38053530,-0.07565539,-0.38041323,-0.92168951,-0.10919522,-0.54899746,-0.82863855,-0.19507432,-0.98077333,0.00000000,-0.07565539,-0.38041323,0.92168951,-0.03918577,-0.19708854,0.97958314,-0.03918577,-0.19708854,-0.97958314,-0.19138157,-0.96215707,-0.19391461,-0.10919522,-0.54899746,0.82863855,-0.18039490,-0.90697956,-0.38053530,-0.13852352,-0.69649345,0.70403147,-0.16257210,-0.81731617,-0.55275124,-0.16257210,-0.81731617,0.55275124,-0.13852352,-0.69649345,-0.70403147,-0.31888792,-0.76989043,-0.55275124,-0.35389262,-0.85436565,-0.38053530,-0.31888792,-0.76989043,0.55275124,-0.27173680,-0.65605640,0.70403147,-0.27173680,-0.65605640,-0.70403147,-0.35389262,-0.85436565,0.38053530,-0.21420942,-0.51713616,-0.82863855,-0.37540817,-0.90633869,0.19391461,-0.14841151,-0.35834834,-0.92168951,-0.38267159,-0.92385632,0.00000000,-0.14841151,-0.35834834,0.92168951,-0.07690664,-0.18564409,0.97958314,-0.07690664,-0.18564409,-0.97958314,-0.37540817,-0.90633869,-0.19391461,-0.21420942,-0.51713616,0.82863855,-0.11163671,-0.16708884,-0.97958314,-0.21549119,-0.32248908,-0.92168951,-0.54499954,-0.81566823,-0.19391461,-0.55555892,-0.83144629,0.00000000,-0.31098360,-0.46540728,0.82863855,-0.21549119,-0.32248908,0.92168951,-0.51374859,-0.76891387,-0.38053530,-0.39451277,-0.59044158,0.70403147,-0.46296579,-0.69289225,-0.55275124,-0.46296579,-0.69289225,0.55275124,-0.39451277,-0.59044158,-0.70403147,-0.51374859,-0.76891387,0.38053530,-0.31098360,-0.46540728,-0.82863855,-0.54499954,-0.81566823,0.19391461,-0.11163671,-0.16708884,0.97958314,-0.39579454,-0.39579454,-0.82863855,-0.50212103,-0.50212103,-0.70403147,-0.69365519,-0.69365519,0.19391461,-0.65388960,-0.65388960,0.38053530,-0.27426985,-0.27426985,-0.92168951,-0.70708334,-0.70708334,0.00000000,-0.27426985,-0.27426985,0.92168951,-0.14209418,-0.14209418,0.97958314,-0.14209418,-0.14209418,-0.97958314,-0.69365519,-0.69365519,-0.19391461,-0.39579454,-0.39579454,0.82863855,-0.65388960,-0.65388960,-0.38053530,-0.50212103,-0.50212103,0.70403147,-0.58925140,-0.58925140,-0.55275124,-0.58925140,-0.58925140,0.55275124,-0.69289225,-0.46296579,-0.55275124,-0.76891387,-0.51374859,-0.38053530,-0.69289225,-0.46296579,0.55275124,-0.59044158,-0.39451277,0.70403147,-0.59044158,-0.39451277,-0.70403147,-0.76891387,-0.51374859,0.38053530,-0.46540728,-0.31098360,-0.82863855,-0.81566823,-0.54499954,0.19391461,-0.32248908,-0.21549119,-0.92168951,-0.83144629,-0.55555892,0.00000000,-0.32248908,-0.21549119,0.92168951,-0.16708884,-0.11163671,0.97958314,-0.16708884,-0.11163671,-0.97958314,-0.81566823,-0.54499954,-0.19391461,-0.46540728,-0.31098360,0.82863855,-0.18564409,-0.07690664,-0.97958314,-0.35834834,-0.14841151,-0.92168951,-0.90633869,-0.37540817,-0.19391461,-0.92385632,-0.38267159,0.00000000,-0.51713616,-0.21420942,0.82863855,-0.35834834,-0.14841151,0.92168951,-0.85436565,-0.35386211,-0.38053530,-0.65605640,-0.27173680,0.70403147,-0.76989043,-0.31888792,-0.55275124,-0.76989043,-0.31888792,0.55275124,-0.65605640,-0.27173680,-0.70403147,-0.85436565,-0.35386211,0.38053530,-0.51713616,-0.21420942,-0.82863855,-0.90633869,-0.37540817,0.19391461,-0.18564409,-0.07690664,0.97958314,-0.54899746,-0.10919522,-0.82863855,-0.69649345,-0.13852352,-0.70403147,-0.96215707,-0.19138157,0.19391461,-0.90697956,-0.18039490,0.38053530,-0.38041323,-0.07565539,-0.92168951,-0.98077333,-0.19507432,0.00000000,-0.38041323,-0.07565539,0.92168951,-0.19708854,-0.03918577,0.97958314,-0.19708854,-0.03918577,-0.97958314,-0.96215707,-0.19138157,-0.19391461,-0.54899746,-0.10919522,0.82863855,-0.90697956,-0.18039490,-0.38053530,-0.69649345,-0.13852352,0.70403147,-0.81731617,-0.16257210,-0.55275124,-0.81731617,-0.16257210,0.55275124,0.00000000,0.00000000,1.00000000,-0.20096439,0.00000000,-0.97958314,0.00000000,0.00000000,-1.00000000,0.14209418,-0.14209418,-0.97958314,0.11163671,-0.16708884,-0.97958314,0.07690664,-0.18564409,-0.97958314,0.03918577,-0.19708854,-0.97958314,0.00000000,-0.20096439,-0.97958314,-0.03918577,-0.19708854,-0.97958314,-0.07690664,-0.18564409,-0.97958314,-0.11163671,-0.16708884,-0.97958314,-0.14209418,-0.14209418,-0.97958314,-0.16708884,-0.11163671,-0.97958314,-0.18564409,-0.07690664,-0.97958314,-0.19708854,-0.03918577,-0.97958314};
unsigned int bufNormLen = sizeof(normElems) / sizeof(normElems[0]);
compCount = 3;
elemCount = bufNormLen / compCount;
csRefbufNormal = csRenderBuffer::CreateRenderBuffer((size_t) elemCount, CS_BUF_STATIC, CS_BUFCOMP_FLOAT, compCount);
bufNormal->CopyInto(normElems, elemCount); //this is the only available method to copy apparently the data from memory/pointer and into the buffer....
state->AddRenderBuffer("normal", bufNormal);//renderbuffers: texture coordinate
//TO DO TO CHANGE retrieve the contents of the buffer from SMGData
const float texElems[] = {0.061220,0.172764,0.080647,0.112472,0.135028,0.130630,0.107782,0.187599,0.025234,0.606227,0.028936,0.544141,0.054891,0.552189,0.048386,0.613417,0.051220,0.234138,0.092315,0.247027,0.020989,0.668252,0.040867,0.674443,0.044778,0.295915,0.081872,0.307471,0.015638,0.730152,0.031336,0.735069,0.039986,0.357878,0.073887,0.368405,0.356456,0.039893,0.466638,0.087931,0.448527,0.094534,0.333915,0.062714,0.008043,0.791799,0.017784,0.794887,0.036021,0.419934,0.067156,0.429587,0.138246,0.056841,0.196016,0.081502,0.032439,0.482033,0.060989,0.490881,0.999822,0.727971,1.001015,0.665501,1.020989,0.668252,1.015638,0.730152,0.005301,0.353109,0.006404,0.290637,0.447682,0.023355,0.488610,0.084811,0.998129,0.790429,1.008043,0.791799,0.004397,0.415586,0.034176,0.041338,0.003585,0.478066,0.015221,0.103359,0.002796,0.540546,0.010297,0.165735,0.001965,0.603025,0.007907,0.228175,0.001015,0.665501,0.978668,0.603891,0.976612,0.541519,1.002796,0.540546,1.001965,0.603025,0.964040,0.229802,0.958226,0.167665,1.010297,0.165735,1.007907,0.228175,0.981020,0.666245,0.967719,0.292073,1.006404,0.290637,0.983979,0.728561,0.970429,0.354404,1.005301,0.353109,0.595877,0.028785,0.511577,0.085667,0.988176,0.790799,0.972657,0.416765,1.004397,0.415586,0.904978,0.046051,1.034176,0.041338,0.974661,0.479141,1.003585,0.478066,0.946455,0.105901,1.015221,0.103359,0.945911,0.485214,0.941200,0.423411,0.885287,0.119299,0.823807,0.066742,0.950535,0.547029,0.908873,0.178221,0.955439,0.608804,0.921503,0.238833,0.961079,0.670468,0.929787,0.300102,0.968202,0.731911,0.936013,0.361679,0.647807,0.049313,0.532175,0.090357,0.978319,0.792904,0.952583,0.737970,0.941260,0.678089,0.902582,0.374475,0.893448,0.314080,0.659037,0.072825,0.548166,0.098187,0.968695,0.796706,0.910362,0.435188,0.777305,0.092963,0.917545,0.496040,0.835902,0.140195,0.924693,0.556900,0.864639,0.195793,0.932358,0.617639,0.881675,0.254305,0.825891,0.218332,0.796385,0.165337,0.909472,0.630184,0.899158,0.570827,0.845097,0.274835,0.921611,0.688967,0.859136,0.333015,0.937209,0.746646,0.870446,0.392059,0.657607,0.096698,0.558962,0.108237,0.959449,0.802140,0.880347,0.451545,0.745300,0.120662,0.889690,0.511206,0.851201,0.471783,0.839664,0.413538,0.719784,0.148411,0.650899,0.120164,0.862365,0.530171,0.763610,0.192518,0.873929,0.588406,0.791803,0.243985,0.886774,0.646148,0.811613,0.298972,0.902153,0.702905,0.826879,0.355773,0.922167,0.757809,0.565047,0.119643,0.950742,0.809109,0.882867,0.719668,0.864196,0.665186,0.796418,0.381227,0.780693,0.325402,0.907539,0.771302,0.810089,0.437969,0.641452,0.142821,0.567268,0.131697,0.942759,0.817485,0.822818,0.495127,0.697492,0.175520,0.835477,0.552316,0.735147,0.220347,0.848920,0.609159,0.761226,0.271289,0.823944,0.632559,0.808822,0.576971,0.733105,0.299125,0.709376,0.247895,0.841590,0.686906,0.751695,0.353000,0.863688,0.738990,0.767340,0.408333,0.893414,0.786940,0.781429,0.464419,0.630338,0.164376,0.566457,0.143852,0.935719,0.827110,0.794966,0.520772,0.676891,0.201534,0.929896,0.837788,0.879896,0.804521,0.767315,0.547906,0.753309,0.491989,0.657173,0.226088,0.618082,0.184573,0.782092,0.603438,0.685241,0.274482,0.798714,0.658036,0.706593,0.326609,0.818709,0.710884,0.723996,0.380807,0.844487,0.760584,0.739178,0.436135,0.563300,0.155686,0.825051,0.784147,0.795182,0.736662,0.711466,0.463755,0.697047,0.407985,0.867123,0.823829,0.725311,0.519808,0.604972,0.203174,0.558329,0.166865,0.925640,0.849281,0.739467,0.575708,0.637870,0.248852,0.754885,0.630980,0.662044,0.299554,0.772822,0.684979,0.681041,0.353007,0.745717,0.712709,0.726706,0.658807,0.655961,0.377673,0.639317,0.322626,0.770454,0.763731,0.670392,0.433769,0.805029,0.809363,0.683774,0.490356,0.855308,0.844632,0.697011,0.547009,0.591182,0.219956,0.551952,0.177121,0.923407,0.861297,0.710973,0.603325,0.618699,0.269516,0.923791,0.873467,0.844816,0.866689,0.681363,0.629851,0.668005,0.572713,0.599486,0.287785,0.576832,0.234706,0.696970,0.686034,0.616747,0.343256,0.716668,0.740438,0.631000,0.400016,0.743695,0.791492,0.643669,0.457442,0.783837,0.835890,0.655731,0.515122,0.544481,0.186237,0.760428,0.863335,0.713639,0.819179,0.627046,0.537243,0.616615,0.478315,0.836350,0.889729,0.637946,0.596005,0.562017,0.247230,0.536166,0.194033,0.927547,0.885321,0.650183,0.654292,0.580132,0.303378,0.665037,0.711638,0.594131,0.361033,0.684737,0.767195,0.605914,0.419482,0.571358,0.375584,0.560593,0.316042,0.648805,0.791726,0.630288,0.734412,0.580561,0.435564,0.678348,0.845702,0.589070,0.495737,0.732723,0.891172,0.597536,0.555923,0.831424,0.913428,0.606595,0.615943,0.546824,0.257354,0.527209,0.200363,0.935538,0.896247,0.617071,0.675566,0.573887,0.631595,0.567156,0.570413,0.531336,0.264931,0.517784,0.205114,0.948527,0.905466,0.833915,0.937286,0.581872,0.692529,0.540867,0.325557,0.592315,0.752973,0.548386,0.386583,0.607782,0.812401,0.554891,0.447811,0.635028,0.869370,0.560989,0.509119,0.696016,0.918498,0.580647,0.887528,0.561220,0.827236,0.532439,0.517967,0.528936,0.455859,0.638246,0.943159,0.536021,0.580066,0.856456,0.960107,0.539986,0.642122,0.515638,0.269848,0.508043,0.208201,0.966637,0.912069,0.544778,0.704085,0.520989,0.331748,0.551220,0.765862,0.525234,0.393773,0.507907,0.771825,0.506404,0.709363,0.501965,0.396975,0.501015,0.334499,0.510297,0.834265,0.502796,0.459454,0.515221,0.896641,0.503585,0.521934,0.534176,0.958662,0.504397,0.584414,0.947682,0.976645,0.505301,0.646891,0.499822,0.272029,0.498129,0.209572,0.988610,0.915189,1.095877,0.971215,1.404978,0.953949,0.470429,0.645596,0.472657,0.583235,0.483979,0.271440,0.488176,0.209201,1.011577,0.914333,0.467719,0.707927,0.481020,0.333755,0.464040,0.770198,0.478668,0.396109,0.458226,0.832335,0.476612,0.458481,0.446455,0.894099,0.474661,0.520859,0.404978,0.953949,0.385287,0.880701,0.408873,0.821779,0.445911,0.514786,0.450536,0.452971,0.323807,0.933258,0.441200,0.576589,0.147808,0.950687,0.095877,0.971215,0.436013,0.638321,0.468202,0.268089,0.478319,0.207096,0.032175,0.909643,0.011577,0.914333,0.429787,0.699898,0.461079,0.329532,0.421503,0.761167,0.455439,0.391196,0.381676,0.745694,0.393448,0.685920,0.432358,0.382361,0.441260,0.321911,0.364639,0.804207,0.424693,0.443100,0.335902,0.859805,0.417545,0.503960,0.277305,0.907037,0.410362,0.564812,0.159037,0.927175,0.402582,0.625524,0.452583,0.262030,0.468695,0.203294,0.048166,0.901813,0.157607,0.903302,0.245300,0.879339,0.370446,0.607941,0.380347,0.548455,0.437209,0.253354,0.459449,0.197860,0.058962,0.891763,0.359136,0.666985,0.421611,0.311033,0.345098,0.725165,0.409472,0.369816,0.325892,0.781668,0.399158,0.429173,0.296385,0.834663,0.389690,0.488794,0.263610,0.807482,0.291803,0.756015,0.362365,0.469829,0.373930,0.411594,0.219785,0.851589,0.351201,0.528217,0.150899,0.879836,0.339664,0.586461,0.422167,0.242191,0.450742,0.190891,0.065046,0.880358,0.326879,0.644227,0.402153,0.297095,0.311613,0.701028,0.386774,0.353852,0.382867,0.280332,0.407539,0.228698,0.280693,0.674598,0.296418,0.618773,0.364196,0.334814,0.261226,0.728711,0.348920,0.390841,0.235147,0.779654,0.335478,0.447684,0.197492,0.824480,0.322818,0.504873,0.141452,0.857179,0.310089,0.562031,0.442759,0.182515,0.067268,0.868303,0.294966,0.479228,0.308822,0.423029,0.130338,0.835624,0.176891,0.798466,0.281429,0.535580,0.393414,0.213060,0.435719,0.172890,0.066457,0.856148,0.267340,0.591668,0.363688,0.261010,0.251695,0.647001,0.341590,0.313094,0.233105,0.700875,0.323944,0.367441,0.209376,0.752105,0.206593,0.673391,0.223996,0.619193,0.298714,0.341964,0.318709,0.289116,0.185241,0.725518,0.282092,0.396562,0.157173,0.773912,0.267315,0.452094,0.118082,0.815427,0.253309,0.508011,0.379896,0.195479,0.429896,0.162212,0.063300,0.844315,0.239178,0.563865,0.344487,0.239416,0.058329,0.833136,0.104972,0.796826,0.211466,0.536245,0.225311,0.480192,0.325051,0.215853,0.367123,0.176171,0.197047,0.592015,0.295182,0.263338,0.181041,0.646993,0.272822,0.315021,0.162044,0.700446,0.254885,0.369020,0.137870,0.751148,0.239467,0.424292,0.425640,0.150719,0.118699,0.730484,0.139317,0.677374,0.210973,0.396675,0.226706,0.341193,0.091182,0.780045,0.197011,0.452991,0.355308,0.155368,0.423407,0.138704,0.051952,0.822879,0.183774,0.509644,0.305029,0.190637,0.170392,0.566231,0.270454,0.236269,0.155961,0.622327,0.245717,0.287291,0.131000,0.599985,0.143669,0.542558,0.216668,0.259562,0.243695,0.208508,0.116747,0.656744,0.196970,0.313966,0.099486,0.712215,0.181363,0.370149,0.076832,0.765294,0.168005,0.427287,0.344817,0.133311,0.423791,0.126533,0.044481,0.813763,0.155731,0.484878,0.283838,0.164110,0.036166,0.805968,0.062017,0.752771,0.127046,0.462757,0.137946,0.403995,0.260429,0.136665,0.336350,0.110271,0.116615,0.521685,0.213639,0.180821,0.105914,0.580518,0.184737,0.232805,0.094131,0.638967,0.165037,0.288362,0.080132,0.696622,0.150183,0.345707,0.427547,0.114679,0.060593,0.683958,0.071358,0.624416,0.117071,0.324434,0.130288,0.265587,0.046824,0.742647,0.106595,0.384057,0.331424,0.086572,0.435539,0.103753,0.027209,0.799637,0.097536,0.444077,0.232723,0.108828,0.089070,0.504263,0.178349,0.154298,0.080561,0.564436,0.148805,0.208274,0.495265,0.147144,1.017784,0.794887,0.995265,0.852857,1.032175,0.909643,1.048166,0.901813,1.058962,0.891763,1.065046,0.880358,1.067268,0.868303,1.066457,0.856148,1.063300,0.844315,1.058329,0.833136,1.051952,0.822879,1.044481,0.813763,1.036166,0.805968,1.027209,0.799637};
unsigned int bufTexLen = sizeof(texElems) / sizeof(texElems[0]);
compCount = 2;
elemCount = bufTexLen / compCount;
csRefbufTex = csRenderBuffer::CreateRenderBuffer((size_t) elemCount, CS_BUF_STATIC, CS_BUFCOMP_FLOAT, compCount);
bufTex->CopyInto(texElems, elemCount); //this is the only available method to copy apparently the data from memory/pointer and into the buffer....
state->AddRenderBuffer("texture coordinate", bufTex);//renderbuffers: color
//TO DO TO CHANGE retrieve the contents of the buffer from SMGData
const float colorElems[] = {1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1,1.000000,1.000000,1.000000,1};
unsigned int bufColorLen = sizeof(colorElems) / sizeof(colorElems[0]);
compCount = 4;
elemCount = bufColorLen / compCount;
csRefbufColor = csRenderBuffer::CreateRenderBuffer((size_t) elemCount, CS_BUF_STATIC, CS_BUFCOMP_FLOAT, compCount);
bufColor->CopyInto(colorElems, elemCount); //this is the only available method to copy apparently the data from memory/pointer and into the buffer....
state->AddRenderBuffer("color", bufColor);//triangles
const float triangles[] = {1,2,3,0,1,3,5,6,7,4,5,7,0,3,9,8,0,9,4,7,11,10,4,11,8,9,13,12,8,13,10,11,15,14,10,15,12,13,17,16,12,17,19,20,21,18,19,21,14,15,23,22,14,23,16,17,25,24,16,25,18,21,27,26,18,27,24,25,29,28,24,29,26,27,2,1,26,2,28,29,6,5,28,6,31,32,33,30,31,33,35,12,16,34,35,16,37,19,18,36,37,18,30,33,39,38,30,39,34,16,24,40,34,24,36,18,26,41,36,26,40,24,28,42,40,28,41,26,1,43,41,1,42,28,5,44,42,5,43,1,0,45,43,0,44,5,4,46,44,4,45,0,8,47,45,8,46,4,10,48,46,10,47,8,12,35,47,12,50,51,52,49,50,52,54,55,56,53,54,56,49,52,31,57,49,31,53,56,59,58,53,59,57,31,30,60,57,30,58,59,62,61,58,62,64,37,36,63,64,36,60,30,38,65,60,38,61,62,67,66,61,67,63,36,69,68,63,69,66,67,71,70,66,71,68,69,73,72,68,73,70,71,51,50,70,51,72,73,55,54,72,55,75,66,70,74,75,70,77,68,72,76,77,72,74,70,50,78,74,50,76,72,54,79,76,54,78,50,49,80,78,49,79,54,53,81,79,53,80,49,57,82,80,57,81,53,58,83,81,58,82,57,60,84,82,60,83,58,61,85,83,61,87,64,63,86,87,63,84,60,65,88,84,65,85,61,66,75,85,66,86,63,68,77,86,68,90,82,84,89,90,84,92,83,85,91,92,85,94,87,86,93,94,86,89,84,88,95,89,88,91,85,75,96,91,75,93,86,77,97,93,77,96,75,74,98,96,74,97,77,76,99,97,76,98,74,78,100,98,78,99,76,79,101,99,79,100,78,80,102,100,80,101,79,81,103,101,81,102,80,82,90,102,82,103,81,83,92,103,83,105,99,101,104,105,101,107,100,102,106,107,102,104,101,103,108,104,103,106,102,90,109,106,90,108,103,92,110,108,92,109,90,89,111,109,89,110,92,91,112,110,91,114,94,93,113,114,93,111,89,95,115,111,95,112,91,96,116,112,96,113,93,97,117,113,97,116,96,98,118,116,98,117,97,99,105,117,99,118,98,100,107,118,100,120,112,116,119,120,116,122,113,117,121,122,117,119,116,118,123,119,118,121,117,105,124,121,105,123,118,107,125,123,107,124,105,104,126,124,104,125,107,106,127,125,106,126,104,108,128,126,108,127,106,109,129,127,109,128,108,110,130,128,110,129,109,111,131,129,111,130,110,112,120,130,112,132,114,113,122,132,113,131,111,115,133,131,115,135,127,129,134,135,129,137,128,130,136,137,130,134,129,131,138,134,131,136,130,120,139,136,120,141,132,122,140,141,122,138,131,133,142,138,133,139,120,119,143,139,119,140,122,121,144,140,121,143,119,123,145,143,123,144,121,124,146,144,124,145,123,125,147,145,125,146,124,126,148,146,126,147,125,127,135,147,127,148,126,128,137,148,128,150,145,147,149,150,147,152,146,148,151,152,148,149,147,135,153,149,135,151,148,137,154,151,137,153,135,134,155,153,134,154,137,136,156,154,136,155,134,138,157,155,138,156,136,139,158,156,139,160,141,140,159,160,140,157,138,142,161,157,142,158,139,143,162,158,143,159,140,144,163,159,144,162,143,145,150,162,145,163,144,146,152,163,146,165,157,161,164,165,161,167,158,162,166,167,162,169,159,163,168,169,163,166,162,150,170,166,150,168,163,152,171,168,152,170,150,149,172,170,149,171,152,151,173,171,151,172,149,153,174,172,153,173,151,154,175,173,154,174,153,155,176,174,155,175,154,156,177,175,156,176,155,157,165,176,157,177,156,158,167,177,158,178,160,159,169,178,159,180,174,176,179,180,176,182,175,177,181,182,177,179,176,165,183,179,165,181,177,167,184,181,167,186,178,169,185,186,169,183,165,164,187,183,164,184,167,166,188,184,166,185,169,168,189,185,168,188,166,170,190,188,170,189,168,171,191,189,171,190,170,172,192,190,172,191,171,173,193,191,173,192,172,174,180,192,174,193,173,175,182,193,175,195,190,192,194,195,192,197,191,193,196,197,193,194,192,180,198,194,180,196,193,182,199,196,182,198,180,179,200,198,179,199,182,181,201,199,181,200,179,183,202,200,183,201,181,184,203,201,184,205,186,185,204,205,185,202,183,187,206,202,187,203,184,188,207,203,188,204,185,189,208,204,189,207,188,190,195,207,190,208,189,191,197,208,191,210,202,206,209,210,206,212,203,207,211,212,207,214,204,208,213,214,208,211,207,195,215,211,195,213,208,197,216,213,197,215,195,194,217,215,194,216,197,196,218,216,196,217,194,198,219,217,198,218,196,199,220,218,199,219,198,200,221,219,200,220,199,201,222,220,201,221,200,202,210,221,202,222,201,203,212,222,203,223,205,204,214,223,204,225,219,221,224,225,221,227,220,222,226,227,222,224,221,210,228,224,210,226,222,212,229,226,212,231,223,214,230,231,214,228,210,209,232,228,209,229,212,211,233,229,211,230,214,213,234,230,213,233,211,215,235,233,215,234,213,216,236,234,216,235,215,217,237,235,217,236,216,218,238,236,218,237,217,219,225,237,219,238,218,220,227,238,220,240,234,236,239,240,236,242,235,237,241,242,237,239,236,238,243,239,238,241,237,225,244,241,225,243,238,227,245,243,227,244,225,224,246,244,224,245,227,226,247,245,226,246,224,228,248,246,228,247,226,229,249,247,229,251,231,230,250,251,230,248,228,232,252,248,232,249,229,233,253,249,233,250,230,234,240,250,234,253,233,235,242,253,235,255,247,249,254,255,249,257,251,250,256,257,250,259,248,252,258,259,252,254,249,253,260,254,253,256,250,240,261,256,240,260,253,242,262,260,242,261,240,239,263,261,239,262,242,241,264,262,241,263,239,243,265,263,243,264,241,244,266,264,244,265,243,245,267,265,245,266,244,246,268,266,246,267,245,247,255,267,247,268,246,248,259,268,248,270,264,266,269,270,266,272,265,267,271,272,267,269,266,268,273,269,268,271,267,255,274,271,255,273,268,259,275,273,259,274,255,254,276,274,254,278,257,256,277,278,256,275,259,258,279,275,258,276,254,260,280,276,260,277,256,261,281,277,261,280,260,262,282,280,262,281,261,263,283,281,263,282,262,264,270,282,264,283,263,265,272,283,265,285,280,282,284,285,282,287,281,283,286,287,283,284,282,270,288,284,270,286,283,272,289,286,272,288,270,269,290,288,269,289,272,271,291,289,271,290,269,273,292,290,273,291,271,274,293,291,274,292,273,275,294,292,275,293,274,276,295,293,276,297,278,277,296,297,277,294,275,279,298,294,279,295,276,280,285,295,280,296,277,281,287,296,281,300,292,294,299,300,294,302,293,295,301,302,295,304,297,296,303,304,296,299,294,298,305,299,298,301,295,285,306,301,285,303,296,287,307,303,287,306,285,284,308,306,284,307,287,286,309,307,286,308,284,288,310,308,288,309,286,289,311,309,289,310,288,290,312,310,290,311,289,291,313,311,291,312,290,292,314,312,292,313,291,293,302,313,293,316,310,312,315,316,312,318,311,313,317,318,313,315,312,314,319,315,314,317,313,302,320,317,302,319,314,322,321,319,322,320,302,301,323,320,301,325,304,303,324,325,303,321,322,327,326,321,327,323,301,306,328,323,306,324,303,307,329,324,307,328,306,308,330,328,308,329,307,309,331,329,309,330,308,310,316,330,310,331,309,311,318,331,311,333,328,330,332,333,330,335,329,331,334,335,331,332,330,316,336,332,316,334,331,318,337,334,318,336,316,315,338,336,315,337,318,317,339,337,317,338,315,319,340,338,319,339,317,320,341,339,320,340,319,321,342,340,321,341,320,323,343,341,323,345,325,324,344,345,324,342,321,326,346,342,326,343,323,328,333,343,328,344,324,329,335,344,329,348,340,342,347,348,342,350,341,343,349,350,343,352,345,344,351,352,344,347,342,346,353,347,346,349,343,333,354,349,333,351,344,335,355,351,335,354,333,332,356,354,332,355,335,334,357,355,334,356,332,336,358,356,336,357,334,337,359,357,337,358,336,338,360,358,338,359,337,339,361,359,339,360,338,340,348,360,340,361,339,341,350,361,341,363,358,360,362,363,360,365,359,361,364,365,361,362,360,348,366,362,348,364,361,350,367,364,350,366,348,347,368,366,347,367,350,349,369,367,349,371,352,351,370,371,351,368,347,353,372,368,353,369,349,354,373,369,354,370,351,355,374,370,355,373,354,356,375,373,356,374,355,357,376,374,357,375,356,358,363,375,358,376,357,359,365,376,359,378,370,374,377,378,374,380,373,375,379,380,375,377,374,376,381,377,376,379,375,363,382,379,363,381,376,365,383,381,365,382,363,362,384,382,362,383,365,364,385,383,364,384,362,366,386,384,366,385,364,367,387,385,367,386,366,368,388,386,368,387,367,369,389,387,369,390,371,370,378,390,370,388,368,372,391,388,372,389,369,373,380,389,373,393,385,387,392,393,387,395,386,388,394,395,388,392,387,389,396,392,389,398,390,378,397,398,378,394,388,391,399,394,391,396,389,380,400,396,380,397,378,377,401,397,377,400,380,379,402,400,379,401,377,381,403,401,381,402,379,382,404,402,382,403,381,383,405,403,383,404,382,384,406,404,384,405,383,385,393,405,385,406,384,386,395,406,386,408,402,404,407,408,404,410,403,405,409,410,405,407,404,406,411,407,406,409,405,393,412,409,393,411,406,395,413,411,395,412,393,392,414,412,392,413,395,394,415,413,394,414,392,396,416,414,396,418,398,397,417,418,397,415,394,399,419,415,399,416,396,400,420,416,400,417,397,401,421,417,401,420,400,402,408,420,402,421,401,403,410,421,403,423,415,419,422,423,419,425,416,420,424,425,420,427,417,421,426,427,421,424,420,408,428,424,408,426,421,410,429,426,410,428,408,407,430,428,407,429,410,409,431,429,409,430,407,411,432,430,411,431,409,412,433,431,412,432,411,413,434,432,413,433,412,414,435,433,414,434,413,415,423,434,415,435,414,416,425,435,416,436,418,417,427,436,417,438,432,434,437,438,434,440,433,435,439,440,435,437,434,423,441,437,423,439,435,425,442,439,425,444,436,427,443,444,427,441,423,422,445,441,422,442,425,424,446,442,424,443,427,426,447,443,426,446,424,428,448,446,428,447,426,429,449,447,429,448,428,430,450,448,430,449,429,431,451,449,431,450,430,432,438,450,432,451,431,433,440,451,433,453,448,450,452,453,450,455,449,451,454,455,451,452,450,438,456,452,438,454,451,440,457,454,440,456,438,437,458,456,437,457,440,439,459,457,439,458,437,441,460,458,441,459,439,442,461,459,442,463,444,443,462,463,443,460,441,445,464,460,445,461,442,446,465,461,446,462,443,447,466,462,447,465,446,448,453,465,448,466,447,449,455,466,449,468,460,464,467,468,464,470,461,465,469,470,465,472,462,466,471,472,466,469,465,453,473,469,453,471,466,455,474,471,455,473,453,452,475,473,452,474,455,454,476,474,454,475,452,456,477,475,456,476,454,457,478,476,457,477,456,458,479,477,458,478,457,459,480,478,459,479,458,460,468,479,460,480,459,461,470,480,461,481,463,462,472,481,462,483,477,479,482,483,479,485,478,480,484,485,480,482,479,468,486,482,468,484,480,470,487,484,470,489,481,472,488,489,472,486,468,467,490,486,467,487,470,469,491,487,469,488,472,471,492,488,471,491,469,473,493,491,473,492,471,474,494,492,474,493,473,475,495,493,475,494,474,476,496,494,476,495,475,477,483,495,477,496,476,478,485,496,478,19,497,20,39,498,499,38,39,499,37,497,19,64,497,37,65,38,499,88,65,499,87,497,64,94,497,87,95,88,499,114,497,94,115,95,499,133,115,499,132,497,114,141,497,132,142,133,499,160,497,141,161,142,499,164,161,499,178,497,160,186,497,178,187,164,499,205,497,186,206,187,499,209,206,499,223,497,205,231,497,223,232,209,499,251,497,231,252,232,499,258,252,499,257,497,251,278,497,257,279,258,499,298,279,499,297,497,278,305,298,499,304,497,297,325,497,304,500,305,499,501,500,499,345,497,325,502,501,499,352,497,345,371,497,352,503,502,499,504,503,499,390,497,371,398,497,390,505,504,499,418,497,398,506,505,499,507,506,499,436,497,418,444,497,436,508,507,499,463,497,444,509,508,499,510,509,499,481,497,463,489,497,481,511,510,499,29,493,495,6,29,495,2,494,496,3,2,496,6,495,483,7,6,483,3,496,485,9,3,485,7,483,482,11,7,482,9,485,484,13,9,484,489,20,497,11,482,486,15,11,486,13,484,487,17,13,487,488,21,20,489,488,20,15,486,490,23,15,490,17,487,491,25,17,491,21,488,492,27,21,492,498,511,499,25,491,493,29,25,493,27,492,494,2,27,494};
int i, n;
n = sizeof(triangles) / sizeof(triangles[0]);
for (i = 0; i< n; i = i + 3) {
state->AddTriangle(csTriangle(triangles[i], triangles[i+1], triangles[i+2]));
}//factory wrapper
csRefwrap = psengine->GetEngine()->CreateMeshFactory(fact, "moonfact");
if (wrap == 0)
Err::FatalError("EuLOADER: failed to create factory wrapper!\n");
return wrap;
}
Creating the terrain was quite a pain and it's quite a long adventure so perhaps of some use to see the code for it too:
csRef
EuLoader::GetTerrain() {
csRefmeshWrapper = 0;
csReffactWrapper = 0;
csReffact;
csRefstate;
csReftypePlugin; const char meshNameC[] = "Terrain";
const char factNameC[] = "terrainF";
char meshName[MAX_STR_LEN+1];
char factName[MAX_STR_LEN+1];
strncpy(meshName, meshNameC, strlen(meshNameC));
strncpy(factName, factNameC, strlen(factNameC));
meshName[strlen(meshNameC)]='\0';
factName[strlen(factNameC)]='\0';csRef
s = psengine->GetEngine()->FindSector("Rotces");
typePlugin = csLoadPluginCheck( psengine->GetObjectRegistry(), TERRAIN_PLUGIN, false); //get heightmap from EuCache via SMGData i.e. make sure it is available before creating empty sector...
char hmapfile[MAX_STR_LEN+1];
unsigned int lhmapfile = MAX_STR_LEN;
if (!psengine->SMG.GetHeightMapFile(factName, hmapfile, &lhmapfile)) {
Err::NonfatalError("EuLoader: failed to find heightmap for requested terrain factory!\n");
return meshWrapper;
}
hmapfile[lhmapfile] = '\0';//get materialmap from EuCache via SMGData
char hmatfile[MAX_STR_LEN+1];
unsigned int lhmatfile = MAX_STR_LEN;
if (!psengine->SMG.GetMaterialMapFile(factName, hmatfile, &lhmatfile)) {
Err::NonfatalError("EuLoader: failed to find materialmap for requested terrain factory!\n");
return meshWrapper;
}
hmatfile[lhmatfile] = '\0';//no need for base material in fact for terrain - there are the ones in the palette!
fact = typePlugin->NewFactory ();
csRefterrainFact = scfQueryInterface (fact);
//obtain needed renderer, collider and data feeder
//NB: those are all defaults because CS doesn't really have a choice anyway.
csRefrenderer = csLoadPluginCheck (psengine->GetObjectRegistry(), TERRAIN_RENDERER);
csRefcollider = csLoadPluginCheck (psengine->GetObjectRegistry(), TERRAIN_COLLIDER);
csRefdatafeeder = csLoadPluginCheck (psengine->GetObjectRegistry(), TERRAIN_DATAFEEDER_THREADED);
if (renderer == 0 || collider == 0 || datafeeder == 0) {
Err::NonfatalError("EuLoader::GetFactory can't find renderer, collider and/or data feeder for generating the Terrain!\n");
return meshWrapper;
}terrainFact->SetRenderer( renderer );
terrainFact->SetCollider( collider );
terrainFact->SetFeeder( datafeeder );//set default cell - DEFAULT values!
//this is a "pseudo-cell" that serves as blueprint for any cells created by this factory
//NB: apparently by default there are NO cells created (?!)
csRefdefaultCell (terrainFact->GetDefaultCell());
if (!defaultCell.IsValid()) {
//this should NOT happen!
Err::NonfatalError("INVALID default cell in terrain factory!\n");
return meshWrapper;
}
defaultCell->SetSize (csVector3 (1024.0f, 63.0f, 1024.0f));
defaultCell->SetGridWidth (257);
defaultCell->SetGridHeight (257);
defaultCell->SetMaterialMapWidth (512);
defaultCell->SetMaterialMapHeight (512);
defaultCell->SetMaterialPersistent (false);
//render properties
defaultCell->GetRenderProperties()->SetParameter("block resolution", "16");
defaultCell->GetRenderProperties()->SetParameter("splat distance", "100");
defaultCell->GetRenderProperties()->SetParameter("lod splitcoeff", "8");
defaultCell->GetRenderProperties()->SetParameter("splat render priority", "object2");
//heightmap and material map aka "feederproperties"
defaultCell->GetFeederProperties()->SetParameter("smooth heightmap", "yes");
defaultCell->GetFeederProperties()->SetParameter("heightmap source", hmapfile); //?
defaultCell->GetFeederProperties()->SetParameter("materialmap source", hmatfile); //?//create ONE actual cell in this factory
csRefcell = terrainFact->AddCell();
cell->SetName("0"); //default, one single cell "0"
if (cell == 0) {
Err::NonfatalError("EuLoader: GetFactory fails to create ONE cell for terrain!\n");
return 0;
}
//position of this one cell
cell->SetPosition(csVector2(-511, -511));//create the actual factory wrapper and register it with the engine
factWrapper = psengine->GetEngine()->CreateMeshFactory(fact, factName);
if (factWrapper == 0) {
Err::FatalError("EuLOADER: failed to create Terrain factory wrapper!\n");
return meshWrapper;
}meshWrapper = psengine->GetEngine()->CreateMeshWrapper (factWrapper, meshName, s, csVector3 (0,0,0));
if (meshWrapper == 0) {
Err::NonfatalError("EuLoader:GetMesh failed to create the requested mesh despite having its factory wrapper!\n");
return meshWrapper;
}
//add material palette if this mesh has any!
uint32_t index = 1;
char matName[MAX_STR_LEN+1];
unsigned int len = MAX_STR_LEN;
csRefArraypal; //just in case there IS a material palette...
while (psengine->SMG.GetMaterialPalette(meshName, index, matName, &len)){
matName[len] = '\0';
csRefm = GetMaterial(matName);
if (m == 0) {
Err::NonfatalError("EuLoader: failed to retrieve material for material palette!\n");
}
else
pal.Push(m);
index = index + 1;
len = MAX_STR_LEN; //reset this...
}
if (index > 1) {
//aka there IS a material palette
csRefmm = meshWrapper->GetMeshObject();
if (mm==0) {
Err::NonfatalError("EuLoader: failed to obtain the mesh object out of the mesh wrapper!\n");
}
else {
csRefsyst = scfQueryInterface (mm);
if (syst == 0) {
Err::NonfatalError("EuLoader: failed to get the terrainSystem to set the material palette on it!\n");
}
else
syst->SetMaterialPalette(pal);
}
}meshWrapper->SetZBufMode(CS_ZBUF_USE); //DO read so that the zbuffer gets updated...ugh;only write to the z-buffer but do not read
meshWrapper->GetMeshObject()->SetMixMode(CS_FX_COPY); //this should be default for most (?); see p321 (333) in cs manual re mixmodes and blendingmeshWrapper->SetRenderPriority(psengine->GetEngine()->GetObjectRenderPriority());
psengine->GetEngine()->PrecacheMesh(meshWrapper); //hmm?//initialize collision detection for this entity
csRefcdsys = csQueryRegistry (psengine->GetObjectRegistry());
csColliderHelper::InitializeCollisionWrapper(cdsys, meshWrapper);return meshWrapper;
Putting some of the above together, there's a more useful GetMesh that takes a numeric id (hence, a Euloran proper id since all objects in Eulora have a numeric id) and either finds or creates the thing (according to what EuCore says that thing should be):
csRef
EuLoader::GetMesh( uint32_t id) {
csRefmeshWrapper = 0;
//retrieve name as CS finds meshes by name
char meshName[MAX_STR_LEN+1];
unsigned int meshNameLen = MAX_STR_LEN;if (!psengine->SMG.GetName(id, meshName, &meshNameLen))
return meshWrapper; //nothing to do as there's not enough info for this object
meshName[meshNameLen] = '\0';
//check if it exists already
meshWrapper = psengine->GetEngine()->FindMeshObject(meshName);
if (meshWrapper != 0)
return meshWrapper; //found it so return it//not found so create it, if there is enough information for it
//will need: factory name, location (aka sectorID + position x,y,z)
char factName[MAX_STR_LEN+1];
unsigned int factNameLen = MAX_STR_LEN;
float x,y,z,rx,ry,rz;
uint32_t locID;
if (! (psengine->SMG.GetFactoryName(id, factName, &factNameLen)) ||
! (psengine->SMG.GetPos(id, &x, &y, &z, &rx, &ry, &rz)) ||
! (psengine->SMG.GetLocID(id, &locID)) ) {Err::NonfatalError("EuLoader: unknown factory name and/or location for requested mesh!");
return meshWrapper;
}
factName[factNameLen] = '\0';
//everything IS available, so retrieve/create factory
csReffactory = GetFactory(factName);
if (factory == 0) {
Err::NonfatalError("EuLoader: failed to retrieve factory for the required entity!\n");
return meshWrapper;
}
//retrieve/create sector for this too!
char sName[MAX_STR_LEN+1];
unsigned int slen = MAX_STR_LEN;
if (! (psengine->SMG.GetName(locID, sName, &slen))) {
Err::NonfatalError("EuLoader: failed to retrieve sector name for the required entity!\n");
return meshWrapper;
}
sName[slen] = '\0';
csRefs = psengine->GetEngine()->FindSector(sName);
if (s == 0) {
//this should NOT happen as the sector should call/create contained entities, not the other way around.
Err::NonfatalError("EuLoader: failed to find the sector for the required entity!\n");
return meshWrapper;
}meshWrapper = psengine->GetEngine()->CreateMeshWrapper (factory, meshName, s, csVector3 (x,y,z));
if (meshWrapper == 0) {
Err::NonfatalError("EuLoader:GetMesh failed to create the requested mesh despite having its factory wrapper!\n");
return meshWrapper;
}//add material palette if this mesh has any!
uint32_t index = 1;
char matName[MAX_STR_LEN+1];
unsigned int len = MAX_STR_LEN;
csRefArraypal; //just in case there IS a material palette...
while (psengine->SMG.GetMaterialPalette(meshName, index, matName, &len)){
matName[len] = '\0';
csRefm = GetMaterial(matName);
if (m == 0) {
Err::NonfatalError("EuLoader: failed to retrieve material for material palette!\n");
}
else
pal.Push(m);
index = index + 1;
len = MAX_STR_LEN; //reset this...
}
if (index > 1) {
//aka there IS a material palette
csRefmm = meshWrapper->GetMeshObject();
if (mm==0) {
Err::NonfatalError("EuLoader: failed to obtain the mesh object out of the mesh wrapper!\n");
}
else {
csRefsyst = scfQueryInterface (mm);
if (syst == 0) {
Err::NonfatalError("EuLoader: failed to get the terrainSystem to set the material palette on it!\n");
}
else
syst->SetMaterialPalette(pal);
}
}//TO DO: to check that all mesh entities have indeed zbuf_use?
//NOPE, not all: particles have cs_zbuf_test
//the zbufmode depends on the type of the mesh, which is in turn given by the ...factory type...
int mtype = psengine->SMG.GetFactoryType(factName);
switch (mtype) {
case FACTORY_PARTICLES: {
meshWrapper->SetZBufMode(CS_ZBUF_TEST);
meshWrapper->GetMeshObject()->SetMixMode(CS_FX_ADD);
// meshWrapper->SetRenderPriority(psengine->GetEngine()->GetObjectRenderPriority());
meshWrapper->SetRenderPriority(psengine->GetEngine()->GetAlphaRenderPriority());} break;
case FACTORY_TERRAIN: {
meshWrapper->SetZBufMode(CS_ZBUF_USE);
meshWrapper->GetMeshObject()->SetMixMode(CS_FX_COPY);
meshWrapper->SetRenderPriority(psengine->GetEngine()->GetWallRenderPriority());
} break;
default: {
meshWrapper->SetZBufMode(CS_ZBUF_USE); //DO read so that the zbuffer gets updated...ugh;only write to the z-buffer but do not read
meshWrapper->GetMeshObject()->SetMixMode(CS_FX_COPY); //this should be default for most (?); see p321 (333) in cs manual re mixmodes and blending
meshWrapper->SetRenderPriority(psengine->GetEngine()->GetObjectRenderPriority());
}
}
//ALL mesh entities are objects so set them with object priority for rendering;
//TO DO: to check this since "entities" include walls and doors and the like?
//i.e. might need other meaningful subcategories and decide rendering priority on that; hm.
// meshWrapper->SetRenderPriority(psengine->GetEngine()->GetRenderPriority("wall"));
psengine->GetEngine()->PrecacheMesh(meshWrapper); //hmm?//initialize collision detection for this entity
csRefcdsys = csQueryRegistry (psengine->GetObjectRegistry());
csColliderHelper::InitializeCollisionWrapper(cdsys, meshWrapper);return meshWrapper;
}
For some really tedious stuff, here's the creation of Foxy herself, hence a Cal3D object:
csRef
EuLoader::GetCal3d( char *name, iSector *s, float x, float y, float z ) {
csRefmeshWrapper = 0;
//check if it exists already
meshWrapper = psengine->GetEngine()->FindMeshObject(name);
if (meshWrapper != 0)
return meshWrapper; //found it so return it//check sector is not null since CS REQUIRES a non-null sector to even create a mesh, ugh.
if (!s)
return meshWrapper;//not found the mesh, so need the factory to create it...
csReffactWrapper = 0;
factWrapper = psengine->GetEngine()->FindMeshFactory(name);if (!factWrapper) {
//factory does not yet exist, so create it.
csReffact;
csRefstate;
csReftypePlugin; typePlugin = csLoadPluginCheck
( psengine->GetObjectRegistry(), CAL3D_PLUGIN, false);
if (typePlugin == 0) {
Err::NonfatalError("EuLoader failed to load SprCal3D Factory PLUGIN TYPE\n");
return meshWrapper;
}
fact = typePlugin->NewFactory ();//create the actual factory wrapper and register it with the engine
factWrapper = psengine->GetEngine()->CreateMeshFactory(fact, name);
if (factWrapper == 0) {
Err::FatalError("EuLOADER: failed to create Cal3D factory wrapper!\n");
return meshWrapper;
}
} //by this point, factWrapper was either found OR created successfully.//now get the specific factory and state for Cal3D to set everything
csRefstate3d = scfQueryInterface (factWrapper->GetMeshObjectFactory());
if (state3d == 0) {
Err::NonfatalError("EuLoader failed to load factory state as iSpriteCal2DFactoryState\n");
return meshWrapper;
}
//test for now - create girl factory
//this IS DONE in CS's loader - does each sprcal3d factory actually NEED to create this "dummy" ?
if (!state3d->Create("dummy")) {
Err::NonfatalError("EuLoader: failed to create dummy for sprcal3d factory\n");
return meshWrapper;
}
//parameters for sprCal3dFactory state - to take them from SMGData! TO DO TO CHANGE
float scale = 1.0;
float ax, ay, az, angle;
csVector3 translation(0.0,0.0,0.0);
int flags = LOADER_FLIP_WINDING; //wtf IS this??
bool rotXAxis = true; //default apparently
bool flipTextures = false; //default apparently
if (rotXAxis)
flags = flags | LOADER_ROTATE_X_AXIS;
else
flags = flags & (~LOADER_ROTATE_X_AXIS); //ugh.
if (flipTextures)
flags = flags | LOADER_INVERT_V_COORD;
else
flags = flags & (~LOADER_INVERT_V_COORD);//skeleton
char skelFile[] = "/this/clientcache/girl_skel.csf";
if (! state3d->LoadCoreSkeleton(psengine->GetVFS(), skelFile) ){
Err::NonfatalError("Failed to load the core skeleton file girl_skel.csf\n");
return meshWrapper;
}
char idleFile[] = "/this/clientcache/girl_idle.caf";
char idleName[] = "idle";
char walkFile[] = "/this/clientcache/girl_idle.caf";
char walkName[] = "walk";
int itype = iSpriteCal3DState::C3D_ANIM_TYPE_IDLE;
int wtype = iSpriteCal3DState::C3D_ANIM_TYPE_TRAVEL;//see p 287/644 in cs manual
float base_vel = 0; //"speed of translation which should be used when the animation is played alone"
float min_vel = 0; //min and max velocities are used by the blender to achieve specific, desired velocities
float max_vel = 0;
int max_interval = 30; //max_random - those give the interval (in seconds) for idle override actions
int min_interval = 10; //min_random
int idle_pct = 0; //probability (%) of this action being the override action
bool lock = false; //??int animID = state3d->LoadCoreAnimation(psengine->GetVFS(), idleFile,
idleName, itype, base_vel,
min_vel, max_vel, min_interval, max_interval,
idle_pct, lock, flags);
if (animID < 0) {
Err::NonfatalError("EuLoader: failed to load core animation\n");
return meshWrapper;
}
base_vel = 2;
max_vel = 3;
animID = state3d->LoadCoreAnimation(psengine->GetVFS(), walkFile,
walkName, wtype, base_vel,
min_vel, max_vel, min_interval, max_interval,
idle_pct, lock, flags);
if (animID < 0) {
Err::NonfatalError("EuLoader: failed to load core animation\n");
return meshWrapper;
}
//meshes aka "attachable parts of the model"
//head
char mfile[] = "/this/clientcache/girl_head.cmf";
char hname[] = "Head";
char mname[] = "/this/clientcache/fskin.dds";
// char mname[] = "fskin.dds";
csRefmtex = GetTexture(mname); //to create/get a BASIC material with this name rather than all the shader mess.
csRefmw = GetMaterial(mname); //after the GetTexture call, this should always end up with the basic wrapper-material on the corresponding texture... such is CS. if (mw == 0) {
Err::NonfatalError("FAILED to obtain material fskin.dds\n");
return meshWrapper;
}
bool attach = true; //default value
state3d->AddCoreMaterial(mw); //done via LoadMaterialTag in cs/plugins/mesh/sprcal3d/persist/sprcal3dldr.cpp
if (state3d->LoadCoreMesh(psengine->GetVFS(), mfile, hname, attach, mw, flags) < 0) {
Err::NonfatalError("FAILED to loadcoremesh\n");
return meshWrapper;
}
//hair
char ghrfile[] = "/this/clientcache/girl_hair.cmf";
char ghrname[] = "Hair";
if (state3d->LoadCoreMesh(psengine->GetVFS(), ghrfile, ghrname, attach, mw, flags) < 0) {
Err::NonfatalError("FAILED to loadcoremesh\n");
return meshWrapper;
}//arm(s)
char glalfile[] = "/this/clientcache/girl_arm.cmf";
char glalname[] = "Arm";
if (state3d->LoadCoreMesh(psengine->GetVFS(), glalfile, glalname, attach, mw, flags) < 0) {
Err::NonfatalError("FAILED to loadcoremesh\n");
return meshWrapper;
}//hand(s)
char ghhfile[] = "/this/clientcache/girl_hand.cmf";
char ghhname[] = "Hand";
if (state3d->LoadCoreMesh(psengine->GetVFS(), ghhfile, ghhname, attach, mw, flags) < 0) {
Err::NonfatalError("FAILED to loadcoremesh\n");
return meshWrapper;
}//torso
char gtfile[] = "/this/clientcache/girl_torso.cmf";
char gtname[] = "Torso";
if (state3d->LoadCoreMesh(psengine->GetVFS(), gtfile, gtname, attach, mw, flags) < 0) {
Err::NonfatalError("FAILED to loadcoremesh\n");
return meshWrapper;
}//legs
char glfile[] = "/this/clientcache/girl_legs.cmf";
char glname[] = "Legs";
if (state3d->LoadCoreMesh(psengine->GetVFS(), glfile, glname, attach, mw, flags) < 0) {
Err::NonfatalError("FAILED to loadcoremesh\n");
return meshWrapper;
}//foot
char gffile[] = "/this/clientcache/girl_foot.cmf";
char gffname[] = "Foot";
if (state3d->LoadCoreMesh(psengine->GetVFS(), gffile, gffname, attach, mw, flags) < 0) {
Err::NonfatalError("FAILED to loadcoremesh\n");
return meshWrapper;
}//default values - hardtransform
ax = 0.0;
ay = 1.0; //this turns it to face away from the camera/viewer as it were
az = 0.0;
angle = 180.0;
csMatrix3 rotation(ax,ay,az,angle*TWO_PI/360);
csReversibleTransform rt(rotation,translation);
factWrapper->GetMeshObjectFactory()->HardTransform(rt);angle = 90.0;
ay = 0.0;
ax = -1.0;
csMatrix3 rotation1(ax,ay,az,angle*TWO_PI/360);
csReversibleTransform rt1(rotation1,translation);
factWrapper->GetMeshObjectFactory()->HardTransform(rt1);//rescale if needed
if (scale != 0)
state3d->RescaleFactory(scale); //this ALSO calls the calculateallboneboundingboxes
else
state3d->CalculateAllBoneBoundingBoxes();
// Wrapup cal3d initialization
state3d->BindMaterials();//and now create and register the mesh itself
meshWrapper = psengine->GetEngine()->CreateMeshWrapper (factWrapper, name, s, csVector3 (x,y,z));
if (meshWrapper == 0) {
Err::NonfatalError("EuLoader:GetMesh failed to create the requested mesh despite having its factory wrapper!\n");
return meshWrapper;
}meshWrapper->SetZBufMode(CS_ZBUF_USE); //DO read so that the zbuffer gets updated...ugh;only write to the z-buffer but do not read
meshWrapper->GetMeshObject()->SetMixMode(CS_FX_COPY); //this should be default for most (?); see p321 (333) in cs manual re mixmodes and blending
meshWrapper->SetRenderPriority(psengine->GetEngine()->GetObjectRenderPriority());psengine->GetEngine()->PrecacheMesh(meshWrapper); //hmm?
//initialize collision detection for this entity
csRefcdsys = csQueryRegistry (psengine->GetObjectRegistry());
csColliderHelper::InitializeCollisionWrapper(cdsys, meshWrapper);return meshWrapper;
}
Finally, the sector itself with lights and then various tests, some still in, some commented out (although the working code is still there otherwise):
bool EuLoader::LoadSector(uint32_t id) {
/*****retrieve name of this sector and check if it is already loaded*****/
char sname[MAX_STR_LEN+1];
unsigned int lsname = MAX_STR_LEN;//get name of this sector and null-terminate it
if (!psengine->SMG.GetName(id, sname, &lsname))
return false;
sname[lsname] = '\0';//check if sector exists
iSector *s = psengine->GetEngine()->FindSector(sname);
if (s != NULL) {
return true; //sector already loaded
}/****create the sector as an empty entity with default overall values****/
s = psengine->GetEngine()->CreateSector(sname);
if (s == NULL) {
//this should never happen.
Err::NonfatalError("EuLoader::LoadSector failed to create the requested sector.");
return false; //failed to create a sector
}//set the visibility culler; NB: smgdata provides either defaults or fresh data
s->SetVisibilityCullerPlugin(DEFAULT_CULLER); //default culler defined in smgdata.h
float r,g,b;
//set the ambient light
if (psengine->SMG.GetAmbient(id, &r, &g, &b))
s->SetDynamicAmbientLight(csColor(r,g,b));
//set the fog, if any - not really, this was/is only in water (?)
// float density;
// if (psengine->SMG.GetFog(id, &r, &g, &b, &density))
// s->SetFog(density, csColor(r,g,b));//load the lights, if any
uint32_t lindex = 1;
float radius, x, y, z;
char lightName[MAX_STR_LEN+1];
unsigned int llen = MAX_STR_LEN;
bool dynamic;
csLightDynamicType ltype;while (psengine->SMG.GetLight(id, lindex, lightName, &llen, &x, &y, &z, &radius, &r, &g, &b, &dynamic)) {
lightName[llen] = '\0';
if (dynamic)
ltype = CS_LIGHT_DYNAMICTYPE_DYNAMIC;
else
ltype = CS_LIGHT_DYNAMICTYPE_STATIC;
csReflight = psengine->GetEngine()->CreateLight(lightName, csVector3(x, y, z), radius, csColor(r,g,b), ltype);
if (!light)
Err::NonfatalError("EuLoader::LoadSector failed to create light");
else {
s->GetLights()->Add(light);
}
lindex = lindex + 1;
}//sky
//using GetMaterial, GetTexture, GetShader abovechar skyfactoryname[] = "sky.png.fact";
char skyobjname[] = "skyobj";
// csRefskyFactory = GetFactory(skyfactoryname);
if (!GetSky()) { //separate for now because generated sphere aka no direct pixels, texels etc.
// if (skyFactory==0) {
Err::NonfatalError("EuLoader::LoadSector failed to obtain the sky factory\n");
return false;
}
else printf ("CHECK: EuLoader got the sky factory fine\n");//TO DO : this should create all known objects in the sector
//the moon
/* csRefmoonwrap = GetMesh(901);
if (moonwrap == 0) {
Err::NonfatalError("NO MOON!!!\n");
return false;
}
*///the terrain
csReftwrap = GetTerrain();
if (twrap == 0) {
Err::NonfatalError("NO TERRAIN!!!\n");
return false;
}/************create particle systems (effects) *********/
// csReffire = GetFire();
csReffountain = GetFountain();
// csRefrain = GetRain();
// csRefglobe = GetGlobe(); /************create the Water***************/
/************create the Portals*************/
return true;
}
There is of course more to the prototoype/test code and otherwise changes and excisions to legacy code but comments are helpfully in place everywhere and so I don't feel the need to repeat them here. Despite those added comments and despite the fact that a lot of now-unused code was commented out rather than deleted at this stage, this prototype client is still thousands LOC shorter than the legacy client so there's some satisfaction to it all at least, that's the most I can say on it currently. Feel free to ask your questions in the comments box below, as usual.
Yeah, I'm writing to my older self as it's way more useful than writing to my younger self. You should try it too. ↩
See src/client/euloader.h and .cpp for the prototype loaders' code + src/client/psengine.cpp for its use. ↩
To do the same for different plugins, you need just to replace TERRAIN_PLUGIN with whichever other plugin you want from the list above. ↩
To quote Eminescu's fitting words here: "O racla mare-i lumea. Stelele-s cuie batute-n ea si soarele-i fereastra la temnita vietii." (A large shrine is this world. The stars are nails through it and the sun is the window to life's gaol.) ↩
Comments feed: RSS 2.0
[...] useless and the worse-than-useless currently bundled up with it. The attempt failed though, despite the progress made in that vein. So here I am taking stock of the various parts of the swamps I am stuck with, for [...]
[...] than 2 weeks after I've set Eulora's client down, the resolution came of course to... pick it back up! Nothing like a bit of up-down to hm, build [...]