Example #1
0
	bool Initialize(const Microsoft::WRL::ComPtr<ID3D11Device> &pDevice)
	{
		if (!createVB(pDevice)){
			return false;
		}
		if (!createIB(pDevice)){
			return false;
		}
		return true;
	}
Example #2
0
bool WaitingForYou::initGeometry()
{
	//
	createVB();
	fillVB();
	//
	createIB();
	fillIB();
	// axis
	{
		//
		static float scale = 100;
		//
		_axis_vertices[0].position = Vec3::ZERO * scale;
		_axis_vertices[0].color_ARGB = Euclid::Color::Red.getARGB();

		_axis_vertices[1].position = Vec3::UNIT_X * scale;
		_axis_vertices[1].color_ARGB = Euclid::Color::Red.getARGB();

		//
		_axis_vertices[2].position = Vec3::ZERO * scale;
		_axis_vertices[2].color_ARGB = Euclid::Color::Green.getARGB();

		_axis_vertices[3].position = Vec3::UNIT_Y * scale;
		_axis_vertices[3].color_ARGB = Euclid::Color::Green.getARGB();

		//
		_axis_vertices[4].position = Vec3::ZERO * scale;
		_axis_vertices[4].color_ARGB = Euclid::Color::Blue.getARGB();

		_axis_vertices[5].position = Vec3::UNIT_Z * scale;
		_axis_vertices[5].color_ARGB = Euclid::Color::Blue.getARGB();
	}
	// water
	{
		//
		static float scale = 1000;
		//
		_water_vertices[0].position = Vec3(-1.0f, 0.0f, -1.0f) * scale;
		_water_vertices[0].color_ARGB = Euclid::Color::Red.getARGB();
		_water_vertices[0].texcoord = Vec2(0.0f, 0.0f);

		_water_vertices[1].position = Vec3(-1.0f, 0.0f, 1.0f) * scale;
		_water_vertices[1].color_ARGB = Euclid::Color::Green.getARGB();
		_water_vertices[1].texcoord = Vec2(0.0f, 1.0f);

		_water_vertices[2].position = Vec3(1.0f, 0.0f, 1.0f) * scale;
		_water_vertices[2].color_ARGB = Euclid::Color::Blue.getARGB();
		_water_vertices[2].texcoord = Vec2(1.0f, 1.0f);

		_water_vertices[3].position = Vec3(1.0f, 0.0f, -1.0f) * scale;
		_water_vertices[3].color_ARGB = Euclid::Color::White.getARGB();
		_water_vertices[3].texcoord = Vec2(1.0f, 0.0f);
	}
	//
	{
		_water_fx = _modules->getRenderEngine()->getEffectManager()->createEffectFromFile("shader\\PositionTextureColor.fx");
	}
	{
		_water_material = _modules->getRenderEngine()->getMaterialManager()->createMaterial(Euclid::eMaterialType_VertexTexture);
		_water_material->setVertexDeclaration(Euclid::eVertexDeclarationType_PositionColorTexture);
		Euclid::MaterialVertexTexture* mvt = static_cast<Euclid::MaterialVertexTexture*>(_water_material);
		mvt->setTexture("image/water.jpg");
	}
	//
	{
		_fx = _modules->getRenderEngine()->getEffectManager()->createEffectFromFile("shader\\PositionTextureLightmapping.fx");
	}
	//
	
	{
		_fx_axis = _modules->getRenderEngine()->getEffectManager()->createEffectFromFile("shader\\PositionColor.fx");
	}
	//
	{
		_material = _modules->getRenderEngine()->getMaterialManager()->createMaterial(Euclid::eMaterialType_VertexTexture);
		_material->setVertexDeclaration(Euclid::eVertexDeclarationType_PositionTexture);
		Euclid::MaterialVertexTexture* mvt = static_cast<Euclid::MaterialVertexTexture*>(_material);
		mvt->setTexture("image/water.JPG");
		mvt->setLightmapping("image/lightmap.png");
	} 
	//
	{
		_modules->getRenderEngine()->getFontManager()->createFont(std::string("freetype\\simkai.ttf"), 18, Euclid::eFontProperty_Normal, "free");
		_font = _modules->getRenderEngine()->getFontManager()->getFont(std::string("free"));
	}


	return true;
}
Example #3
0
bool WaitingForYou::initGeometry()
{
	//
	createVB();
	fillVB();
	//
	createIB();
	fillIB();
	// axis
	{
		//
		static float scale = 100;
		//
		_axis_vertices[0].position = Vec3::ZERO * scale;
		_axis_vertices[0].color_ARGB = Euclid::Color::Red.getARGB();

		_axis_vertices[1].position = Vec3::UNIT_X * scale;
		_axis_vertices[1].color_ARGB = Euclid::Color::Red.getARGB();

		//
		_axis_vertices[2].position = Vec3::ZERO * scale;
		_axis_vertices[2].color_ARGB = Euclid::Color::Green.getARGB();

		_axis_vertices[3].position = Vec3::UNIT_Y * scale;
		_axis_vertices[3].color_ARGB = Euclid::Color::Green.getARGB();

		//
		_axis_vertices[4].position = Vec3::ZERO * scale;
		_axis_vertices[4].color_ARGB = Euclid::Color::Blue.getARGB();

		_axis_vertices[5].position = Vec3::UNIT_Z * scale;
		_axis_vertices[5].color_ARGB = Euclid::Color::Blue.getARGB();
	}
	// water
	{
		//
		static float scale = 1000;
		//
		_water_vertices[0].position = Vec3(-1.0f, 0.0f, -1.0f) * scale;
		_water_vertices[0].color_ARGB = Euclid::Color::White.getARGB();
		_water_vertices[0].texcoord = Vec2(0.0f, 0.0f);

		_water_vertices[1].position = Vec3(-1.0f, 0.0f, 1.0f) * scale;
		_water_vertices[1].color_ARGB = Euclid::Color::White.getARGB();
		_water_vertices[1].texcoord = Vec2(0.0f, 1.0f);

		_water_vertices[2].position = Vec3(1.0f, 0.0f, 1.0f) * scale;
		_water_vertices[2].color_ARGB = Euclid::Color::White.getARGB();
		_water_vertices[2].texcoord = Vec2(1.0f, 1.0f);

		_water_vertices[3].position = Vec3(1.0f, 0.0f, -1.0f) * scale;
		_water_vertices[3].color_ARGB = Euclid::Color::White.getARGB();
		_water_vertices[3].texcoord = Vec2(1.0f, 0.0f);
	}
	//
	{
		_water_fx = _modules->getRenderEngine()->getEffectManager()->createEffectFromFile("shader\\PositionTextureColor.fx");
	}
	{
		_fx_skybox = _modules->getRenderEngine()->getEffectManager()->createEffectFromFile("shader\\PositionTextureFogLinear.fx");
	}
	{
		_water_material = _modules->getRenderEngine()->getMaterialManager()->createMaterial(Euclid::eMaterialType_VertexTexture);
		_water_material->setVertexDeclaration(Euclid::eVertexDeclarationType_PositionColorTexture);
		Euclid::MaterialVertexTexture* mvt = static_cast<Euclid::MaterialVertexTexture*>(_water_material);
		mvt->setTexture("image/water00.jpg");
	}
	//
	{
		_fx = _modules->getRenderEngine()->getEffectManager()->createEffectFromFile("shader\\PositionTextureLightmapping.fx");
	}
	//
	
	{
		_fx_axis = _modules->getRenderEngine()->getEffectManager()->createEffectFromFile("shader\\PositionColor.fx");
	}
	//
	{
		_material = _modules->getRenderEngine()->getMaterialManager()->createMaterial(Euclid::eMaterialType_VertexTexture);
		_material->setVertexDeclaration(Euclid::eVertexDeclarationType_PositionTexture);
		Euclid::MaterialVertexTexture* mvt = static_cast<Euclid::MaterialVertexTexture*>(_material);
		mvt->setTexture("image/rock.JPG");
		mvt->setLightmapping("image/lightmap.png");
	} 
	//
	{
		_modules->getRenderEngine()->getFontManager()->createFont(std::string("freetype\\simkai.ttf"), 18, Euclid::eFontProperty_Normal, "free");
		_font = _modules->getRenderEngine()->getFontManager()->getFont(std::string("free"));
	}
	//
	createRTT();
	// sky vertices
	{
		int i = 0; int j = 0;
		// +z
		_skybox[i][j].position = Vec3(+0.5f, +0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(0.f, 0.f); ++j;
		_skybox[i][j].position = Vec3(+0.5f, -0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(0.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, -0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(1.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, +0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(1.f, 0.f);
		// -z
		++i; j = 0;
		_skybox[i][j].position = Vec3(-0.5f, +0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(0.f, 0.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, -0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(0.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(+0.5f, -0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(1.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(+0.5f, +0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(1.f, 0.f);
		// +x
		++i; j = 0;
		_skybox[i][j].position = Vec3(+0.5f, +0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(0.f, 0.f); ++j;
		_skybox[i][j].position = Vec3(+0.5f, -0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(0.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(+0.5f, -0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(1.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(+0.5f, +0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(1.f, 0.f);
		// -x
		++i; j = 0;
		_skybox[i][j].position = Vec3(-0.5f, +0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(0.f, 0.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, -0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(0.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, -0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(1.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, +0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(1.f, 0.f);
		// +y
		++i; j = 0;
		_skybox[i][j].position = Vec3(+0.5f, +0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(0.f, 0.f); ++j;
		_skybox[i][j].position = Vec3(+0.5f, +0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(0.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, +0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(1.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, +0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(1.f, 0.f);
		// -y
		++i; j = 0;
		_skybox[i][j].position = Vec3(+0.5f, -0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(0.f, 0.f); ++j;
		_skybox[i][j].position = Vec3(+0.5f, -0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(0.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, -0.5f, +0.5f); _skybox[i][j].texcoord = Vec2(1.f, 1.f); ++j;
		_skybox[i][j].position = Vec3(-0.5f, -0.5f, -0.5f); _skybox[i][j].texcoord = Vec2(1.f, 0.f);
	}

	{
		_texture_skybox[0] = _modules->getRenderEngine()->getTextureManager()->createTextureFromFile("image/blue/+z.jpg");
		_texture_skybox[1] = _modules->getRenderEngine()->getTextureManager()->createTextureFromFile("image/blue/-z.jpg");
		//
		_texture_skybox[2] = _modules->getRenderEngine()->getTextureManager()->createTextureFromFile("image/blue/-x.jpg");
		_texture_skybox[3] = _modules->getRenderEngine()->getTextureManager()->createTextureFromFile("image/blue/+x.jpg");
		//
		_texture_skybox[4] = _modules->getRenderEngine()->getTextureManager()->createTextureFromFile("image/blue/+y.jpg");
		_texture_skybox[5] = _modules->getRenderEngine()->getTextureManager()->createTextureFromFile("image/blue/-y.jpg");
	}
	// skydome
	_segment_skydome = 16;
	_ring_skydome = 16;
	{
		float step_segment = Euler::TwoPI / (_segment_skydome - 1);
		float step_ring = 0.5f * Euler::PI / (_ring_skydome - 1);
		float radius = 1000.0f;
		Euclid::sPositionTexture vertex;
		for (u32 ring = 0; ring < _ring_skydome; ++ring)
		{
			float radian_ring = ring * step_ring;
			vertex.position.y = radius * Euler::Basic::Sin(radian_ring);
			vertex.texcoord.y = (float)ring / (float)(_ring_skydome - 1);
			for (u32 segment = 0; segment < _segment_skydome; ++segment)
			{
				float radian_segment = segment * step_segment;
				vertex.position.x = radius * Euler::Basic::Cos(radian_ring) * Euler::Basic::Cos(radian_segment);
				vertex.position.z = radius * Euler::Basic::Cos(radian_ring) * Euler::Basic::Sin(radian_segment);
				vertex.texcoord.x = (float)segment / (float)(_segment_skydome - 1);
				_vertices_skydome.push_back(vertex);
			}
		}
		{
			int offset = 1;
			for (int i = 0; i < _ring_skydome - 1;i += offset)
			{
				for (int j = 0; j < _segment_skydome - 1; j += offset)
				{
					u16 baseIndex = j + i * _segment_skydome;
					{
						//
						_indices_skydome.push_back(baseIndex);
						_indices_skydome.push_back(baseIndex + _segment_skydome * offset);
						_indices_skydome.push_back(baseIndex + offset);
						//
						_indices_skydome.push_back(baseIndex + _segment_skydome * offset);
						_indices_skydome.push_back(baseIndex + offset + _segment_skydome * offset);
						_indices_skydome.push_back(baseIndex + offset);
					}
				}
			}
		}
	}
	{
		_texture_skydome = _modules->getRenderEngine()->getTextureManager()->createTextureFromFile("image/dome/Sky_horiz_1_4096.jpg");
	}
	return true;
}