Windows Dev Center

# DirectX marble maze game sample

## This sample demonstrates how to build a basic 3D game using DirectX.

4.2 Star
(20)
40,234 times
4/2/2014

### Solution explorer

C++
```//// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
//// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
//// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
//// PARTICULAR PURPOSE.
////

#pragma once

class Triangle
{
public:
XMFLOAT3 A;
XMFLOAT3 B;
XMFLOAT3 C;
XMFLOAT4 plane;

Triangle(const Triangle& rhs)
{
A = rhs.A;
B = rhs.B;
C = rhs.C;
plane = rhs.plane;
}

Triangle(const XMFLOAT3& V0, const XMFLOAT3& V1, const XMFLOAT3& V2) :
A(V0),
B(V1),
C(V2)
{
}

// Returns true if the triangle is degenerate.
FORCEINLINE BOOL IsDegenerate() const
{
return XMVector3Equal(planeNormal, XMVectorZero());
}

// Tests this triangle against another one to see if it a) shares any edges, and b) is coplanar
FORCEINLINE void CheckSharesVertsOrCoplanar(
FXMVECTOR V0,
FXMVECTOR V1,
FXMVECTOR V2,
CXMVECTOR planeIn,
BOOL& sharesEdgeOut,
BOOL& coplanar
) const
{
XMVECTOR sharesEdge = XMVectorOrInt(
XMVectorOrInt(
XMVectorEqual(V0, VA),
XMVectorEqual(V1, VA)
),
XMVectorEqual(V2, VA)
);
sharesEdge = XMVectorOrInt(
sharesEdge,
XMVectorOrInt(
XMVectorOrInt(
XMVectorEqual(V0, VB),
XMVectorEqual(V1, VB)
),
XMVectorEqual(V2, VB)
)
);
sharesEdge = XMVectorOrInt(
sharesEdge,
XMVectorOrInt(
XMVectorOrInt(
XMVectorEqual(V0, VC),
XMVectorEqual(V1, VC)
),
XMVectorEqual(V2, VC)
)
);

sharesEdgeOut = XMVector3EqualInt(sharesEdge, XMVectorTrueInt());

coplanar = XMVector3Equal(VP, planeIn);
}

// Returns the unit normal of the triangle surface..
FORCEINLINE XMVECTOR Normal() const
{
}
};

// Simple sphere wrapper. We store the sphere as a 16-byte aligned FLOAT4, so that we can perform
// fast unaligned reads. All of the parameters are packed into a single FLOAT4.
struct Sphere
{
XMFLOAT4 center;

{
return center.w;
}

Sphere()
{
}

explicit Sphere(const XMFLOAT3& centerIn, FLOAT radius)
{
center = XMFLOAT4(centerIn.x, centerIn.y, centerIn.z, radius);
}

explicit Sphere(float x, float y, float z, float radius)
{
center = XMFLOAT4(x, y, z, radius);
}
};
```