亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? shadow_model.cpp

?? it is a visual c++ file
?? CPP
字號(hào):
//////////////////////////////////////////////////////////////////////////////////////////
//	SHADOW_MODEL.cpp
//	functions for shadow-volume model
//	Downloaded from: www.paulsprojects.net
//	Created:	3rd September 2002
//
//	Copyright (c) 2006, Paul Baker
//	Distributed under the New BSD Licence. (See accompanying file License.txt or copy at
//	http://www.paulsprojects.net/NewBSDLicense.txt)
//////////////////////////////////////////////////////////////////////////////////////////	
#include <windows.h>
#include <GL\gl.h>
#include "LOG.h"
#include "Maths/Maths.h"
#include "SHADOW_MODEL.h"

extern LOG errorLog;

bool SHADOW_MODEL::GenerateTorus(float innerRadius, float outerRadius)
{
	int torusPrecision=24;

	numVertices=(torusPrecision+1)*(torusPrecision+1);
	numIndices=2*torusPrecision*torusPrecision*3;
	numTriangles=numIndices/3;

	vertices=new SHADOW_MODEL_VERTEX[numVertices];
	if(!vertices)
	{
		errorLog.OutputError("Unable to allocate memory for torus vertices");
		return false;
	}

	indices=new unsigned int[numIndices];
	if(!indices)
	{
		errorLog.OutputError("Unable to allocate memory for torus indices");
		return false;
	}
	
	//calculate the first ring - inner radius 4, outer radius 1.5
	for(int i=0; i<torusPrecision+1; i++)
	{
		vertices[i].position=VECTOR3D(innerRadius, 0.0f, 0.0f).GetRotatedZ(i*360.0f/torusPrecision)+
									VECTOR3D(outerRadius, 0.0f, 0.0f);
		
		vertices[i].normal=VECTOR3D(0.0f, 0.0f, 1.0f).
							CrossProduct(VECTOR3D(0.0f, -1.0f, 0.0f).GetRotatedZ(i*360.0f/torusPrecision));
	}

	//rotate this to get other rings
	for(int ring=1; ring<torusPrecision+1; ring++)
	{
		for(int i=0; i<torusPrecision+1; i++)
		{
			vertices[ring*(torusPrecision+1)+i].position=vertices[i].position.GetRotatedY(ring*360.0f/torusPrecision);
			
			vertices[ring*(torusPrecision+1)+i].normal=vertices[i].normal.GetRotatedY(ring*360.0f/torusPrecision);
		}
	}

	//calculate the indices
	for(int ring=0; ring<torusPrecision; ring++)
	{
		for(int i=0; i<torusPrecision; i++)
		{
			indices[((ring*torusPrecision+i)*2)*3+0]=ring*(torusPrecision+1)+i;
			indices[((ring*torusPrecision+i)*2)*3+1]=(ring+1)*(torusPrecision+1)+i;
			indices[((ring*torusPrecision+i)*2)*3+2]=ring*(torusPrecision+1)+i+1;
			indices[((ring*torusPrecision+i)*2+1)*3+0]=ring*(torusPrecision+1)+i+1;
			indices[((ring*torusPrecision+i)*2+1)*3+1]=(ring+1)*(torusPrecision+1)+i;
			indices[((ring*torusPrecision+i)*2+1)*3+2]=(ring+1)*(torusPrecision+1)+i+1;
		}
	}


	//Calculate the plane equation for each face
	planeEquations=new PLANE[numTriangles];
	if(!planeEquations)
	{
		errorLog.OutputError("Unable to allocate memory for %d planes", numTriangles);
		return false;
	}

	for(unsigned int j=0; j<numTriangles; ++j)
	{
		planeEquations[j].SetFromPoints(vertices[indices[j*3+0]].position,
										vertices[indices[j*3+1]].position,
										vertices[indices[j*3+2]].position);
	}

	//Create space for the "is facing light" booleans
	isFacingLight=new bool[numTriangles];
	if(!isFacingLight)
	{
		errorLog.OutputError("Unable to allocate memory for %d booleans", numTriangles);
		return false;
	}

	//Create space for connectivity data
	neighbourIndices=new GLint[numTriangles*3];
	if(!neighbourIndices)
	{
		errorLog.OutputError("Unable to allocate memory for %d neighbour indices", numTriangles*3);
		return false;
	}

	//Create space for "is silhouette edge" booleans
	isSilhouetteEdge=new bool[numTriangles*3];
	if(!isSilhouetteEdge)
	{
		errorLog.OutputError("Unable to allocate memory for %d booleans", numTriangles*3);
		return false;
	}

	//Calculate the neighbours
	SetConnectivity();

	return true;
}

