本文整理汇总了C++中Color3函数的典型用法代码示例。如果您正苦于以下问题:C++ Color3函数的具体用法?C++ Color3怎么用?C++ Color3使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Color3函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
shared_ptr<Image3>& ImageStats::getImageMean(int ft, bool normalize){
if (normalize){
for (int c = 0 ; c < COLOR_CHS ; c++){
m_meanMin[ft][c] = std::numeric_limits<float>::max();
m_meanMax[ft][c] = std::numeric_limits<float>::min();
for (int x = 0 ; x < m_w ; x++){
for (int y = 0 ; y < m_h ; y++){
if ( m_dataMn[ft][c][x][y] < m_meanMin[ft][c]) m_meanMin[ft][c] = m_dataMn[ft][c][x][y];
if ( m_dataMn[ft][c][x][y] > m_meanMax[ft][c]) m_meanMax[ft][c] = m_dataMn[ft][c][x][y];
}
}
}
for (int x = 0 ; x < m_w ; x++)
for (int y = 0 ; y < m_h ; y++)
m_imageMean[ft]->fastSet(x,y,Color3((m_dataMn[ft][RED][x][y] - m_meanMin[ft][RED])/(m_meanMax[ft][RED] - m_meanMin[ft][RED]),
(m_dataMn[ft][GREEN][x][y] - m_meanMin[ft][GREEN])/(m_meanMax[ft][GREEN] - m_meanMin[ft][GREEN]),
(m_dataMn[ft][BLUE][x][y] - m_meanMin[ft][BLUE])/(m_meanMax[ft][BLUE] - m_meanMin[ft][BLUE])));
}
else{
for (int x = 0 ; x < m_w ; x++)
for (int y = 0 ; y < m_h ; y++)
m_imageMean[ft]->fastSet(x,y,Color3(m_dataMn[ft][RED][x][y],m_dataMn[ft][GREEN][x][y],m_dataMn[ft][BLUE][x][y]));
}
return m_imageMean[ft];
}
示例2: switch
Exporter::Result Exporter::exportLight(NiNodeRef parent, INode *node, GenLight* light)
{
TimeValue t = 0;
NiLightRef niLight;
switch (light->Type())
{
case OMNI_LIGHT:
{
if (light->GetAmbientOnly())
{
niLight = new NiAmbientLight();
}
else
{
NiPointLightRef pointLight = new NiPointLight();
float atten = light->GetAtten(t, ATTEN_START);
switch (light->GetDecayType())
{
case 0: pointLight->SetConstantAttenuation(1.0f); break;
case 1: pointLight->SetLinearAttenuation( atten / 4.0f ); break;
case 2: pointLight->SetQuadraticAttenuation( sqrt(atten / 4.0f) ); break;
}
niLight = StaticCast<NiLight>(pointLight);
}
}
break;
case TSPOT_LIGHT:
case FSPOT_LIGHT:
niLight = new NiSpotLight();
break;
case DIR_LIGHT:
case TDIR_LIGHT:
niLight = new NiDirectionalLight();
break;
}
if (niLight == NULL)
return Skip;
niLight->SetName(node->GetName());
Matrix3 tm = getObjectTransform(node, t, !mFlattenHierarchy);
niLight->SetLocalTransform( TOMATRIX4(tm, false) );
niLight->SetDimmer( light->GetIntensity(0) );
Color3 rgbcolor = TOCOLOR3( light->GetRGBColor(0) );
if (light->GetAmbientOnly())
{
niLight->SetDiffuseColor(Color3(0,0,0));
niLight->SetSpecularColor(Color3(0,0,0));
niLight->SetAmbientColor(rgbcolor);
}
else
{
niLight->SetDiffuseColor(rgbcolor);
niLight->SetSpecularColor(rgbcolor);
niLight->SetAmbientColor(Color3(0,0,0));
}
parent->AddChild( DynamicCast<NiAVObject>(niLight) );
return Ok;
}
示例3: Color3
void Triangle::getMaterialProperties(MaterialProp& mp, const real_t mult[3],const Vector2& texCoord, const Material* materials[3])
{
mp.diffuse = Color3(0,0,0);
mp.ambient = Color3(0,0,0);
mp.specular= Color3(0,0,0);
mp.refractive_index= 0;
mp.texColor = Color3(0,0,0);
for ( int i = 0; i < 3; ++i )
{
if(materials[i])
{
mp.diffuse += materials[i]->diffuse*mult[i];
mp.ambient += materials[i]->ambient*mult[i];
mp.specular += materials[i]->specular*mult[i];
mp.refractive_index += materials[i]->refractive_index*mult[i];
if(materials[i]->get_texture_data())
{
int width,height;
materials[i]->get_texture_size(&width, &height );
mp.texColor += mult[i]*materials[i]->get_texture_pixel( texCoord[0]*width, texCoord[1]*height);
}
else
mp.texColor+=Color3(1,1,1)*mult[i];
}
}
}
示例4: evalFourier3
Color3 evalFourier3(float * const coeffs[3], size_t nCoeffs, Float phi) {
#if FOURIER_SCALAR == 1
double cosPhi = std::cos((double) phi),
cosPhi_prev = cosPhi,
cosPhi_cur = 1.0f;
double Y = 0, R = 0, B = 0;
for (size_t i=0; i<nCoeffs; ++i) {
Y += coeffs[0][i] * cosPhi_cur;
R += coeffs[1][i] * cosPhi_cur;
B += coeffs[2][i] * cosPhi_cur;
double cosPhi_next = 2*cosPhi*cosPhi_cur - cosPhi_prev;
cosPhi_prev = cosPhi_cur; cosPhi_cur = cosPhi_next;
}
double G = 1.39829f*Y -0.100913f*B - 0.297375f*R;
return Color3((Float) R, (Float) G, (Float) B);
#else
double cosPhi = std::cos((double) phi);
__m256d
cosPhi_prev = _mm256_set1_pd(cosPhi),
cosPhi_cur = _mm256_set1_pd(1.0),
Y = _mm256_set_sd((double) coeffs[0][0]),
R = _mm256_set_sd((double) coeffs[1][0]),
B = _mm256_set_sd((double) coeffs[2][0]),
factorPhi_prev, factorPhi_cur;
initializeRecurrence(cosPhi, factorPhi_prev, factorPhi_cur);
for (size_t i=1; i<nCoeffs; i+=4) {
__m256d cosPhi_next = _mm256_add_pd(_mm256_mul_pd(factorPhi_prev, cosPhi_prev),
_mm256_mul_pd(factorPhi_cur, cosPhi_cur));
Y = _mm256_add_pd(Y, _mm256_mul_pd(cosPhi_next, _mm256_cvtps_pd(_mm_load_ps(coeffs[0]+i))));
R = _mm256_add_pd(R, _mm256_mul_pd(cosPhi_next, _mm256_cvtps_pd(_mm_load_ps(coeffs[1]+i))));
B = _mm256_add_pd(B, _mm256_mul_pd(cosPhi_next, _mm256_cvtps_pd(_mm_load_ps(coeffs[2]+i))));
cosPhi_prev = _mm256_splat2_pd(cosPhi_next);
cosPhi_cur = _mm256_splat3_pd(cosPhi_next);
}
MM_ALIGN32 struct {
double Y;
double R;
double B;
double unused;
} tmp;
simd::hadd(Y, R, B, _mm256_setzero_pd(), (double *) &tmp);
double G = 1.39829*tmp.Y -0.100913*tmp.B - 0.297375*tmp.R;
return Color3((Float) tmp.R, (Float) G, (Float) tmp.B);
#endif
}
示例5: Color3
Material::Material(){
ambient = Color3(0,0,0);
diffuse = Color3(0,0,0);
specular = Color3(0,0,0);
shininess = 1;
reflect = Color3(0,0,0);
refract = Color3(0,0,0);
refract_index = 1;
}
示例6: SpriteSheet
shared_ptr<SpriteSheet> SpriteSheet::create(const Any& a, Table<ModelID, shared_ptr<Model> >& modelTable) {
a.verifyName("SpriteSheet");
const shared_ptr<SpriteSheet>& s = shared_ptr<SpriteSheet>(new SpriteSheet());
s->m_source = a.source();
AnyTableReader r(a);
// Read the textures
Texture::Specification spec;
if (r.getIfPresent("emissive", spec)) {
spec.generateMipMaps = false;
spec.encoding.format = ImageFormat::RGBA_DXT5();
s->m_emissive = Texture::create(spec);
} else {
s->m_emissive = Texture::opaqueBlack();
}
if (r.getIfPresent("color", spec)) {
spec.generateMipMaps = false;
spec.encoding.format = ImageFormat::RGBA_DXT5();
s->m_color = Texture::create(spec);
} else {
s->m_color = Texture::createColor(Color4unorm8(Color4::zero()));
}
String bumpFilename;
spec = Texture::Specification("<white>");
if (r.getFilenameIfPresent("bump", bumpFilename)) {
spec.filename = bumpFilename;
}
spec.generateMipMaps = false;
spec.preprocess = Texture::Preprocess::normalMap();
spec.encoding.format = ImageFormat::RGBA8();
spec.encoding.readMultiplyFirst = Color3(2.0f);
spec.encoding.readAddSecond = Color3(-1.0f);
s->m_normal = Texture::create(spec);
// Read the animation table
Table<String, Any> tbl;
r.getIfPresent("modelTable", tbl);
for (Table<String, Any>::Iterator it = tbl.begin(); it.hasMore(); ++it) {
if (modelTable.containsKey(it.key())) {
String msg = format("Two models with the same name, '%s': ", it.key().c_str());
msg += format("the first %s:%d and ", modelTable[it.key()]->source().filename.c_str(), modelTable[it.key()]->source().line);
msg += format("and the second from %s:%d.", it.value().source().filename.c_str(), it.value().source().line);
report(msg, ReportLevel::ERROR);
} else {
modelTable.set(it.key(), Model::create(s, it.key(), it.value()));
}
}
r.verifyDone();
return s;
}
示例7: Color3
/*
* Trace a ray, calculating the color of this ray.
* This function is called recursively for recursive light.
*
* @param scene The scene object, which contains all geometries information.
* @param recursion The level of recursive light. If the level is larger or
* equal to 4, stop recursion.
* @param ray_dir Direction vector of ray.
* @param ray_pos Start point of ray.
* @param tMin Minimum legal time cost for this ray.
* @param tMax Maximum legal time cost for this ray.
*
* @return The color of this ray.
*/
Color3 Raytracer::trace_ray(Scene const*scene, // geometries
const int recursion, // recursion level
const Vector3 &ray_dir, const Vector3 &ray_pos, // ray
const float tMin, const float tMax // ray range
)
{
// if this function go beyond the last recursive level, stop and return black color.
if (recursion <= 0)
return Color3(0, 0, 0);
// intersection point information
HitVertexInfor hit_vertex;
// if not hit any geometry, return background color
bool bHit = ray_hit(scene, ray_dir, ray_pos, tMin, tMax, hit_vertex);
if (!bHit)
return scene->background_color;
// if hit, compute color and return it
Color3 DI_light (0, 0, 0);
Color3 reflected_light(0, 0, 0);
Color3 refracted_light(0, 0, 0);
// 1. direct illumination
if (hit_vertex.refractive_index == 0)
DI_light = calculate_DI_light(scene, hit_vertex);
// 2. reflection light
if (hit_vertex.specular != Color3(0, 0, 0)) // avoid non-necessary reflection calculation
{
// reflection ray direction
Vector3 rfl_ray_dir = normalize(
ray_dir - 2 * dot(ray_dir, hit_vertex.normal) * hit_vertex.normal);
reflected_light = hit_vertex.specular * hit_vertex.tex_color *
trace_ray(scene, recursion-1, rfl_ray_dir, hit_vertex.position,
SLOPE_FACTOR, 1000000);
}
if (hit_vertex.refractive_index == 0) // avoid non-necessary refraction calculation
return DI_light + reflected_light;
// 3. refraction light
Vector3 rfr_ray_dir; // refractive ray direction
float R;
if (refraction_happened(scene, ray_dir, hit_vertex, rfr_ray_dir, R))
refracted_light = hit_vertex.tex_color *
trace_ray(scene, recursion-1, rfr_ray_dir, hit_vertex.position,
SLOPE_FACTOR, 1000000);
return DI_light + R * reflected_light + (1-R) * refracted_light;
}
示例8: Color3
namespace aed {
const Color3 Color3::Black = Color3( 0.0, 0.0, 0.0 );
const Color3 Color3::White = Color3( 1.0, 1.0, 1.0 );
const Color3 Color3::Red = Color3( 1.0, 0.0, 0.0 );
const Color3 Color3::Green = Color3( 0.0, 1.0, 0.0 );
const Color3 Color3::Blue = Color3( 0.0, 0.0, 1.0 );
Color3::Color3( const unsigned char* arr )
{
static const real_t inv = 1.0 / 255.0;
r = arr[0] * inv;
g = arr[1] * inv;
b = arr[2] * inv;
}
void Color3::to_array( unsigned char arr[4] ) const
{
// clamp values
Color3 tmp = clamp( *this, 0.0, 1.0 );
// convert to ints
arr[0] = static_cast<unsigned char>( tmp.r * 0xff );
arr[1] = static_cast<unsigned char>( tmp.g * 0xff );
arr[2] = static_cast<unsigned char>( tmp.b * 0xff );
arr[3] = 0xff;
}
void Color3::to_array( float arr[DIM] ) const
{
arr[0] = float( r );
arr[1] = float( g );
arr[2] = float( b );
}
Color3 clamp( const Color3& c, real_t min, real_t max )
{
return Color3(
clamp( c.r, min, max ),
clamp( c.g, min, max ),
clamp( c.b, min, max )
);
}
std::ostream& operator<<( std::ostream& os, const Color3& c )
{
return os << '(' << c.r << ',' << c.g << ',' << c.b << ')';
}
} /* aed */
示例9: DrawBox
void GraphicsLinux::DrawBox(const Color4 &cColor, const Vector2i &vPos1, const Vector2i &vPos2, uint32 nRoundX, uint32 nRoundY)
{
// Check if native window handle is valid
if (m_nNativeWindowHandle) {
// Set graphics options
::XGCValues sGCValues;
sGCValues.function = GXcopy;
sGCValues.foreground = ToolsLinux::GetXColor(Color3(cColor), m_nColorDepth);
sGCValues.background = ToolsLinux::GetXColor(Color3(cColor), m_nColorDepth);
XChangeGC(m_pDisplay, m_sGC, GCFunction | GCForeground | GCBackground, &sGCValues);
// Draw box
XFillRectangle(m_pDisplay, m_nNativeWindowHandle, m_sGC, vPos1.x, vPos1.y, vPos2.x-vPos1.x+1, vPos2.y-vPos1.y+1);
}
}
示例10: calcPhongLighting
Color3 LightShadeModel::calcColor(
Vector3D pos, Vector3D dir, Vector3D n, Color3 color,
LightSource *ls, Model *m, UINT face_id,
UINT colorMask){
if (lightModel == PhongLighting){
Vector3D l = ls->pos - pos;
l.normalize();
return calcPhongLighting(n, Vector3D(0,0,0) - dir, l, color,
ls->color, &(m->material), colorMask);
} else {
return Color3(0,0,0);
}
return Color3(0,0,0);
}
示例11: finalGathering
static Color3 finalGathering(KdTree<Photon> *map , Scene& scene ,
Intersection& inter , RNG& rng , const Vector3& wo ,
int gatherSamples , int knn , Real maxSqrDis)
{
Color3 res = Color3(0.0 , 0.0 , 0.0);
for (int i = 0; i < gatherSamples; i++)
{
Real pdf;
Vector3 wi = sampleCosHemisphere(rng.randVector3() , &pdf);
Ray ray = Ray(inter.p + wi * EPS , wi);
Intersection _inter;
Geometry *_g = scene.intersect(ray , _inter);
if (_g == NULL)
continue;
Color3 tmp = estimate(map , 0 , knn , scene , _inter , -wi , maxSqrDis);
BSDF bsdf(wi , _inter , scene);
Real cosine , bsdfPdf;
Color3 brdf = bsdf.f(scene , wo , cosine , &bsdfPdf);
if (brdf.isBlack())
continue;
pdf *= bsdfPdf;
res = res + (tmp | brdf) * (cosine / pdf);
}
res = res / gatherSamples;
return res;
}
示例12: window
void App::main() {
window()->setCaption("Q3 Renderer");
setDebugMode(true);
debugController.setActive(true);
dumpPolygons = false;
clipMovement = true;
sky = Sky::create(renderDevice, dataDir + "sky/");
debugCamera.setNearPlaneZ(-0.5f);
debugCamera.setFarPlaneZ(-100);//(float)-inf());
debugController.init(renderDevice, userInput);
debugController.setMoveRate(500 * BSPMAP::LOAD_SCALE);
debugController.setActive(true);
renderDevice->setColorClearValue(Color3(0.1f, 0.5f, 1.0f));
// Load the map
map = new BSPMAP::Map();
bool ret = map->load("D:/games/dojo/scratch/data-files/q3/", "ut_ricochet.bsp");
// bool ret = map->load("D:/media/models/q3/maps/urbanterror/", "ut_ricochet.bsp");
debugAssert(ret); (void)ret;
debugController.setPosition(map->getStartingPosition());
debugController.lookAt(map->getStartingPosition() - Vector3::unitZ());
debugCamera.setCoordinateFrame(debugController.getCoordinateFrame());
applet->run();
}
示例13: tmp
void RayTracer::traceOnePixel(int x, int y, int threadID) {
//used for constructing viewport
Vector2 tmp(m_settings.width, m_settings.height);
Ray primaryRay;
// If one ray per pixel: (kinda debugging mode with blue color for places with no surfel hit
if (m_settings.raysPerPixel == 1){
//Get the primary ray from the pixel x,y
primaryRay = m_camera->worldRay(x + 0.5f, y + 0.5f, Rect2D(tmp));
//Get the first surfel hit.
//Can't call L_i unfortunately because we want the blue background for debugging
const shared_ptr<Surfel>& s = RayTracer::castRay(primaryRay, finf(), 0);
//If there is a surfel hit, get the direct illumination value and apply to the pixel
if (s){
//Call L_scatteredDirect to get direct illumination. Invert primaryRay to get the direction for incident light
m_image->set(Point2int32(x,y), L_o(s, -primaryRay.direction(), m_settings.recursiveBounces, *(m_rnd[threadID])));
} else{
//Set the pixels with no surfel hit. Include this line so we could make it a specific color for debug purposes.
m_image->set(Point2int32(x,y), Color3(0,0,1));
}
} else {
Radiance3 L(0,0,0);
//If more than one ray, randomly generate required number of rays within the pixel
for (int i = 0; i < m_settings.raysPerPixel; ++i){
primaryRay = m_camera->worldRay(x + m_rnd[threadID]->uniform(), y + m_rnd[threadID]->uniform(), Rect2D(tmp));
L += L_i(primaryRay.origin(), primaryRay.direction(), m_settings.recursiveBounces, *(m_rnd[threadID]));
}
m_image->set(Point2int32(x,y), L/m_settings.raysPerPixel);
}
}
示例14: lighting
void Demo::onGraphics(RenderDevice* rd) {
LightingParameters lighting(G3D::toSeconds(11, 00, 00, AM));
rd->setProjectionAndCameraMatrix(app->debugCamera);
// Cyan background
rd->setColorClearValue(Color3(0.1f, 0.5f, 1.0f));
rd->clear(app->sky.isNull(), true, true);
if (app->sky.notNull()) {
app->sky->render(rd, lighting);
}
// Setup lighting
rd->enableLighting();
rd->setLight(0, GLight::directional(lighting.lightDirection, lighting.lightColor));
rd->setAmbientLightColor(lighting.ambient);
Draw::axes(CoordinateFrame(Vector3(0, 4, 0)), rd);
rd->disableLighting();
if (app->sky.notNull()) {
app->sky->renderLensFlare(rd, lighting);
}
}
示例15: scene
void App::configureShaderArgs(Args& args) {
const shared_ptr<Light>& light = scene()->lightingEnvironment().lightArray[0];
const Color3& lambertianColor = colorList[lambertianColorIndex].element(0).color(Color3::white()).rgb();
const Color3& glossyColor = colorList[glossyColorIndex].element(0).color(Color3::white()).rgb();
// Viewer
args.setUniform("wsEyePosition", m_debugCamera->frame().translation);
// Lighting
args.setUniform("wsLight", light->position().xyz().direction());
args.setUniform("lightColor", light->color);
args.setUniform("ambient", Color3(0.3f));
args.setUniform("environmentMap", scene()->lightingEnvironment().environmentMapArray[0], Sampler::cubeMap());
// Material
args.setUniform("lambertianColor", lambertianColor);
args.setUniform("lambertianScalar", lambertianScalar);
args.setUniform("glossyColor", glossyColor);
args.setUniform("glossyScalar", glossyScalar);
args.setUniform("smoothness", smoothness);
args.setUniform("reflectScalar", reflect);
}