Ejemplo n.º 1
0
	array<Vector2DI, 4> RectI::GetVertexes() const
	{
		array<Vector2DI, 4> result =
		{
			Vector2DI(X, Y),
			Vector2DI(X + Width, Y),
			Vector2DI(X + Width, Y + Height),
			Vector2DI(X, Y + Height)
		};
		return result;
	}
Ejemplo n.º 2
0
	std::vector<Object*> &World::GetCullingObjects(RectF cullingRange)
	{
		tempObjects.clear();

		for (int r = 0; r <= resolution; ++r)
		{
			auto layer = layers[r];

			auto cellSize = layer->GetGrids()[0]->GetGridRange().GetSize();

			//分解能0の場合はワールド全部を探索
			RectF searchRange = (r != 0) ? RectF(cullingRange.X - cellSize.X / 2, cullingRange.Y - cellSize.Y / 2, cullingRange.Width + cellSize.X, cullingRange.Height + cellSize.Y)
				: layer->GetGrids()[0]->GetGridRange();

			Vector2DI upperLeft;
			Vector2DI lowerRight;

			//カリング対象のグリッド区間絞込
			{
				Vector2DF upperLeftRaw = (searchRange.GetPosition() - worldRange.GetPosition()) / cellSize;
				Vector2DF lowerRightRaw = (searchRange.GetPosition() + searchRange.GetSize() - worldRange.GetPosition()) / cellSize;

				upperLeftRaw.X = Max(0.0f, upperLeftRaw.X);
				upperLeftRaw.Y = Max(0.0f, upperLeftRaw.Y);

				lowerRightRaw.X = Min(worldRange.GetSize().X / cellSize.X - 1.0f, lowerRightRaw.X);
				lowerRightRaw.Y = Min(worldRange.GetSize().Y / cellSize.Y - 1.0f, lowerRightRaw.Y);

				upperLeft = Vector2DI((int)floor(upperLeftRaw.X), (int)floor(upperLeftRaw.Y));
				lowerRight = Vector2DI((int)floor(lowerRightRaw.X), (int)floor(lowerRightRaw.Y));
			}

			int xSize = 1 << r;

			for (int x = upperLeft.X; x <= lowerRight.X; ++x)
			{
				for (int y = upperLeft.Y; y <= lowerRight.Y; ++y)
				{
					auto grid = layer->GetGrids()[y*xSize + x];

					grid->GetCullingObjects(searchRange, tempObjects);
				}
			}
		}
		std::sort(tempObjects.begin(), tempObjects.end(), [](Object* obj1, Object* obj2)
		{
			return obj1->GetSortedKey() < obj2->GetSortedKey();
		});
		return tempObjects;
	}
Ejemplo n.º 3
0
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Core_Imp::Core_Imp()
		: m_window(nullptr)
		, m_keyboard(nullptr)
		, m_mouse(nullptr)
		, m_graphics(nullptr)
		, m_sound(nullptr)
		, m_joystickContainer(nullptr)
		, m_file(nullptr)
		, m_logger(nullptr)
		, m_profiler(nullptr)
		, m_profilerViewer(nullptr)
		, m_currentScene(nullptr)
		, m_removedFuncPtr(nullptr)
		, m_isInitializedByExternal(false)
		, m_objectSystemFactory(nullptr)
		, m_animationSyatem(nullptr)
		, m_targetFPS(60)
		, m_currentFPS(60)
		, m_nextFPS(60)
		, m_previousTime(0)
		, m_startFrameTime(0)
		, m_windowSize(Vector2DI(0,0))
		, m_isProfilerVisible(false)
	{
		m_previousTime = GetTime();
	}