//Calculate neighbour faces for each edge
void SHADOW_MODEL::SetConnectivity()
{
	//set the neighbour indices to be -1
	for(unsigned int i=0; i<numTriangles*3; ++i)
		neighbourIndices[i]=-1;

	//loop through triangles
	for(unsigned int i=0; i<numTriangles-1; ++i)
	{
		//loop through edges on the first triangle
		for(int edgeI=0; edgeI<3; ++edgeI)
		{
			//continue if this edge already has a neighbour set
			if(neighbourIndices[i*3+edgeI]!=-1)
				continue;

			//loop through triangles with greater indices than this one
			for(unsigned int j=i+1; j<numTriangles; ++j)
			{
				//loop through edges on triangle j
				for(int edgeJ=0; edgeJ<3; ++edgeJ)
				{
					//get the vertex indices on each edge
					int edgeI1=indices[i*3+edgeI];
					int edgeI2=indices[i*3+(edgeI+1)%3];
					int edgeJ1=indices[j*3+edgeJ];
					int edgeJ2=indices[j*3+(edgeJ+1)%3];

					//if these are the same (possibly reversed order), these faces are neighbours
					if(		(edgeI1==edgeJ1 && edgeI2==edgeJ2)
						||	(edgeI1==edgeJ2 && edgeI2==edgeJ1))
					{
						neighbourIndices[i*3+edgeI]=j;
						neighbourIndices[j*3+edgeJ]=i;
					}
				}
			}
		}
	}
}

//calculate silhouette edges
void SHADOW_MODEL::CalculateSilhouetteEdges(VECTOR3D lightPosition)
{
	//Calculate which faces face the light
	for(unsigned int i=0; i<numTriangles; ++i)
	{
		if(planeEquations[i].ClassifyPoint(lightPosition)==POINT_IN_FRONT_OF_PLANE)
			isFacingLight[i]=true;
		else
			isFacingLight[i]=false;
	}

	//loop through edges
	for(unsigned int i=0; i<numTriangles*3; ++i)
	{
		//if this face is not facing the light, not a silhouette edge
		if(!isFacingLight[i/3])
		{
			isSilhouetteEdge[i]=0;
			continue;
		}

		//this face is facing the light
		//if the neighbouring face is not facing the light, or there is no neighbouring face,
		//then this is a silhouette edge
		if(neighbourIndices[i]==-1 || !isFacingLight[neighbourIndices[i]])
		{
			isSilhouetteEdge[i]=1;
			continue;
		}

		isSilhouetteEdge[i]=0;
	}
}

