15 this->varLengthX()->setRange(0.01, 100.0f);
16 this->varLengthZ()->setRange(1, 100.0f);
18 this->varSegmentX()->setRange(1, 100);
19 this->varSegmentZ()->setRange(1, 100);
31 this->varLocation()->attach(callback);
32 this->varScale()->attach(callback);
33 this->varRotation()->attach(callback);
35 this->varSegmentX()->attach(callback);
36 this->varSegmentZ()->attach(callback);
38 this->varLengthX()->attach(callback);
39 this->varLengthZ()->attach(callback);
42 auto tsRender = std::make_shared<GLSurfaceVisualModule>();
43 this->stateTriangleSet()->connect(tsRender->inTriangleSet());
46 auto exES = std::make_shared<ExtractEdgeSetFromPolygonSet<TDataType>>();
47 this->statePolygonSet()->connect(exES->inPolygonSet());
50 auto esRender = std::make_shared<GLWireframeVisualModule>();
51 esRender->varBaseColor()->setValue(
Color(0, 0, 0));
53 this->stateTriangleSet()->connect(esRender->inEdgeSet());
57 this->stateTriangleSet()->promoteOuput();
58 this->stateQuadSet()->promoteOuput();
60 this->stateTriangleSet()->promoteOuput();
61 this->stateQuadSet()->promoteOuput();
62 this->statePolygonSet()->promoteOuput();
121 auto center = this->varLocation()->getData();
122 auto rot = this->varRotation()->getData();
123 auto scale = this->varScale()->getData();
125 auto segmentX = this->varSegmentX()->getData();
126 auto segmentZ = this->varSegmentZ()->getData();
128 auto lengthX = this->varLengthX()->getData();
129 auto lengthZ = this->varLengthZ()->getData();
132 Vec3i segments =
Vec3i(segmentX, 1, segmentZ);
141 std::vector<Coord> vertices;
142 std::vector<TopologyModule::Quad> quads;
143 std::vector<TopologyModule::Triangle> triangles;
145 Real dx = lengthX / segmentX;
146 Real dz = lengthZ / segmentZ;
150 return center + q.
rotate(v);
153 uint numOfPolygon = segments[0] * segments[2];
159 for (
uint j = 0; j < numOfPolygon; j++)
166 polygonIndices.resize(counter2);
172 for (
int nz = 0; nz <= segmentZ; nz++)
174 for (
int nx = 0; nx <= segmentX; nx++)
176 x = nx * dx - lengthX / 2;
177 z = nz * dz - lengthZ / 2;
178 vertices.push_back(RV(
Coord(x,
Real(0), z)));
187 for (
int nz = 0; nz < segmentZ; nz++)
189 for (
int nx = 0; nx < segmentX; nx++)
191 v0 = nx + nz * (segmentX + 1);
192 v1 = nx + 1 + nz * (segmentX + 1);;
193 v2 = nx + 1 + (nz + 1) * (segmentX + 1);;
194 v3 = nx + (nz + 1) * (segmentX + 1);;
196 auto& quads = polygonIndices[incre];
198 if ((nx + nz) % 2 == 0) {
216 auto polySet = this->statePolygonSet()->getDataPtr();
218 polySet->setPoints(vertices);
219 polySet->setPolygons(polygonIndices);
222 polygonIndices.clear();
224 auto& ts = this->stateTriangleSet()->getData();
225 polySet->turnIntoTriangleSet(ts);
227 auto& qs = this->stateQuadSet()->getData();
228 polySet->extractQuadSet(qs);
DYN_FUNC Vector< Real, 3 > rotate(const Vector< Real, 3 > &v) const
Rotate a vector by the quaternion, guarantee the quaternion is normalized before rotating the vector.
DYN_FUNC bool operator<(const priority_queue< T, Container, Compare > &a, const priority_queue< T, Container, Compare > &b)