当前位置: 首页>>代码示例>>C++>>正文


C++ CLight::InitLight方法代码示例

本文整理汇总了C++中CLight::InitLight方法的典型用法代码示例。如果您正苦于以下问题:C++ CLight::InitLight方法的具体用法?C++ CLight::InitLight怎么用?C++ CLight::InitLight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CLight的用法示例。


在下文中一共展示了CLight::InitLight方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Init

void Init()
{
    //
	::SetTimer(g_hwnd,100,1000,NULL);
   

	bool bret = LoadBitmapFile(&bitmap,"wall.bmp");

	int bitmapwidth = bitmap.bitmapinfoheader.biWidth;
	int bitmapheight = bitmap.bitmapinfoheader.biHeight;

	CRenderObject *pobj = new CRenderObject;
	std::vector<Vertex> pointlist;
	pointlist.push_back(Vertex(POINT3D(10,10,10) ));
	pointlist.push_back(Vertex(POINT3D(10,10,-10)));
	pointlist.push_back(Vertex(POINT3D(-10,10,-10)));
	pointlist.push_back(Vertex(POINT3D(-10,10,10)));
	pointlist.push_back(Vertex(POINT3D(10,-10,10)));
	pointlist.push_back(Vertex(POINT3D(-10,-10,10)));
	pointlist.push_back(Vertex(POINT3D(-10,-10,-10)));
	pointlist.push_back(Vertex(POINT3D(10,-10,-10)));
    
	pobj->m_translateverticesList = pointlist;
	pobj->m_verticesList = pointlist;
  

	//Set texture pointlist
	std::vector<POINT2D> texturelist;
	texturelist.push_back(POINT2D(0,0));
	texturelist.push_back(POINT2D(bitmapwidth-1,0));
	texturelist.push_back(POINT2D(bitmapwidth-1,bitmapheight-1));
	texturelist.push_back(POINT2D(0,bitmapheight-1));

	pobj->m_texturecoordinatesList = texturelist;


	int tempindices[36]=
	{
		0,1,2, 0,2,3,
		0,7,1, 0,4,7,
		1,7,6, 1,6,2,
		2,6,5, 2,3,5,
		0,5,4, 0,3,5,
		5,6,7, 4,5,7
	};
	int textindices[36] =
	{
        2,1,0, 2,0,3,
		2,0,1, 2,3,0,
		1,0,3, 1,3,0,
		0,1,2, 2,3,0,
		2,0,1, 2,3,0,
		2,1,0, 3,2,0
	};

	for(int i =0; i <12;++i)
	{

    POLYGON temp ;
	temp.v[0]  = tempindices[i*3+0];
	temp.v[1]  = tempindices[i*3+1];
	temp.v[2]  = tempindices[i*3 +2];

	temp.text[0] = textindices[i*3+0];
	temp.text[1] = textindices[i*3+1];
	temp.text[2] = textindices[i*3+2];


    temp.state |= OBJECT_HAS_TEXTURE|SHADE_MODEL_CONSTANT;
	temp.color = RGBA(RGB(128,123,140));
	temp.texture = &bitmap;
	temp.pointlist = &pobj->m_verticesList;
	temp.texturecoordinatelist = &pobj->m_texturecoordinatesList;
	pobj->m_PolyGonList.push_back(temp);
   }
	pobj->world_pos = POINT3D(-10,0,50);
	CRenderObject *pobj2 = new CRenderObject(*pobj);
	pobj2->world_pos = POINT3D(15,0,50);
	CRenderObject* pobj3 =new CRenderObject(*pobj);
	pobj3->world_pos = POINT3D(0,10,80);
	CRenderObject *pobj4  = new CRenderObject(*pobj);
	pobj4->world_pos = POINT3D(20,-10,100);

	g_RenderManager.Add(pobj);
	g_RenderManager.Add(pobj2);
	g_RenderManager.Add(pobj3);
	g_RenderManager.Add(pobj4);

  //Set lights
  CLight *pLight = new CLight;
  pLight->InitLight(CLight::kAmbientLight,RGBA(RGB(255,0,0)),Black_Color,Black_Color);
  g_lights.AddLight(pLight);
 
  CLight *pLight2 = new CLight;
  pLight2->InitLight(CLight::kInfiniteLigtht,Black_Color,RGBA(255,0,0),Black_Color,ZeroVector,
	               Vector4D(-1.0,0.0,1.0));
   g_lights.AddLight(pLight2);

  CLight *pLight3 = new  CLight;
  pLight3->InitLight(CLight::kPointLight,Black_Color,RGBA(0,255,0),Black_Color,Vector4D(0,10,0),
//.........这里部分代码省略.........
开发者ID:orbv,项目名称:Simple-3D-Software-Render,代码行数:101,代码来源:Main.cpp


注:本文中的CLight::InitLight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。