MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / RenderLine

Method RenderLine

extensions/olcPGEX_Graphics3D.h:1030–1068  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1028 }
1029
1030 uint32_t GFX3D::PipeLine::RenderLine(olc::GFX3D::vec3d &p1, olc::GFX3D::vec3d &p2, olc::Pixel col)
1031 {
1032 // Coordinates are assumed to be in world space
1033 olc::GFX3D::vec3d t1, t2;
1034
1035 // Transform into view
1036 t1 = GFX3D::Math::Mat_MultiplyVector(matView, p1);
1037 t2 = GFX3D::Math::Mat_MultiplyVector(matView, p2);
1038
1039 // Project onto screen
1040 t1 = GFX3D::Math::Mat_MultiplyVector(matProj, t1);
1041 t2 = GFX3D::Math::Mat_MultiplyVector(matProj, t2);
1042
1043 // Project
1044 t1.x = t1.x / t1.w;
1045 t1.y = t1.y / t1.w;
1046 t1.z = t1.z / t1.w;
1047
1048 t2.x = t2.x / t2.w;
1049 t2.y = t2.y / t2.w;
1050 t2.z = t2.z / t2.w;
1051
1052 vec3d vOffsetView = { 1,1,0 };
1053 t1 = Math::Vec_Add(t1, vOffsetView);
1054 t2 = Math::Vec_Add(t2, vOffsetView);
1055
1056 t1.x *= 0.5f * fViewW;
1057 t1.y *= 0.5f * fViewH;
1058 t2.x *= 0.5f * fViewW;
1059 t2.y *= 0.5f * fViewH;
1060
1061 vOffsetView = { fViewX,fViewY,0 };
1062 t1 = Math::Vec_Add(t1, vOffsetView);
1063 t2 = Math::Vec_Add(t2, vOffsetView);
1064
1065 pge->DrawLine((int32_t)t1.x, (int32_t)t1.y, (int32_t)t2.x, (int32_t)t2.y, col);
1066
1067 return 0;
1068 }
1069
1070 uint32_t GFX3D::PipeLine::RenderCircleXZ(olc::GFX3D::vec3d &p1, float r, olc::Pixel col)
1071 {

Callers

nothing calls this directly

Calls 1

DrawLineMethod · 0.45

Tested by

no test coverage detected