void Planet::drawAtmoCell(float r1, float r2, float a1, float a2, Color4F r1col, Color4F r2col) { Vec2 v11(r1 * cosf(a1), r1 * sinf(a1)); Vec2 v12(r1 * cosf(a2), r1 * sinf(a2)); Vec2 v21(r2 * cosf(a1), r2 * sinf(a1)); Vec2 v22(r2 * cosf(a2), r2 * sinf(a2)); node()->drawTriangleGradient(v11, v21, v12, r1col, r2col, r1col); node()->drawTriangleGradient(v12, v21, v22, r1col, r2col, r2col); }
void Planet::drawStratumCell(float a1, float a2, const Stratum& s1, const Stratum& s2) { float r11 = _coreRadius + s1.alt1; float r12 = _coreRadius + s2.alt1; float r21 = _coreRadius + s1.alt2; float r22 = _coreRadius + s2.alt2; Vec2 v11(r11 * cosf(a1), r11 * sinf(a1)); Vec2 v12(r12 * cosf(a2), r12 * sinf(a2)); Vec2 v21(r21 * cosf(a1), r21 * sinf(a1)); Vec2 v22(r22 * cosf(a2), r22 * sinf(a2)); node()->drawTriangleGradient(v11, v21, v12, s1.col1, s2.col1, s1.col2); node()->drawTriangleGradient(v12, v21, v22, s1.col2, s2.col1, s2.col2); }
int main(int argc, char *argv[]) { Pooma::initialize(argc,argv); Pooma::Tester tester(argc, argv); // -------------------------------------------------------------------------- // 3D // -------------------------------------------------------------------------- Tensor<3,double,Full> t3f1(0.0, 3.0, 6.0, 1.0, 4.0, 7.0, 2.0, 5.0, 8.0); tester.out() << "t3f1: " << t3f1 << std::endl; Tensor<3,double,Full> t3f2 = -t3f1; tester.out() << "t3f2: " << t3f2 << std::endl; Tensor<3,double,Symmetric> t3s1(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); tester.out() << "t3s1: " << t3s1 << std::endl; Tensor<3,double,Symmetric> t3s2(-1.0, -2.0, -3.0, -4.0, -5.0, -6.0); tester.out() << "t3s2: " << t3s2 << std::endl; Tensor<3,double,Full> t3s1AsFull(1.0,2.0,4.0, 2.0,3.0,5.0, 4.0,5.0,6.0); tester.out() << "t3s1AsFull: " << t3s1AsFull << std::endl; Tensor<3,double,Full> t3s2AsFull = -t3s1AsFull; tester.out() << "t3s2AsFull: " << t3s2AsFull << std::endl; Tensor<3,double,Symmetric> t3s3(9.0, 9.0, 9.0, 9.0, 9.0, 9.0), t3s4(9.0, 9.0, 9.0, 9.0, 9.0, 9.0); t3s3 = t3s1 + t3s2; tester.out() << "t3s3 = t3s1 + t3s2: " << t3s3 << std::endl; tester.check("t3s3", t3s3, Tensor<3,double,Symmetric>(0.0)); tester.check("t3s3 against Full", (t3s3 == Tensor<3,double,Symmetric>(0.0))); Tensor<3,double,Full> t3f3(99.9), t3f4(99.9), t3f5(99.9), t3f6(99.9); t3f3 = t3f1 + t3f2; // No need to check results here; done in TestTensors t3f4 = t3s1 + t3s2; tester.out() << "t3f4 = t3s1 + t3s2: " << t3f4 << std::endl; tester.check("t3f4", (t3f4 == t3s3)); t3f5 = t3f1 + t3s2; tester.out() << "t3f5 = t3f1 + t3s2: " << t3f5 << std::endl; tester.check("t3f5", t3f5, t3f1 + t3s2AsFull); t3f6 = t3s2 + t3f1; tester.out() << "t3f6 = t3s2 + t3f1: " << t3f6 << std::endl; tester.check("t3f6", t3f6, t3f1 + t3s2AsFull); t3f6 -= t3f1; tester.out() << "t3f6 -= t3f1: " << t3f6 << std::endl; tester.check("t3f6", t3f6, t3s2AsFull); t3s4 = t3s3 - t3f1; tester.out() << "t3s4 = t3s3 - t3f1: " << t3s4 << std::endl; tester.check("t3s4", (t3s4 == Tensor<3,double,Symmetric>(0,-3,-4,-6,-7,-8))); // Test Tensor dot Tensor: // Full: double sum = 0.0; int i, j, k; t3f3 = dot(t3f1, t3f2); for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { for (k = 0; k < 3; ++k) { t3f3(i,k) -= t3f1(i,j)*t3f2(j,k); } } } t3f3 = t3f3*t3f3; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { sum += t3f3(i,j); } } tester.check("dot(t3f1, t3f2)", (sum == 0)); // Symmetric: sum = 0.0; t3f3 = dot(t3s1, t3s2); for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { for (k = 0; k < 3; ++k) { t3f3(i,k) -= t3s1(i,j)*t3s2(j,k); } } } t3f3 = t3f3*t3f3; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { sum += t3f3(i,j); } } tester.check("dot(t3s1, t3s2)", (sum == 0)); // Test Tensor dot Vector, and vice-versa: // Full: // Vector dot Tensor Vector<3> v31(1.0, 2.0, 3.0); tester.out() << "v31: " << v31 << std::endl; Vector<3> v32(9.0); v32 = dot(v31, t3f2); tester.out() << "v32 = dot(v31, t3f2): " << v32 << std::endl; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { v32(j) -= v31(i)*t3f2(i,j); } } v32 = v32*v32; sum = 0.0; for (i = 0; i < 3; ++i) { sum += v32(i); } tester.check("dot(v31, t3f2)", (sum == 0)); // Tensor dot Vector v32 = dot(t3f2, v31); tester.out() << "v32 = dot(t3f2, v31): " << v32 << std::endl; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { v32(i) -= t3f2(i,j)*v31(j); } } v32 = v32*v32; sum = 0.0; for (i = 0; i < 3; ++i) { sum += v32(i); } tester.check("dot(t3f2, v31)", (sum == 0)); // Symmetric: // Vector dot Tensor v32 = dot(v31, t3s2); tester.out() << "v32 = dot(v31, t3s2): " << v32 << std::endl; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { v32(j) -= v31(i)*t3s2(i,j); } } v32 = v32*v32; sum = 0.0; for (i = 0; i < 3; ++i) { sum += v32(i); } tester.check("dot(v31, t3s2)", (sum == 0)); // Tensor dot Vector v32 = dot(t3s2, v31); tester.out() << "v32 = dot(t3s2, v31): " << v32 << std::endl; for (i = 0; i < 3; ++i) { for (j = 0; j < 3; ++j) { v32(i) -= t3s2(i,j)*v31(j); } } v32 = v32*v32; sum = 0.0; for (i = 0; i < 3; ++i) { sum += v32(i); } tester.check("dot(t3s2, v31)", (sum == 0)); // -------------------------------------------------------------------------- // 2D // -------------------------------------------------------------------------- Tensor<2,double,Full> t2f1(0.0, 2.0, 1.0, 3.0); tester.out() << "t2f1: " << t2f1 << std::endl; Tensor<2,double,Full> t2f2 = -t2f1; tester.out() << "t2f2: " << t2f2 << std::endl; Tensor<2,double,Symmetric> t2s1(1.0, 2.0, 3.0); tester.out() << "t2s1: " << t2s1 << std::endl; Tensor<2,double,Symmetric> t2s2(-1.0, -2.0, -3.0); tester.out() << "t2s2: " << t2s2 << std::endl; Tensor<2,double,Full> t2s1AsFull(1.0,2.0, 2.0,3.0); tester.out() << "t2s1AsFull: " << t2s1AsFull << std::endl; Tensor<2,double,Full> t2s2AsFull = -t2s1AsFull; tester.out() << "t2s2AsFull: " << t2s2AsFull << std::endl; Tensor<2,double,Symmetric> t2s3(9.0, 9.0, 9.0), t2s4(9.0, 9.0, 9.0); t2s3 = t2s1 + t2s2; tester.out() << "t2s3 = t2s1 + t2s2: " << t2s3 << std::endl; tester.check("t2s3", t2s3, Tensor<2,double,Symmetric>(0.0)); tester.check("t2s3 against Full", (t2s3 == Tensor<2,double,Symmetric>(0.0))); Tensor<2,double,Full> t2f3(99.9), t2f4(99.9), t2f5(99.9), t2f6(99.9), t2f7(99.9); t2f3 = t2f1 + t2f2; tester.out() << "t2f3 = t2f1 + t2f2: " << t2f3 << std::endl; tester.check("t2f3", t2f3, Tensor<2,double,Full>(0.0)); t2f4 = t2s1 + t2s2; tester.out() << "t2f4 = t2s1 + t2s2: " << t2f4 << std::endl; tester.check("t2f4", (t2f4 == t2s3)); t2f5 = t2f1 + t2s2; tester.out() << "t2f5 = t2f1 + t2s2: " << t2f5 << std::endl; tester.check("t2f5", t2f5, t2f1 + t2s2AsFull); t2f6 = t2s2 + t2f1; tester.out() << "t2f6 = t2s2 + t2f1: " << t2f6 << std::endl; tester.check("t2f6", t2f6, t2f1 + t2s2AsFull); t2f6 -= t2f1; tester.out() << "t2f6 -= t2f1: " << t2f6 << std::endl; tester.check("t2f6", t2f6, t2s2AsFull); t2s4 = t2s3 - t2f1; tester.out() << "t2s4 = t2s3 - t2f1: " << t2s4 << std::endl; tester.check("t2s4", (t2s4 == Tensor<2,double,Symmetric>(-0, -2, -3))); // Test Tensor dot Tensor: // Full: sum = 0.0; t2f3 = dot(t2f1, t2f2); for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { for (k = 0; k < 2; ++k) { t2f3(i,k) -= t2f1(i,j)*t2f2(j,k); } } } t2f3 = t2f3*t2f3; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { sum += t2f3(i,j); } } tester.check("dot(t2f1, t2f2)", (sum == 0)); // Symmetric: sum = 0.0; t2f3 = dot(t2s1, t2s2); for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { for (k = 0; k < 2; ++k) { t2f3(i,k) -= t2s1(i,j)*t2s2(j,k); } } } t2f3 = t2f3*t2f3; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { sum += t2f3(i,j); } } tester.check("dot(t2s1, t2s2)", (sum == 0)); // Test Tensor dot Vector, and vice-versa: // Full: // Vector dot Tensor Vector<2> v21(1.0, 2.0); tester.out() << "v21: " << v21 << std::endl; Vector<2> v22(9.0); v22 = dot(v21, t2f2); tester.out() << "v22 = dot(v21, t2f2): " << v22 << std::endl; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { v22(j) -= v21(i)*t2f2(i,j); } } v22 = v22*v22; sum = 0.0; for (i = 0; i < 2; ++i) { sum += v22(i); } tester.check("dot(v21, t2f2)", (sum == 0)); // Tensor dot Vector v22 = dot(t2f2, v21); tester.out() << "v22 = dot(t2f2, v21): " << v22 << std::endl; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { v22(i) -= t2f2(i,j)*v21(j); } } v22 = v22*v22; sum = 0.0; for (i = 0; i < 2; ++i) { sum += v22(i); } tester.check("dot(t2f2, v21)", (sum == 0)); // Symmetric: // Vector dot Tensor v22 = dot(v21, t2s2); tester.out() << "v22 = dot(v21, t2s2): " << v22 << std::endl; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { v22(j) -= v21(i)*t2s2(i,j); } } v22 = v22*v22; sum = 0.0; for (i = 0; i < 2; ++i) { sum += v22(i); } tester.check("dot(v21, t2s2)", (sum == 0)); // Tensor dot Vector v22 = dot(t2s2, v21); tester.out() << "v22 = dot(t2s2, v21): " << v22 << std::endl; for (i = 0; i < 2; ++i) { for (j = 0; j < 2; ++j) { v22(i) -= t2s2(i,j)*v21(j); } } v22 = v22*v22; sum = 0.0; for (i = 0; i < 2; ++i) { sum += v22(i); } tester.check("dot(t2s2, v21)", (sum == 0)); // -------------------------------------------------------------------------- // 1D // -------------------------------------------------------------------------- Tensor<1,double,Full> t1f1(1.0); tester.out() << "t1f1: " << t1f1 << std::endl; Tensor<1,double,Full> t1f2 = -t1f1; tester.out() << "t1f2: " << t1f2 << std::endl; Tensor<1,double,Symmetric> t1s1(1.0); tester.out() << "t1s1: " << t1s1 << std::endl; Tensor<1,double,Symmetric> t1s2(-1.0); tester.out() << "t1s2: " << t1s2 << std::endl; Tensor<1,double,Full> t1s1AsFull(1.0); tester.out() << "t1s1AsFull: " << t1s1AsFull << std::endl; Tensor<1,double,Full> t1s2AsFull = -t1s1AsFull; tester.out() << "t1s2AsFull: " << t1s2AsFull << std::endl; Tensor<1,double,Symmetric> t1s3(9.0), t1s4(9.0); t1s3 = t1s1 + t1s2; tester.out() << "t1s3 = t1s1 + t1s2: " << t1s3 << std::endl; tester.check("t1s3", t1s3, Tensor<1,double,Symmetric>(0.0)); tester.check("t1s3 against Full", (t1s3 == Tensor<1,double,Symmetric>(0.0))); Tensor<1,double,Full> t1f3(99.9), t1f4(99.9), t1f5(99.9), t1f6(99.9), t1f7(99.9); t1f3 = t1f1 + t1f2; tester.out() << "t1f3 = t1f1 + t1f2: " << t1f3 << std::endl; tester.check("t1f3", t1f3, Tensor<1,double,Full>(0.0)); t1f4 = t1s1 + t1s2; tester.out() << "t1f4 = t1s1 + t1s2: " << t1f4 << std::endl; tester.check("t1f4", (t1f4 == t1s3)); t1f5 = t1f1 + t1s2; tester.out() << "t1f5 = t1f1 + t1s2: " << t1f5 << std::endl; tester.check("t1f5", t1f5, t1f1 + t1s2AsFull); t1f6 = t1s2 + t1f1; tester.out() << "t1f6 = t1s2 + t1f1: " << t1f6 << std::endl; tester.check("t1f6", t1f6, t1f1 + t1s2AsFull); t1f6 -= t1f1; tester.out() << "t1f6 -= t1f1: " << t1f6 << std::endl; tester.check("t1f6", t1f6, t1s2AsFull); t1s4 = t1s3 - t1f1; tester.out() << "t1s4 = t1s3 - t1f1: " << t1s4 << std::endl; tester.check("t1s4", (t1s4 == Tensor<1,double,Symmetric>(-1))); // Test Tensor dot Tensor: // Full: sum = 0.0; t1f3 = dot(t1f1, t1f2); for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { for (k = 0; k < 1; ++k) { t1f3(i,k) -= t1f1(i,j)*t1f2(j,k); } } } t1f3 = t1f3*t1f3; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { sum += t1f3(i,j); } } tester.check("dot(t1f1, t1f2)", (sum == 0)); // Symmetric: sum = 0.0; t1f3 = dot(t1s1, t1s2); for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { for (k = 0; k < 1; ++k) { t1f3(i,k) -= t1s1(i,j)*t1s2(j,k); } } } t1f3 = t1f3*t1f3; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { sum += t1f3(i,j); } } tester.check("dot(t1s1, t1s2)", (sum == 0)); // Test Tensor dot Vector, and vice-versa: // Full: // Vector dot Tensor Vector<1> v11(1.0); tester.out() << "v11: " << v11 << std::endl; Vector<1> v12(9.0); v12 = dot(v11, t1f2); tester.out() << "v12 = dot(v11, t1f2): " << v12 << std::endl; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { v12(j) -= v11(i)*t1f2(i,j); } } v12 = v12*v12; sum = 0.0; for (i = 0; i < 1; ++i) { sum += v12(i); } tester.check("dot(v11, t1f2)", (sum == 0)); // Tensor dot Vector v12 = dot(t1f2, v11); tester.out() << "v12 = dot(t1f2, v11): " << v12 << std::endl; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { v12(i) -= t1f2(i,j)*v11(j); } } v12 = v12*v12; sum = 0.0; for (i = 0; i < 1; ++i) { sum += v12(i); } tester.check("dot(t1f2, v11)", (sum == 0)); // Symmetric: // Vector dot Tensor v12 = dot(v11, t1s2); tester.out() << "v12 = dot(v11, t1s2): " << v12 << std::endl; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { v12(j) -= v11(i)*t1s2(i,j); } } v12 = v12*v12; sum = 0.0; for (i = 0; i < 1; ++i) { sum += v12(i); } tester.check("dot(v11, t1s2)", (sum == 0)); // Tensor dot Vector v12 = dot(t1s2, v11); tester.out() << "v12 = dot(t1s2, v11): " << v12 << std::endl; for (i = 0; i < 1; ++i) { for (j = 0; j < 1; ++j) { v12(i) -= t1s2(i,j)*v11(j); } } v12 = v12*v12; sum = 0.0; for (i = 0; i < 1; ++i) { sum += v12(i); } tester.check("dot(t1s2, v11)", (sum == 0)); int ret = tester.results("TestSymmetricTensors"); Pooma::finalize(); return ret; }
osg::Drawable *ClampNode::createBrick(void) const { // Get the brick Clamp* clamp = static_cast<Clamp*>(_lego); // Get brick color QColor color = clamp->getColor(); // Get clamp bounding box clamp->calculateBoundingBox(); BoundingBox bb = clamp->getBoundingBox(); // Get integer sizes int width = bb.getWidth(); int length = bb.getLength(); int height = bb.getHeight(); // Get real position, according to tile size double mw = (-width)*Lego::length_unit/2; double mwpm = (-width)*Lego::length_unit/2+Lego::height_unit/2; double mwp = (-width)*Lego::length_unit/2+0.93*Lego::height_unit; double pw = (width)*Lego::length_unit/2; double pwm = (width)*Lego::length_unit/2-Lego::height_unit/2; double ml = (-length)*Lego::length_unit/2; double mlp = (-length+0.5)*Lego::length_unit/2; double pl = (length)*Lego::length_unit/2; double plm = (length-0.5)*Lego::length_unit/2; double mh = (-height)*Lego::height_unit/2; double mhp = (-height)*Lego::height_unit/2+2*Lego::plot_top_height; double mhpm = (-height)*Lego::height_unit/2+Lego::plot_top_height; double phm = (height)*Lego::height_unit/2-Lego::height_unit/2; double phmp = (height)*Lego::height_unit/2-0.5*Lego::height_unit/2; // Create 3 vertices osg::ref_ptr<osg::Vec3Array> vertices = new osg::Vec3Array; osg::Vec3 v0(ml, mw, mh); osg::Vec3 v1(pl, mw, mh); osg::Vec3 v2(pl, pw, mh); osg::Vec3 v3(ml, pw, mh); osg::Vec3 v4(ml, pw, mhp); osg::Vec3 v5(pl, pw, mhp); osg::Vec3 v6(pl, mw, mhp); osg::Vec3 v7(ml, mw, mhp); osg::Vec3 v8(mlp, mw, mhp); osg::Vec3 v9(mlp, mw, phm); osg::Vec3 v10(ml, mw, phm); osg::Vec3 v11(ml, mwp, phmp); osg::Vec3 v12(mlp, mwp, phmp); osg::Vec3 v13(mlp, pw, mhp); osg::Vec3 v14(plm, mw, mhp); osg::Vec3 v15(plm, mw, phm); osg::Vec3 v16(pl, mw, phm); osg::Vec3 v17(pl, mwp, phmp); osg::Vec3 v18(plm, mwp, phmp); osg::Vec3 v19(plm, pw, mhp); osg::Vec3 v20(mlp, mwpm, mh); osg::Vec3 v21(plm, mwpm, mh); osg::Vec3 v22(plm, pwm, mh); osg::Vec3 v23(mlp, pwm, mh); osg::Vec3 v24(mlp, mwpm, mhpm); osg::Vec3 v25(plm, mwpm, mhpm); osg::Vec3 v26(plm, pwm, mhpm); osg::Vec3 v27(mlp, pwm, mhpm); // Create 1 faces, 0 faces are quads splitted into two triangles // NB: Down face is transparent, we don't even create it // Bottom vertices->push_back(v3); vertices->push_back(v2); vertices->push_back(v1); vertices->push_back(v0); // Bottom hole vertices->push_back(v20); vertices->push_back(v21); vertices->push_back(v22); vertices->push_back(v23); // Bottom far vertices->push_back(v24); vertices->push_back(v25); vertices->push_back(v26); vertices->push_back(v27); // Front face vertices->push_back(v2); vertices->push_back(v3); vertices->push_back(v4); vertices->push_back(v5); // Back face vertices->push_back(v0); vertices->push_back(v1); vertices->push_back(v6); vertices->push_back(v7); // Left bottom face vertices->push_back(v0); vertices->push_back(v3); vertices->push_back(v4); vertices->push_back(v7); // Right bottom face vertices->push_back(v1); vertices->push_back(v2); vertices->push_back(v5); vertices->push_back(v6); // Top face vertices->push_back(v4); vertices->push_back(v5); vertices->push_back(v6); vertices->push_back(v7); // Left part back vertices->push_back(v7); vertices->push_back(v8); vertices->push_back(v9); vertices->push_back(v10); // Left part left ext vertices->push_back(v4); vertices->push_back(v7); vertices->push_back(v10); vertices->push_back(v11); // Left part front vertices->push_back(v4); vertices->push_back(v11); vertices->push_back(v12); vertices->push_back(v13); // Left part left int vertices->push_back(v8); vertices->push_back(v9); vertices->push_back(v12); vertices->push_back(v13); // Right part back vertices->push_back(v6); vertices->push_back(v14); vertices->push_back(v15); vertices->push_back(v16); // Left part left ext vertices->push_back(v5); vertices->push_back(v6); vertices->push_back(v16); vertices->push_back(v17); // Left part front vertices->push_back(v5); vertices->push_back(v17); vertices->push_back(v18); vertices->push_back(v19); // Left part left int vertices->push_back(v14); vertices->push_back(v15); vertices->push_back(v18); vertices->push_back(v19); // Bottom front vertices->push_back(v20); vertices->push_back(v21); vertices->push_back(v25); vertices->push_back(v24); // Bottom right vertices->push_back(v21); vertices->push_back(v22); vertices->push_back(v26); vertices->push_back(v25); // Bottom back vertices->push_back(v22); vertices->push_back(v23); vertices->push_back(v27); vertices->push_back(v26); // Bottom left vertices->push_back(v23); vertices->push_back(v20); vertices->push_back(v24); vertices->push_back(v27); // Create tile geometry osg::ref_ptr<osg::Geometry> clampGeometry = new osg::Geometry; // Match vertices clampGeometry->setVertexArray(vertices); // Create colors osg::Vec4 osgColor(static_cast<float>(color.red())/255.0, static_cast<float>(color.green())/255.0, static_cast<float>(color.blue())/255.0, 1.0); osg::ref_ptr<osg::Vec4Array> colors = new osg::Vec4Array; // Every face has the same color, so there is only one color colors->push_back(osgColor); // Match color clampGeometry->setColorArray(colors); clampGeometry->setColorBinding(osg::Geometry::BIND_OVERALL); // Create normals osg::ref_ptr<osg::Vec3Array> normals = new osg::Vec3Array; normals->push_back(osg::Vec3(0, 0, -1)); normals->push_back(osg::Vec3(0, 0, -1)); normals->push_back(osg::Vec3(0, 1, 0)); normals->push_back(osg::Vec3(0, -1, 0)); normals->push_back(osg::Vec3(-1, 0, 0)); normals->push_back(osg::Vec3(1, 0, 0)); normals->push_back(osg::Vec3(0, 0, 1)); normals->push_back(osg::Vec3(0, -1, 0)); normals->push_back(osg::Vec3(-1, 0, 0)); double w = pw - mwp; double h = phmp - mhp; double norm = std::sqrt(w*w + h*h); normals->push_back(osg::Vec3(0, h/norm, w/norm)); normals->push_back(osg::Vec3(1, 0, 0)); normals->push_back(osg::Vec3(0, -1, 0)); normals->push_back(osg::Vec3(1, 0, 0)); normals->push_back(osg::Vec3(0, h/norm, w/norm)); normals->push_back(osg::Vec3(-1, 0, 0)); normals->push_back(osg::Vec3(0, 1, 0)); normals->push_back(osg::Vec3(-1, 0, 0)); normals->push_back(osg::Vec3(0, -1, 0)); normals->push_back(osg::Vec3(1, 0, 0)); // Match normals clampGeometry->setNormalArray(normals); clampGeometry->setNormalBinding(osg::Geometry::BIND_PER_PRIMITIVE); // Define 1 GL_QUADS with 1*4 vertices, corresponding to bottom part clampGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 0*4, 4)); // Define 1 GL_QUADS with 1*4 vertices, corresponding to 1 hole in bottom part clampGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 1*4, 4)); // Retesslate to create hole osgUtil::Tessellator tesslator; tesslator.setTessellationType(osgUtil::Tessellator::TESS_TYPE_GEOMETRY); tesslator.setWindingType(osgUtil::Tessellator::TESS_WINDING_ODD); tesslator.retessellatePolygons(*clampGeometry); // Create 17 GL_QUADS, i.e. 18*4 vertices clampGeometry->addPrimitiveSet(new osg::DrawArrays(osg::PrimitiveSet::QUADS, 2*4, 18*4)); // Return the tile whithout plot return clampGeometry.release(); }