Bring that Whole New World to the Old Continent too
Applies the clang-format style to the 2.1 branch as done for master in
5dbf1809c6.
This commit is contained in:
@ -27,22 +27,20 @@
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
#include "test_render.h"
|
||||
#include "servers/visual_server.h"
|
||||
#include "os/main_loop.h"
|
||||
#include "math_funcs.h"
|
||||
#include "print_string.h"
|
||||
#include "os/os.h"
|
||||
#include "quick_hull.h"
|
||||
#include "os/keyboard.h"
|
||||
#include "os/main_loop.h"
|
||||
#include "os/os.h"
|
||||
#include "print_string.h"
|
||||
#include "quick_hull.h"
|
||||
#include "servers/visual_server.h"
|
||||
|
||||
#define OBJECT_COUNT 50
|
||||
|
||||
namespace TestRender {
|
||||
|
||||
|
||||
class TestMainLoop : public MainLoop {
|
||||
|
||||
|
||||
RID test_cube;
|
||||
RID instance;
|
||||
RID camera;
|
||||
@ -61,37 +59,30 @@ class TestMainLoop : public MainLoop {
|
||||
|
||||
float ofs;
|
||||
bool quit;
|
||||
|
||||
protected:
|
||||
|
||||
|
||||
public:
|
||||
virtual void input_event(const InputEvent& p_event) {
|
||||
virtual void input_event(const InputEvent &p_event) {
|
||||
|
||||
if (p_event.type==InputEvent::KEY && p_event.key.pressed)
|
||||
quit=true;
|
||||
if (p_event.type == InputEvent::KEY && p_event.key.pressed)
|
||||
quit = true;
|
||||
}
|
||||
|
||||
virtual void init() {
|
||||
|
||||
|
||||
print_line("INITIALIZING TEST RENDER");
|
||||
VisualServer *vs=VisualServer::get_singleton();
|
||||
VisualServer *vs = VisualServer::get_singleton();
|
||||
test_cube = vs->get_test_cube();
|
||||
scenario = vs->scenario_create();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Vector<Vector3> vts;
|
||||
|
||||
/*
|
||||
/*
|
||||
DVector<Plane> sp = Geometry::build_sphere_planes(2,5,5);
|
||||
Geometry::MeshData md2 = Geometry::build_convex_mesh(sp);
|
||||
vts=md2.vertices;
|
||||
*/
|
||||
/*
|
||||
/*
|
||||
|
||||
static const int s = 20;
|
||||
for(int i=0;i<s;i++) {
|
||||
@ -117,20 +108,20 @@ public:
|
||||
vts.push_back(Vector3(1,0,0));
|
||||
vts.push_back(Vector3(-1,0,0));*/
|
||||
|
||||
vts.push_back(Vector3(1,1,1));
|
||||
vts.push_back(Vector3(1,-1,1));
|
||||
vts.push_back(Vector3(-1,1,1));
|
||||
vts.push_back(Vector3(-1,-1,1));
|
||||
vts.push_back(Vector3(1,1,-1));
|
||||
vts.push_back(Vector3(1,-1,-1));
|
||||
vts.push_back(Vector3(-1,1,-1));
|
||||
vts.push_back(Vector3(-1,-1,-1));
|
||||
vts.push_back(Vector3(1, 1, 1));
|
||||
vts.push_back(Vector3(1, -1, 1));
|
||||
vts.push_back(Vector3(-1, 1, 1));
|
||||
vts.push_back(Vector3(-1, -1, 1));
|
||||
vts.push_back(Vector3(1, 1, -1));
|
||||
vts.push_back(Vector3(1, -1, -1));
|
||||
vts.push_back(Vector3(-1, 1, -1));
|
||||
vts.push_back(Vector3(-1, -1, -1));
|
||||
|
||||
Geometry::MeshData md;
|
||||
Error err = QuickHull::build(vts,md);
|
||||
print_line("ERR: "+itos(err));
|
||||
Error err = QuickHull::build(vts, md);
|
||||
print_line("ERR: " + itos(err));
|
||||
test_cube = vs->mesh_create();
|
||||
vs->mesh_add_surface_from_mesh_data(test_cube,md);
|
||||
vs->mesh_add_surface_from_mesh_data(test_cube, md);
|
||||
//vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME);
|
||||
|
||||
/*
|
||||
@ -142,43 +133,38 @@ public:
|
||||
vs->material_set_shader(tcmat,sm);
|
||||
*/
|
||||
|
||||
|
||||
List<String> cmdline = OS::get_singleton()->get_cmdline_args();
|
||||
int object_count = OBJECT_COUNT;
|
||||
if (cmdline.size() > 0 && cmdline[cmdline.size()-1].to_int()) {
|
||||
object_count = cmdline[cmdline.size()-1].to_int();
|
||||
if (cmdline.size() > 0 && cmdline[cmdline.size() - 1].to_int()) {
|
||||
object_count = cmdline[cmdline.size() - 1].to_int();
|
||||
};
|
||||
|
||||
for (int i=0;i<object_count;i++) {
|
||||
for (int i = 0; i < object_count; i++) {
|
||||
|
||||
InstanceInfo ii;
|
||||
|
||||
ii.instance = vs->instance_create2(test_cube, scenario);
|
||||
|
||||
ii.instance = vs->instance_create2( test_cube, scenario );
|
||||
ii.base.translate(Math::random(-20, 20), Math::random(-20, 20), Math::random(-20, 18));
|
||||
ii.base.rotate(Vector3(0, 1, 0), Math::randf() * Math_PI);
|
||||
ii.base.rotate(Vector3(1, 0, 0), Math::randf() * Math_PI);
|
||||
vs->instance_set_transform(ii.instance, ii.base);
|
||||
|
||||
|
||||
ii.base.translate( Math::random(-20,20), Math::random(-20,20),Math::random(-20,18) );
|
||||
ii.base.rotate( Vector3(0,1,0), Math::randf() * Math_PI );
|
||||
ii.base.rotate( Vector3(1,0,0), Math::randf() * Math_PI );
|
||||
vs->instance_set_transform( ii.instance, ii.base );
|
||||
|
||||
ii.rot_axis = Vector3( Math::random(-1,1), Math::random(-1,1), Math::random(-1,1) ).normalized();
|
||||
ii.rot_axis = Vector3(Math::random(-1, 1), Math::random(-1, 1), Math::random(-1, 1)).normalized();
|
||||
|
||||
instances.push_back(ii);
|
||||
|
||||
}
|
||||
|
||||
camera = vs->camera_create();
|
||||
|
||||
// vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
|
||||
// vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
|
||||
|
||||
viewport = vs->viewport_create();
|
||||
vs->viewport_attach_to_screen(viewport);
|
||||
vs->viewport_attach_camera( viewport, camera );
|
||||
vs->viewport_set_scenario( viewport, scenario );
|
||||
vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,3,30 ) ) );
|
||||
vs->camera_set_perspective( camera, 60, 0.1, 1000);
|
||||
|
||||
vs->viewport_attach_camera(viewport, camera);
|
||||
vs->viewport_set_scenario(viewport, scenario);
|
||||
vs->camera_set_transform(camera, Transform(Matrix3(), Vector3(0, 3, 30)));
|
||||
vs->camera_set_perspective(camera, 60, 0.1, 1000);
|
||||
|
||||
/*
|
||||
RID lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
|
||||
@ -190,47 +176,47 @@ public:
|
||||
RID lightaux;
|
||||
|
||||
//*
|
||||
lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
|
||||
lightaux = vs->light_create(VisualServer::LIGHT_DIRECTIONAL);
|
||||
//vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
|
||||
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_DIFFUSE, Color(1.0,1.0,1.0) );
|
||||
vs->light_set_color(lightaux, VisualServer::LIGHT_COLOR_DIFFUSE, Color(1.0, 1.0, 1.0));
|
||||
//vs->light_set_shadow( lightaux, true );
|
||||
light = vs->instance_create2( lightaux, scenario );
|
||||
light = vs->instance_create2(lightaux, scenario);
|
||||
Transform lla;
|
||||
//lla.set_look_at(Vector3(),Vector3(1,-1,1),Vector3(0,1,0));
|
||||
lla.set_look_at(Vector3(),Vector3(-0.000000,-0.836026,-0.548690),Vector3(0,1,0));
|
||||
lla.set_look_at(Vector3(), Vector3(-0.000000, -0.836026, -0.548690), Vector3(0, 1, 0));
|
||||
|
||||
vs->instance_set_transform( light, lla );
|
||||
vs->instance_set_transform(light, lla);
|
||||
// */
|
||||
|
||||
//*
|
||||
lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
|
||||
// vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
|
||||
vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_DIFFUSE, Color(1.0,1.0,0.0) );
|
||||
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_RADIUS, 4 );
|
||||
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8 );
|
||||
lightaux = vs->light_create(VisualServer::LIGHT_OMNI);
|
||||
// vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,1.0) );
|
||||
vs->light_set_color(lightaux, VisualServer::LIGHT_COLOR_DIFFUSE, Color(1.0, 1.0, 0.0));
|
||||
vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_RADIUS, 4);
|
||||
vs->light_set_param(lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8);
|
||||
//vs->light_set_shadow( lightaux, true );
|
||||
//light = vs->instance_create( lightaux );
|
||||
// */
|
||||
|
||||
ofs=0;
|
||||
quit=false;
|
||||
ofs = 0;
|
||||
quit = false;
|
||||
}
|
||||
virtual bool iteration(float p_time) {
|
||||
|
||||
VisualServer *vs=VisualServer::get_singleton();
|
||||
VisualServer *vs = VisualServer::get_singleton();
|
||||
//Transform t;
|
||||
//t.rotate(Vector3(0, 1, 0), ofs);
|
||||
//t.translate(Vector3(0,0,20 ));
|
||||
//vs->camera_set_transform(camera, t);
|
||||
|
||||
ofs+=p_time*0.05;
|
||||
ofs += p_time * 0.05;
|
||||
|
||||
//return quit;
|
||||
|
||||
for(List<InstanceInfo>::Element *E=instances.front();E;E=E->next()) {
|
||||
for (List<InstanceInfo>::Element *E = instances.front(); E; E = E->next()) {
|
||||
|
||||
Transform pre( Matrix3(E->get().rot_axis, ofs), Vector3() );
|
||||
vs->instance_set_transform( E->get().instance, pre * E->get().base );
|
||||
Transform pre(Matrix3(E->get().rot_axis, ofs), Vector3());
|
||||
vs->instance_set_transform(E->get().instance, pre * E->get().base);
|
||||
/*
|
||||
if( !E->next() ) {
|
||||
|
||||
@ -246,18 +232,12 @@ public:
|
||||
return quit;
|
||||
}
|
||||
|
||||
|
||||
virtual void finish() {
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
MainLoop *test() {
|
||||
|
||||
MainLoop* test() {
|
||||
|
||||
return memnew( TestMainLoop );
|
||||
|
||||
return memnew(TestMainLoop);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user