TEST(ChunkTests, InterpolatesNoiseInputsCorrectly) { const unsigned VOXELS_PER_CHUNK = Units::chunkToVoxel(1); DummyChunk ch1(0, 0, 0); glm::vec3 v000(ch1.getNoiseModuleInput(glm::vec3(0, 0, 0))); glm::vec3 v100(ch1.getNoiseModuleInput(glm::vec3(1, 0, 0))); glm::vec3 v200(ch1.getNoiseModuleInput(glm::vec3(2, 0, 0))); EXPECT_EQ(glm::vec3(0.0, 0.0, 0.0), v000); EXPECT_EQ(glm::vec3(1.f / (float)VOXELS_PER_CHUNK, 0.0, 0.0), v100); EXPECT_EQ(glm::vec3((1.f / (float)VOXELS_PER_CHUNK) * 2, 0.0, 0.0), v200); }
void cObjectFactoryPlane::resizePlane( float p_size_x, float p_size_z ) { size_x = p_size_x; size_z = p_size_z; mass = 1.0f; inv_mass = 1.0f; int segments_x = 10; int segments_z = 10; // resize vertex list, 3 triangles resizeTriangleList(2*segments_x*segments_z); // compute size of one small plate float psize_x = size_x / (float)segments_x; float psize_z = size_z / (float)segments_z; float phsize_x = psize_x*0.5f; float phsize_z = psize_z*0.5f; CVector<3,float> v000(-phsize_x, 0, -phsize_z); CVector<3,float> v100(phsize_x, 0, -phsize_z); CVector<3,float> v001(-phsize_x, 0, phsize_z); CVector<3,float> v101(phsize_x, 0, phsize_z); int triangle_iter = 0; for (int seg_z = 0; seg_z < segments_z; seg_z++) { float z = -phsize_z*(float)(segments_z-1) + psize_z*(float)seg_z; for (int seg_x = 0; seg_x < segments_x; seg_x++) { float x = -phsize_x*(float)(segments_x-1) + psize_x*(float)seg_x; setTriangleDataVT(triangle_iter, CVector<3,float>(-phsize_x+x, 0, phsize_z+z), CVector<3,float>(phsize_x+x, 0, phsize_z+z), CVector<3,float>(phsize_x+x, 0, -phsize_z+z), CVector<2,float>(((float)(seg_x)/(float)segments_x), ((float)(seg_z+1)/(float)segments_z)), CVector<2,float>(((float)(seg_x+1)/(float)segments_x), ((float)(seg_z+1)/(float)segments_z)), CVector<2,float>(((float)(seg_x+1)/(float)segments_x), ((float)(seg_z)/(float)segments_z)) ); triangle_iter++; setTriangleDataVT(triangle_iter, CVector<3,float>(phsize_x+x, 0, -phsize_z+z), CVector<3,float>(-phsize_x+x, 0, -phsize_z+z), CVector<3,float>(-phsize_x+x, 0, phsize_z+z), CVector<2,float>(((float)(seg_x+1)/(float)segments_x), ((float)(seg_z)/(float)segments_z)), CVector<2,float>(((float)(seg_x)/(float)segments_x), ((float)(seg_z)/(float)segments_z)), CVector<2,float>(((float)(seg_x)/(float)segments_x), ((float)(seg_z+1)/(float)segments_z)) ); triangle_iter++; } } setTexcoordsValid(true); computeTriangleFlatNormals(); setNormalsValid(true); setupBoundingSphereRadius(); }