opengl光照问题
我在SetupRC函数中设定光照如下:glClearColor(1.0f,1.0f,1.0f,1.0f);//光源属性设置GLfloatambientProperties...
我在SetupRC函数中设定光照如下:
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
//光源属性设置
GLfloat ambientProperties[] = {0.3f, 0.4f, 0.8f, 1.0f};//环境光强度值
GLfloat diffuseProperties[] = {1.0f, 1.0f, 0.0f, 1.0f};//漫反射光强度值,用他改变颜色
GLfloat specularProperties[] = {1.0f, 1.0f, 1.0f, 1.0f};//镜面光强度值
GLfloat lmodel_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};//全局环境光强度值
GLfloat light_position[] = {-3000.0f, 0.0f, 0.0f, 1.0f};//光源位置值
//材料属性设置
GLfloat no_mat[] = {0.0f,0.0f,0.0f,1.0f}; //黑色材致或无材致
GLfloat mat_ambient[] = {0.8f,0.7f,0.3f,1.0f};//物体对环境光的反射因素
GLfloat mat_diffuse[] = {0.3f,0.5f,0.8f,1.0f};//物体对漫反射光的反射因素
GLfloat mat_specular[] = {1.0f,1.0f,1.0f,1.0f};//物体对镜面光的反射因素
GLfloat mat_emission[] = {0.3f,0.4f,0.8f,1.0f};//设置物体对荧光的颜色
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient);//设置全局环境光
//初始化光源GL_LIGHT0的颜色属性
glLightfv( GL_LIGHT0,GL_AMBIENT,ambientProperties);
glLightfv( GL_LIGHT0,GL_DIFFUSE,diffuseProperties);
glLightfv( GL_LIGHT0,GL_SPECULAR,specularProperties);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,1.0f);
glEnable(GL_LIGHT0);//允许GL_LIGHT0光源
glEnable(GL_LIGHTING);//允许光照
好像可以改变漫反射光的颜色来改变整个图象的颜色,但是我如果画两个球,要求这两个球有不同的颜色,应该如何来实现?(必须使用光照),也就是为什么使用了光照,自己在绘图函数中设定的颜色就没有作用了,如何使绘图函数中设定的颜色有作用同时有光照和立体效果? 展开
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
//光源属性设置
GLfloat ambientProperties[] = {0.3f, 0.4f, 0.8f, 1.0f};//环境光强度值
GLfloat diffuseProperties[] = {1.0f, 1.0f, 0.0f, 1.0f};//漫反射光强度值,用他改变颜色
GLfloat specularProperties[] = {1.0f, 1.0f, 1.0f, 1.0f};//镜面光强度值
GLfloat lmodel_ambient[] = {0.2f, 0.2f, 0.2f, 1.0f};//全局环境光强度值
GLfloat light_position[] = {-3000.0f, 0.0f, 0.0f, 1.0f};//光源位置值
//材料属性设置
GLfloat no_mat[] = {0.0f,0.0f,0.0f,1.0f}; //黑色材致或无材致
GLfloat mat_ambient[] = {0.8f,0.7f,0.3f,1.0f};//物体对环境光的反射因素
GLfloat mat_diffuse[] = {0.3f,0.5f,0.8f,1.0f};//物体对漫反射光的反射因素
GLfloat mat_specular[] = {1.0f,1.0f,1.0f,1.0f};//物体对镜面光的反射因素
GLfloat mat_emission[] = {0.3f,0.4f,0.8f,1.0f};//设置物体对荧光的颜色
glLightModelfv(GL_LIGHT_MODEL_AMBIENT,lmodel_ambient);//设置全局环境光
//初始化光源GL_LIGHT0的颜色属性
glLightfv( GL_LIGHT0,GL_AMBIENT,ambientProperties);
glLightfv( GL_LIGHT0,GL_DIFFUSE,diffuseProperties);
glLightfv( GL_LIGHT0,GL_SPECULAR,specularProperties);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,1.0f);
glEnable(GL_LIGHT0);//允许GL_LIGHT0光源
glEnable(GL_LIGHTING);//允许光照
好像可以改变漫反射光的颜色来改变整个图象的颜色,但是我如果画两个球,要求这两个球有不同的颜色,应该如何来实现?(必须使用光照),也就是为什么使用了光照,自己在绘图函数中设定的颜色就没有作用了,如何使绘图函数中设定的颜色有作用同时有光照和立体效果? 展开
1个回答
展开全部
<%@LANGUAGE="VBSCRIPT"%>
<!--#include file="Connections/conn.asp" -->
<%
set rs_detail=Server.CreateObject("ADODB.RecordSet")
sql="SELECT * FROM DB_goodinfo WHERE GoodID = '" + Request.QueryString("GoodID") + "'"
rs_detail.open sql,conn,3,3
%>
<%
RecID=request.QueryString("GoodID")
strSQL="Select a.*,b.TypeID from DB_goodinfo a Left Outer Join DB_goodType b On a.Type=b.Type where a.GoodID='"&RecID&"'"
Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open strSQL,conn,1,1
if session("BH")>0 then '记录浏览次数
RecordBrows RS("TypeID"),RS("GoodID"),"brows"
end if
%>
<%
Sub RecordBrows(TypeID,GoodID,sType)
dim tmpRS,strSQL
Set tmpRS=Server.CreateObject("ADODB.RecordSet")
if sType="buy" then
tmpRS.Open "Select b.TypeID From DB_goodinfo a Left Outer Join DB_goodType b On a.Type=b.Type where a.GoodID=" & GoodID ,conn,1,1
TypeID=tmpRS("TypeID")
tmpRS.close
end if
tmpRS.Open "Select ID From DB_UserTypeClick Where UserID=" & Session("UserID") & " and TypeID=" & TypeID & " and GoodID=" & GoodID,conn,1,1
if tmpRS.Eof and tmpRS.Bof then
if sType="brows" then
strSQL="Insert Into DB_UserTypeClick(UserID,TypeID,GoodID,Clicks,Buys) Values ("& Session("UserID") & "," & TypeID & "," & GoodID & ",1,0)"
end if
if sType="buy" then
strSQL="Insert Into DB_UserTypeClick(UserID,TypeID,GoodID,Clicks,Buys) Values ("& Session("UserID") & "," & TypeID & "," & GoodID & ",0,1)"
end if
else
if sType="brows" then
strSQL="Update DB_UserTypeClick Set Clicks=Clicks+1 Where UserID=" & Session("UserID") & " and TypeID=" & TypeID & " and GoodID=" & GoodID
end if
if sType="buy" then
strSQL="Update DB_UserTypeClick Set Buys=Buys+1 Where UserID=" & Session("UserID") & " and TypeID=" & TypeID & " and GoodID=" & GoodID
end if
end if
tmpRS.close
if strSQL<>"" then
conn.Execute strSQL
end if
End Sub
%>
<!--#include file="Connections/conn.asp" -->
<%
set rs_detail=Server.CreateObject("ADODB.RecordSet")
sql="SELECT * FROM DB_goodinfo WHERE GoodID = '" + Request.QueryString("GoodID") + "'"
rs_detail.open sql,conn,3,3
%>
<%
RecID=request.QueryString("GoodID")
strSQL="Select a.*,b.TypeID from DB_goodinfo a Left Outer Join DB_goodType b On a.Type=b.Type where a.GoodID='"&RecID&"'"
Set RS=Server.CreateObject("ADODB.RecordSet")
RS.Open strSQL,conn,1,1
if session("BH")>0 then '记录浏览次数
RecordBrows RS("TypeID"),RS("GoodID"),"brows"
end if
%>
<%
Sub RecordBrows(TypeID,GoodID,sType)
dim tmpRS,strSQL
Set tmpRS=Server.CreateObject("ADODB.RecordSet")
if sType="buy" then
tmpRS.Open "Select b.TypeID From DB_goodinfo a Left Outer Join DB_goodType b On a.Type=b.Type where a.GoodID=" & GoodID ,conn,1,1
TypeID=tmpRS("TypeID")
tmpRS.close
end if
tmpRS.Open "Select ID From DB_UserTypeClick Where UserID=" & Session("UserID") & " and TypeID=" & TypeID & " and GoodID=" & GoodID,conn,1,1
if tmpRS.Eof and tmpRS.Bof then
if sType="brows" then
strSQL="Insert Into DB_UserTypeClick(UserID,TypeID,GoodID,Clicks,Buys) Values ("& Session("UserID") & "," & TypeID & "," & GoodID & ",1,0)"
end if
if sType="buy" then
strSQL="Insert Into DB_UserTypeClick(UserID,TypeID,GoodID,Clicks,Buys) Values ("& Session("UserID") & "," & TypeID & "," & GoodID & ",0,1)"
end if
else
if sType="brows" then
strSQL="Update DB_UserTypeClick Set Clicks=Clicks+1 Where UserID=" & Session("UserID") & " and TypeID=" & TypeID & " and GoodID=" & GoodID
end if
if sType="buy" then
strSQL="Update DB_UserTypeClick Set Buys=Buys+1 Where UserID=" & Session("UserID") & " and TypeID=" & TypeID & " and GoodID=" & GoodID
end if
end if
tmpRS.close
if strSQL<>"" then
conn.Execute strSQL
end if
End Sub
%>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询