Windows/Direct3D Framework

The WD3D framework can be downloaded here. It includes an example program for creating a simple scene, a rotating, Gourad-shaded RGB cube, a sphere, and a cone.

It has been tested on Intel C++ 6.0.

A compiled executable of the example program for Windows is here. It requires DirectX 8.

The following shows the code for another simple scene, only a cube, but here, it may be manipulated with the keys. The keys are:

A, Z - Rotate around x-axis
S, X - Rotate around y-axis
D, C - Rotate around z-axis

All of this is defined in the function below. Keyboard manipulation is done using "behaviour" objects (RotationInterpolator, below), which manipulates TransformState objects, all stored in the scene graph.

The only difference between this and the first example is that the source signal for the behaviour in the first example comes from a SawTooth object, while it in the latter comes from a KeySource object.

The compiled executable is here.

void Scene::makeObjects()
{
typedef VertexPosD<Vector3D> VertexType;

static Cube<VertexType> cube(device,1);

static PSCullMode cullMode(D3DCULL_CW);
static RSLighting lighting(false);
static CSColourVertex colourVertex(false);

static Matrix3D viewMatrix;
static Matrix3D projectionMatrix;

viewMatrix.lookAtLH(Vector3D(0.0,0.0,-10.0),Vector3D(0.0,0.0,0.0),Vector3D(0.0,1.0,0.0));
projectionMatrix.perspectiveFOVLH(D3DX_PI/4,4.0/3.0,0.0,10.0);

static TransformState<false> viewTransform(viewMatrix,D3DTS_VIEW);
static TransformState<false> projectionTransform(projectionMatrix,D3DTS_PROJECTION);

static Matrix3D matrixX(true);
static Matrix3D matrixY(true);
static Matrix3D matrixZ(true);

static TransformState<false> transformX(matrixX);
static TransformState<true> transformY(matrixY);
static TransformState<true> transformZ(matrixZ);

static KeySource keySourceX(keyboard,'A','Z',10000,true);
static KeySource keySourceY(keyboard,'S','X',10000,true);
static KeySource keySourceZ(keyboard,'D','C',10000,true);

static RotationInterpolator<&Matrix3D::rotateX,KeySource,double (KeySource::*)() const,&KeySource::value,false> rotateX(transformX,keySourceX,0.0,D3DX_PI*2);
static RotationInterpolator<&Matrix3D::rotateY,KeySource,double (KeySource::*)() const,&KeySource::value,true> rotateY(transformY,keySourceY,0.0,D3DX_PI*2);
static RotationInterpolator<&Matrix3D::rotateZ,KeySource,double (KeySource::*)() const,&KeySource::value,true> rotateZ(transformZ,keySourceZ,0.0,D3DX_PI*2);

group.add(cullMode);
group.add(lighting);

group.add(viewTransform);
group.add(projectionTransform);

group.add(transformX);
group.add(transformY);
group.add(transformZ);

group.add(rotateX);
group.add(rotateY);
group.add(rotateZ);

group.add(cube);
}