Ejemplo n.º 4
0
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	DepthBuffer_Imp_GL* DepthBuffer_Imp_GL::Create(Graphics* graphics, int32_t width, int32_t height)
	{
		GLuint buf;

		// ID生成
		glGenTextures(1, &buf);

		// テクスチャをバインド
		glBindTexture(GL_TEXTURE_2D, buf);

		// テクスチャ領域生成
		glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, nullptr);

		// テクスチャを拡大・縮小する方法の指定
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

		// テクスチャをアンバインド
		glBindTexture(GL_TEXTURE_2D, 0);

		GLCheckError();

		return new DepthBuffer_Imp_GL(graphics, buf, Vector2DI(width, height));
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	bool Core_Imp::InitializeByExternalWindow(void* handle1, void* handle2, int32_t width, int32_t height, bool isOpenGLMode, bool isMultithreadingMode)
	{
		if (m_window != nullptr) return false;
		if (m_keyboard != nullptr) return false;
		if (m_mouse != nullptr) return false;
		if (m_joystickContainer != nullptr) return false;
		if (m_logger != nullptr) return false;

		m_isInitializedByExternal = true;

#if _WIN32
		if (isOpenGLMode)
		{
			glfwMakeOpenGLEnabled();
		}
		else
		{
			glfwMakeOpenGLDisabled();
		}
#else
		if (!isOpenGLMode)
		{
			return false;
		}
#endif

		m_logger = Log_Imp::Create(ToAString("Log.html").c_str(), ToAString(L"").c_str());

		m_graphics = Graphics_Imp::Create(handle1, handle2, width, height, false, m_logger, isMultithreadingMode);
		if (m_graphics == nullptr) return false;

		m_sound = new Sound_Imp();

		m_objectSystemFactory = new ObjectSystemFactory_Imp(m_graphics, m_logger, Vector2DI(width,height));

		m_profiler = Profiler_Imp::Create();
		m_profilerViewer = ProfilerViewer_Imp::Create(m_profiler, m_graphics, m_logger, Vector2DI(width, height));

		m_animationSyatem = new AnimationSystem_Imp();

		m_logger->WriteLineStrongly(L"コア初期化成功");

		return true;
	}
Ejemplo n.º 6
0
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	DepthBuffer_Imp_DX11* DepthBuffer_Imp_DX11::Create(Graphics* graphics, int32_t width, int32_t height)
	{
		auto g = (Graphics_Imp_DX11*)graphics;

		ID3D11Texture2D* depthBuffer = nullptr;
		ID3D11DepthStencilView* depthStencilView = nullptr;
		ID3D11ShaderResourceView* srv = nullptr;

		D3D11_TEXTURE2D_DESC desc;
		desc.Width = width;
		desc.Height = height;
		desc.MipLevels = 1;
		desc.ArraySize = 1;
		desc.Format = DXGI_FORMAT_R24G8_TYPELESS;
		desc.SampleDesc.Count = 1;
		desc.SampleDesc.Quality = 0;
		desc.Usage = D3D11_USAGE_DEFAULT;
		desc.BindFlags = D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_DEPTH_STENCIL;
		desc.CPUAccessFlags = 0;
		desc.MiscFlags = 0;

		
		if(FAILED(g->GetDevice()->CreateTexture2D(&desc, NULL, &depthBuffer)))
		{
			goto End;
		}

		D3D11_DEPTH_STENCIL_VIEW_DESC viewDesc;
		viewDesc.Format = DXGI_FORMAT_D24_UNORM_S8_UINT;
		viewDesc.ViewDimension	= D3D11_DSV_DIMENSION_TEXTURE2DMS;
		viewDesc.Flags			= 0;
		if (FAILED(g->GetDevice()->CreateDepthStencilView(depthBuffer, &viewDesc, &depthStencilView)))
		{
			goto End;
		}
		
		D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
		ZeroMemory(&srvDesc, sizeof(srvDesc));
		srvDesc.Format = DXGI_FORMAT_R24_UNORM_X8_TYPELESS;
		srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
		srvDesc.Texture2D.MostDetailedMip = 0;
		srvDesc.Texture2D.MipLevels = desc.MipLevels;

		if (FAILED(g->GetDevice()->CreateShaderResourceView(depthBuffer, &srvDesc, &srv)))
		{
			goto End;
		}

		return new DepthBuffer_Imp_DX11(graphics, depthBuffer, depthStencilView, srv, Vector2DI(width, height));

	End:;
		SafeRelease(depthBuffer);
		SafeRelease(depthStencilView);
		SafeRelease(srv);
		return nullptr;
	}
Ejemplo n.º 7
0
	RenderedCameraObject3D::RenderedCameraObject3D(Graphics* graphics)
		: RenderedObject3D(graphics)
	{
		m_values.size = Vector2DI();
		m_values.fov = 0.0f;
		m_values.zfar = 0.0f;
		m_values.znear = 0.0f;
		m_values.hdrMode = false;
		m_values.postEffectCount = 0;
		
		proxy = new RenderedCameraObject3DProxy(graphics);
	}
