void CoreLayer2D_Imp::DrawShapeAdditionally(CoreShape* shape, Color color, Texture2D* texture, AlphaBlendMode alphaBlend, int32_t priority) { auto shape_Imp = CoreShape2DToImp(shape); for (auto triangle : shape_Imp->GetDividedTriangles()) { std::array<Vector2DF, 4> pos; std::array<Vector2DF, 4> uvs; for (int i = 0; i < 3; ++i) { pos[i] = triangle->GetPointByIndex(i); uvs[i] = triangle->GetUVByIndex(i); } pos[3] = pos[2]; uvs[3] = uvs[2]; std::array<Color,4> col; col[0] = color; col[1] = color; col[2] = color; col[3] = color; Sprite sprite; sprite.pos = pos; sprite.col = col; sprite.uv = uvs; sprite.Texture_ = (shape->GetShapeType() == ShapeType::LineShape) ? nullptr : CreateSharedPtrWithReleaseDLL(texture); sprite.AlphaBlend_ = alphaBlend; sprite.Priority = priority; sprites.push_back(sprite); } }
void CoreGeometryObject2D_Imp::Draw(Renderer2D* renderer) { if (!GetAbsoluteBeingDrawn() || !GetIsAlive() || m_shape == nullptr) { return; } auto shape_Imp = CoreShape2DToImp(m_shape); auto& triangles = shape_Imp->GetDividedTriangles(); if (triangles.size() == 0) { auto layer = GetLayer(); auto g = (Graphics_Imp*)layer->GetGraphicsImp(); g->GetLog()->Write("無効な形状を描画しました。正しく表示されない場合があります。", LogLevel::Warning); } for (auto triangle : triangles) { std::array<Vector2DF, 4> position; std::array<Vector2DF, 4> uvs; for (int i = 0; i < 3; ++i) { position[i] = triangle->GetPointByIndex(i); uvs[i] = triangle->GetUVByIndex(i); } position[3] = position[2]; uvs[3] = uvs[2]; auto matrix = GetAbsoluteMatrixToTransform(); for (auto& pos : position) { pos -= centerPosition; auto v3 = Vector3DF(pos.X, pos.Y, 1); auto result = matrix * v3; pos = Vector2DF(result.X, result.Y); } Color color[4]; auto col = GetAbsoluteColor(); color[0] = col; color[1] = col; color[2] = col; color[3] = col; renderer->AddSprite( position.data(), color, uvs.data(), (m_shape->GetShapeType() == ShapeType::LineShape) ? nullptr : m_texture, alphaBlendMode, GetAbsoluteDrawingPriority(), m_textureFilterType); } }