102 Vector3 leftv = pos + rot * Vector3(0, 0, bwidth + width / 2.0);
103 Vector3 rightv = pos + rot * Vector3(0, 0, -bwidth - width / 2.0);
106 if (dleft < bheight + 0.1 && dright < bheight + 0.1)
108 if (dleft < bheight + 0.1 && dright >= bheight + 0.1 && dright < 4.0)
110 if (dleft >= bheight + 0.1 && dleft < 4.0 && dright < bheight + 0.1)
112 if (dleft >= bheight + 0.1 && dleft < 4.0 && dright >= bheight + 0.1 && dright < 4.0)
179 Vector3 leftv = pos + rot * Vector3(0, 0, bwidth + width / 2.0);
180 Vector3 rightv = pos + rot * Vector3(0, 0, -bwidth - width / 2.0);
181 Vector3 middle = lpts[0] - ((lpts[0] + (pts[1] - lpts[0]) / 2) -
182 (lpts[7] + (pts[6] - lpts[7]) / 2)) * 0.5;
187 bool builtpillars =
true;
189 float sidefactor = 0.5;
192 if (pos.y - heightmiddle < 10)
194 if (heightleft >= heightright)
200 static int pillarcounter = 0;
208 if (pillarcounter % 5)
209 builtpillars =
false;
212 middle = lpts[0] - ((lpts[0] + (pts[1] - lpts[0]) / 2) -
213 (lpts[7] + (pts[6] - lpts[7]) / 2)) * sidefactor;
215 float width2 = len / 30;
217 if (pillartype == 2 && len > 20)
219 builtpillars =
false;
228 if (width2 >= 0.2 && builtpillars)
231 addQuad(middle + Vector3(-width2, -len, -width2),
232 middle + Vector3(-width2, 0, -width2),
233 middle + Vector3(width2, 0, -width2),
234 middle + Vector3(width2, -len, -width2),
237 addQuad(middle + Vector3(width2, -len, width2),
238 middle + Vector3(width2, 0, width2),
239 middle + Vector3(-width2, 0, width2),
240 middle + Vector3(-width2, -len, width2),
243 addQuad(middle + Vector3(-width2, -len, width2),
244 middle + Vector3(-width2, 0, width2),
245 middle + Vector3(-width2, 0, -width2),
246 middle + Vector3(-width2, -len, -width2),
249 addQuad(middle + Vector3(width2, -len, -width2),
250 middle + Vector3(width2, 0, -width2),
251 middle + Vector3(width2, 0, width2),
252 middle + Vector3(width2, -len, width2),
274 Str<2000> msg; msg <<
"[RoR] Road Block |";
275 msg <<
" pos=(" << pos.x <<
" " << pos.y <<
" " << pos.z <<
")";
276 msg <<
" rot=(" << rot.x <<
" " << rot.y <<
" " << rot.z <<
")";
277 msg <<
" width=" << width;
278 msg <<
" bwidth=" << bwidth;
279 msg <<
" bheight=" << bheight;
280 msg <<
" type=" << (int)type;
281 for (
int i = 0; i < 8; ++i)
283 msg <<
"\n\t Point#" << i <<
": " << pts[i].x <<
" " << pts[i].y <<
" " << pts[i].z;
293 pts[1] = pos + rot * Vector3(0, -bheight, bwidth + width / 2.0);
295 pts[2] = pos + rot * Vector3(0, -bheight / 4.0, bwidth / 3.0 + width / 2.0);
296 pts[3] = pos + rot * Vector3(0, 0, width / 2.0);
297 pts[4] = pos + rot * Vector3(0, 0, -width / 2.0);
298 pts[5] = pos + rot * Vector3(0, -bheight / 4.0, -bwidth / 3.0 - width / 2.0);
299 pts[6] = pos + rot * Vector3(0, -bheight, -bwidth - width / 2.0);
304 pts[1] = pos + rot * Vector3(0, bheight, bwidth + width / 2.0);
306 pts[2] = pos + rot * Vector3(0, bheight, width / 2.0);
307 pts[3] = pos + rot * Vector3(0, 0, width / 2.0);
308 pts[4] = pos + rot * Vector3(0, 0, -width / 2.0);
309 pts[5] = pos + rot * Vector3(0, bheight, -width / 2.0);
310 pts[6] = pos + rot * Vector3(0, bheight, -bwidth - width / 2.0);
315 pts[1] = pos + rot * Vector3(0, -bheight, bwidth + width / 2.0);
317 pts[2] = pos + rot * Vector3(0, -bheight / 4.0, bwidth / 3.0 + width / 2.0);
318 pts[3] = pos + rot * Vector3(0, 0, width / 2.0);
319 pts[4] = pos + rot * Vector3(0, 0, -width / 2.0);
320 pts[5] = pos + rot * Vector3(0, bheight, -width / 2.0);
321 pts[6] = pos + rot * Vector3(0, bheight, -bwidth - width / 2.0);
326 pts[1] = pos + rot * Vector3(0, bheight, bwidth + width / 2.0);
328 pts[2] = pos + rot * Vector3(0, bheight, width / 2.0);
329 pts[3] = pos + rot * Vector3(0, 0, width / 2.0);
330 pts[4] = pos + rot * Vector3(0, 0, -width / 2.0);
331 pts[5] = pos + rot * Vector3(0, -bheight / 4.0, -bwidth / 3.0 - width / 2.0);
332 pts[6] = pos + rot * Vector3(0, -bheight, -bwidth - width / 2.0);
337 pts[0] = pos + rot * Vector3(0, -0.4, bwidth + width / 2.0);
338 pts[1] = pos + rot * Vector3(0, bheight, bwidth + width / 2.0);
339 pts[2] = pos + rot * Vector3(0, bheight, width / 2.0);
340 pts[3] = pos + rot * Vector3(0, 0, width / 2.0);
341 pts[4] = pos + rot * Vector3(0, 0, -width / 2.0);
342 pts[5] = pos + rot * Vector3(0, bheight, -width / 2.0);
343 pts[6] = pos + rot * Vector3(0, bheight, -bwidth - width / 2.0);
344 pts[7] = pos + rot * Vector3(0, -0.4, -bwidth - width / 2.0);
348 pts[0] = pos + rot * Vector3(0, -1.4, bwidth + width / 2.0);
349 pts[1] = pos + rot * Vector3(0, bheight, bwidth + width / 2.0);
350 pts[2] = pos + rot * Vector3(0, bheight, width / 2.0);
351 pts[3] = pos + rot * Vector3(0, 0, width / 2.0);
352 pts[4] = pos + rot * Vector3(0, 0, -width / 2.0);
353 pts[5] = pos + rot * Vector3(0, bheight, -width / 2.0);
354 pts[6] = pos + rot * Vector3(0, bheight, -bwidth - width / 2.0);
355 pts[7] = pos + rot * Vector3(0, -1.4, -bwidth - width / 2.0);
435 Vector3 bx = pref2 - pref1;
437 Vector3 by = Vector3::UNIT_Y;
438 Vector3 bz = bx.crossProduct(by);
441 reverse.SetColumn(0, bx);
442 reverse.SetColumn(1, by);
443 reverse.SetColumn(2, bz);
445 forward = reverse.Inverse();
447 for (i = 0; i < 4; i++)
449 Vector3 trv = forward * (ps[i] - pref1);
452 float ty = 0.746 - trv.y * 0.25 / 4.5;
456 texc[i] = Vector2(trv.x / 10.0, ty);
461 float ty = 0.496 - (trv.y - 0.7) * 0.25 / 4.5;
464 texc[i] = Vector2(trv.x / 10.0, ty);
468 float ty = 0.496 + trv.y * 0.25 / 4.5;
472 texc[i] = Vector2(trv.x / 10.0, ty);
487 for (i = 0; i < 4; i++)
492 Vector3 bx = pref2 - pref1;
494 Vector3 by = Vector3::UNIT_Y;
495 Vector3 bz = bx.crossProduct(by);
498 reverse.SetColumn(0, bx);
499 reverse.SetColumn(1, by);
500 reverse.SetColumn(2, bz);
502 forward = reverse.Inverse();
505 for (i = 0; i < 4; i++)
507 Vector3 trv = forward * (ps[i] - pref1);
512 texc[i] = Vector2(trv.x / 10.0, 0.621 + (trv.z - trvrefz) * 0.25 / 4.5);
544 texc[i] = Vector2(trv.x / 10.0, v1);
546 texc[i] = Vector2(trv.x / 10.0, v2);
552 for (i = 0; i < 4; i++)
553 texc[i] = Vector2(0, 0);
606 Ogre::String mesh_name = Ogre::String(
"RoadSystem-").append(Ogre::StringConverter::toString(
mid));
607 msh = MeshManager::getSingleton().createManual(mesh_name, ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
611 if (materialName ==
"")
615 else if (!MaterialManager::getSingleton().resourceExists(materialName,
App::GetGameContext()->GetTerrain()->getTerrainFileResourceGroup()))
617 LOG(fmt::format(
"[RoR|ProceduralRoad] Custom material '{}' does not exist. Using default.", materialName));
627 vertices = (
float*)malloc(vbufCount *
sizeof(
float));
632 covertices[i].texcoord =
tex[i];
633 covertices[i].vertex =
vertex[i];
635 covertices[i].normal = Vector3::ZERO;
646 v1 = covertices[
tris[i * 3 + 1]].vertex - covertices[
tris[i * 3]].vertex;
647 v2 = covertices[
tris[i * 3 + 2]].vertex - covertices[
tris[i * 3]].vertex;
648 v1 = v1.crossProduct(v2);
650 covertices[
tris[i * 3]].normal += v1;
651 covertices[
tris[i * 3 + 1]].normal += v1;
652 covertices[
tris[i * 3 + 2]].normal += v1;
657 covertices[i].normal.normalise();
661 msh->sharedVertexData =
new VertexData();
665 VertexDeclaration* decl =
msh->sharedVertexData->vertexDeclaration;
667 decl->addElement(0, offset, VET_FLOAT3, VES_POSITION);
668 offset += VertexElement::getTypeSize(VET_FLOAT3);
669 decl->addElement(0, offset, VET_FLOAT3, VES_NORMAL);
670 offset += VertexElement::getTypeSize(VET_FLOAT3);
671 decl->addElement(0, offset, VET_FLOAT2, VES_TEXTURE_COORDINATES, 0);
672 offset += VertexElement::getTypeSize(VET_FLOAT2);
676 HardwareVertexBufferSharedPtr vbuf =
677 HardwareBufferManager::getSingleton().createVertexBuffer(
678 offset,
msh->sharedVertexData->vertexCount, HardwareBuffer::HBU_STATIC_WRITE_ONLY);
681 vbuf->writeData(0, vbuf->getSizeInBytes(), vertices,
true);
684 VertexBufferBinding* bind =
msh->sharedVertexData->vertexBufferBinding;
685 bind->setBinding(0, vbuf);
689 HardwareIndexBufferSharedPtr ibuf = HardwareBufferManager::getSingleton().
691 HardwareIndexBuffer::IT_16BIT,
693 HardwareBuffer::HBU_STATIC_WRITE_ONLY);
696 ibuf->writeData(0, ibuf->getSizeInBytes(),
tris,
true);
699 mainsub->useSharedVertices =
true;
700 mainsub->indexData->indexBuffer = ibuf;
701 mainsub->indexData->indexCount = ibufCount;
702 mainsub->indexData->indexStart = 0;
704 msh->_setBounds(aab,
true);
Game state manager and message-queue provider.