implemented shadows for non positional lights

fixed skybox
implemented translation and rotation
This commit is contained in:
devZoGok
2021-10-18 19:05:52 +03:00
parent 7a8a178a74
commit 9479e3324f
52 changed files with 389 additions and 208 deletions
Regular → Executable
+24 -6
View File
@@ -9,17 +9,19 @@
using namespace std;
namespace vb01{
Node::Node(Vector3 pos){
Node::Node(Vector3 pos, Quaternion orientation, Vector3 scale){
this->pos=pos;
this->scale=scale;
this->orientation=orientation;
}
Node::~Node(){}
void Node::update(){
for(Mesh *m : meshes)
m->update();
for(Light *l : lights)
l->update();
for(Mesh *m : meshes)
m->update();
for(ParticleEmitter *p : emitters)
p->update();
for(Text *t : texts)
@@ -29,13 +31,16 @@ namespace vb01{
}
void Node::attachChild(Node *child){
/*
Node *parent=getParent();
while(parent){
parent->getDescendants().push_back(child);
parent=parent->getParent();
}
children.push_back(child);
descendants.push_back(child);
*/
child->setParent(this);
children.push_back(child);
}
void Node::attachMesh(Mesh *mesh){
@@ -53,7 +58,8 @@ namespace vb01{
light->setNode(this);
Node *rootNode=Root::getSingleton()->getRootNode();
vector<Node*> descendants=rootNode->getDescendants();
vector<Node*> descendants;
rootNode->getDescendants(rootNode,descendants);
descendants.push_back(rootNode);
int numLights=0;
for(Node *n : descendants)
@@ -63,7 +69,10 @@ namespace vb01{
for(Mesh *m : meshes){
Material *mat=m->getMaterial();
string str=to_string(numLights>0?numLights:1);
if(mat) mat->getShader()->editShader(false,'=',';',str);
if(mat){
mat->getShader()->editShader(true,'=',';',str);
mat->getShader()->editShader(false,'=',';',str);
}
}
}
}
@@ -72,4 +81,13 @@ namespace vb01{
texts.push_back(text);
text->setNode(this);
}
void Node::getDescendants(Node *node, vector<Node*> &descendants){
for(int i=0;i<node->getNumChildren();i++){
if(node->getChild(i)->getNumChildren()>0)
getDescendants(node->getChild(i),descendants);
else
descendants.push_back(node->getChild(i));
}
}
}