void D10State::setRect() { HRESULT hr; ods("D3D10: SetRect"); float w = static_cast<float>(uiWidth); float h = static_cast<float>(uiHeight); float left = static_cast<float>(uiLeft) - 0.5f; float top = static_cast<float>(uiTop) - 0.5f; float right = static_cast<float>(uiRight) + 0.5f; float bottom = static_cast<float>(uiBottom) + 0.5f; float texl = (left) / w; float text = (top) / h; float texr = (right + 1.0f) / w; float texb = (bottom + 1.0f) / h; left = 2.0f * (left / vp.Width) - 1.0f; right = 2.0f * (right / vp.Width) - 1.0f; top = -2.0f * (top / vp.Height) + 1.0f; bottom = -2.0f * (bottom / vp.Height) + 1.0f; ods("D3D10: Vertex (%f %f) (%f %f)", left, top, right, bottom); // Create vertex buffer SimpleVertex vertices[] = { { SimpleVec3(left, top, 0.5f), SimpleVec2(texl, text) }, { SimpleVec3(right, top, 0.5f), SimpleVec2(texr, text) }, { SimpleVec3(right, bottom, 0.5f), SimpleVec2(texr, texb) }, { SimpleVec3(left, bottom, 0.5f), SimpleVec2(texl, texb) }, }; void *pData = NULL; hr = pVertexBuffer->Map(D3D10_MAP_WRITE_DISCARD, 0, &pData); memcpy(pData, vertices, sizeof(vertices)); ods("D3D10: Map %lx %d", hr, sizeof(vertices)); pVertexBuffer->Unmap(); }
void D11State::setRect() { HRESULT hr; ods("D3D11: SetRect"); float w = static_cast<float>(uiWidth); float h = static_cast<float>(uiHeight); float left = static_cast<float>(uiLeft) - 0.5f; float top = static_cast<float>(uiTop) - 0.5f; float right = static_cast<float>(uiRight) + 0.5f; float bottom = static_cast<float>(uiBottom) + 0.5f; float texl = (left) / w; float text = (top) / h; float texr = (right + 1.0f) / w; float texb = (bottom + 1.0f) / h; left = 2.0f * (left / vp.Width) - 1.0f; right = 2.0f * (right / vp.Width) - 1.0f; top = -2.0f * (top / vp.Height) + 1.0f; bottom = -2.0f * (bottom / vp.Height) + 1.0f; ods("D3D11: Vertex (%f %f) (%f %f)", left, top, right, bottom); // Create vertex buffer SimpleVertex vertices[] = { { SimpleVec3(left, top, 0.5f), SimpleVec2(texl, text) }, { SimpleVec3(right, top, 0.5f), SimpleVec2(texr, text) }, { SimpleVec3(right, bottom, 0.5f), SimpleVec2(texr, texb) }, { SimpleVec3(left, bottom, 0.5f), SimpleVec2(texl, texb) }, }; // map/unmap to temporarily deny GPU access to the resource pVertexBuffer D3D11_MAPPED_SUBRESOURCE res; hr = pDeviceContext->Map(pVertexBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &res); const int verticesSize = sizeof(vertices); static_assert(verticesSize == VERTEXBUFFER_SIZE, "The vertex buffer size differs from the locally created vertex buffer."); memcpy(res.pData, vertices, verticesSize); ods("D3D11: Map: %lx %d", hr, sizeof(vertices)); pDeviceContext->Unmap(pVertexBuffer, 0); }
/** Returns the location of the corresponding kart. */ SimpleVec3 getLocation(int idKart) { AbstractKart* kart = World::getWorld()->getKart(idKart); Vec3 v = kart->getXYZ(); return SimpleVec3(v.getX(), v.getY(), v.getZ()); }
/** Gets the kart's velocity */ SimpleVec3 getVelocity(int idKart) { AbstractKart* kart = World::getWorld()->getKart(idKart); btVector3 velocity = kart->getVelocity(); return SimpleVec3(velocity.getX(), velocity.getY(), velocity.getZ()); }