The MyScene function in Helworld.c corresponds to the BuildScene function that is implemented in all the Direct3D samples in the DirectX SDK. This is where all the work occurs that displays unique objects with unique textures and lighting effects.
The MyScene function calls a series of locally defined functions that set up the separate features of the scene that is being created. These functions are:
When these functions have set up the visual object, MyScene calls the IDirect3DRMFrame::AddVisual method to add the object to the environment's world frame. After adding the visual object, MyScene no longer needs the interfaces it has created, so it calls the Release method repeatedly to release them all.
/////////////////////////////////////////////////////////////////////
//
// MyScene
// Calls the functions that create the frames, lights, mesh, and
// texture. Releases all interfaces on completion.
//
/////////////////////////////////////////////////////////////////////
BOOL
MyScene(LPDIRECT3DRMDEVICE dev, LPDIRECT3DRMVIEWPORT view,
LPDIRECT3DRMFRAME lpScene, LPDIRECT3DRMFRAME lpCamera)
{
LPDIRECT3DRMFRAME lpLightframe1 = NULL;
LPDIRECT3DRMFRAME lpWorld_frame = NULL;
LPDIRECT3DRMLIGHT lpLight1 = NULL;
LPDIRECT3DRMLIGHT lpLight2 = NULL;
LPDIRECT3DRMTEXTURE lpTex = NULL;
LPDIRECT3DRMWRAP lpWrap = NULL;
LPDIRECT3DRMMESHBUILDER lpSphere3_builder = NULL;
MakeMyFrames(lpScene, lpCamera, &lpLightframe1, &lpWorld_frame);
MakeMyLights(lpScene, lpCamera, lpLightframe1, &lpLight1,
&lpLight2);
SetMyPositions(lpScene, lpCamera, lpLightframe1, lpWorld_frame);
MakeMyMesh(&lpSphere3_builder);
MakeMyWrap(lpSphere3_builder, &lpWrap);
AddMyTexture(lpSphere3_builder, &lpTex);
// If you need to create a material (for example, to create
// a shiny surface), call CreateMaterial and SetMaterial here.
// Now that the visual object has been created, add it
// to the world frame.
lpWorld_frame->lpVtbl->AddVisual(lpWorld_frame,
(LPDIRECT3DRMVISUAL) lpSphere3_builder);
lpLightframe1->lpVtbl->Release(lpLightframe1);
lpWorld_frame->lpVtbl->Release(lpWorld_frame);
lpSphere3_builder->lpVtbl->Release(lpSphere3_builder);
lpLight1->lpVtbl->Release(lpLight1);
lpLight2->lpVtbl->Release(lpLight2);
lpTex->lpVtbl->Release(lpTex);
lpWrap->lpVtbl->Release(lpWrap);
return TRUE;
}