control primitive drawing order
This commit is contained in:
parent
9eb1a5b481
commit
fbc5f2ea55
@ -60,6 +60,8 @@ public:
|
||||
|
||||
g_draw->DrawString(b3Color_white, "Left/Right/Up/Down Arrow - Translate shape");
|
||||
g_draw->DrawString(b3Color_white, "X/Y/Z - Rotate shape");
|
||||
|
||||
g_draw->Flush();
|
||||
}
|
||||
|
||||
virtual void KeyDown(int key)
|
||||
|
@ -72,11 +72,52 @@ public:
|
||||
b3QHull hull;
|
||||
hull.Set(m_points, m_count);
|
||||
|
||||
b3HullShape shape;
|
||||
shape.m_hull = &hull;
|
||||
for (u32 i = 0; i < m_count; ++i)
|
||||
{
|
||||
b3Draw_draw->DrawPoint(m_points[i], 4.0f, b3Color_green);
|
||||
}
|
||||
|
||||
for (u32 i = 0; i < hull.edgeCount; i += 2)
|
||||
{
|
||||
const b3HalfEdge* edge = hull.GetEdge(i);
|
||||
const b3HalfEdge* twin = hull.GetEdge(i + 1);
|
||||
|
||||
b3Vec3 v1 = hull.GetVertex(edge->origin);
|
||||
b3Vec3 v2 = hull.GetVertex(twin->origin);
|
||||
|
||||
b3Draw_draw->DrawSegment(v1, v2, b3Color_black);
|
||||
}
|
||||
|
||||
g_draw->Flush();
|
||||
|
||||
for (u32 i = 0; i < hull.faceCount; ++i)
|
||||
{
|
||||
const b3Face* face = hull.GetFace(i);
|
||||
const b3HalfEdge* begin = hull.GetEdge(face->edge);
|
||||
|
||||
b3Vec3 n = hull.GetPlane(i).normal;
|
||||
|
||||
const b3HalfEdge* edge = hull.GetEdge(begin->next);
|
||||
do
|
||||
{
|
||||
u32 i1 = begin->origin;
|
||||
u32 i2 = edge->origin;
|
||||
const b3HalfEdge* next = hull.GetEdge(edge->next);
|
||||
u32 i3 = next->origin;
|
||||
|
||||
b3Vec3 v1 = hull.GetVertex(i1);
|
||||
b3Vec3 v2 = hull.GetVertex(i2);
|
||||
b3Vec3 v3 = hull.GetVertex(i3);
|
||||
|
||||
b3Color solidColor(1.0f, 1.0f, 1.0f, 0.5f);
|
||||
g_draw->DrawSolidTriangle(n, v1, v2, v3, solidColor);
|
||||
|
||||
edge = next;
|
||||
} while (hull.GetEdge(edge->next) != begin);
|
||||
}
|
||||
|
||||
g_draw->Flush();
|
||||
|
||||
g_draw->DrawSolidShape(&shape, b3Color_white, b3Transform_identity);
|
||||
|
||||
g_draw->DrawString(b3Color_white, "G - Generate a random convex hull");
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user