本文整理汇总了C++中PointLight::SetPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ PointLight::SetPosition方法的具体用法?C++ PointLight::SetPosition怎么用?C++ PointLight::SetPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointLight
的用法示例。
在下文中一共展示了PointLight::SetPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: project1
void project1() {
// Create scene
Scene scn;
scn.SetSkyColor(Color(0.8f, 0.9f, 1.0f));
// Create boxes
LambertMaterial lambert1;
lambert1.SetDiffuseColor(Color(0.3f,0.3f,0.3f));
MeshObject box1;
box1.MakeBox(5.0f,0.1f,5.0f, &lambert1);
scn.AddObject(box1);
LambertMaterial lambert2;
lambert2.SetDiffuseColor(Color(0.7f,0.7f,0.7f));
MeshObject box2;
box2.MakeBox(1.0f,1.0f,1.0f, &lambert2);
InstanceObject inst1(box2);
Matrix34 mtx;
mtx.MakeRotateX(0.5f);
mtx.d.y=1.0f;
inst1.SetMatrix(mtx);
scn.AddObject(inst1);
InstanceObject inst2(box2);
mtx.MakeRotateY(1.0f);
mtx.d.Set(-1.0f,0.0f,1.0f);
inst2.SetMatrix(mtx);
scn.AddObject(inst2);
// Create lights
DirectLight sunlgt;
sunlgt.SetBaseColor(Color(1.0f, 1.0f, 0.9f));
sunlgt.SetIntensity(0.5f);
sunlgt.SetDirection(Vector3(-0.5f, -1.0f, -0.5f));
scn.AddLight(sunlgt);
PointLight redlgt;
redlgt.SetBaseColor(Color(1.0f, 0.2f, 0.2f));
redlgt.SetIntensity(2.0f);
redlgt.SetPosition(Vector3(2.0f, 2.0f, 0.0f));
scn.AddLight(redlgt);
// Create camera
Camera cam;
cam.LookAt(Vector3(2.0f,2.0f,5.0f), Vector3(0.0f,0.0f,0.0f));
cam.SetResolution(800,600);
cam.SetFOV(40.0f);
cam.SetAspect(1.33f);
// Render image
cam.Render(scn);
cam.SaveBitmap("project1.bmp");
}
示例2: setTorchLight
void setTorchLight(float x, float y, float z, float radius) {
//PLight
PointLight p;
p.SetColor(fireLightColor[0], fireLightColor[1], fireLightColor[2]);
p.SetPosition(x, y, z);
p.SetAttenuation(0.01, 0.1, 0.1);
//p.SetAttenuation(1.0, 0.05, 0.0);
p.SetRadius(radius);
p.SetGrain(10);
plights.push_back(p);
}
示例3: OnAddPointLight_Click
void MainForm::OnAddPointLight_Click(wxMouseEvent & evt)
{
PointLightPtr ptr = scene->AddPointLight();
PointLight * p = ptr.Get();
p->SetPosition(0.0f, 0.0f, 0.0f);
p->SetDiffuse(1.0f,1.0f,1.0f,1.0f);
p->SetRange(100.0f);
EditorPointLight * pl = new EditorPointLight(ptr);
EditorSceneObjectsManager::GetPtr()->AddElement(pl);
ActiveTool::Set(new SelectTool());
}
示例4: LoadLight
void LoadLight(TiXmlElement *element)
{
Light *light = NULL;
// name
const char* name = element->Attribute("name");
printf("Light [");
if ( name ) printf("%s",name);
printf("]");
// type
const char* type = element->Attribute("type");
if ( type ) {
if ( COMPARE(type,"ambient") ) {
printf(" - Ambient\n");
AmbientLight *l = new AmbientLight();
light = l;
for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
if ( COMPARE( child->Value(), "intensity" ) ) {
Color c(1,1,1);
ReadColor( child, c );
l->SetIntensity(c);
printf(" intensity %f %f %f\n",c.r,c.g,c.b);
}
}
} else if ( COMPARE(type,"direct") ) {
printf(" - Direct\n");
DirectLight *l = new DirectLight();
light = l;
for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
if ( COMPARE( child->Value(), "intensity" ) ) {
Color c(1,1,1);
ReadColor( child, c );
l->SetIntensity(c);
printf(" intensity %f %f %f\n",c.r,c.g,c.b);
} else if ( COMPARE( child->Value(), "direction" ) ) {
Point3 v(1,1,1);
ReadVector( child, v );
l->SetDirection(v);
printf(" direction %f %f %f\n",v.x,v.y,v.z);
}
}
} else if ( COMPARE(type,"point") ) {
printf(" - Point\n");
PointLight *l = new PointLight();
light = l;
for ( TiXmlElement *child = element->FirstChildElement(); child!=NULL; child = child->NextSiblingElement() ) {
if ( COMPARE( child->Value(), "intensity" ) ) {
Color c(1,1,1);
ReadColor( child, c );
l->SetIntensity(c);
printf(" intensity %f %f %f\n",c.r,c.g,c.b);
} else if ( COMPARE( child->Value(), "position" ) ) {
Point3 v(0,0,0);
ReadVector( child, v );
l->SetPosition(v);
printf(" position %f %f %f\n",v.x,v.y,v.z);
}
}
} else {
printf(" - UNKNOWN\n");
}
}
if ( light ) {
light->SetName(name);
lights.push_back(light);
}
}
示例5: window
World::World(sf::RenderWindow& inWindow)
: window(inWindow), gbuffer(WINDOW_WIDTH, WINDOW_HEIGHT), hdrDownsampleTexture(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, true), hdrBlurTexture(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2, true), hdrDownsample2Texture(WINDOW_WIDTH / 4, WINDOW_HEIGHT / 4, true), hdrBlur2Texture(WINDOW_WIDTH / 4, WINDOW_HEIGHT / 4, true), fullscreenQuad(0, 0, WINDOW_WIDTH, WINDOW_HEIGHT), aaTexture(WINDOW_WIDTH, WINDOW_HEIGHT)
{
// OpenGL State
glBlendEquation(GL_FUNC_ADD);
glBlendFunc(GL_ONE, GL_ONE);
glStencilOpSeparate(GL_BACK, GL_KEEP, GL_INCR_WRAP, GL_KEEP);
glStencilOpSeparate(GL_FRONT, GL_KEEP, GL_DECR_WRAP, GL_KEEP);
// Seed the PRNG.
srand(static_cast<unsigned int>(time(0)));
// Load light meshes.
pointLightMesh.LoadFromFile("Models/pointlightMesh.obj");
spotLightMesh.LoadFromFile("Models/spotlightMesh.obj");
directionalLightMesh.LoadFromFile("Models/directionalMesh.obj");
// Lighting Shaders.
pointLightShader.LoadFromFile("Shaders/lightShader.vert", "Shaders/pointlightShader.frag");
spotLightShader.LoadFromFile("Shaders/lightShader.vert", "Shaders/spotlightShader.frag");
directionalLightShader.LoadFromFile("Shaders/lightShader.vert", "Shaders/directionalShader.frag");
// HDR Shaders.
hdrDownsample.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrDownsample.frag");
hdrTonemap.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrTonemap.frag");
hdrBlur.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrBlur.frag");
hdrBrightness.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrBrightness.frag");
// Load Models.
mdl2.LoadFromFile("Models/sphere.obj");
mdl.LoadFromFile("Models/floor.obj");
mdl3.LoadFromFile("Models/sphere.obj");
quadMesh.LoadFromFile("Models/quad.obj");
// Load Shaders
basicShader.LoadFromFile("Shaders/basic.vert", "Shaders/basic.frag");
pass1Shader.LoadFromFile("Shaders/drpass1.vert", "Shaders/drpass1.frag");
pass2Shader.LoadFromFile("Shaders/drpass2.vert", "Shaders/drpass2.frag");
pass2ShaderDirectional.LoadFromFile("Shaders/empty.vert", "Shaders/drpass2directional.frag");
quadShader.LoadFromFile("Shaders/fsquad.vert", "Shaders/hdrTonemap.frag");
terrainShader.LoadFromFile("Shaders/terrainshader.vert", "Shaders/terrainshader.frag");
flatShader.LoadFromFile("Shaders/basic.vert", "Shaders/flatshade.frag");
emptyShader.LoadFromFile("Shaders/empty.vert", "Shaders/empty.frag");
sphereShader.LoadFromFile("Shaders/sphere.vert", "Shaders/sphere.frag");
// Anti-Aliasing Shaders
#if USE_FXAA == 1
fxaaShader.LoadFromFile("Shaders/fxaa.vert", "Shaders/fxaa.frag");
#endif
baseAAShader.LoadFromFile("Shaders/baseaa.vert", "Shaders/baseaa.frag");
// Load textures.
mdlTex.loadFromFile("Textures/test.png");
terrainTexture.loadFromFile("Textures/terraintex.png");
terrainWater.loadFromFile("Textures/terrainwater.png");
// Main world directional light.
DirectionalLight worldLight;
worldLight.SetDirection(Vector3(-1.0f, 0.0f, 0.0f));
worldLight.SetColor(Color(0.8f, 0.8f, 0.8f));
worldLight.SetDiffuseIntensity(0.9f);
worldLight.SetAmbientIntensity(0.4f);
directionalLights.push_back(worldLight);
// Lights
const unsigned int numLights = 40;
const float lightRadius = 2.0f;
PointLight l;
l.SetPosition(Vector3(10.0f, 2.0f, 10.0f));
l.SetScale(Vector3(3.0f, 3.0f, 3.0f));
l.SetColor(Color(0.0f, 0.0f, 1.4f, 1.0f));
l.SetAttenuationConstant(0.4f);
l.SetDiffuseIntensity(0.4f);
l.SetAmbientIntensity(0.2f);
pointLights.push_back(l);
const int maxXZ = 15;
const int minXZ = -15;
const int maxY = 5;
const float minRad = 0.3f;
const float maxRad = 2.0f;
for (int i = 0; i < numLights; i++)
{
PointLight l;
// Generate position.
int x = (rand() % (maxXZ - minXZ)) + minXZ;
int y = (rand() % maxY);
int z = (rand() % (maxXZ - minXZ)) + minXZ;
l.SetPosition(Vector3(x, y, z));
// Generate Scale
float frand = ((float)rand() / (float)RAND_MAX);
float fdiff = maxRad - minRad;
//l.SetScale(Vector3(scale, scale, scale));
// Generate Color
float r = float_rand(0.0f, maxCol);
float g = float_rand(0.0f, maxCol);
//.........这里部分代码省略.........
示例6: Init
void Dragon_Dogs_ParticleSystem::Init(Scene * scene)
{
StaticEntityPtr skyPtr = scene->AddStaticEntity("assets/sphere.smodel", "sky");
StaticEntity * sky = skyPtr.Get();
sky->Illuminate(false);
sky->SetScale(10000, 10000, 10000);
Material * m = sky->GetMaterial(0);
m->SetDiffuseMap("assets/risinger.jpg");
m->UseDiffuseMap(true);
psPtr = scene->AddParticleSystem();
ParticleSystem * ps = psPtr.Get();
ps->SetColorTexture("assets/fire.png");
ps->SetEmmiterPosition(Vector3(45.0f, 0.0f, 0.0f));
ps->SetMinSpawnPosition(Vector3(-1.0f, 0.0f, 0.0f));
ps->SetMaxSpawnPosition(Vector3(1.0f, 0.0f, 0.0f));
ps->SetMaxLifeTime(70);
ps->SetMinLifeTime(50);
ps->SetMaxParticles(70);
ps->SetSpawnTime(4.0);
ps->SetMinSize(10);
ps->SetMaxSize(14);
////entitiy->SetPosition(10.0f,0.0f,0.0f);
drPtr = scene->AddParticleSystem();
ps = drPtr.Get();
ps->SetColorTexture("assets/fire.png");
ps->SetEmmiterPosition(Vector3(-30.0f, 150.0, 10.0f));
ps->SetMinSpawnPosition(Vector3(-0.2f, 0.3f, 0.0f));
ps->SetMaxSpawnPosition(Vector3(0.2f, -0.3f, 0.0f));
ps->SetMinSpawnVelocity(Vector3(-1.0f, -2.0f, -1.8f));
ps->SetMaxSpawnVelocity(Vector3(1.0f, -2.0f, -1.0f));
ps->SetMaxLifeTime(30);
ps->SetMinLifeTime(45);
ps->SetMaxParticles(70);
ps->SetSpawnTime(4.0);
ps->SetMinSize(10);
ps->SetMaxSize(14);
ps->AllowParticleAdd(false);
plDragon = scene->AddPointLight();
PointLight * plD = plDragon.Get();
plD->SetDiffuse(1.0f, 0.4f, 0.0f, 1.0f);
plD->SetRange(1.0f);
plD->SetPosition(-30.0f, 150.0, 10.0f);
dragonTime = 0;
dragonOn = false;
enPtr = scene->AddAnimatedEntity("assets/ninja.model", "ninja");
AnimatedEntity * en = enPtr.Get();
en->SetPosition(0.0f, 0.0f, 0.0f);
en->Illuminate(true);
en->SetScale(10.0f, 10.0f, 10.0f);
en->SetPosZ(-100);
//en->SetRotationY(90.0f);
Material * mat = en->GetMaterial(0);
mat->UseDiffuseMap(true);
mat->SetDiffuseColor(Color::White());
mat->SetDiffuseMap("assets/nskin.jpg");
mat->SetEmmisivePower(1);
mat->SetSpecularPower(0);
mat->SetSpecularIntesity(0);
mat = en->GetMaterial(1);
mat->UseDiffuseMap(false);
mat->SetEmmisivePower(1);
mat->SetSpecularIntesity(0);
mat->SetSpecularPower(0);
mat->SetDiffuseColor(Color(0.3f, 0.3f, 0.3f, 1.0f));
pointLight = scene->AddPointLight();
PointLight * p = pointLight.Get();
p->SetDiffuse(1.0f, 0.4f, 0.0f, 1.0f);
p->SetRange(500.0f);
p->SetPosition(45.0f, 4.0f, 0.0f);
planePtr = scene->AddStaticEntity("assets/plane.model", "plane");
StaticEntity * plane = planePtr.Get();
plane->Illuminate(true);
plane->SetScale(500.0f, 1.0f, 500.0f);
Material * pMat = plane->GetMaterial(0);
pMat->UseDiffuseMap(false);
pMat->SetDiffuseColor(Color(0.3f, 0.3f, 0.3f, 1.0f));
pMat->SetEmmisivePower(1);
pMat->SetSpecularPower(0);
pMat->SetSpecularIntesity(0);
plane->SetPosition(0.0f, -7.0f, 0.0f);
dogPtr = scene->AddStaticEntity("assets/dog.smodel", "dog");
StaticEntity * dog = dogPtr.Get();
//.........这里部分代码省略.........
示例7: project2
void project2() {
// Create scene
Scene scn;
scn.SetSkyColor(Color(0.8f, 0.8f, 1.0f));
// Create ground
MeshObject ground;
ground.MakeBox(5.0f,0.1f,5.0f);
scn.AddObject(ground);
// Create dragon
MeshObject dragon;
dragon.LoadPLY("dragon.ply");
dragon.Smooth();
std::chrono::time_point<std::chrono::system_clock> start, end;
start = std::chrono::system_clock::now();
std::cout << "Constructing the tree ..." << std::endl;
BoxTreeObject tree;
tree.Construct(dragon);
scn.AddObject(tree);
end = std::chrono::system_clock::now();
std::chrono::duration<double> elapsed_seconds = end-start;
std::cout << "Tree construcion done in " << elapsed_seconds.count() * 1000 << " milliseconds" << std::endl;
// Create instance
InstanceObject inst(tree);
Matrix34 mtx;
mtx.MakeRotateY(PI);
mtx.d.Set(-0.05f,0.0f,-0.1f);
inst.SetMatrix(mtx); scn.AddObject(inst);
// Create lights
DirectLight sunlgt;
sunlgt.SetBaseColor(Color(1.0f, 1.0f, 0.9f));
sunlgt.SetIntensity(1.0f);
sunlgt.SetDirection(Vector3(2.0f, -3.0f, -2.0f));
scn.AddLight(sunlgt);
PointLight redlgt;
redlgt.SetBaseColor(Color(1.0f, 0.2f, 0.2f));
redlgt.SetIntensity(0.02f);
redlgt.SetPosition(Vector3(-0.2f, 0.2f, 0.2f));
scn.AddLight(redlgt);
PointLight bluelgt;
bluelgt.SetBaseColor(Color(0.2f, 0.2f, 1.0f));
bluelgt.SetIntensity(0.02f);
bluelgt.SetPosition(Vector3(0.1f, 0.1f, 0.3f));
scn.AddLight(bluelgt);
// Create camera
Camera cam;
cam.LookAt(Vector3(-0.1f,0.1f,0.2f),Vector3(-0.05f,0.12f,0.0f));
cam.SetFOV(40.0f);
cam.SetAspect(1.33f);
cam.SetResolution(800,600);
start = std::chrono::system_clock::now();
std::cout << "Rendering the scene ..." << std::endl;
// Render image
cam.Render(scn);
cam.SaveBitmap("project2.bmp");
end = std::chrono::system_clock::now();
elapsed_seconds = end-start;
std::cout << "Scene rendering done in " << elapsed_seconds.count() * 1000 << " milliseconds" << std::endl;
}