Let me just get this out of the way: I am not a graphics programmer, I may confuse a couple terms and concepts so please bear with me.
I have a scene made of cubes that I've generated with h3dutCreateGeometryRes and a light node.
Code:
float posData[] = {
-0.5f, -0.5f, -0.5f,
0.5f, -0.5f, 0.5f,
0.5f, -0.5f, -0.5f,
-0.5f, -0.5f, 0.5f,
-0.5f, 0.5f, -0.5f,
0.5f, 0.5f, 0.5f,
0.5f, 0.5f, -0.5f,
-0.5f, 0.5f, 0.5f
};
unsigned int indexData[] = {
// bottom
0, 1, 2, 3, 1, 0,
// top
4, 5, 6, 7, 5, 4,
// left
0, 3, 4, 3, 7, 4,
// right
1, 2, 6, 1, 6, 5,
// back
3, 1, 5, 3, 5, 7
// front
// nothing yet.
};
short normalData[] = { // ignore the bad normals.
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
0, 0, 1,
};
float uvData[] = {
0, 0,
1, 0,
0, 1,
1, 1,
0, 0,
1, 0,
0, 1,
1, 1,
};
blockGeom = h3dutCreateGeometryRes("geoRes", 8, 30, posData, indexData, normalData, 0, 0, uvData, 0);
These cubes are of size 1,1,1 and I have a 16x16x16 chunk of them.
The light node is constructed this way:
Code:
H3DNode light = h3dAddLightNode(this->scene, "Light1", 0, "LIGHTING", "SHADOWMAP");
h3dSetNodeTransform(light, 0, 0, 18, 0, 0, 0, 1, 1, 1);
h3dSetNodeParamF(light, H3DLight::RadiusF, 0, 5.f);
h3dSetNodeParamF(light, H3DLight::ColorF3, 0, 1);
h3dSetNodeParamF(light, H3DLight::ColorF3, 1, 0);
h3dSetNodeParamF(light, H3DLight::ColorF3, 2, 0);
h3dSetNodeParamF(light, H3DLight::FovF, 90, 5); // Not sure what FOV means in terms of light, is it a spotlight?
Also I'm very sure I'm doing something wrong when adding an actual voxel:
Code:
blocks[x][y][z] = h3dAddModelNode(this->scene, "DynGeoModelNode", blockGeom);
h3dAddMeshNode(blocks[x][y][z], "DynGeoMesh", g->assets.matBlock, 0, 30, 0, 3);
h3dSetNodeTransform(blocks[x][y][z], x, y, z, 0, 0, 0, 1, 1, 1);
First off, is it mandatory that each node has it's own name? It's a bit of a pain for voxel worlds (Although I might combine voxels in each chunk into it's own model for speed.
Also I'm not sure if the last argument to h3dAddMeshNode is correct, it seems to render corrently regardless of what I put there.
Sorry for such a barrage of questions, I've been trying to figure stuff out with this library for a long time (there's little documentation), and asking help from humans is usually a last resort.