3 types of lights

supported number of n lights
This commit is contained in:
devZoGok
2021-10-18 19:03:19 +03:00
parent 0083f9e5b8
commit aebc069053
16 changed files with 350 additions and 23 deletions
+25 -8
View File
@@ -3,6 +3,8 @@
#include"node.h"
#include"quad.h"
#include"material.h"
#include"light.h"
#include<glm.hpp>
using namespace vb01;
using namespace std;
@@ -11,14 +13,29 @@ int main(){
Root *root=Root::getSingleton();
root->start(800,600);
Quad *q=new Quad(Vector3(.5,.5,.5));
Node *node=new Node(Vector3(0,0,2));
node->setObject(q);
Material *mat=new Material();
mat->setDiffuseMap("/home/dominykas/c++/FSim/woodChips.jpg");
mat->setLightingEnabled(true);
q->setMaterial(mat);
root->getRootNode()->attachChild(node);
Vector3 v1[]={Vector3(2,2,.5),Vector3(.5,.5,.5)};
Vector3 v2[]={Vector3(-.0,0,2),Vector3(.5,0,-2)};
for(int i=0;i<1;i++){
Quad *q=new Quad(v1[i]);
Node *node=new Node(v2[i]);
node->setObject(q);
Material *mat=new Material();
mat->setDiffuseMap("/home/dominykas/c++/FSim/woodChips.jpg");
mat->setLightingEnabled(true);
q->setMaterial(mat);
root->getRootNode()->attachChild(node);
}
Camera *cam=Root::getSingleton()->getCamera();
cam->setPosition(Vector3(0,0,-4));
Light *l1=new Light();
l1->setPosition(Vector3(-.5,.1,0));
l1->setColor(Vector3(0,1,0));
l1->setAttenuationValues(.07,.14,1);
l1->setDirection(Vector3(0,-1,0));
l1->setInnerAngle(glm::radians(40.));
l1->setOuterAngle(glm::radians(60.));
l1->setType(Light::POINT);
root->getRootNode()->addLight(l1);
while(true)
root->update();
return 0;