// конструктор модели с костями AnimModel::AnimModel(wchar_t* binFilePath, wchar_t* textureFilePath, bool* result) { // инициализация переменных position = Const::spawnPoint; // координаты модели // загрузить модель из файла BRR(LoadAmimModelFromFile(binFilePath)); // инициализация элементов после загрузки std::fill(curFrame.begin(), curFrame.end(), 0); std::fill(accumulation.begin(), accumulation.end(), 0.0f); std::fill(blendFactors.begin(), blendFactors.end(), 0.0f); blendFactors[0] = 1.0f; // создать матрицу порядка умножения финальных костей BRR(BuildOrder()); // загрузить текстуру if (FAILED(D3DX11CreateShaderResourceViewFromFile(Mediator::pDev, textureFilePath, NULL, NULL, &pSRtexture, NULL))) { BRR(Mediator::errors->Push(textureFilePath)); *result = false; return; } *result = true; }
// конструктор кнопки Button::Button(wchar_t* filePath, XMFLOAT3 position, NumXY<float> dimentions, const wchar_t* caption, bool* result) : Sprite(filePath, position, dimentions, SA_CENTER, result) { BRR(*result); if (!filePath) transarent = true; // инициализация переменны this->absPosition.x = position.x + Mediator::winDimentions->x / 2; this->absPosition.y = position.y + Mediator::winDimentions->y / 2; this->dimentions = dimentions; BRR(SetCaption(caption)); }
// конструктор спрайта Sprite::Sprite(wchar_t* filePath, XMFLOAT3 position, NumXY<float> dimentions, SPRITE_ALIGN spriteAlign, bool* result) : position(position), dimentions(dimentions), spriteAlign(spriteAlign) { if (filePath) { textured = true; HRR(D3DX11CreateShaderResourceViewFromFile(Mediator::pDev, filePath, NULL, NULL, &pSRtexture, NULL)); } // создать буфер вершин BRR(CreateVertexBuffer()); // создание матрицы перемещения BRR(UpdateMatrixTranslation(*Mediator::winDimentions)); *result = true; }
// конструктор меню Menu::Menu(Console* console, bool* result) : Sprite(NULL, XMFLOAT3(0.0f, 0.0f, 10.0f), NumXY<float>(800.0f, 600.0f), SA_CENTER, result) { BRR(*result); // инициализация переменных this->console = console; }
// конструктор Map::Map(bool* result) { // проверка правильности данных BRR(Const::patchCellSize % Const::regionCellSize == 0); // переменные int indicesAmount = Const::patchCellSize * Const::patchCellSize * 6; UINT* indicesData = new UINT[indicesAmount]; int vertNumber = 0; int indNumber = 0; // заполнисть статические переменные Patch::FillStatic(indicesAmount); // инициализация индексов for (int i(0); i < Const::patchCellSize; i++) for (int j(0); j < Const::patchCellSize; j++) { indicesData[indNumber + 0] = 0 + j + i * patchVertSize; indicesData[indNumber + 1] = 1 + j + i * patchVertSize; indicesData[indNumber + 2] = patchVertSize + 0 + j + i * patchVertSize; indicesData[indNumber + 3] = patchVertSize + 0 + j + i * patchVertSize; indicesData[indNumber + 4] = 1 + j + i * patchVertSize; indicesData[indNumber + 5] = patchVertSize + 1 + j + i * patchVertSize; indNumber += 6; } // создание буфера индексов D3D11_BUFFER_DESC bufferIndDesc = { 0 }; bufferIndDesc.BindFlags = D3D11_BIND_INDEX_BUFFER; bufferIndDesc.ByteWidth = sizeof(UINT)* indicesAmount; bufferIndDesc.CPUAccessFlags = 0; bufferIndDesc.MiscFlags = 0; bufferIndDesc.StructureByteStride = 0; bufferIndDesc.Usage = D3D11_USAGE_IMMUTABLE; D3D11_SUBRESOURCE_DATA subIndData = { 0 }; subIndData.pSysMem = indicesData; HRR(Mediator::pDev->CreateBuffer(&bufferIndDesc, &subIndData, &pIndexBuffer)); // удаление данных ReleaseNULLS(indicesData); // создание поля указателей патчей patchField = new Patch**[Const::patchFieldSize]; for (UINT i(0); i < Const::patchFieldSize; i++) { patchField[i] = new Patch*[Const::patchFieldSize]; for (UINT j(0); j < Const::patchFieldSize; j++) { patchField[i][j] = NULL; } } // ??? пробный патч patchField[0][0] = new Patch(NumXY<int>(), result); Mediator::map = this; }
// конструктор камеры Camera::Camera(bool* result) { azimuth = -1.2f; // создать матрицу проекции float ratio = (float)Mediator::winDimentions->x / Mediator::winDimentions->y; projMatrix = XMMatrixPerspectiveFovLH(XM_PIDIV4, ratio, NearFarZ.x, NearFarZ.y); // создать матрицу ортографической проекции orthoMatrix = XMMatrixOrthographicOffCenterLH(0.0f, (float)Mediator::winDimentions->x, (float)Mediator::winDimentions->y, 0.0f, NearFarOZ.x, NearFarOZ.y); // запись в буфер шейдера BRR(Mediator::shader->SetResetBuffer(orthoMatrix)); // вычисление координат камеры camPosition.x = radius * sin(azimuth) * cos(pitch); camPosition.z = radius * cos(azimuth) * cos(pitch); camPosition.y = radius * sin(pitch); camPosition += camFocus; Mediator::camera = this; *result = true; }
/** * @brief UART3 serial driver identifier. */ #if STM8S_SERIAL_USE_UART3 || defined(__DOXYGEN__) SerialDriver SD3; #endif /*===========================================================================*/ /* Driver local variables. */ /*===========================================================================*/ /** * @brief Driver default configuration. */ static ROMCONST SerialConfig default_config = { BRR(SERIAL_DEFAULT_BITRATE), SD_MODE_PARITY_NONE | SD_MODE_STOP_1 }; /*===========================================================================*/ /* Driver local functions. */ /*===========================================================================*/ static void set_error(SerialDriver *sdp, uint8_t sr) { ioflags_t sts = 0; /* Note, SR register bit definitions are equal for all UARTs so using the UART1 definitions is fine.*/ if (sr & UART1_SR_OR) sts |= SD_OVERRUN_ERROR; if (sr & UART1_SR_NF)