MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / DrawCone

Method DrawCone

src/Nazara/Renderer/DebugDrawer.cpp:438–512  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

436 }
437
438 void DebugDrawer::DrawCone(const Vector3f& origin, const Quaternionf& rotation, float angle, float length)
439 {
440 if (!Initialize())
441 {
442 NazaraError("Failed to initialize Debug Drawer");
443 return;
444 }
445
446 Matrix4f transformMatrix;
447 transformMatrix.MakeIdentity();
448 transformMatrix.SetRotation(rotation);
449 transformMatrix.SetTranslation(origin);
450
451 BufferMapper<VertexBuffer> mapper(s_vertexBuffer, BufferAccess_DiscardAndWrite, 0, 16);
452 VertexStruct_XYZ* vertex = static_cast<VertexStruct_XYZ*>(mapper.GetPointer());
453
454 // On calcule le reste des points
455 Vector3f base(Vector3f::Forward()*length);
456
457 // Il nous faut maintenant le rayon du cercle projeté à cette distance
458 // Tangente = Opposé/Adjaçent <=> Opposé = Adjaçent*Tangente
459 float radius = length*std::tan(DegreeToRadian(angle));
460 Vector3f lExtend = Vector3f::Left()*radius;
461 Vector3f uExtend = Vector3f::Up()*radius;
462
463 vertex->position.Set(transformMatrix * Vector3f::Zero());
464 vertex++;
465 vertex->position.Set(transformMatrix * (base + lExtend + uExtend));
466 vertex++;
467
468 vertex->position.Set(transformMatrix * (base + lExtend + uExtend));
469 vertex++;
470 vertex->position.Set(transformMatrix * (base + lExtend - uExtend));
471 vertex++;
472
473 vertex->position.Set(transformMatrix * Vector3f::Zero());
474 vertex++;
475 vertex->position.Set(transformMatrix * (base + lExtend - uExtend));
476 vertex++;
477
478 vertex->position.Set(transformMatrix * (base + lExtend - uExtend));
479 vertex++;
480 vertex->position.Set(transformMatrix * (base - lExtend - uExtend));
481 vertex++;
482
483 vertex->position.Set(transformMatrix * Vector3f::Zero());
484 vertex++;
485 vertex->position.Set(transformMatrix * (base - lExtend + uExtend));
486 vertex++;
487
488 vertex->position.Set(transformMatrix * (base - lExtend + uExtend));
489 vertex++;
490 vertex->position.Set(transformMatrix * (base - lExtend - uExtend));
491 vertex++;
492
493 vertex->position.Set(transformMatrix * Vector3f::Zero());
494 vertex++;
495 vertex->position.Set(transformMatrix * (base - lExtend - uExtend));

Callers

nothing calls this directly

Calls 4

SendColorMethod · 0.80
SetRotationMethod · 0.45
SetMethod · 0.45
UnmapMethod · 0.45

Tested by

no test coverage detected