Terrain Mesh Size or Terrain Diameter
Posted 18 April 2012 - 11:26 AM
I having trouble getting the terrain mesh size in world space which I need to do some distance calculations in the vertex shader.
I have the following code in TerrainRender.cpp which I though would work, but doesn't...
shaderSolid->Uniform("meshSize", (float)(g_Game->GetWorld()->GetTerrain()->GetTilesPerSide() * TERRAIN_TILE_SIZE));
Basically what I need it for is to range the vertices e.g. -1 to 1, or 0 to 1 say.
Also, is there some kind of radius or diameter used for circular terrain's? if I could grab that information as well that would help me a lot.
thanks in advance
Posted 19 April 2012 - 03:49 PM
Circular terrain is just square terrain with permanent shroud-of-darkness around the corners, so GetTilesPerSide() gives you the diameter.
Posted 23 April 2012 - 09:10 AM
I'm going to post my calculations here, if anyone can spot a problem with what I'm doing any help would be greatly appreciated
/*Camera Normal Matrix*/
CMatrix3D cameraNormalMatrix = cameraInverse.GetInverse().GetTranspose();
worldOrigin.X = CVector4D(cameraInverse._11, cameraInverse._12, cameraInverse._13, cameraInverse._14).Dot(CVector4D(0.0, 0.0, 0.0, 1.0));
worldOrigin.Y = CVector4D(cameraInverse._21, cameraInverse._22, cameraInverse._23, cameraInverse._44).Dot(CVector4D(0.0, 0.0, 0.0, 1.0));
worldOrigin.Z = CVector4D(cameraInverse._31, cameraInverse._32, cameraInverse._33, cameraInverse._44).Dot(CVector4D(0.0, 0.0, 0.0, 1.0));
worldOrigin.W = CVector4D(cameraInverse._41, cameraInverse._42, cameraInverse._43, cameraInverse._44).Dot(CVector4D(0.0, 0.0, 0.0, 1.0));
Ideally here I would have like to have just done cameraNormalMatrix * CVector4D(0.0, 0.0, 0.0, 1.0);
however I could not see any function to do this calculation. Is there one?
thanks in advance
Edited by mpatton, 23 April 2012 - 09:13 AM.
Posted 23 April 2012 - 02:00 PM