Direct3D


         

ShadowWin::CreateScene()


CreateScene(), 6.6.

6.6. ShadowWin::CreateScene()

//------------- -------- D3DRMLOADRESOURCE resinfo; resinfo.hModule = NULL; resinfo.lpName = MAKEINTRESOURCE(IDR_CUBEMESH); resinfo.lpType = "MESH"; d3drm->CreateMeshBuilder(&floorbuilder); floorbuilder->Load(&resinfo, NULL, D3DRMLOAD_FROMRESOURCE, NULL, NULL); floorbuilder->Scale(D3DVALUE(5), D3DVALUE(.05), D3DVALUE(5)); floorbuilder->SetPerspective(TRUE); floorbuilder->SetQuality(D3DRMRENDER_FLAT);

//------------ -------------- LPDIRECT3DRMTEXTURE texture; HRSRC texture_id = FindResource(NULL, MAKEINTRESOURCE(IDR_FLOORTEXTURE), "TEXTURE"); d3drm->LoadTextureFromResource(texture_id, &texture); floorbuilder->SetTexture(texture); texture->Release(); texture = 0;

//------------ ------------ D3DRMBOX box; floorbuilder->GetBox(&box); D3DVALUE w = box.max.x - box.min.x; D3DVALUE h = box.max.z - box.min.z;

LPDIRECT3DRMWRAP wrap; d3drm->CreateWrap( D3DRMWRAP_FLAT, NULL, D3DVALUE(0.0), D3DVALUE(0.0), D3DVALUE(0.0), // D3DVALUE(0.0), D3DVALUE(1.0), D3DVALUE(0.0), // z D3DVALUE(0.0), D3DVALUE(0.0), D3DVALUE(1.0), // y D3DVALUE(.5) ,D3DVALUE(0.5), // D3DDivide(1,w), D3DDivide(1,h), // &wrap); wrap->Apply(floorbuilder); wrap->Release(); wrap = 0;

//------------- ---------- LPDIRECT3DRMFRAME floorframe; d3drm->CreateFrame(scene, &floorframe); floorframe->AddVisual(floorbuilder); floorframe->Release(); floorframe = 0;

//---------------- -------- resinfo.hModule = NULL; resinfo.lpName = MAKEINTRESOURCE(IDR_FORKMESH); resinfo.lpType = "MESH"; d3drm->CreateMeshBuilder(&forkbuilder); forkbuilder->Load(&resinfo, NULL, D3DRMLOAD_FROMRESOURCE, NULL, NULL); forkbuilder->SetQuality(D3DRMRENDER_FLAT);

//--------------- ---------- LPDIRECT3DRMFRAME forkframe; d3drm->CreateFrame(scene, &forkframe); forkframe->SetRotation(scene, D3DVALUE(1), D3DVALUE(1), D3DVALUE(1), D3DVALUE(0.4)); forkframe->SetPosition(scene, D3DVALUE(0), D3DVALUE(6), D3DVALUE(0)); forkframe->AddVisual(forkbuilder); forkframe->AddMoveCallback(AdjustSpin, NULL);

//-------------- -------- LPDIRECT3DRMLIGHT ambientlight; d3drm->CreateLightRGB(D3DRMLIGHT_AMBIENT, D3DVALUE(1),D3DVALUE(1), D3DVALUE(1), &ambientlight); scene->AddLight(ambientlight); ambientlight->Release(); ambientlight = 0;

//-------------- ---------- LPDIRECT3DRMLIGHT pointlight; d3drm->CreateLightRGB(D3DRMLIGHT_POINT, D3DVALUE(1),D3DVALUE(1), D3DVALUE(1), &pointlight);

LPDIRECT3DRMFRAME lightframe; d3drm->CreateFrame(scene, &lightframe); lightframe->SetPosition(scene, D3DVALUE(0), D3DVALUE(30), D3DVALUE(0)); lightframe->AddLight(pointlight); lightframe->Release(); lightframe = 0;

//-------------- ---------- LPDIRECT3DRMVISUAL shadow; d3drm->CreateShadow(forkbuilder, pointlight, D3DVALUE(0), box.max.y+D3DVALUE(0.1), D3DVALUE(0), D3DVALUE(0), box.max.y+D3DVALUE(1.0), D3DVALUE(0), (LPDIRECT3DRMVISUAL*)&shadow); forkframe->AddVisual(shadow);

shadow->Release(); shadow = 0; forkframe->Release(); forkframe = 0; pointlight->Release(); pointlight = 0;

//------------- -------- d3drm->CreateFrame(scene, &camera); camera->SetPosition(scene, D3DVALUE(0.0), D3DVALUE(25.0), D3DVALUE(-20.0)); camera->SetOrientation(scene, D3DVALUE(0), D3DVALUE(-25), D3DVALUE(20), D3DVALUE(.1), D3DVALUE(1), D3DVALUE(0)); d3drm->CreateViewport(device, camera, 0, 0, device->GetWidth(), device->GetHeight(), &viewport);

return TRUE; }

<