mirror of
https://github.com/Relintai/sfw.git
synced 2025-01-17 14:47:18 +01:00
More cleanups.
This commit is contained in:
parent
11a8bde0d9
commit
843dc6baf3
@ -255,7 +255,7 @@ GameScene::GameScene() {
|
||||
camera_2d = memnew(Camera2D);
|
||||
camera_2d->size = Vector2(1920, 1080);
|
||||
|
||||
mesh = memnew(Mesh());
|
||||
mesh = Ref<Mesh>(memnew(Mesh()));
|
||||
//cmaterial = memnew(ColoredMaterial());
|
||||
//cmaterial->color = glm::vec4(1, 1, 0, 1);
|
||||
color_material.instance();
|
||||
@ -266,11 +266,11 @@ GameScene::GameScene() {
|
||||
mesh->upload();
|
||||
|
||||
mi = memnew(MeshInstance3D());
|
||||
mi->material = color_material.ptr();
|
||||
mi->material = color_material;
|
||||
mi->mesh = mesh;
|
||||
|
||||
mi2 = memnew(MeshInstance3D());
|
||||
mi2->material = color_material.ptr();
|
||||
mi2->material = color_material;
|
||||
mi2->mesh = mesh;
|
||||
mi2->transform.origin.x = 1;
|
||||
|
||||
|
@ -53,7 +53,7 @@ public:
|
||||
Sprite *sprite;
|
||||
|
||||
Camera3D *camera;
|
||||
Mesh *mesh;
|
||||
Ref<Mesh> mesh;
|
||||
MeshInstance3D *mi;
|
||||
MeshInstance3D *mi2;
|
||||
Ref<ColorMaterial> color_material;
|
||||
|
@ -280,4 +280,4 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -171,4 +171,4 @@ bool Signal::is_connected(T *obj, void (*func)(T*, Signal *)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -267,4 +267,4 @@ public:
|
||||
};
|
||||
*/
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -22,4 +22,4 @@ public:
|
||||
virtual ~Resource();
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -28,4 +28,4 @@ public:
|
||||
int32_t model_view_matrix_location;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -2,74 +2,75 @@
|
||||
#include "render_core/mesh_utils.h"
|
||||
//--STRIP
|
||||
|
||||
void MeshUtils::create_cone(Mesh *mesh) {
|
||||
if (!mesh)
|
||||
return;
|
||||
void MeshUtils::create_cone(Ref<Mesh> mesh) {
|
||||
if (!mesh.is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t vc = mesh->vertices.size();
|
||||
uint32_t vc = mesh->vertices.size();
|
||||
|
||||
//eleje
|
||||
mesh->add_color(1, 0, 0);
|
||||
mesh->add_vertex3(0, 0.5, 0);
|
||||
//eleje
|
||||
mesh->add_color(1, 0, 0);
|
||||
mesh->add_vertex3(0, 0.5, 0);
|
||||
|
||||
mesh->add_color(1,0,0);
|
||||
mesh->add_vertex3(-0.5, -0.5, 0.5);
|
||||
mesh->add_color(1, 0, 0);
|
||||
mesh->add_vertex3(-0.5, -0.5, 0.5);
|
||||
|
||||
mesh->add_color(1, 0, 0);
|
||||
mesh->add_vertex3(0.5, -0.5, 0.5);
|
||||
mesh->add_color(1, 0, 0);
|
||||
mesh->add_vertex3(0.5, -0.5, 0.5);
|
||||
|
||||
mesh->add_triangle(0 + vc, 1 + vc, 2 + vc);
|
||||
mesh->add_triangle(0 + vc, 1 + vc, 2 + vc);
|
||||
|
||||
//bal
|
||||
mesh->add_color(0, 1, 0);
|
||||
mesh->add_vertex3(0, 0.5, 0);
|
||||
//bal
|
||||
mesh->add_color(0, 1, 0);
|
||||
mesh->add_vertex3(0, 0.5, 0);
|
||||
|
||||
mesh->add_color(0, 1, 0);
|
||||
mesh->add_vertex3(-0.5, -0.5, -0.5);
|
||||
mesh->add_color(0, 1, 0);
|
||||
mesh->add_vertex3(-0.5, -0.5, -0.5);
|
||||
|
||||
mesh->add_color(0, 1, 0);
|
||||
mesh->add_vertex3(-0.5, -0.5, 0.5);
|
||||
mesh->add_color(0, 1, 0);
|
||||
mesh->add_vertex3(-0.5, -0.5, 0.5);
|
||||
|
||||
mesh->add_triangle(3 + vc, 4 + vc, 5 + vc);
|
||||
mesh->add_triangle(3 + vc, 4 + vc, 5 + vc);
|
||||
|
||||
//jobb
|
||||
mesh->add_color(0, 0, 1);
|
||||
mesh->add_vertex3(0, 0.5, 0);
|
||||
//jobb
|
||||
mesh->add_color(0, 0, 1);
|
||||
mesh->add_vertex3(0, 0.5, 0);
|
||||
|
||||
mesh->add_color(0, 0, 1);
|
||||
mesh->add_vertex3(0.5, -0.5, 0.5);
|
||||
mesh->add_color(0, 0, 1);
|
||||
mesh->add_vertex3(0.5, -0.5, 0.5);
|
||||
|
||||
mesh->add_color(0, 0, 1);
|
||||
mesh->add_vertex3(0.5, -0.5, -0.5);
|
||||
mesh->add_color(0, 0, 1);
|
||||
mesh->add_vertex3(0.5, -0.5, -0.5);
|
||||
|
||||
mesh->add_triangle(6 + vc, 7 + vc, 8 + vc);
|
||||
mesh->add_triangle(6 + vc, 7 + vc, 8 + vc);
|
||||
|
||||
//hátulja
|
||||
mesh->add_color(1, 1, 0);
|
||||
mesh->add_vertex3(0, 0.5, 0);
|
||||
//hátulja
|
||||
mesh->add_color(1, 1, 0);
|
||||
mesh->add_vertex3(0, 0.5, 0);
|
||||
|
||||
mesh->add_color(1, 1, 0);
|
||||
mesh->add_vertex3(0.5, -0.5, -0.5);
|
||||
mesh->add_color(1, 1, 0);
|
||||
mesh->add_vertex3(0.5, -0.5, -0.5);
|
||||
|
||||
mesh->add_color(1, 1, 0);
|
||||
mesh->add_vertex3(-0.5, -0.5, -0.5);
|
||||
mesh->add_color(1, 1, 0);
|
||||
mesh->add_vertex3(-0.5, -0.5, -0.5);
|
||||
|
||||
mesh->add_triangle(9 + vc, 10 + vc, 11 + vc);
|
||||
mesh->add_triangle(9 + vc, 10 + vc, 11 + vc);
|
||||
|
||||
//alja
|
||||
//alja
|
||||
|
||||
mesh->add_color(1, 0, 1);
|
||||
mesh->add_vertex3(-0.5, -0.5, -0.5);
|
||||
mesh->add_color(1, 0, 1);
|
||||
mesh->add_vertex3(-0.5, -0.5, -0.5);
|
||||
|
||||
mesh->add_color(1, 0, 1);
|
||||
mesh->add_vertex3(0.5, -0.5, 0.5);
|
||||
mesh->add_color(1, 0, 1);
|
||||
mesh->add_vertex3(0.5, -0.5, 0.5);
|
||||
|
||||
mesh->add_color(1, 0, 1);
|
||||
mesh->add_vertex3(-0.5, -0.5, 0.5);
|
||||
mesh->add_color(1, 0, 1);
|
||||
mesh->add_vertex3(-0.5, -0.5, 0.5);
|
||||
|
||||
mesh->add_color(1, 0, 1);
|
||||
mesh->add_vertex3(0.5, -0.5, -0.5);
|
||||
mesh->add_color(1, 0, 1);
|
||||
mesh->add_vertex3(0.5, -0.5, -0.5);
|
||||
|
||||
mesh->add_triangle(12 + vc, 13 + vc, 14 + vc);
|
||||
mesh->add_triangle(13 + vc, 12 + vc, 15 + vc);
|
||||
mesh->add_triangle(12 + vc, 13 + vc, 14 + vc);
|
||||
mesh->add_triangle(13 + vc, 12 + vc, 15 + vc);
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
|
||||
class MeshUtils {
|
||||
public:
|
||||
static void create_cone(Mesh *mesh);
|
||||
static void create_cone(Ref<Mesh> mesh);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -94,4 +94,4 @@ private:
|
||||
Vector<Transform2D> camera_2d_model_view_matrix_stack;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
@ -33,5 +33,9 @@ void MeshInstance2D::render() {
|
||||
MeshInstance2D::MeshInstance2D() {
|
||||
}
|
||||
MeshInstance2D::~MeshInstance2D() {
|
||||
for (int i = 0; i < children.size(); ++i) {
|
||||
memdelete(children[i]);
|
||||
}
|
||||
|
||||
children.clear();
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
#define MESH_INSTACE_2D_H
|
||||
|
||||
//--STRIP
|
||||
#include "object_2d.h"
|
||||
|
||||
#include "core/vector.h"
|
||||
|
||||
#include "render_core/material.h"
|
||||
@ -10,7 +12,9 @@
|
||||
#include "core/transform.h"
|
||||
//--STRIP
|
||||
|
||||
class MeshInstance2D {
|
||||
class MeshInstance2D : public Object2D {
|
||||
SFW_OBJECT(MeshInstance2D, Object2D);
|
||||
|
||||
public:
|
||||
void render();
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
//--STRIP
|
||||
#include "render_objects/mesh_instance_3d.h"
|
||||
|
||||
@ -5,7 +6,7 @@
|
||||
//--STRIP
|
||||
|
||||
void MeshInstance3D::render() {
|
||||
if (!mesh) {
|
||||
if (!mesh.is_valid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -13,7 +14,7 @@ void MeshInstance3D::render() {
|
||||
|
||||
Camera3D::current_camera->set_model_view_matrix(mat_orig * transform);
|
||||
|
||||
if (material) {
|
||||
if (material.is_valid()) {
|
||||
material->bind();
|
||||
}
|
||||
|
||||
@ -31,9 +32,11 @@ void MeshInstance3D::render() {
|
||||
}
|
||||
|
||||
MeshInstance3D::MeshInstance3D() {
|
||||
material = NULL;
|
||||
mesh = NULL;
|
||||
}
|
||||
MeshInstance3D::~MeshInstance3D() {
|
||||
for (int i = 0; i < children.size(); ++i) {
|
||||
memdelete(children[i]);
|
||||
}
|
||||
|
||||
children.clear();
|
||||
}
|
||||
|
@ -13,14 +13,16 @@
|
||||
//--STRIP
|
||||
|
||||
class MeshInstance3D : public Object3D {
|
||||
SFW_OBJECT(MeshInstance3D, Object3D);
|
||||
|
||||
public:
|
||||
void render();
|
||||
|
||||
MeshInstance3D();
|
||||
~MeshInstance3D();
|
||||
|
||||
Material *material;
|
||||
Mesh *mesh;
|
||||
Ref<Material> material;
|
||||
Ref<Mesh> mesh;
|
||||
|
||||
Vector<MeshInstance3D *> children;
|
||||
};
|
||||
|
@ -6,5 +6,5 @@ cd ..
|
||||
|
||||
python tools/merger/join.py --template tools/merger/sfw.h.inl --path . --output tools/merger/out/sfw.h
|
||||
python tools/merger/join.py --template tools/merger/sfw.cpp.inl --path . --output tools/merger/out/sfw.cpp
|
||||
python tools/merger/join.py --template tools/merger/sfw.x.inl --path . --output tools/merger/out/sfw
|
||||
python tools/merger/join.py --template tools/merger/sfw_3rd.x.inl --path . --output tools/merger/out/sfw_3rd.h
|
||||
|
||||
|
@ -721,6 +721,7 @@ SOFTWARE.
|
||||
//--STRIP
|
||||
{{FILE:sfw/render_objects/camera_2d.h}}
|
||||
//--STRIP
|
||||
//#include "object_2d.h"
|
||||
//#include "core/vector.h"
|
||||
//#include "render_core/material.h"
|
||||
//#include "render_core/mesh.h"
|
||||
|
Loading…
Reference in New Issue
Block a user