本文整理汇总了C++中ShadeContext::P方法的典型用法代码示例。如果您正苦于以下问题:C++ ShadeContext::P方法的具体用法?C++ ShadeContext::P怎么用?C++ ShadeContext::P使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShadeContext
的用法示例。
在下文中一共展示了ShadeContext::P方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Illuminate
BOOL DefObjLight::Illuminate(ShadeContext& sc, Point3& normal, Color& color, Point3 &dir, float &dot_nl, float &diffCoef)
{
dir = Normalize(lightPos-sc.P());
diffCoef = dot_nl = DotProd(normal, dir);
color = intensCol;
return (dot_nl <= 0.0f) ? 0 : 1;
}
示例2: EvalColor
RGBA Plate::EvalColor(ShadeContext& sc) {
BMM_Color_64 c;
IPoint2 s;
int id = sc.NodeID();
PlateMap *pmap = FindMap(id);
if (gbufID) sc.SetGBufferID(gbufID);
if (pmap) {
s = sc.ScreenCoord();
int w = pmap->bm->Width();
int h = pmap->bm->Height();
Point3 view = sc.OrigView();
Point3 v2 = sc.V();
Point3 p = sc.P();
Point3 dV,dvf;
Point3 N0 = sc.OrigNormal();
Point3 vf = RefractVector(sc, N0, view, sc.GetIOR());
RenderGlobalContext *gc = sc.globContext;
if (gc==NULL) return blackrgba;
// total deflection due to refraction
dV = view-v2;
// deflection due to flat refracton (no bumps)
dvf = view-vf;
dV = refrAmt*(dV-dvf) + thick*dvf;
// compute screen deflection: This is really a cheat, and the
// scale factor is arbitrary. Infact it depends on the distance
// between to the point on the glass plate and to the point being
// seen behind it, which we don't know.
// these should be multiplied by the factor (Zbehind-Zcur)/Zcur
// This assumes that the factor is .1
float dsx,dsy;
if (gc->projType==0) {
// perspective
dsx = dV.x*0.1f*gc->xscale;
dsy = dV.y*0.1f*gc->yscale;
}
else {
// parallel projection
dsx = -dV.x*gc->xscale*10.0f;
dsy = -dV.y*gc->yscale*10.0f;
}
if (gc->fieldRender) dsy *= 2.0f;
int x = s.x - (pmap->org.x+gc->devWidth/2);
int y = s.y - (pmap->org.y+gc->devHeight/2);
if (applyBlur) {
float du = 1.0f/float(w);
float dv = 1.0f/float(h);
float u = (float(x)+dsx)*du;
float v = (float(y)+dsy)*dv;
if (u<0.0f||u>1.0f||v<0.0f||v>1.0f) {
if (useEnvMap) {
return sc.EvalGlobalEnvironMap(view-dvf);
}
else
return blackrgba;
}
else
pmap->bm->GetFiltered(u,v, du*blur, dv*blur,&c);
}
else {
int ix = x + int(dsx);
int iy = y + int(dsy);
if (ix<0||ix>=w||iy<0||iy>=h) {
if (useEnvMap)
return sc.EvalGlobalEnvironMap(view-dvf);
else
return blackrgba;
}
else
pmap->bm->GetLinearPixels(ix,iy,1,&c);
}
return c;
}
else
return blackrgba;
}
示例3: getGradientValueNormal
float BerconGradient::getGradientValueNormal(ShadeContext& sc) {
switch (p_normalType) {
case 0: { // View
return -DotProd(sc.Normal(), sc.V());
}
case 1: { // Local X
return (sc.VectorTo(sc.Normal(), REF_OBJECT)).x;
}
case 2: { // Local Y
return (sc.VectorTo(sc.Normal(), REF_OBJECT)).y;
}
case 3: { // Local Z
return (sc.VectorTo(sc.Normal(), REF_OBJECT)).z;
}
case 4: { // World X
return (sc.VectorTo(sc.Normal(), REF_WORLD)).x;
}
case 5: { // World Y
return (sc.VectorTo(sc.Normal(), REF_WORLD)).y;
}
case 6: { // World Z
return (sc.VectorTo(sc.Normal(), REF_WORLD)).z;
}
case 7: { // Camera X
return sc.Normal().x; //(sc.VectorTo(sc.Normal(), REF_CAMERA)).x;
}
case 8: { // Camera Y
return sc.Normal().y; //(sc.VectorTo(sc.Normal(), REF_CAMERA)).y;
}
case 9: { // Camera Z
return sc.Normal().z; //(sc.VectorTo(sc.Normal(), REF_CAMERA)).z;
}
case 10: { // To Object
if (sc.InMtlEditor() || !p_node)
return -DotProd(sc.Normal(), sc.V());
return DotProd(sc.Normal(), FNormalize(sc.PointFrom((p_node->GetNodeTM(sc.CurTime())).GetTrans(),REF_WORLD) - sc.P()));
}
case 11: { // Object Z
if (sc.InMtlEditor() || !p_node)
return -DotProd(sc.Normal(), sc.V());
return DotProd(sc.Normal(), FNormalize(sc.VectorFrom(p_node->GetNodeTM(sc.CurTime()).GetRow(2),REF_WORLD)));
}
}
return 0.f;
}
示例4: getGradientValueDist
float BerconGradient::getGradientValueDist(ShadeContext& sc) {
switch (p_normalType) {
case 0: { // View
return -sc.P().z; //Length(sc.OrigView()); //(sc.PointTo(sc.P(), REF_CAMERA)).z;
}
case 1: { // Local X
return (sc.PointTo(sc.P(), REF_OBJECT)).x;
}
case 2: { // Local Y
return (sc.PointTo(sc.P(), REF_OBJECT)).y;
}
case 3: { // Local Z
return (sc.PointTo(sc.P(), REF_OBJECT)).z;
}
case 4: { // World X
return (sc.PointTo(sc.P(), REF_WORLD)).x;
}
case 5: { // World Y
return (sc.PointTo(sc.P(), REF_WORLD)).y;
}
case 6: { // World Z
return (sc.PointTo(sc.P(), REF_WORLD)).z;
}
case 7: { // Camera X
return sc.P().x; //(sc.PointTo(sc.P(), REF_CAMERA)).x;
}
case 8: { // Camera Y
return sc.P().y; //(sc.PointTo(sc.P(), REF_CAMERA)).y;
}
case 9: { // Camera Z
return -sc.P().z; //-(sc.PointTo(sc.P(), REF_CAMERA)).z;
}
case 10: { // To Object
if (sc.InMtlEditor() || !p_node)
return -sc.P().z; //(sc.PointTo(sc.P(), REF_CAMERA)).z;
return Length((p_node->GetNodeTM(sc.CurTime())).GetTrans() - sc.PointTo(sc.P(), REF_WORLD));
}
case 11: { // Object Z
if (sc.InMtlEditor() || !p_node)
return -sc.P().z; //(sc.PointTo(sc.P(), REF_CAMERA)).z;
Matrix3 tm = p_node->GetNodeTM(sc.CurTime());
Point3 a = tm.GetTrans() - sc.PointTo(sc.P(), REF_WORLD);
Point3 b = FNormalize(tm.GetRow(2));
return (-DotProd(b, a) / Length(b));
}
}
return 0.f;
}