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


C++ Ray::enableShadow方法代码示例

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


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

示例1: assert

std::vector<Ray*>& Ray::reflect(const Vector4f& norm){
    //norm.Print();
    assert(norm[3]==0);
	if(m_pIntersectionProperties != NULL && m_iRecursiveTime > 1){
            float reflectance = Ray::CalculateReflectance(norm,this->m_RayLine.m_Direction,NULL,
                this->m_pIntersectionProperties->m_Material);
            Vector4f dir = this->m_RayLine.m_Direction - (norm * 2.0 * 
                    norm.dot(this->m_RayLine.m_Direction));
            Line ref_dir;
            ref_dir.m_Direction = dir;
            ref_dir.m_StartPoint = this->m_pIntersectionProperties->m_IntersectionPoint + (float)0.001 * norm;
            // Mirror reflection
            if(m_pIntersectionProperties->m_Material->m_eMaterialType == eMaterialType_opague){
                Ray* newray = new Ray(this, ref_dir , this->m_iRecursiveTime-1);
                if(this->m_bShadowEnabled){
                    newray->enableShadow(this->m_iNumOfLighting);
                }
                else{
                    newray->disableShadow();
                }
                newray->m_fReflectionIntensity = 1.0;
                newray->m_iID = -1;
                this->m_pReflectedRayList.push_back(newray); 
            }
            // glossy reflection
            if(m_pIntersectionProperties->m_Material->m_eMaterialType == eMaterialType_glossy){
                Vector4f horizontal = ref_dir.m_Direction.cross(this->m_pIntersectionProperties->m_PlanarNormal);
                Vector4f projection = this->m_pIntersectionProperties->m_PlanarNormal.cross(horizontal);
                horizontal.Normalize();
                projection.Normalize();
                for(unsigned int i = 0; i < m_pIntersectionProperties->m_Material->m_iGlossySamepleCount;
                        i++){
                    Ray* newray = new Ray(this, ref_dir, this->m_iRecursiveTime-1);
                    if(this->m_bShadowEnabled){
                        newray->enableShadow(this->m_iNumOfLighting);
                    }
                    else{
                        newray->disableShadow();
                    }
                    Vector4f newdir = newray->jitter(horizontal,projection,this->m_pIntersectionProperties->m_PlanarNormal,0.6);
                    newray->m_fReflectionIntensity = newdir.dot(ref_dir.m_Direction);
                    newray->m_iID = -1;
                    this->m_pReflectedRayList.push_back(newray);
                    // TODO: add glossy reflection here.
                }
            }
	}
    return m_pReflectedRayList;
}
开发者ID:lomo44,项目名称:Graphics,代码行数:49,代码来源:Ray.cpp

示例2: InitializeRayList

void RayTracer::InitializeRayList(){
	assert(m_pRenderAttribute!=NULL);
	double factor = (double(this->m_pRenderAttribute->m_iScreenHeight)/2)
			/tan(this->m_pRenderAttribute->m_ViewFrustrum->m_fFieldOfView*M_PI/360.0);
	int _height = this->m_pRenderAttribute->m_iScreenHeight;
	int _width = this->m_pRenderAttribute->m_iScreenWidth;
	for (int i = 0; i < _height; i++) {
		for (int j = 0; j < _width; j++) {
			// Sets up ray origin and direction in view space,
			// image plane is at z = -1.

			/** ToDO:
			 * Need to implement anti-aliasing, random sampling.
			 */
            if(antiAliasing){
                    for (int li = -1; li<2; li++) {
                        if (li == 0) {
                            Vector4f origin;
                            Vector4f imagePlane;
                            origin[3] = 1;
                            imagePlane[0] = (-double(_width)/2 + 0.5+j)/factor;
                            imagePlane[1] = (-double(_height)/2 + 0.5+i)/factor;
                            imagePlane[2] = -1;
                            Vector4f _dir (imagePlane[0],imagePlane[1],imagePlane[2]);
                            Vector4f dir = this->m_ViewToWorld * _dir;
                            origin = this->m_ViewToWorld * origin;;
                            Line newrayline;
                            newrayline.m_Direction = dir;
                            newrayline.m_StartPoint = origin;
                            Ray* newray = new Ray(NULL,newrayline,this->m_pRenderAttribute->m_iRayTracingDepth);
                            newray->m_iID = i*_height + j;
                            if(this->m_pRenderAttribute->m_bShadowEnable){
                                //std::cout<<this->m_LightList.size()<<std::endl;
                                newray->enableShadow(this->m_LightList.size());
                            }
                            else{
                                newray->disableShadow();
                            }
                            m_RayBuffer.push(newray);
                            m_RayList.push_back(newray);
                        }
                        else{
                            for (int zhuang = -1; zhuang<2; zhuang++) {
                                if (zhuang != 0) {
                                    Vector4f origin;
                                    Vector4f imagePlane;
                                    origin[3] = 1;
                                    imagePlane[0] = (-double(_width)/2 + 0.5 +j+ li*0.25)/factor;
                                    imagePlane[1] = (-double(_height)/2 + 0.5 +i+ zhuang*0.25)/factor;
                                    imagePlane[2] = -1;
                                    Vector4f _dir (imagePlane[0],imagePlane[1],imagePlane[2]);
                                    Vector4f dir = this->m_ViewToWorld * _dir;
                                    origin = this->m_ViewToWorld * origin;;
                                    Line newrayline;
                                    newrayline.m_Direction = dir;
                                    newrayline.m_StartPoint = origin;
                                    dir.Normalize();
                                    Ray* newray = new Ray(NULL,newrayline,this->m_pRenderAttribute->m_iRayTracingDepth);
                                    newray->m_iID = i*_height + j;
                                    if(this->m_pRenderAttribute->m_bShadowEnable){
                                        //std::cout<<this->m_LightList.size()<<std::endl;
                                        newray->enableShadow(this->m_LightList.size());
                                    }
                                    else{
                                        newray->disableShadow();
                                    }
                                    m_RayBuffer.push(newray);
                                    m_RayList.push_back(newray);
                                }

                            }
                        }
                    
                }
            }
            else{
                Vector4f origin;
                Vector4f imagePlane;
                origin[3] = 1;
                imagePlane[0] = (-double(_width)/2 + 0.5 + j)/factor;
    			imagePlane[1] = (-double(_height)/2 + 0.5 + i)/factor;
    			imagePlane[2] = -1;
    			Vector4f _dir (imagePlane[0],imagePlane[1],imagePlane[2]);
    			Vector4f dir = this->m_ViewToWorld * _dir;
    			origin = this->m_ViewToWorld * origin;;
    			Line newrayline;
    			newrayline.m_Direction = dir;
    			newrayline.m_StartPoint = origin;
                dir.Normalize();
    			Ray* newray = new Ray(NULL,newrayline,this->m_pRenderAttribute->m_iRayTracingDepth);
                newray->m_iID = i*_height + j;
                if(this->m_pRenderAttribute->m_bShadowEnable){
                    //std::cout<<this->m_LightList.size()<<std::endl;
                    newray->enableShadow(this->m_LightList.size());
                }
                else{
                    newray->disableShadow();
                }
    			m_RayBuffer.push(newray);
    			m_RayList.push_back(newray);
//.........这里部分代码省略.........
开发者ID:lomo44,项目名称:Graphics,代码行数:101,代码来源:RayTracer.cpp


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