void IceCrusher::draw(DrawingContext& context) { m_sprite->draw(context.color(), get_pos(), m_layer+2); if (!(state == CRUSHING) && m_sprite->has_action("whites")) { // draw icecrusher's eyes slightly behind lefteye->draw(context.color(), get_pos()+eye_position(false), m_layer+1); righteye->draw(context.color(), get_pos()+eye_position(true), m_layer+1); // draw the whites of icecrusher's eyes even further behind whites->draw(context.color(), get_pos(), m_layer); } }
void IceCrusher::draw(DrawingContext& context) { context.push_target(); context.set_target(DrawingContext::NORMAL); sprite->draw(context, get_pos(), layer+2); if(!(state == CRUSHING) && sprite->has_action("whites")) { // draw icecrusher's eyes slightly behind lefteye->draw(context, get_pos()+eye_position(false), layer+1); righteye->draw(context, get_pos()+eye_position(true), layer+1); // draw the whites of icecrusher's eyes even further behind whites->draw(context, get_pos(), layer); } context.pop_target(); }
void Cube::Draw(ID3DXEffect* effects, D3DXMATRIX& view_matrix, D3DXMATRIX& proj_matrix, D3DXVECTOR3& eye_pos) { handle_faceid = effects->GetParameterByName(0, "FaceId"); handle_wvp_matrix_ = effects->GetParameterByName(0, "matWVP"); technique_ = effects->GetTechniqueByName("Tech1"); handle_eye_position_ = effects->GetParameterByName(0, "EyePosition"); // Set world view projection matrix D3DXMATRIX wvp_matrix = world_matrix_ * view_matrix * proj_matrix; effects->SetMatrix(handle_wvp_matrix_, &wvp_matrix); D3DXVECTOR4 eye_position(eye_pos.x, eye_pos.y, eye_pos.z, 1.0f); // Get eye position effects->SetVector(handle_eye_position_, &eye_position); // Set technique effects->SetTechnique(technique_); // Begin render unsigned int numPass = 0; effects->Begin(&numPass, D3DXFX_DONOTSAVESTATE); for (unsigned int i = 0; i < numPass; ++i) { effects->BeginPass(i); // Draw cube by draw every face of the cube for(int i = 0; i < kNumFaces_; ++i) { effects->SetInt(handle_faceid, textureId[i]); effects->CommitChanges(); d3d_device_->SetStreamSource(0, vertex_buffer_, 0, sizeof(Vertex)); d3d_device_->SetIndices(pIB[i]) ; d3d_device_->SetVertexDeclaration(vertex_declare_); d3d_device_->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, 0, 0, 24, 0, 2); } effects->EndPass(); } effects->End(); }