void SHADOW_MODEL::DrawInfiniteShadowVolume(VECTOR3D lightPosition, bool drawCaps)
{
	glBegin(GL_QUADS);
	{
		for(unsigned int i=0; i<numTriangles; ++i)
		{
			//if this face does not face the light, continue
			if(!isFacingLight[i])
				continue;

			//Loop through edges on this face
			for(int j=0; j<3; ++j)
			{
				//Draw the shadow volume "edge" if this is a silhouette edge
				if(isSilhouetteEdge[i*3+j])
				{
					VECTOR3D vertex1=vertices[indices[i*3+j]].position;
					VECTOR3D vertex2=vertices[indices[i*3+(j+1)%3]].position;

					glVertex3fv(vertex2);
					glVertex3fv(vertex1);
					glVertex4f(	vertex1.x-lightPosition.x,
								vertex1.y-lightPosition.y,
								vertex1.z-lightPosition.z, 0.0f);
					glVertex4f(	vertex2.x-lightPosition.x,
								vertex2.y-lightPosition.y,
								vertex2.z-lightPosition.z, 0.0f);
				}
			}
		}
	}
	glEnd();

	//Draw caps if required
	if(drawCaps)
	{
		glBegin(GL_TRIANGLES);
		{
			for(unsigned int i=0; i<numTriangles; ++i)
			{
				for(int j=0; j<3; ++j)
				{
					VECTOR3D vertex=vertices[indices[i*3+j]].position;
					
					if(isFacingLight[i])
						glVertex3fv(vertex);
					else
						glVertex4f(	vertex.x-lightPosition.x,
									vertex.y-lightPosition.y,
									vertex.z-lightPosition.z, 0.0f);
				}
			}
		}
		glEnd();
	}
}

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产成人精品免费| 日韩免费看的电影| 国产精品欧美精品| 成人免费黄色大片| 国产精品九色蝌蚪自拍| 97国产精品videossex| 一区二区欧美精品| 欧美日产在线观看| 美女脱光内衣内裤视频久久影院| 亚洲色图在线视频| 91久久精品一区二区三| 日韩不卡一区二区三区| 26uuu精品一区二区在线观看| 成人伦理片在线| 日本大胆欧美人术艺术动态| 亚洲男女一区二区三区| 制服.丝袜.亚洲.另类.中文| 国产一区二区三区久久久| 国产精品免费久久久久| 精品国产1区2区3区| www.综合网.com| 午夜精品福利一区二区三区av | 26uuu色噜噜精品一区二区| 欧美日韩一区精品| 国产激情视频一区二区在线观看| 天堂成人国产精品一区| 国产午夜精品久久久久久免费视 | 日本中文字幕一区| 亚洲一区二区三区中文字幕| 精品国产精品网麻豆系列| 欧美夫妻性生活| 国产91对白在线观看九色| 亚洲国产视频在线| 国产女人aaa级久久久级 | 99久久伊人精品| 国产成人午夜99999| 精品一区二区精品| 一区二区成人在线| 一区二区三区四区在线播放| 一二三四社区欧美黄| 亚洲精品久久久久久国产精华液| 精品电影一区二区| 精品国产麻豆免费人成网站| 日韩精品一区二| 欧美不卡一区二区三区| 欧美日韩亚洲综合在线| 欧美在线免费播放| 成人91在线观看| 蜜桃视频免费观看一区| 美女精品一区二区| 久久国产精品色| 香蕉久久夜色精品国产使用方法 | 精品福利在线导航| 久久精品水蜜桃av综合天堂| 国产精品素人一区二区| 最新不卡av在线| 一区二区三国产精华液| 爽爽淫人综合网网站| 蜜臀av性久久久久蜜臀av麻豆| 看片网站欧美日韩| 国产999精品久久久久久| 大胆欧美人体老妇| 91成人在线免费观看| 欧美一区永久视频免费观看| 欧美性猛片aaaaaaa做受| jiyouzz国产精品久久| 日本电影欧美片| 91精品久久久久久蜜臀| 久久这里只有精品首页| 1区2区3区精品视频| 国产精品天干天干在线综合| 亚洲狠狠丁香婷婷综合久久久| 亚洲18色成人| 国产美女av一区二区三区| 成人aaaa免费全部观看| 欧美性感一类影片在线播放| 日韩免费视频一区| 国产精品久久久久影院亚瑟| 亚欧色一区w666天堂| 国产一区不卡视频| 色八戒一区二区三区| 日韩手机在线导航| 日韩三级中文字幕| 欧美国产欧美综合| 欧美高清一级片在线观看| 一区二区三区欧美视频| 久久精品国产亚洲5555| 91视频在线观看| 欧美性生活大片视频| 久久免费国产精品| 国产精品人人做人人爽人人添| 一区二区三区国产精华| 美女爽到高潮91| 一本色道久久综合狠狠躁的推荐| 色综合一个色综合亚洲| 在线亚洲高清视频| 久久综合丝袜日本网| 一区二区三区精品久久久| 韩国一区二区视频| 成人av资源在线| 日韩亚洲电影在线| 一区二区三区在线影院| 国产精品一区二区在线观看不卡| 国产成人精品三级麻豆| 欧美日韩国产精品自在自线| 国产精品久久综合| 国产精品一区二区三区网站| 在线视频综合导航| 国产精品丝袜在线| 国产一区欧美二区| 欧美日韩一区二区在线观看视频 | 久久久久久久久蜜桃| 日本中文字幕不卡| 在线观看亚洲一区| 中文字幕在线观看不卡| 国产一区二区三区久久悠悠色av| 91麻豆精品国产91久久久| 综合电影一区二区三区| 国产在线精品免费| 日韩精品一区二区三区视频| 日日摸夜夜添夜夜添亚洲女人| 在线观看网站黄不卡| 成人欧美一区二区三区视频网页| 精品中文字幕一区二区小辣椒 | 日本道精品一区二区三区| 国产精品伦理一区二区| 国产激情91久久精品导航 | 国产一区二三区| 日韩欧美你懂的| 丝袜美腿一区二区三区| 国产精品久线观看视频| 国产精品88av| 欧美国产日韩一二三区| 东方aⅴ免费观看久久av| 欧美激情资源网| 成人一道本在线| 中文欧美字幕免费| av电影在线观看一区| 亚洲少妇最新在线视频| 色综合久久久久综合| 亚洲码国产岛国毛片在线| 91老司机福利 在线| 亚洲自拍偷拍欧美| 91成人国产精品| 亚洲成a天堂v人片| 日韩一区二区在线播放| 久久97超碰色| 久久久久久久久久久久久女国产乱| 国产美女在线精品| 国产精品拍天天在线| 91日韩精品一区| 香港成人在线视频| 日韩视频一区二区三区| 精品无码三级在线观看视频| 久久精品视频在线看| 91玉足脚交白嫩脚丫在线播放| 亚洲精品中文字幕乱码三区| 欧美日韩亚洲不卡| 美国三级日本三级久久99| 国产三级一区二区| 91捆绑美女网站| 日韩精品亚洲专区| 久久精品夜色噜噜亚洲a∨| 91小视频在线免费看| 日韩和欧美一区二区| 久久免费看少妇高潮| 色综合视频一区二区三区高清| 首页亚洲欧美制服丝腿| 久久精品欧美日韩| 欧美综合亚洲图片综合区| 日本欧美在线观看| 亚洲国产精品99久久久久久久久 | 国产老妇另类xxxxx| 17c精品麻豆一区二区免费| 欧美在线视频全部完| 国内精品久久久久影院一蜜桃| 国产精品乱码久久久久久| 欧美日韩色一区| 国产精品一级黄| 视频一区欧美精品| 国产精品免费看片| 欧美一区二区三区人| 成人美女在线观看| 日本不卡的三区四区五区| 制服丝袜成人动漫| 岛国一区二区三区| 亚洲va国产天堂va久久en| 久久先锋影音av鲁色资源 | 中文字幕精品综合| 欧美午夜电影网| 国产精品99精品久久免费| 午夜国产精品一区| 久久精品一区四区| 欧美猛男gaygay网站| 成人黄色小视频在线观看| 秋霞成人午夜伦在线观看| 亚洲男同性恋视频| 久久久久亚洲综合| 91精品国产麻豆| 91久久奴性调教|