本文整理汇总了C++中reflect函数的典型用法代码示例。如果您正苦于以下问题:C++ reflect函数的具体用法?C++ reflect怎么用?C++ reflect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了reflect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: reflect
//reflect across the line containing points p and q
point reflect(const point & p, const point & q) const {
if (p == q) return reflect(p);
point r(*this - p), s = q - p;
r = point(r.x * s.x + r.y * s.y, r.x * s.y - r.y * s.x) / s.norm();
r = point(r.x * s.x - r.y * s.y, r.x * s.y + r.y * s.x) + p;
return r;
}
开发者ID:nikhiljangam,项目名称:Algorithms-Anthology,代码行数:8,代码来源:5.1.1+Point+(2D).cpp
示例2: eval
Spectrum eval(const BSDFSamplingRecord &bRec, EMeasure measure) const {
if (Frame::cosTheta(bRec.wi) <= 0 ||
Frame::cosTheta(bRec.wo) <= 0 || measure != ESolidAngle)
return Spectrum(0.0f);
bool hasSpecular = (bRec.typeMask & EGlossyReflection)
&& (bRec.component == -1 || bRec.component == 0);
bool hasDiffuse = (bRec.typeMask & EDiffuseReflection)
&& (bRec.component == -1 || bRec.component == 1);
Spectrum result(0.0f);
if (hasSpecular) {
Float alpha = dot(bRec.wo, reflect(bRec.wi)),
exponent = m_exponent->eval(bRec.its).average();
if (alpha > 0.0f) {
result += m_specularReflectance->eval(bRec.its) *
((exponent + 2) * INV_TWOPI * std::pow(alpha, exponent));
}
}
if (hasDiffuse)
result += m_diffuseReflectance->eval(bRec.its) * INV_PI;
return result * Frame::cosTheta(bRec.wo);
}
开发者ID:AdrianJohnston,项目名称:ShapeNetRender,代码行数:26,代码来源:phong.cpp
示例3: gentab
static void gentab(int bits, uint64 poly, int reflected)
{
int i;
uint64 topbit = 1ULL << (bits-1);
uint64 mask = ~0ULL >> (64-bits);
for (i = 0; i < 256; ++i) {
uint64 crc = i;
int j;
if (reflected) crc = reflect(crc, 8);
crc <<= bits - 8;
for (j = 0; j < 8; ++j)
crc = (crc << 1) ^ ((crc & topbit) ? poly : 0);
if (reflected) crc = reflect(crc, bits);
crctab[i] = crc & mask;
}
}
开发者ID:bruceg,项目名称:bglibs,代码行数:16,代码来源:crc-gentab.c
示例4: RunFloat2Or3Tests
void RunFloat2Or3Tests(std::string const& typeName)
{
RunCommonVectorTests<T>(typeName);
RunPerfTest<T, T>(typeName + " reflect", [](T* value, T const& param)
{
*value = reflect(*value, param);
});
RunPerfTest<T, float4x4>(typeName + " transform_normal (float4x4)", [](T* value, float4x4 const& param)
{
*value = transform_normal(*value, param);
});
RunPerfTest<T, float4x4>(typeName + " transform4 (float4x4)", [](T* value, float4x4 const& param)
{
float4 t = transform4(*value, param);
value->x = t.x + t.y + t.z + t.w;
});
RunPerfTest<T, quaternion>(typeName + " transform4 (quaternion)", [](T* value, quaternion const& param)
{
float4 t = transform4(*value, param);
value->x = t.x + t.y + t.z + t.w;
});
}
开发者ID:ButchersBoy,项目名称:Win2D,代码行数:26,代码来源:CppNumericsPerfTest.cpp
示例5: color_diffused
t_double3 color_diffused(t_scene *scene, t_surface *surface, t_vector ray)
{
t_double3 color_hit;
t_light *light;
int light_nb;
double dot_light;
t_surface *light_intersect;
t_double3 reflected;
color_hit = (t_double3){0, 0, 0};
light = scene->light;
light_nb = 0;
while (light)
{
light_intersect = is_in_light(surface, scene, light, &dot_light);
if (light_intersect->object == NULL || light_intersect->distance > 0)
{
color_hit = v_plus_v(color_hit, color_mix(scale_v(light->color,
dot_light), surface->object->gloss,
// scale_v(surface->object->color, dot_light)));
scale_v(surface->color, dot_light)));
reflected = reflect(scale_v(normalize(v_minus_v(light->pos, surface->point)), -1), surface->normal);
color_hit = v_plus_v(color_hit, scale_v(light->color, pow(max_double(0, -dot_product(reflected, ray.dir) * surface->object->gloss), 2)));
}
free(light_intersect);
light_nb++;
light = light->next;
}
if (light_nb > 1)
color_hit = scale_v(color_hit, (1.0 / (double)light_nb));
return (color_hit);
}
开发者ID:aempisse,项目名称:42,代码行数:32,代码来源:raytracer.c
示例6: getPhong
color getPhong(
const normal& i_N, const vector& i_V, const float cosinePower,
const eiBool i_keyLightsOnly, const eiBool unshadowed)
{
color C = 0.0f;
vector R = reflect( normalize(i_V), normalize(i_N) );
LightSampler sampler(this, P, i_N, PI/2.0f );
float isKeyLight = 1;
//if( i_keyLightsOnly != 0 )
//{
// lightsource( "iskeylight", isKeyLight );
//}
if( isKeyLight != 0 )
{
const float nonspecular = 0.0f;
//lightsource( "__nonspecular", nonspecular );
if( nonspecular < 1 )
{
//SAMPLE_LIGHT_2(color, C, 0.0f,
// C += Cl()*pow(max<float>(0.0f,R%Ln),cosinePower)*(1.0f-nonspecular);
//);
while (sampler.sample())
{
vector Ln = normalize(L);
C += Cl*pow(max<float>(0.0f,R%Ln),cosinePower)*(1.0f-nonspecular);
}
}
}
return C;
}
开发者ID:maya2renderer,项目名称:maya2renderer,代码行数:33,代码来源:ei_maya_phong_architectural.cpp
示例7: d3dreflect
void D3DShaderObjectProvider::find_locations()
{
sampler_locations.clear();
texture_locations.clear();
uniform_buffer_locations.clear();
if (d3dcompiler_dll) // If the compiler is available, we must use it! This ensures compatility with the blob
{
ComPtr<ID3D11ShaderReflection> reflect;
HRESULT result = d3dreflect(bytecode.get_data(), bytecode.get_size(), IID_ID3D11ShaderReflection, (void**)reflect.output_variable());
D3DTarget::throw_if_failed("D3DReflect failed", result);
D3D11_SHADER_DESC desc;
result = reflect->GetDesc(&desc);
D3DTarget::throw_if_failed("D3DReflect.GetDesc failed", result);
for (UINT i = 0; i < desc.BoundResources; i++)
{
D3D11_SHADER_INPUT_BIND_DESC binding;
result = reflect->GetResourceBindingDesc(i, &binding);
D3DTarget::throw_if_failed("D3DReflect.GetResourceBindingDesc failed", result);
set_binding(binding);
}
}
else
{
DXBC_Reflect reflect(bytecode.get_data(), bytecode.get_size());
for (size_t cnt = 0; cnt < reflect.binding.size(); cnt++)
{
set_binding(reflect.binding[cnt]);
}
}
}
开发者ID:keigen-shu,项目名称:ClanLib,代码行数:35,代码来源:d3d_shader_object_provider.cpp
示例8: getPhong
color getPhong(
const normal& i_N, const vector& i_V, const float cosinePower,
const eiBool i_keyLightsOnly, const eiBool unshadowed)
{
color C = 0;
vector R = reflect( normalize(i_V), normalize(i_N) );
while( illuminance( P(), i_N, PI/2.0f ) )
{
float isKeyLight = 1;
//if( i_keyLightsOnly != 0 )
//{
// lightsource( "iskeylight", isKeyLight );
//}
if( isKeyLight != 0 )
{
const float nonspecular = 0.0f;
//lightsource( "__nonspecular", nonspecular );
if( nonspecular < 1 )
{
vector Ln = normalize(L());
SAMPLE_LIGHT_2(color, C, 0.0f,
C += Cl()*pow(max<float>(0.0f,R%Ln),cosinePower)*(1.0f-nonspecular);
);
}
}
开发者ID:matrixworld,项目名称:maya2renderer,代码行数:26,代码来源:ei_maya_phong.cpp
示例9: dot
Ray Ray::refract(const HitInfo& hit) const {
Vector3 n;
// indices of refraction
float n1 = 1.0f;
float n2 = 1.0f;
if (dot(hit.N, this->d) < 0) { // entering object
n2 = hit.material->getRefractionIndex();
n = hit.N;
}
else { // leaving object
n1 = hit.material->getRefractionIndex();
n = -hit.N;
}
// compute energy of refracted ray ( cos^2 (theta2) )
float cosTheta1 = dot(this->d, n); // NOTE: should this be n or hit.N?
float e = 1 - ((n1*n1) / (n2*n2)) * (1 - cosTheta1*cosTheta1);
// total internal reflection
if (e < 0.0f) return reflect(hit);
// create refraction ray
Vector3 dir = (n1 / n2) * (this->d - n * cosTheta1) - n * (sqrt(e));
Vector3 origin = hit.P + (dir * epsilon);
return Ray(origin, dir);
}
开发者ID:rayyada,项目名称:CSE168PA2,代码行数:29,代码来源:Ray.cpp
示例10: pdf
Float pdf(const BSDFSamplingRecord &bRec, EMeasure measure) const {
if (Frame::cosTheta(bRec.wi) <= 0 ||
Frame::cosTheta(bRec.wo) <= 0 || measure != ESolidAngle)
return 0.0f;
bool hasSpecular = (bRec.typeMask & EGlossyReflection)
&& (bRec.component == -1 || bRec.component == 0);
bool hasDiffuse = (bRec.typeMask & EDiffuseReflection)
&& (bRec.component == -1 || bRec.component == 1);
Float diffuseProb = 0.0f, specProb = 0.0f;
if (hasDiffuse)
diffuseProb = warp::squareToCosineHemispherePdf(bRec.wo);
if (hasSpecular) {
Float alpha = dot(bRec.wo, reflect(bRec.wi)),
exponent = m_exponent->eval(bRec.its).average();
if (alpha > 0)
specProb = std::pow(alpha, exponent) *
(exponent + 1.0f) / (2.0f * M_PI);
}
if (hasDiffuse && hasSpecular)
return m_specularSamplingWeight * specProb +
(1-m_specularSamplingWeight) * diffuseProb;
else if (hasDiffuse)
return diffuseProb;
else if (hasSpecular)
return specProb;
else
return 0.0f;
}
开发者ID:AdrianJohnston,项目名称:ShapeNetRender,代码行数:33,代码来源:phong.cpp
示例11: if
void Douille::update(float pDelay, Map * map)
{
CVector3f lastPos = position;
delay -= pDelay;
if (vel.length() > .5f)
{
position += vel * pDelay;
vel[2] -= 9.8f * pDelay;
CVector3f p1 = lastPos;
CVector3f p2 = position;
CVector3f normal;
if (map->rayTest(p1, p2, normal))
{
// On dit à tout le monde de jouer le son (pour l'instant juste server side)
if (!soundPlayed)
{
if (type == DOUILLE_TYPE_DOUILLE) dksPlay3DSound(gameVar.sfx_douille[rand()%3],-1,1,position,255);
else if (type == DOUILLE_TYPE_GIB)
{
scene->client->game->spawnBlood(position, .1f);
// delay = 0;
}
soundPlayed = true;
}
position = p2 + normal*.1f;
vel = reflect(vel, normal);
vel *= .3f;
}
}
}
开发者ID:Daivuk,项目名称:BaboViolent2,代码行数:30,代码来源:Game.cpp
示例12: menu
/* menu: return one of the possible transformation */
int menu(char (*sq)[MAXN + 1], char (*trans)[MAXN + 1], int n)
{
char mirror[MAXN][MAXN + 1];
if (de90(sq, trans, n))
return 1;
if (de180(sq, trans, n))
return 2;
if (de270(sq, trans, n))
return 3;
reflect(sq, mirror, n);
if (equal(mirror, trans, n))
return 4;
if (de90(mirror, trans, n) || de180(mirror, trans, n)
|| de270(mirror, trans, n))
return 5;
if (equal(sq, trans, n))
return 6;
return 7;
}
开发者ID:mythnc,项目名称:online-judge-solved-lists,代码行数:27,代码来源:transform.c
示例13: main
int main() {
srand(0); //seed generator with 0 for debugging
dungeon *game = generate_dungeon(10, 20);
tutorial(game);
for(;;) {
set_stage(game);
get_desc(game);
switch(input("", I_CHAR)) {
case 'q': goto END_GAME;
case 'n': move(game, D_NORTH); break;
case 's': move(game, D_SOUTH); break;
case 'e': move(game, D_EAST); break;
case 'w': move(game, D_WEST); break;
case 'i': action(game, A_INVENTORY); break;
case 'd': action(game, A_DROP); break;
case 'l': action(game, A_LOOT); break;
case 'p': action(game, A_PUTON); break;
case 'a': action(game, A_ARM); break;
case 'c': action(game, A_CONSUME); break;
case 'f': fight(game); break;
case 'h': help(); break;
case 'r': reflect(&(game->player)); break;
case 'z': dump_dungeon(game); break;
default: printf("Invalid Command!\n");
}
}
END_GAME:
return 0;
}
开发者ID:SomeCrazyGuy,项目名称:roguelike,代码行数:32,代码来源:pro.c
示例14: main
void main(void){
float dxtex = 1.0 / textureSizeX;
float dytex = 1.0 / textureSizeY;
vec2 st = gl_TexCoord[0].st;
// access center pixel and 4 surrounded pixel
vec3 center = getNormal(st).rgb;
vec3 left = getNormal(st + vec2(dxtex, 0.0)).rgb;
vec3 right = getNormal(st + vec2(-dxtex, 0.0)).rgb;
vec3 up = getNormal(st + vec2(0.0, -dytex)).rgb;
vec3 down = getNormal(st + vec2(0.0, dytex)).rgb;
// discrete Laplace operator
vec3 laplace = abs(-4.0*center + left + right + up + down);
// if one rgb-component of convolution result is over threshold => edge
vec4 line = texture2D(normalImage, st);
if(laplace.r > normalEdgeThreshold
|| laplace.g > normalEdgeThreshold
|| laplace.b > normalEdgeThreshold){
line = vec4(0.0, 0.0, 0.0, 1.0); // => color the pixel green
} else {
line = vec4(1.0, 1.0, 1.0, 1.0); // black
}
//end Line;
//start Phong
//vec3 lightPosition = vec3(100.0, 100.0, 50.0);
vec3 lightPosition = gl_LightSource[0].position.xyz;
vec3 L = normalize(lightPosition - v);
vec3 E = normalize(-v);
vec3 R = normalize(-reflect(L,N));
// ambient term
vec4 Iamb = ambient;
// diffuse term
vec4 Idiff = texture2D( normalImage, gl_TexCoord[0].st) * diffuse;
//vec4 Idiff = vec4(1.0, 1.0, 1.0, 1.0) * diffuse;
Idiff *= max(dot(N,L), 0.0);
Idiff = clamp(Idiff, 0.0, 1.0);
// specular term
vec4 Ispec = specular;
Ispec *= pow(max(dot(R,E),0.0), shinyness);
Ispec = clamp(Ispec, 0.0, 1.0);
vec4 color = Iamb + Idiff;
if ( bSpecular == 1 ) color += Ispec;
// store previous alpha value
float alpha = color.a;
// quantize process: multiply by factor, round and divde by factor
color = floor(0.5 + (qLevel * color)) / qLevel;
// set fragment/pixel color
color.a = alpha;
gl_FragColor = color * line;
}
开发者ID:0401morita,项目名称:ofxPostProcessing,代码行数:60,代码来源:ToonPass.cpp
示例15: renderPixelStandard
/* task that renders a single screen tile */
Vec3fa renderPixelStandard(float x, float y, const ISPCCamera& camera)
{
/* initialize ray */
RTCRay ray;
ray.org = Vec3fa(camera.xfm.p);
ray.dir = Vec3fa(normalize(x*camera.xfm.l.vx + y*camera.xfm.l.vy + camera.xfm.l.vz));
ray.tnear = 0.0f;
ray.tfar = inf;
ray.geomID = RTC_INVALID_GEOMETRY_ID;
ray.primID = RTC_INVALID_GEOMETRY_ID;
ray.mask = -1;
ray.time = 0;
/* intersect ray with scene */
rtcIntersect(g_scene,ray);
/* shade pixels */
Vec3fa color = Vec3fa(0.0f);
if (ray.geomID != RTC_INVALID_GEOMETRY_ID)
{
/* interpolate diffuse color */
Vec3fa diffuse = Vec3fa(1.0f,0.0f,0.0f);
if (ray.geomID > 0)
{
unsigned int geomID = ray.geomID; {
rtcInterpolate(g_scene,geomID,ray.primID,ray.u,ray.v,RTC_USER_VERTEX_BUFFER0,&diffuse.x,nullptr,nullptr,3);
}
diffuse = 0.5f*diffuse;
}
/* calculate smooth shading normal */
Vec3fa Ng = normalize(ray.Ng);
color = color + diffuse*0.5f;
Vec3fa lightDir = normalize(Vec3fa(-1,-1,-1));
/* initialize shadow ray */
RTCRay shadow;
shadow.org = ray.org + ray.tfar*ray.dir;
shadow.dir = neg(lightDir);
shadow.tnear = 0.001f;
shadow.tfar = inf;
shadow.geomID = 1;
shadow.primID = 0;
shadow.mask = -1;
shadow.time = 0;
/* trace shadow ray */
rtcOccluded(g_scene,shadow);
/* add light contribution */
if (shadow.geomID) {
Vec3fa r = normalize(reflect(ray.dir,Ng));
float s = pow(clamp(dot(r,lightDir),0.0f,1.0f),10.0f);
float d = clamp(-dot(lightDir,Ng),0.0f,1.0f);
color = color + diffuse*d + 0.5f*Vec3fa(s);
}
}
return color;
}
开发者ID:ElrosMorlin,项目名称:embree,代码行数:60,代码来源:curve_geometry_device.cpp
示例16: refract
float3 refract(float3 inDir, float3 normal) {
float ri = refractiveIndex;
float cosa = -normal.dot(inDir);
if(cosa < 0) { cosa = -cosa; normal = -normal; ri = 1 / ri; }
float disc = 1 - (1 - cosa * cosa) / ri / ri;
if(disc < 0) return reflect(inDir, normal);
return inDir * (1.0 / ri) + normal * (cosa / ri - sqrt(disc));
}
开发者ID:emeersman,项目名称:raytracing,代码行数:8,代码来源:main.cpp
示例17: reflect
Spectrum MirrorBSDF::sample_f(const Vector3D& wo, Vector3D* wi, float* pdf) {
// TODO Part 5:
// Implement MirrorBSDF
reflect(wo, wi);
*pdf = 1.0;
return reflectance * (1 / fabs(wi->z));
}
开发者ID:SsnL,项目名称:Fluid,代码行数:8,代码来源:bsdf.cpp
示例18: glPushMatrix
void PremadeMap::drawReflect(void) const
{
glPushMatrix();
flatTexture reflect(Bomberman::ModelHandler::get().getModel("loadmap_reflect"));
glTranslated(515, 203, 0);
reflect.draw();
glPopMatrix();
}
开发者ID:teamBICYCLE,项目名称:Bomberman,代码行数:8,代码来源:PremadeMap.cpp
示例19: reflect
Spectrum MirrorBSDF::sample_f(const Vector3D& wo, Vector3D* wi, float* pdf) {
// TODO:
// Implement MirrorBSDF
reflect(wo,wi);
*pdf = 1.f;
return this->reflectance * (1.f / fabs(wo.z));
}
开发者ID:hilllo,项目名称:15-662CG,代码行数:8,代码来源:bsdf.cpp
示例20: reflect
ostream & NeRegSuf::print(ostream &out)const{
reflect();
return out << "sumsqy = " << sumsqy << endl
<< "sumy_ = " << sumy_ << endl
<< "n_ = " << n_ << endl
<< "xty_ = " << xty_ << endl
<< "xtx = " << endl << xtx_;
}
开发者ID:MarkEdmondson1234,项目名称:Boom,代码行数:8,代码来源:RegressionModel.cpp
注:本文中的reflect函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论