SgMesh* MeshGenerator::generateArrow(double length, double width, double coneLengthRatio, double coneWidthRatio) { double r = width / 2.0; double h = length * coneLengthRatio; SgShapePtr cone = new SgShape; //setDivisionNumber(20); cone->setMesh(generateCone(r * coneWidthRatio, h)); SgPosTransform* conePos = new SgPosTransform; conePos->setTranslation(Vector3(0.0, length / 2.0 + h / 2.0, 0.0)); conePos->addChild(cone); SgShapePtr cylinder = new SgShape; //setDivisionNumber(12); cylinder->setMesh(generateCylinder(r, length, true, false)); //cylinder->setMesh(generateCylinder(r, length - h, true, false)); //SgPosTransform* cylinderPos = new SgPosTransform; //cylinderPos->setTranslation(Vector3(0.0, -h, 0.0)); //cylinderPos->addChild(cylinder); MeshExtractor meshExtractor; SgGroupPtr group = new SgGroup; group->addChild(conePos); //group->addChild(cylinderPos); group->addChild(cylinder); return meshExtractor.integrate(group); }
void SphereMarker::initialize(double radius, const Vector3f& color, float transparency) { SgShapePtr shape = new SgShape; MeshGenerator meshGenerator; shape->setMesh(meshGenerator.generateSphere(1.0)); material = shape->setMaterial(new SgMaterial); material->setDiffuseColor(color); material->setEmissiveColor(color); material->setTransparency(transparency); scale = new SgScaleTransform; scale->addChild(shape); scale->setScale(radius); addChild(scale); }