void CNpc::Set_ContantTable(void) { m_pEffect->SetMatrix("g_matWorld", &m_pTransCom->m_matWorld); _matrix matView, matProj; m_pGraphicDev->GetTransform(D3DTS_VIEW, &matView); m_pGraphicDev->GetTransform(D3DTS_PROJECTION, &matProj); m_pEffect->SetMatrix("g_matView", &matView); m_pEffect->SetMatrix("g_matProj", &matProj); const D3DLIGHT9* pLightInfo = Engine::Get_LightInfo(0); if (NULL == pLightInfo) return; m_pEffect->SetVector("g_vLightDir", &_vec4(pLightInfo->Direction, 0.f)); m_pEffect->SetVector("g_vLightDiffuse", &_vec4((_float*)&pLightInfo->Diffuse)); m_pEffect->SetVector("g_vLightAmbient", &_vec4((_float*)&pLightInfo->Ambient)); }
int main(int argc, char **argv) { SDL_Surface *screen; SDL_Event event; struct vec4 cubeCenter, cube[8]; scalar rota; struct mat4 rot; int i; SDL_Init( SDL_INIT_EVERYTHING ); screen = SDL_SetVideoMode(width, height, 32, 0); proj = proj_perspective(45, (scalar) width / (scalar) height, 1, 10); cubeCenter = vec4_zero(); while(1) { rota = (scalar) SDL_GetTicks() / 1000.0; cubeCenter.z = 5 + sin(rota); rot = mat4_aangle(_vec4(0, 1, 0, 1), rota); cube[0] = vec4_add(mat4_mulv(rot, _vec4( 1, -1, 1, 0)), cubeCenter); cube[1] = vec4_add(mat4_mulv(rot, _vec4(-1, -1, 1, 0)), cubeCenter); cube[2] = vec4_add(mat4_mulv(rot, _vec4(-1, 1, 1, 0)), cubeCenter); cube[3] = vec4_add(mat4_mulv(rot, _vec4( 1, 1, 1, 0)), cubeCenter); cube[4] = vec4_add(mat4_mulv(rot, _vec4( 1, -1, -1, 0)), cubeCenter); cube[5] = vec4_add(mat4_mulv(rot, _vec4(-1, -1, -1, 0)), cubeCenter); cube[6] = vec4_add(mat4_mulv(rot, _vec4(-1, 1, -1, 0)), cubeCenter); cube[7] = vec4_add(mat4_mulv(rot, _vec4( 1, 1, -1, 0)), cubeCenter); SDL_FillRect(screen, 0, 0); drawLine3d(screen, cube[0], cube[1]); drawLine3d(screen, cube[0], cube[3]); drawLine3d(screen, cube[1], cube[2]); drawLine3d(screen, cube[2], cube[3]); drawLine3d(screen, cube[4], cube[5]); drawLine3d(screen, cube[4], cube[7]); drawLine3d(screen, cube[5], cube[6]); drawLine3d(screen, cube[6], cube[7]); drawLine3d(screen, cube[0], cube[4]); drawLine3d(screen, cube[1], cube[5]); drawLine3d(screen, cube[2], cube[6]); drawLine3d(screen, cube[3], cube[7]); SDL_Flip(screen); while(SDL_PollEvent(&event) != 0) { switch(event.type) { case (SDL_QUIT): SDL_Quit(); return 0; default: break; } } } SDL_Quit(); return 0; }