Ejemplo n.º 8
0
RenderTexture2D_Imp* RenderTexture2D_Imp::Create(Graphics* graphics, int32_t width, int32_t height, TextureFormat format)
{
	auto g = (Graphics_Imp*)graphics;

	auto rhi = ar::RenderTexture2D::Create(g->GetRHI());
	if (rhi->Initialize(g->GetRHI(), width, height, (ar::TextureFormat)format))
	{
		return new RenderTexture2D_Imp(g, rhi, Vector2DI(width, height), format);
	}

	asd::SafeDelete(rhi);
	return nullptr;
}
Ejemplo n.º 9
0
DepthBuffer_Imp* DepthBuffer_Imp::Create(Graphics* graphics, int32_t width, int32_t height)
{
	auto g = (Graphics_Imp*)graphics;

	auto rhi = ar::DepthTexture::Create(g->GetRHI());
	if (rhi->Initialize(g->GetRHI(), width, height))
	{
		return new DepthBuffer_Imp(graphics, rhi, Vector2DI(width, height));
	}

	asd::SafeDelete(rhi);
	return nullptr;
}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Vector2DI Vector2DI::operator-()
	{
		return Vector2DI(-X, -Y);
	}
Ejemplo n.º 11
0
	Vector2DI RectI::GetSize() const
	{
		return Vector2DI(Width, Height);
	}
Ejemplo n.º 12
0
	Vector2DI RectI::GetPosition() const
	{
		return Vector2DI(X, Y);
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Vector2DI Vector2DI::operator+(const Vector2DI& right)
	{
		return Vector2DI(X + right.X, Y + right.Y);
	}
Ejemplo n.º 14
0
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	bool Core_Imp::InitializeByExternalWindow(void* handle1, void* handle2, int32_t width, int32_t height, CoreOption option)
	{
		if (m_window != nullptr) return false;
		if (m_keyboard != nullptr) return false;
		if (m_mouse != nullptr) return false;
		if (m_joystickContainer != nullptr) return false;
		if (m_file != nullptr) return false;
		if (m_logger != nullptr) return false;

		m_isInitializedByExternal = true;

#if _WIN32
		if (option.GraphicsDevice == GraphicsDeviceType::OpenGL)
		{
			glfwMakeOpenGLEnabled();
		}
		else
		{
			glfwMakeOpenGLDisabled();
		}
#else
		if (option.GraphicsDevice != GraphicsDeviceType::OpenGL)
		{
			return false;
		}
#endif

		m_file = File_Imp::Create();
		m_logger = Log_Imp::Create(ToAString("Log.html").c_str(), ToAString(L"").c_str());

		m_graphics = Graphics_Imp::Create(handle1, handle2, width, height, option.GraphicsDevice, m_logger,m_file, option.IsReloadingEnabled, option.IsFullScreen);
		if (m_graphics == nullptr) return false;

		m_sound = new Sound_Imp(m_file, m_logger, option.IsReloadingEnabled);

		m_objectSystemFactory = new ObjectSystemFactory_Imp(this, m_graphics, m_logger, Vector2DI(width, height));

		m_profiler = Profiler_Imp::Create();
		m_layerProfiler = LayerProfiler_Imp::Create();
		m_profilerViewer = ProfilerViewer_Imp::Create(this, m_profiler, m_layerProfiler, m_graphics, m_logger, Vector2DI(width, height));

		m_animationSyatem = new AnimationSystem_Imp();

		m_windowSize = Vector2DI(width, height);
		layerRenderer = new LayerRenderer(m_graphics);
		layerRenderer->SetWindowSize(m_windowSize);

		{
			asd::Vector2DF lpos[4];
			lpos[0].X = 0;
			lpos[0].Y = 0;
			lpos[1].X = (float)m_windowSize.X;
			lpos[1].Y = 0;
			lpos[2].X = (float)m_windowSize.X;
			lpos[2].Y = (float)m_windowSize.Y;
			lpos[3].X = 0;
			lpos[3].Y = (float)m_windowSize.Y;
			layerRenderer->SetLayerPosition(lpos);
		}
		
		m_logger->WriteHeading(L"システム");

		WriteSystemSpecToLog(m_logger);
		m_logger->WriteLineStrongly(L"コア初期化成功");

		return true;
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Vector2DI Vector2DI::operator-(const Vector2DI& right)
	{
		return Vector2DI(X - right.X, Y - right.Y);
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Vector2DI Vector2DI::operator/(int32_t right)
	{
		return Vector2DI(X / right, Y / right);
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Vector2DI Vector2DI::operator*(int32_t right)
	{
		return Vector2DI(X * right, Y * right);
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Vector2DI Vector2DI::operator/(const Vector2DI& right)
	{
		return Vector2DI(X / right.X, Y / right.Y);
	}
	//----------------------------------------------------------------------------------
	//
	//----------------------------------------------------------------------------------
	Vector2DI Vector2DI::operator*(const Vector2DI& right)
	{
		return Vector2DI(X * right.X, Y * right.Y);
	}