30 #pragma region ProceduralObject
34 if (pos >= 0 && pos < (
int)points.size())
46 if (pos >= 0 && pos < (
int)points.size())
48 points.insert(points.begin() + pos, p);
52 void ProceduralObject::deletePoint(
int pos)
54 if (pos >= 0 && pos < (
int)points.size())
56 points.erase(points.begin() + pos);
62 #pragma region ProceduralManager
64 ProceduralManager::ProceduralManager(Ogre::SceneNode* groupingSceneNode)
65 : pGroupingSceneNode(groupingSceneNode)
76 if (pos >= 0 && pos < (
int)
pObjects.size())
106 for (
size_t i = 0; i <
pObjects.size(); i++)
124 Ogre::SimpleSpline spline;
128 spline.setAutoCalculate(
false);
131 spline.addPoint(pp->position);
133 spline.recalcTangents();
136 for (
int i_point = 0; i_point < po->
getNumPoints(); i_point++)
144 for (
int i_seg = 1; i_seg <= num_segments; i_seg++)
148 po->
road->
addBlock(pp->position, pp->rotation, pp->type, pp->width, pp->bwidth, pp->bheight, pp->pillartype);
152 const float progress =
static_cast<float>(i_seg) /
static_cast<float>(num_segments);
155 const Ogre::Vector3 smooth_pos = spline.interpolate(i_point - 1, progress);
156 const Ogre::Quaternion smooth_rot =
Quaternion::nlerp(progress, prev_pp->rotation, pp->rotation);
157 const float smooth_width = Math::lerp(prev_pp->width, pp->width, progress);
158 const float smooth_bwidth = Math::lerp(prev_pp->bwidth, pp->bwidth, progress);
159 const float smooth_bheight = Math::lerp(prev_pp->bheight, pp->bheight, progress);
161 po->
road->
addBlock(smooth_pos, smooth_rot, pp->type, smooth_width, smooth_bwidth, smooth_bheight, pp->pillartype);
168 po->
road->
addBlock(pp->position, pp->rotation, pp->type, pp->width, pp->bwidth, pp->bheight, pp->pillartype);
182 Log(
"[RoR] Procedural road diagnostic.\n"
183 " types: 0=ROAD_AUTOMATIC, 1=ROAD_FLAT, 2=ROAD_LEFT, 3=ROAD_RIGHT, 4=ROAD_BOTH, 5=ROAD_BRIDGE, 6=ROAD_MONORAIL\n"
184 " pillartypes: 0=none, 1=road bridge, 2=monorail");
185 for (
int i=0; i< (int)
pObjects.size(); ++i)
187 LogFormat(
"~~~~~~ ProceduralObject %d ~~~~~~", i);
189 for (
int j = 0; j<(int)po->
points.size(); ++j)
192 LogFormat(
"\t Point [%d] posXYZ %f %f %f, type %d, width %f, bwidth %f, bheight %f, pillartype %i",
193 j, pp->position.x, pp->position.y, pp->position.z,
194 pp->type, pp->width, pp->bwidth, pp->bheight, pp->pillartype);