summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/tests/test_detailer.cpp217
-rw-r--r--bin/tests/test_detailer.h44
-rw-r--r--bin/tests/test_gui.cpp4
-rw-r--r--bin/tests/test_main.cpp34
-rw-r--r--bin/tests/test_misc.cpp499
-rw-r--r--bin/tests/test_misc.h40
-rw-r--r--bin/tests/test_particles.cpp121
-rw-r--r--bin/tests/test_particles.h43
-rw-r--r--bin/tests/test_physics.cpp28
-rw-r--r--bin/tests/test_physics_2d.cpp10
-rw-r--r--bin/tests/test_python.cpp56
-rw-r--r--bin/tests/test_python.h43
-rw-r--r--bin/tests/test_render.cpp11
-rw-r--r--bin/tests/test_shader_lang.cpp251
14 files changed, 156 insertions, 1245 deletions
diff --git a/bin/tests/test_detailer.cpp b/bin/tests/test_detailer.cpp
deleted file mode 100644
index 5dba7c3f72..0000000000
--- a/bin/tests/test_detailer.cpp
+++ /dev/null
@@ -1,217 +0,0 @@
-/*************************************************************************/
-/* test_detailer.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "test_detailer.h"
-#include "servers/visual_server.h"
-#include "os/main_loop.h"
-#include "math_funcs.h"
-#include "print_string.h"
-#include "geometry.h"
-#include "quick_hull.h"
-namespace TestMultiMesh {
-
-
-class TestMainLoop : public MainLoop {
-
- RID instance;
- RID camera;
- RID viewport;
- RID light;
- RID mesh;
- RID scenario;
-
-#define MULTIMESH_COUNT 1500
-
- float ofs_x,ofs_y;
- bool quit;
-public:
-
-
- virtual void _update_qh() {
-
- VisualServer *vs=VisualServer::get_singleton();
- Vector<Vector3> vts;
-/*
-
- static const int s = 20;
- for(int i=0;i<s;i++) {
- Matrix3 rot(Vector3(0,1,0),i*Math_PI/s);
-
- for(int j=0;j<s;j++) {
- Vector3 v;
- v.x=Math::sin(j*Math_PI*2/s);
- v.y=Math::cos(j*Math_PI*2/s);
-
- vts.push_back( rot.xform(v*2 ) );
- }
- }*/
- /*
- Math::seed(0);
- for(int i=0;i<50;i++) {
-
- vts.push_back( Vector3(Math::randf()*2-1.0,Math::randf()*2-1.0,Math::randf()*2-1.0).normalized()*2);
- }*/
- /*
- vts.push_back(Vector3(0,0,1));
- vts.push_back(Vector3(0,0,-1));
- vts.push_back(Vector3(0,1,0));
- vts.push_back(Vector3(0,-1,0));
- 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));
-*/
-
-
- DVector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5,0.7,4,Vector3::AXIS_Z);
- Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
- vts=convex_data.vertices;
-
- Geometry::MeshData md;
- Error err = QuickHull::build(vts,md);
- print_line("ERR: "+itos(err));
-
- vs->mesh_remove_surface(mesh,0);
- vs->mesh_add_surface_from_mesh_data(mesh,md);
-
-
-
- //vs->scenario_set_debug(scenario,VS::SCENARIO_DEBUG_WIREFRAME);
-
- /*
- RID sm = vs->shader_create();
- //vs->shader_set_fragment_code(sm,"OUT_ALPHA=mod(TIME,1);");
- //vs->shader_set_vertex_code(sm,"OUT_VERTEX=IN_VERTEX*mod(TIME,1);");
- vs->shader_set_fragment_code(sm,"OUT_DIFFUSE=vec3(1,0,1);OUT_GLOW=abs(sin(TIME));");
- RID tcmat = vs->mesh_surface_get_material(test_cube,0);
- vs->material_set_shader(tcmat,sm);
- */
-
- }
-
- virtual void input_event(const InputEvent& p_event) {
-
- if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&4) {
-
- ofs_x+=p_event.mouse_motion.relative_y/200.0;
- ofs_y+=p_event.mouse_motion.relative_x/200.0;
- }
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index==1) {
-
- QuickHull::debug_stop_after++;
- _update_qh();
- }
- if (p_event.type==InputEvent::MOUSE_BUTTON && p_event.mouse_button.pressed && p_event.mouse_button.button_index==2) {
-
- if (QuickHull::debug_stop_after>0)
- QuickHull::debug_stop_after--;
- _update_qh();
- }
-
-
- }
-
- virtual void request_quit() {
-
- quit=true;
- }
-
-
-
- virtual void init() {
-
- VisualServer *vs=VisualServer::get_singleton();
-
-
- mesh = vs->mesh_create();
-
- scenario = vs->scenario_create();
-
- QuickHull::debug_stop_after=0;
- _update_qh();
-
- instance = vs->instance_create2(mesh,scenario);
-
- camera = vs->camera_create();
-
-
- vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
- viewport = vs->viewport_create();
- vs->viewport_attach_camera( viewport, camera );
- vs->viewport_attach_to_screen(viewport);
- vs->viewport_set_scenario( viewport, scenario );
-
- vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,0,2 ) ) );
-
- RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
- //vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.3,0.3,0.3) );
- light = vs->instance_create2( lightaux,scenario );
- vs->instance_set_transform(light,Transform(Matrix3(Vector3(0.1,0.4,0.7).normalized(),0.9)));
-
- ofs_x=0;
- ofs_y=0;
- quit=false;
- }
-
- virtual bool idle(float p_time) {
- return false;
- }
-
- virtual bool iteration(float p_time) {
-
- VisualServer *vs=VisualServer::get_singleton();
-
- Transform tr_camera;
- tr_camera.rotate( Vector3(0,1,0), ofs_y );
- tr_camera.rotate( Vector3(1,0,0),ofs_x );
- tr_camera.translate(0,0,10);
-
- vs->camera_set_transform( camera, tr_camera );
-
- return quit;
- }
- virtual void finish() {
-
- }
-
-};
-
-MainLoop* test() {
-
- return memnew(TestMainLoop);
-
-}
-
-}
diff --git a/bin/tests/test_detailer.h b/bin/tests/test_detailer.h
deleted file mode 100644
index 597e088caf..0000000000
--- a/bin/tests/test_detailer.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*************************************************************************/
-/* test_detailer.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef TEST_MULTIMESH_H
-#define TEST_MULTIMESH_H
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-#include "os/main_loop.h"
-
-namespace TestMultiMesh {
-
-MainLoop* test();
-
-}
-
-
-#endif
diff --git a/bin/tests/test_gui.cpp b/bin/tests/test_gui.cpp
index f4341fd7b3..bfce03d663 100644
--- a/bin/tests/test_gui.cpp
+++ b/bin/tests/test_gui.cpp
@@ -370,7 +370,7 @@ public:
tabc->set_size( Point2( 180,250 ) );
- Ref<ImageTexture> text = memnew( ImageTexture );
+ /*Ref<ImageTexture> text = memnew( ImageTexture );
text->load("test_data/concave.png");
Sprite* sprite = memnew(Sprite);
@@ -383,7 +383,7 @@ public:
sprite->set_texture(text);
sprite->add_child(sprite2);
sprite2->set_pos(Point2(50, 50));
- sprite2->show();
+ sprite2->show();*/
}
diff --git a/bin/tests/test_main.cpp b/bin/tests/test_main.cpp
index 363aede96e..1f7f2d7dda 100644
--- a/bin/tests/test_main.cpp
+++ b/bin/tests/test_main.cpp
@@ -37,13 +37,10 @@
#include "test_gui.h"
#include "test_render.h"
#include "test_sound.h"
-#include "test_misc.h"
#include "test_physics.h"
#include "test_physics_2d.h"
-#include "test_python.h"
+
#include "test_io.h"
-#include "test_particles.h"
-#include "test_detailer.h"
#include "test_shader_lang.h"
#include "test_gdscript.h"
#include "test_image.h"
@@ -56,7 +53,6 @@ const char ** tests_get_names() {
"containers",
"math",
"render",
- "particles",
"multimesh",
"gui",
"io",
@@ -96,11 +92,6 @@ MainLoop* test_main(String p_test,const List<String>& p_args) {
return TestPhysics2D::test();
}
- if (p_test=="misc") {
-
- return TestMisc::test();
- }
-
if (p_test=="render") {
return TestRender::test();
@@ -123,16 +114,6 @@ MainLoop* test_main(String p_test,const List<String>& p_args) {
return TestIO::test();
}
- if (p_test=="particles") {
-
- return TestParticles::test();
- }
-
- if (p_test=="multimesh") {
-
- return TestMultiMesh::test();
- }
-
if (p_test=="shaderlang") {
return TestShaderLang::test();
@@ -163,19 +144,6 @@ MainLoop* test_main(String p_test,const List<String>& p_args) {
return TestImage::test();
}
- if (p_test=="detailer") {
-
- return TestMultiMesh::test();
- }
-
-#ifdef PYTHON_ENABLED
-
- if (p_test=="python") {
-
- return TestPython::test();
- }
-#endif
-
return NULL;
}
diff --git a/bin/tests/test_misc.cpp b/bin/tests/test_misc.cpp
deleted file mode 100644
index 9d7adc3573..0000000000
--- a/bin/tests/test_misc.cpp
+++ /dev/null
@@ -1,499 +0,0 @@
-/*************************************************************************/
-/* test_misc.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "test_misc.h"
-#include "servers/visual_server.h"
-#include "os/main_loop.h"
-#include "math_funcs.h"
-#include "print_string.h"
-
-
-namespace TestMisc {
-
-struct ConvexTestResult
-{
-
- Vector3 edgeA[2];
- Vector3 edgeB[2];
- bool valid;
- Vector3 contactA;
- Vector3 contactB;
- Vector3 contactNormal;
- float depth;
-
- /*
- Vector3 contactA;
- Vector3 contactB;
- Vector3 contactNormal;
- Vector3 contactX;
- Vector3 contactY;
- Vector3 edgeA[2];
- Vector3 edgeB[2];
- float depth;
- bool valid;
- bool isEdgeEdge;
- bool needTransform;
- neBool ComputerEdgeContactPoint(ConvexTestResult & res);
- neBool ComputerEdgeContactPoint2(float & au, float & bu);
- void Reverse()
- {
- neSwap(contactA, contactB);
- contactNormal *= -1.0f;
- }*/
- bool ComputerEdgeContactPoint2(float & au, float & bu);
-};
-
-
-
-bool ConvexTestResult::ComputerEdgeContactPoint2(float & au, float & bu)
-{
- float d1343, d4321, d1321, d4343, d2121;
- float numer, denom;
-
- Vector3 p13;
- Vector3 p43;
- Vector3 p21;
- Vector3 diff;
-
- p13 = (edgeA[0]) - (edgeB[0]);
- p43 = (edgeB[1]) - (edgeB[0]);
-
- if ( p43.length_squared() < CMP_EPSILON2 )
- {
- valid = false;
- goto ComputerEdgeContactPoint2_Exit;
- }
-
- p21 = (edgeA[1]) - (edgeA[0]);
-
- if ( p21.length_squared()<CMP_EPSILON2 )
- {
- valid = false;
- goto ComputerEdgeContactPoint2_Exit;
- }
-
- d1343 = p13.dot(p43);
- d4321 = p43.dot(p21);
- d1321 = p13.dot(p21);
- d4343 = p43.dot(p43);
- d2121 = p21.dot(p21);
-
- denom = d2121 * d4343 - d4321 * d4321;
-
- if (ABS(denom) < CMP_EPSILON)
- {
- valid = false;
-
- goto ComputerEdgeContactPoint2_Exit;
- }
-
- numer = d1343 * d4321 - d1321 * d4343;
- au = numer / denom;
- bu = (d1343 + d4321 * (au)) / d4343;
-
- if (au < 0.0f || au >= 1.0f)
- {
- valid = false;
- }
- else if (bu < 0.0f || bu >= 1.0f)
- {
- valid = false;
- }
- else
- {
- valid = true;
- }
- {
- Vector3 tmpv;
-
- tmpv = p21 * au;
- contactA = (edgeA[0]) + tmpv;
-
- tmpv = p43 * bu;
- contactB = (edgeB[0]) + tmpv;
- }
-
- diff = contactA - contactB;
-
- depth = Math::sqrt(diff.dot(diff));
-
- return true;
-
-ComputerEdgeContactPoint2_Exit:
-
- return false;
-}
-
-struct neCollisionResult {
-
- float depth;
- bool penetrate;
- Matrix3 collisionFrame;
- Vector3 contactA;
- Vector3 contactB;
-};
-
-
-struct TConvex {
-
- float radius;
- float half_height;
- float CylinderRadius() const { return radius; }
- float CylinderHalfHeight() const { return half_height; }
-};
-
-float GetDistanceFromLine2(Vector3 v, Vector3 & project, const Vector3 & pointA, const Vector3 & pointB)
-{
- Vector3 ba = pointB - pointA;
-
- float len = ba.length();
-
- if (len<CMP_EPSILON)
- ba=Vector3();
- else
- ba *= 1.0f / len;
-
- Vector3 pa = v - pointA;
-
- float k = pa.dot(ba);
-
- project = pointA + ba * k;
-
- Vector3 diff = v - project;
-
- return diff.length();
-}
-
-void TestCylinderVertEdge(neCollisionResult & result, Vector3 & edgeA1, Vector3 & edgeA2, Vector3 & vertB,
- TConvex & cA, TConvex & cB, Transform & transA, Transform & transB, bool flip)
-{
- Vector3 project;
-
- float dist = GetDistanceFromLine2(vertB,project, edgeA1, edgeA2);
-
- float depth = cA.CylinderRadius() + cB.CylinderRadius() - dist;
-
- if (depth <= 0.0f)
- return;
-
- if (depth <= result.depth)
- return;
-
- result.penetrate = true;
-
- result.depth = depth;
-
- if (!flip)
- {
- result.collisionFrame.set_axis(2,(project - vertB).normalized());
-
- result.contactA = project - result.collisionFrame.get_axis(2) * cA.CylinderRadius();
-
- result.contactB = vertB + result.collisionFrame.get_axis(2) * cB.CylinderRadius();
- }
- else
- {
-
- result.collisionFrame.set_axis(2,(vertB - project).normalized());
-
- result.contactA = vertB - result.collisionFrame.get_axis(2) * cB.CylinderRadius();
-
- result.contactB = project + result.collisionFrame.get_axis(2) * cA.CylinderRadius();
- }
-}
-
-void TestCylinderVertVert(neCollisionResult & result, Vector3 & vertA, Vector3 & vertB,
- TConvex & cA, TConvex & cB, Transform & transA, Transform & transB)
-{
- Vector3 diff = vertA - vertB;
-
- float dist = diff.length();
-
- float depth = cA.CylinderRadius() + cB.CylinderRadius() - dist;
-
- if (depth <= 0.0f)
- return;
-
- if (depth <= result.depth)
- return;
-
- result.penetrate = true;
-
- result.depth = depth;
-
- result.collisionFrame.set_axis(2, diff * (1.0f / dist));
-
- result.contactA = vertA - result.collisionFrame.get_axis(2) * cA.CylinderRadius();
-
- result.contactB = vertB + result.collisionFrame.get_axis(2) * cB.CylinderRadius();
-}
-
-void Cylinder2CylinderTest(neCollisionResult & result, TConvex & cA, Transform & transA, TConvex & cB, Transform & transB)
-{
- result.penetrate = false;
-
- Vector3 dir = transA.basis.get_axis(1).cross(transB.basis.get_axis(1));
-
- float len = dir.length();
-
-// bool isParallel = len<CMP_EPSILON;
-
-// int doVertCheck = 0;
-
- ConvexTestResult cr;
-
- cr.edgeA[0] = transA.origin + transA.basis.get_axis(1) * cA.CylinderHalfHeight();
- cr.edgeA[1] = transA.origin - transA.basis.get_axis(1) * cA.CylinderHalfHeight();
- cr.edgeB[0] = transB.origin + transB.basis.get_axis(1) * cB.CylinderHalfHeight();
- cr.edgeB[1] = transB.origin - transB.basis.get_axis(1) * cB.CylinderHalfHeight();
-
-// float dot = transA.basis.get_axis(1).dot(transB.basis.get_axis(1));
-
- if (len>CMP_EPSILON)
- {
- float au, bu;
-
- cr.ComputerEdgeContactPoint2(au, bu);
-
- if (cr.valid)
- {
- float depth = cA.CylinderRadius() + cB.CylinderRadius() - cr.depth;
-
- if (depth <= 0.0f)
- return;
-
- result.depth = depth;
-
- result.penetrate = true;
-
- result.collisionFrame.set_axis(2, (cr.contactA - cr.contactB)*(1.0f / cr.depth));
-
- result.contactA = cr.contactA - result.collisionFrame.get_axis(2) * cA.CylinderRadius();
-
- result.contactB = cr.contactB + result.collisionFrame.get_axis(2) * cB.CylinderRadius();
-
- return;
- }
- }
- result.depth = -1.0e6f;
-
- int i;
-
- for (i = 0; i < 2; i++)
- {
- //project onto edge b
-
- Vector3 diff = cr.edgeA[i] - cr.edgeB[1];
-
- float dot = diff.dot(transB.basis.get_axis(1));
-
- if (dot < 0.0f)
- {
- TestCylinderVertVert(result, cr.edgeA[i], cr.edgeB[1], cA, cB, transA, transB);
- }
- else if (dot > (2.0f * cB.CylinderHalfHeight()))
- {
- TestCylinderVertVert(result, cr.edgeA[i], cr.edgeB[0], cA, cB, transA, transB);
- }
- else
- {
- TestCylinderVertEdge(result, cr.edgeB[0], cr.edgeB[1], cr.edgeA[i], cB, cA, transB, transA, true);
- }
- }
- for (i = 0; i < 2; i++)
- {
- //project onto edge b
-
- Vector3 diff = cr.edgeB[i] - cr.edgeA[1];
-
- float dot = diff.dot(transA.basis.get_axis(1));
-
- if (dot < 0.0f)
- {
- TestCylinderVertVert(result, cr.edgeB[i], cr.edgeA[1], cA, cB, transA, transB);
- }
- else if (dot > (2.0f * cB.CylinderHalfHeight()))
- {
- TestCylinderVertVert(result, cr.edgeB[i], cr.edgeA[0], cA, cB, transA, transB);
- }
- else
- {
- TestCylinderVertEdge(result, cr.edgeA[0], cr.edgeA[1], cr.edgeB[i], cA, cB, transA, transB, false);
- }
- }
-}
-
-
-class TestMainLoop : public MainLoop {
-
- RID meshA;
- RID meshB;
- RID poly;
- RID instance;
- RID camera;
- RID viewport;
- RID boxA;
- RID boxB;
- RID scenario;
-
- Transform rot_a;
- Transform rot_b;
-
- bool quit;
-public:
- virtual void input_event(const InputEvent& p_event) {
-
- if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&BUTTON_MASK_LEFT) {
-
- rot_b.origin.y+=-p_event.mouse_motion.relative_y/100.0;
- rot_b.origin.x+=p_event.mouse_motion.relative_x/100.0;
- }
- if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&BUTTON_MASK_MIDDLE) {
-
- //rot_b.origin.x+=-p_event.mouse_motion.relative_y/100.0;
- rot_b.origin.z+=p_event.mouse_motion.relative_x/100.0;
- }
- if (p_event.type==InputEvent::MOUSE_MOTION && p_event.mouse_motion.button_mask&BUTTON_MASK_RIGHT) {
-
- float rot_x=-p_event.mouse_motion.relative_y/100.0;
- float rot_y=p_event.mouse_motion.relative_x/100.0;
- rot_b.basis = rot_b.basis * Matrix3(Vector3(1,0,0),rot_x) * Matrix3(Vector3(0,1,0),rot_y);
- }
-
- }
- virtual void request_quit() {
-
- quit=true;
- }
- virtual void init() {
-
- VisualServer *vs=VisualServer::get_singleton();
-
- camera = vs->camera_create();
-
- viewport = vs->viewport_create();
- vs->viewport_attach_to_screen(viewport);
- vs->viewport_attach_camera( viewport, camera );
- vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,0,3 ) ) );
-
- /* CONVEX SHAPE */
-
- DVector<Plane> cylinder_planes = Geometry::build_cylinder_planes(0.5,2,9,Vector3::AXIS_Y);
- RID cylinder_material = vs->fixed_material_create();
- vs->fixed_material_set_param( cylinder_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.8,0.2,0.9));
- vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_ONTOP,true);
- //vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_WIREFRAME,true);
- vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_DOUBLE_SIDED,true);
- vs->material_set_flag( cylinder_material, VisualServer::MATERIAL_FLAG_UNSHADED,true);
-
- RID cylinder_mesh = vs->mesh_create();
- Geometry::MeshData cylinder_data = Geometry::build_convex_mesh(cylinder_planes);
- vs->mesh_add_surface_from_mesh_data(cylinder_mesh,cylinder_data);
- vs->mesh_surface_set_material( cylinder_mesh, 0, cylinder_material );
-
- meshA=vs->instance_create2(cylinder_mesh,scenario);
- meshB=vs->instance_create2(cylinder_mesh,scenario);
- boxA=vs->instance_create2(vs->get_test_cube(),scenario);
- boxB=vs->instance_create2(vs->get_test_cube(),scenario);
-
- /*
- RID lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_RADIUS, 80 );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ATTENUATION, 1 );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ENERGY, 1.5 );
- light = vs->instance_create2( lightaux );
- */
- RID 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_shadow( lightaux, true );
- vs->instance_create2( lightaux,scenario );
-
- //rot_a=Transform(Matrix3(Vector3(1,0,0),Math_PI/2.0),Vector3());
- rot_b=Transform(Matrix3(),Vector3(2,0,0));
-
- //rot_x=0;
- //rot_y=0;
- quit=false;
- }
- virtual bool idle(float p_time) {
-
- VisualServer *vs=VisualServer::get_singleton();
-
- vs->instance_set_transform(meshA,rot_a);
- vs->instance_set_transform(meshB,rot_b);
-
-
- neCollisionResult res;
- TConvex a;
- a.radius=0.5;
- a.half_height=1;
- Cylinder2CylinderTest(res,a,rot_a,a,rot_b);
- if (res.penetrate) {
-
- Matrix3 scale;
- scale.scale(Vector3(0.1,0.1,0.1));
- vs->instance_set_transform(boxA,Transform(scale,res.contactA));
- vs->instance_set_transform(boxB,Transform(scale,res.contactB));
- print_line("depth: "+rtos(res.depth));
- } else {
-
- Matrix3 scale;
- scale.scale(Vector3());
- vs->instance_set_transform(boxA,Transform(scale,res.contactA));
- vs->instance_set_transform(boxB,Transform(scale,res.contactB));
-
- }
- print_line("collided: "+itos(res.penetrate));
-
- return false;
- }
-
-
- virtual bool iteration(float p_time) {
-
-
-
- return quit;
- }
- virtual void finish() {
-
- }
-
-};
-
-
-MainLoop* test() {
-
- return memnew( TestMainLoop );
-
-}
-
-}
-
-
-
diff --git a/bin/tests/test_misc.h b/bin/tests/test_misc.h
deleted file mode 100644
index 55608f6a0e..0000000000
--- a/bin/tests/test_misc.h
+++ /dev/null
@@ -1,40 +0,0 @@
-/*************************************************************************/
-/* test_misc.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef TEST_MISC_H
-#define TEST_MISC_H
-
-#include "os/main_loop.h"
-
-namespace TestMisc {
-
-MainLoop* test();
-
-}
-
-#endif
diff --git a/bin/tests/test_particles.cpp b/bin/tests/test_particles.cpp
deleted file mode 100644
index 23a4b9e635..0000000000
--- a/bin/tests/test_particles.cpp
+++ /dev/null
@@ -1,121 +0,0 @@
-/*************************************************************************/
-/* test_particles.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "test_particles.h"
-#include "servers/visual_server.h"
-#include "os/main_loop.h"
-#include "math_funcs.h"
-#include "print_string.h"
-
-namespace TestParticles {
-
-
-class TestMainLoop : public MainLoop {
-
- RID particles;
- RID instance;
- RID camera;
- RID viewport;
- RID light;
- RID scenario;
-
- struct InstanceInfo {
-
- RID instance;
- Transform base;
- Vector3 rot_axis;
- };
-
- List<InstanceInfo> instances;
-
- float ofs;
- bool quit;
-public:
- virtual void input_event(const InputEvent& p_event) {
-
-
- }
- virtual void request_quit() {
-
- quit=true;
- }
- virtual void init() {
-
- VisualServer *vs=VisualServer::get_singleton();
- particles = vs->particles_create();
- vs->particles_set_amount(particles,1000);
-
- instance = vs->instance_create2(particles,scenario);
-
-
- camera = vs->camera_create();
-
-// vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
- viewport = vs->viewport_create();
- vs->viewport_attach_camera( viewport, camera );
- vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,0,20 ) ) );
- /*
- RID lightaux = vs->light_create( VisualServer::LIGHT_OMNI );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_RADIUS, 80 );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ATTENUATION, 1 );
- vs->light_set_var( lightaux, VisualServer::LIGHT_VAR_ENERGY, 1.5 );
- light = vs->instance_create2( lightaux );
- */
- RID lightaux = vs->light_create( VisualServer::LIGHT_DIRECTIONAL );
- // vs->light_set_color( lightaux, VisualServer::LIGHT_COLOR_AMBIENT, Color(0.0,0.0,0.0) );
- light = vs->instance_create2( lightaux, scenario );
-
- ofs=0;
- quit=false;
- }
- virtual bool idle(float p_time) {
- return false;
- }
-
-
- virtual bool iteration(float p_time) {
-
-// VisualServer *vs=VisualServer::get_singleton();
-
- ofs+=p_time;
- return quit;
- }
- virtual void finish() {
-
- }
-
-};
-
-
-MainLoop* test() {
-
- return memnew( TestMainLoop );
-
-}
-
-}
diff --git a/bin/tests/test_particles.h b/bin/tests/test_particles.h
deleted file mode 100644
index e95637a4e6..0000000000
--- a/bin/tests/test_particles.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*************************************************************************/
-/* test_particles.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef TEST_PARTICLES_H
-#define TEST_PARTICLES_H
-
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-#include "os/main_loop.h"
-
-namespace TestParticles {
-
-MainLoop* test();
-
-}
-
-#endif
diff --git a/bin/tests/test_physics.cpp b/bin/tests/test_physics.cpp
index f202d0dda1..3a8ca65734 100644
--- a/bin/tests/test_physics.cpp
+++ b/bin/tests/test_physics.cpp
@@ -138,10 +138,6 @@ protected:
/* SPHERE SHAPE */
RID sphere_mesh = vs->make_sphere_mesh(10,20,0.5);
- RID sphere_material = vs->fixed_material_create();
- //vs->material_set_flag( sphere_material, VisualServer::MATERIAL_FLAG_WIREFRAME, true );
- vs->fixed_material_set_param( sphere_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.7,0.8,3.0) );
- vs->mesh_surface_set_material( sphere_mesh, 0, sphere_material );
type_mesh_map[PhysicsServer::SHAPE_SPHERE]=sphere_mesh;
RID sphere_shape=ps->shape_create(PhysicsServer::SHAPE_SPHERE);
@@ -151,12 +147,9 @@ protected:
/* BOX SHAPE */
DVector<Plane> box_planes = Geometry::build_box_planes(Vector3(0.5,0.5,0.5));
- RID box_material = vs->fixed_material_create();
- vs->fixed_material_set_param( box_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(1.0,0.2,0.2) );
RID box_mesh = vs->mesh_create();
Geometry::MeshData box_data = Geometry::build_convex_mesh(box_planes);
vs->mesh_add_surface_from_mesh_data(box_mesh,box_data);
- vs->mesh_surface_set_material( box_mesh, 0, box_material );
type_mesh_map[PhysicsServer::SHAPE_BOX]=box_mesh;
RID box_shape=ps->shape_create(PhysicsServer::SHAPE_BOX);
@@ -167,13 +160,11 @@ protected:
/* CAPSULE SHAPE */
DVector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5,0.7,12,Vector3::AXIS_Z);
- RID capsule_material = vs->fixed_material_create();
- vs->fixed_material_set_param( capsule_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.3,0.4,1.0) );
RID capsule_mesh = vs->mesh_create();
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh,capsule_data);
- vs->mesh_surface_set_material( capsule_mesh, 0, capsule_material );
+
type_mesh_map[PhysicsServer::SHAPE_CAPSULE]=capsule_mesh;
RID capsule_shape=ps->shape_create(PhysicsServer::SHAPE_CAPSULE);
@@ -186,14 +177,12 @@ protected:
/* CONVEX SHAPE */
DVector<Plane> convex_planes = Geometry::build_cylinder_planes(0.5,0.7,5,Vector3::AXIS_Z);
- RID convex_material = vs->fixed_material_create();
- vs->fixed_material_set_param( convex_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(0.8,0.2,0.9));
RID convex_mesh = vs->mesh_create();
Geometry::MeshData convex_data = Geometry::build_convex_mesh(convex_planes);
QuickHull::build(convex_data.vertices,convex_data);
vs->mesh_add_surface_from_mesh_data(convex_mesh,convex_data);
- vs->mesh_surface_set_material( convex_mesh, 0, convex_material );
+
type_mesh_map[PhysicsServer::SHAPE_CONVEX_POLYGON]=convex_mesh;
RID convex_shape=ps->shape_create(PhysicsServer::SHAPE_CONVEX_POLYGON);
@@ -223,11 +212,9 @@ protected:
d.resize(VS::ARRAY_MAX);
d[VS::ARRAY_VERTEX]=p_faces;
d[VS::ARRAY_NORMAL]=normals;
- vs->mesh_add_surface(trimesh_mesh, VS::PRIMITIVE_TRIANGLES, d );
- RID trimesh_mat = vs->fixed_material_create();
- vs->fixed_material_set_param( trimesh_mat, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(1.0,0.5,0.8));
+ vs->mesh_add_surface_from_arrays(trimesh_mesh, VS::PRIMITIVE_TRIANGLES, d );
//vs->material_set_flag( trimesh_mat, VisualServer::MATERIAL_FLAG_UNSHADED,true);
- vs->mesh_surface_set_material( trimesh_mesh, 0, trimesh_mat );
+
RID triins = vs->instance_create2(trimesh_mesh,scenario);
@@ -464,7 +451,7 @@ public:
}
virtual bool iteration(float p_time) {
- if (mover) {
+ if (mover.is_valid()) {
static float joy_speed = 10;
PhysicsServer * ps = PhysicsServer::get_singleton();
Transform t = ps->body_get_state(mover,PhysicsServer::BODY_STATE_TRANSFORM);
@@ -548,15 +535,10 @@ public:
DVector<Plane> capsule_planes = Geometry::build_capsule_planes(0.5,1,12,5,Vector3::AXIS_Y);
- RID capsule_material = vs->fixed_material_create();
-
- vs->fixed_material_set_param( capsule_material, VisualServer::FIXED_MATERIAL_PARAM_DIFFUSE, Color(1,1,1) );
-
RID capsule_mesh = vs->mesh_create();
Geometry::MeshData capsule_data = Geometry::build_convex_mesh(capsule_planes);
vs->mesh_add_surface_from_mesh_data(capsule_mesh,capsule_data);
- vs->mesh_surface_set_material( capsule_mesh, 0, capsule_material );
type_mesh_map[PhysicsServer::SHAPE_CAPSULE]=capsule_mesh;
RID capsule_shape=ps->shape_create(PhysicsServer::SHAPE_CAPSULE);
diff --git a/bin/tests/test_physics_2d.cpp b/bin/tests/test_physics_2d.cpp
index 845e20b6c3..f369c361d3 100644
--- a/bin/tests/test_physics_2d.cpp
+++ b/bin/tests/test_physics_2d.cpp
@@ -85,7 +85,7 @@ class TestPhysics2DMainLoop : public MainLoop {
}
}
- Image image(32,2,0,Image::FORMAT_GRAYSCALE_ALPHA,pixels);
+ Image image(32,2,0,Image::FORMAT_LA8,pixels);
body_shape_data[Physics2DServer::SHAPE_SEGMENT].image=vs->texture_create_from_image(image);
@@ -113,7 +113,7 @@ class TestPhysics2DMainLoop : public MainLoop {
}
}
- Image image(32,32,0,Image::FORMAT_GRAYSCALE_ALPHA,pixels);
+ Image image(32,32,0,Image::FORMAT_LA8,pixels);
body_shape_data[Physics2DServer::SHAPE_CIRCLE].image=vs->texture_create_from_image(image);
@@ -141,7 +141,7 @@ class TestPhysics2DMainLoop : public MainLoop {
}
}
- Image image(32,32,0,Image::FORMAT_GRAYSCALE_ALPHA,pixels);
+ Image image(32,32,0,Image::FORMAT_LA8,pixels);
body_shape_data[Physics2DServer::SHAPE_RECTANGLE].image=vs->texture_create_from_image(image);
@@ -173,7 +173,7 @@ class TestPhysics2DMainLoop : public MainLoop {
}
}
- Image image(32,64,0,Image::FORMAT_GRAYSCALE_ALPHA,pixels);
+ Image image(32,64,0,Image::FORMAT_LA8,pixels);
body_shape_data[Physics2DServer::SHAPE_CAPSULE].image=vs->texture_create_from_image(image);
@@ -381,7 +381,7 @@ public:
RID vp = vs->viewport_create();
canvas = vs->canvas_create();
vs->viewport_attach_canvas(vp,canvas);
- vs->viewport_attach_to_screen(vp);
+ vs->viewport_attach_to_screen(vp,Rect2(Vector2(),OS::get_singleton()->get_window_size()));
Matrix32 smaller;
//smaller.scale(Vector2(0.6,0.6));
//smaller.elements[2]=Vector2(100,0);
diff --git a/bin/tests/test_python.cpp b/bin/tests/test_python.cpp
deleted file mode 100644
index f4a3d7a3a2..0000000000
--- a/bin/tests/test_python.cpp
+++ /dev/null
@@ -1,56 +0,0 @@
-/*************************************************************************/
-/* test_python.cpp */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#include "test_python.h"
-
-#ifdef PYTHON_ENABLED
-
-#include "Python.h"
-#include "print_string.h"
-
-namespace TestPython {
-
-void test() {
-
- print_line("testing python");
- PyRun_SimpleString("import engine\n");
- PyRun_SimpleString("def test(self):\n\tprint(\"noway\")\n");
- PyRun_SimpleString("a=engine.ObjectPtr()\n");
- PyRun_SimpleString("a.noway(22,'hello')\n");
- PyRun_SimpleString("a.normalize()\n");
- PyRun_SimpleString("class Moch(engine.ObjectPtr):\n\tdef mooch(self):\n\t\tprint('muchi')\n");
- PyRun_SimpleString("b=Moch();\n");
- PyRun_SimpleString("b.mooch();\n");
- PyRun_SimpleString("b.meis();\n");
-
-
-}
-
-}
-
-#endif
diff --git a/bin/tests/test_python.h b/bin/tests/test_python.h
deleted file mode 100644
index 77e9603fe2..0000000000
--- a/bin/tests/test_python.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*************************************************************************/
-/* test_python.h */
-/*************************************************************************/
-/* This file is part of: */
-/* GODOT ENGINE */
-/* http://www.godotengine.org */
-/*************************************************************************/
-/* Copyright (c) 2007-2016 Juan Linietsky, Ariel Manzur. */
-/* */
-/* Permission is hereby granted, free of charge, to any person obtaining */
-/* a copy of this software and associated documentation files (the */
-/* "Software"), to deal in the Software without restriction, including */
-/* without limitation the rights to use, copy, modify, merge, publish, */
-/* distribute, sublicense, and/or sell copies of the Software, and to */
-/* permit persons to whom the Software is furnished to do so, subject to */
-/* the following conditions: */
-/* */
-/* The above copyright notice and this permission notice shall be */
-/* included in all copies or substantial portions of the Software. */
-/* */
-/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
-/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
-/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
-/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
-/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
-/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
-/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
-/*************************************************************************/
-#ifndef TEST_PYTHON_H
-#define TEST_PYTHON_H
-
-#ifdef PYTHON_ENABLED
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-namespace TestPython {
-
-void test();
-
-}
-
-#endif
-#endif
diff --git a/bin/tests/test_render.cpp b/bin/tests/test_render.cpp
index 9c3a287afa..b971d412aa 100644
--- a/bin/tests/test_render.cpp
+++ b/bin/tests/test_render.cpp
@@ -173,7 +173,10 @@ public:
// vs->camera_set_perspective( camera, 60.0,0.1, 100.0 );
viewport = vs->viewport_create();
- vs->viewport_attach_to_screen(viewport);
+ Size2i screen_size = OS::get_singleton()->get_window_size();
+ vs->viewport_set_size(viewport,screen_size.x,screen_size.y);
+ vs->viewport_attach_to_screen(viewport,Rect2(Vector2(),screen_size));
+ vs->viewport_set_active(viewport,true);
vs->viewport_attach_camera( viewport, camera );
vs->viewport_set_scenario( viewport, scenario );
vs->camera_set_transform(camera, Transform( Matrix3(), Vector3(0,3,30 ) ) );
@@ -192,7 +195,7 @@ public:
//*
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, Color(1.0,1.0,1.0) );
//vs->light_set_shadow( lightaux, true );
light = vs->instance_create2( lightaux, scenario );
Transform lla;
@@ -205,8 +208,8 @@ public:
//*
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_color( lightaux, Color(1.0,1.0,0.0) );
+ vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_RANGE, 4 );
vs->light_set_param( lightaux, VisualServer::LIGHT_PARAM_ENERGY, 8 );
//vs->light_set_shadow( lightaux, true );
//light = vs->instance_create( lightaux );
diff --git a/bin/tests/test_shader_lang.cpp b/bin/tests/test_shader_lang.cpp
index 9c0075c47d..1a677bcbe2 100644
--- a/bin/tests/test_shader_lang.cpp
+++ b/bin/tests/test_shader_lang.cpp
@@ -37,7 +37,7 @@
#include "scene/gui/text_edit.h"
#include "print_string.h"
#include "servers/visual/shader_language.h"
-#include "drivers/gles2/shader_compiler_gles2.h"
+//#include "drivers/gles2/shader_compiler_gles2.h"
typedef ShaderLanguage SL;
@@ -57,50 +57,54 @@ static String _mktab(int p_level) {
static String _typestr(SL::DataType p_type) {
- switch(p_type) {
+ return ShaderLanguage::get_datatype_name(p_type);
+
+ return "";
+}
+
+
+static String _prestr(SL::DataPrecision p_pres) {
- case SL::TYPE_VOID: return "void";
- case SL::TYPE_BOOL: return "bool";
- case SL::TYPE_FLOAT: return "float";
- case SL::TYPE_VEC2: return "vec2";
- case SL::TYPE_VEC3: return "vec3";
- case SL::TYPE_VEC4: return "vec4";
- case SL::TYPE_MAT3: return "mat3";
- case SL::TYPE_MAT4: return "mat4";
- case SL::TYPE_TEXTURE: return "texture";
- case SL::TYPE_CUBEMAP: return "cubemap";
- default: {}
- }
+ switch(p_pres) {
+ case SL::PRECISION_LOWP: return "lowp ";
+ case SL::PRECISION_MEDIUMP: return "mediump ";
+ case SL::PRECISION_HIGHP: return "highp ";
+ case SL::PRECISION_DEFAULT: return "";
+ }
return "";
}
+
static String _opstr(SL::Operator p_op) {
- switch(p_op) {
- case SL::OP_ASSIGN: return "=";
- case SL::OP_ADD: return "+";
- case SL::OP_SUB: return "-";
- case SL::OP_MUL: return "*";
- case SL::OP_DIV: return "/";
- case SL::OP_ASSIGN_ADD: return "+=";
- case SL::OP_ASSIGN_SUB: return "-=";
- case SL::OP_ASSIGN_MUL: return "*=";
- case SL::OP_ASSIGN_DIV: return "/=";
- case SL::OP_NEG: return "-";
- case SL::OP_NOT: return "!";
- case SL::OP_CMP_EQ: return "==";
- case SL::OP_CMP_NEQ: return "!=";
- case SL::OP_CMP_LEQ: return "<=";
- case SL::OP_CMP_GEQ: return ">=";
- case SL::OP_CMP_LESS: return "<";
- case SL::OP_CMP_GREATER: return ">";
- case SL::OP_CMP_OR: return "||";
- case SL::OP_CMP_AND: return "&&";
- default: return "";
- }
+ return ShaderLanguage::get_operator_text(p_op);
- return "";
+
+}
+
+
+static String get_constant_text(SL::DataType p_type, const Vector<SL::ConstantNode::Value>& p_values) {
+
+ switch(p_type) {
+ case SL::TYPE_BOOL: return p_values[0].boolean?"true":"false";
+ case SL::TYPE_BVEC2: return String()+"bvec2("+(p_values[0].boolean?"true":"false")+(p_values[1].boolean?"true":"false")+")";
+ case SL::TYPE_BVEC3: return String()+"bvec3("+(p_values[0].boolean?"true":"false")+","+(p_values[1].boolean?"true":"false")+","+(p_values[2].boolean?"true":"false")+")";
+ case SL::TYPE_BVEC4: return String()+"bvec4("+(p_values[0].boolean?"true":"false")+","+(p_values[1].boolean?"true":"false")+","+(p_values[2].boolean?"true":"false")+","+(p_values[3].boolean?"true":"false")+")";
+ case SL::TYPE_INT: return rtos(p_values[0].sint);
+ case SL::TYPE_IVEC2: return String()+"ivec2("+rtos(p_values[0].sint)+","+rtos(p_values[1].sint)+")";
+ case SL::TYPE_IVEC3: return String()+"ivec3("+rtos(p_values[0].sint)+","+rtos(p_values[1].sint)+","+rtos(p_values[2].sint)+")";
+ case SL::TYPE_IVEC4: return String()+"ivec4("+rtos(p_values[0].sint)+","+rtos(p_values[1].sint)+","+rtos(p_values[2].sint)+","+rtos(p_values[3].sint)+")";
+ case SL::TYPE_UINT: return rtos(p_values[0].real);
+ case SL::TYPE_UVEC2: return String()+"uvec2("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+")";
+ case SL::TYPE_UVEC3: return String()+"uvec3("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+","+rtos(p_values[2].real)+")";
+ case SL::TYPE_UVEC4: return String()+"uvec4("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+","+rtos(p_values[2].real)+","+rtos(p_values[3].real)+")";
+ case SL::TYPE_FLOAT: return rtos(p_values[0].real);
+ case SL::TYPE_VEC2: return String()+"vec2("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+")";
+ case SL::TYPE_VEC3: return String()+"vec3("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+","+rtos(p_values[2].real)+")";
+ case SL::TYPE_VEC4: return String()+"vec4("+rtos(p_values[0].real)+","+rtos(p_values[1].real)+","+rtos(p_values[2].real)+","+rtos(p_values[3].real)+")";
+ default: ERR_FAIL_V(String());
+ }
}
static String dump_node_code(SL::Node *p_node,int p_level) {
@@ -109,18 +113,48 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
switch(p_node->type) {
- case SL::Node::TYPE_PROGRAM: {
+ case SL::Node::TYPE_SHADER: {
- SL::ProgramNode *pnode=(SL::ProgramNode*)p_node;
+ SL::ShaderNode *pnode=(SL::ShaderNode*)p_node;
- for(Map<StringName,SL::Uniform>::Element *E=pnode->uniforms.front();E;E=E->next()) {
+ for(Map<StringName,SL::ShaderNode::Uniform>::Element *E=pnode->uniforms.front();E;E=E->next()) {
String ucode="uniform ";
- ucode+=_typestr(E->get().type)+"="+String(E->get().default_value)+"\n";
- code+=ucode;
+ ucode+=_prestr(E->get().precission);
+ ucode+=_typestr(E->get().type);
+ ucode+=" "+String(E->key());
+
+ if (E->get().default_value.size()) {
+ ucode+=" = "+get_constant_text(E->get().type,E->get().default_value);
+ }
+
+ static const char*hint_name[SL::ShaderNode::Uniform::HINT_MAX]={
+ "",
+ "color",
+ "range",
+ "albedo",
+ "normal",
+ "black",
+ "white"
+ };
+
+ if (E->get().hint)
+ ucode+=" : "+String(hint_name[E->get().hint]);
+
+ code+=ucode+"\n";
}
+ for(Map<StringName,SL::ShaderNode::Varying>::Element *E=pnode->varyings.front();E;E=E->next()) {
+
+ String vcode="varying ";
+ vcode+=_prestr(E->get().precission);
+ vcode+=_typestr(E->get().type);
+ vcode+=" "+String(E->key());
+
+ code+=vcode+"\n";
+
+ }
for(int i=0;i<pnode->functions.size();i++) {
SL::FunctionNode *fnode=pnode->functions[i].function;
@@ -131,16 +165,15 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
if (i>0)
header+=", ";
- header+=_typestr(fnode->arguments[i].type)+" "+fnode->arguments[i].name;
+ header+=_prestr(fnode->arguments[i].precision)+_typestr(fnode->arguments[i].type)+" "+fnode->arguments[i].name;
}
- header+=") {\n";
+ header+=")\n";
code+=header;
code+=dump_node_code(fnode->body,p_level+1);
- code+="}\n";
}
- code+=dump_node_code(pnode->body,p_level);
+ //code+=dump_node_code(pnode->body,p_level);
} break;
case SL::Node::TYPE_FUNCTION: {
@@ -149,15 +182,23 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
SL::BlockNode *bnode=(SL::BlockNode*)p_node;
//variables
- for(Map<StringName,SL::DataType>::Element *E=bnode->variables.front();E;E=E->next()) {
+ code+=_mktab(p_level-1)+"{\n";
+ for(Map<StringName,SL::BlockNode::Variable>::Element *E=bnode->variables.front();E;E=E->next()) {
- code+=_mktab(p_level)+_typestr(E->value())+" "+E->key()+";\n";
+ code+=_mktab(p_level)+_prestr(E->get().precision)+_typestr(E->get().type)+" "+E->key()+";\n";
}
for(int i=0;i<bnode->statements.size();i++) {
- code+=_mktab(p_level)+dump_node_code(bnode->statements[i],p_level)+";\n";
+ String scode = dump_node_code(bnode->statements[i],p_level);
+
+ if (bnode->statements[i]->type==SL::Node::TYPE_CONTROL_FLOW || bnode->statements[i]->type==SL::Node::TYPE_CONTROL_FLOW) {
+ code+=scode; //use directly
+ } else {
+ code+=_mktab(p_level)+scode+";\n";
+ }
}
+ code+=_mktab(p_level-1)+"}\n";
} break;
@@ -168,18 +209,7 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
} break;
case SL::Node::TYPE_CONSTANT: {
SL::ConstantNode *cnode=(SL::ConstantNode*)p_node;
- switch(cnode->datatype) {
-
-
- case SL::TYPE_BOOL: code=cnode->value.operator bool()?"true":"false"; break;
- case SL::TYPE_FLOAT: code=cnode->value; break;
- case SL::TYPE_VEC2: { Vector2 v = cnode->value; code="vec2("+rtos(v.x)+", "+rtos(v.y)+")"; } break;
- case SL::TYPE_VEC3: { Vector3 v = cnode->value; code="vec3("+rtos(v.x)+", "+rtos(v.y)+", "+rtos(v.z)+")"; } break;
- case SL::TYPE_VEC4: { Plane v = cnode->value; code="vec4("+rtos(v.normal.x)+", "+rtos(v.normal.y)+", "+rtos(v.normal.z)+", "+rtos(v.d)+")"; } break;
- case SL::TYPE_MAT3: { Matrix3 x = cnode->value; code="mat3( vec3("+rtos(x.get_axis(0).x)+", "+rtos(x.get_axis(0).y)+", "+rtos(x.get_axis(0).z)+"), vec3("+rtos(x.get_axis(1).x)+", "+rtos(x.get_axis(1).y)+", "+rtos(x.get_axis(1).z)+"), vec3("+rtos(x.get_axis(2).x)+", "+rtos(x.get_axis(2).y)+", "+rtos(x.get_axis(2).z)+"))"; } break;
- case SL::TYPE_MAT4: { Transform x = cnode->value; code="mat4( vec3("+rtos(x.basis.get_axis(0).x)+", "+rtos(x.basis.get_axis(0).y)+", "+rtos(x.basis.get_axis(0).z)+"), vec3("+rtos(x.basis.get_axis(1).x)+", "+rtos(x.basis.get_axis(1).y)+", "+rtos(x.basis.get_axis(1).z)+"), vec3("+rtos(x.basis.get_axis(2).x)+", "+rtos(x.basis.get_axis(2).y)+", "+rtos(x.basis.get_axis(2).z)+"), vec3("+rtos(x.origin.x)+", "+rtos(x.origin.y)+", "+rtos(x.origin.z)+"))"; } break;
- default: code="<error: "+Variant::get_type_name(cnode->value.get_type())+" ("+itos(cnode->datatype)+">";
- }
+ return get_constant_text(cnode->datatype,cnode->values);
} break;
case SL::Node::TYPE_OPERATOR: {
@@ -193,28 +223,25 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
case SL::OP_ASSIGN_SUB:
case SL::OP_ASSIGN_MUL:
case SL::OP_ASSIGN_DIV:
+ case SL::OP_ASSIGN_SHIFT_LEFT:
+ case SL::OP_ASSIGN_SHIFT_RIGHT:
+ case SL::OP_ASSIGN_MOD:
+ case SL::OP_ASSIGN_BIT_AND:
+ case SL::OP_ASSIGN_BIT_OR:
+ case SL::OP_ASSIGN_BIT_XOR:
code=dump_node_code(onode->arguments[0],p_level)+_opstr(onode->op)+dump_node_code(onode->arguments[1],p_level);
break;
-
- case SL::OP_ADD:
- case SL::OP_SUB:
- case SL::OP_MUL:
- case SL::OP_DIV:
- case SL::OP_CMP_EQ:
- case SL::OP_CMP_NEQ:
- case SL::OP_CMP_LEQ:
- case SL::OP_CMP_GEQ:
- case SL::OP_CMP_LESS:
- case SL::OP_CMP_GREATER:
- case SL::OP_CMP_OR:
- case SL::OP_CMP_AND:
-
- code="("+dump_node_code(onode->arguments[0],p_level)+_opstr(onode->op)+dump_node_code(onode->arguments[1],p_level)+")";
- break;
- case SL::OP_NEG:
+ case SL::OP_BIT_INVERT:
+ case SL::OP_NEGATE:
case SL::OP_NOT:
+ case SL::OP_DECREMENT:
+ case SL::OP_INCREMENT:
code=_opstr(onode->op)+dump_node_code(onode->arguments[0],p_level);
break;
+ case SL::OP_POST_DECREMENT:
+ case SL::OP_POST_INCREMENT:
+ code=dump_node_code(onode->arguments[0],p_level)+_opstr(onode->op);
+ break;
case SL::OP_CALL:
case SL::OP_CONSTRUCT:
code=dump_node_code(onode->arguments[0],p_level)+"(";
@@ -225,7 +252,12 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
}
code+=")";
break;
- default: {}
+ default: {
+
+ code="("+dump_node_code(onode->arguments[0],p_level)+_opstr(onode->op)+dump_node_code(onode->arguments[1],p_level)+")";
+ break;
+
+ }
}
} break;
@@ -233,20 +265,19 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
SL::ControlFlowNode *cfnode=(SL::ControlFlowNode*)p_node;
if (cfnode->flow_op==SL::FLOW_OP_IF) {
- code+="if ("+dump_node_code(cfnode->statements[0],p_level)+") {\n";
- code+=dump_node_code(cfnode->statements[1],p_level+1);
- if (cfnode->statements.size()==3) {
+ code+=_mktab(p_level)+"if ("+dump_node_code(cfnode->expressions[0],p_level)+")\n";
+ code+=dump_node_code(cfnode->blocks[0],p_level+1);
+ if (cfnode->blocks.size()==2) {
- code+="} else {\n";
- code+=dump_node_code(cfnode->statements[2],p_level+1);
+ code+=_mktab(p_level)+"else\n";
+ code+=dump_node_code(cfnode->blocks[1],p_level+1);
}
- code+="}\n";
} else if (cfnode->flow_op==SL::FLOW_OP_RETURN) {
- if (cfnode->statements.size()) {
- code="return "+dump_node_code(cfnode->statements[0],p_level);
+ if (cfnode->blocks.size()) {
+ code="return "+dump_node_code(cfnode->blocks[0],p_level);
} else {
code="return";
}
@@ -264,16 +295,14 @@ static String dump_node_code(SL::Node *p_node,int p_level) {
}
-static Error recreate_code(void *p_str,SL::ProgramNode *p_program) {
+static Error recreate_code(void *p_str,SL::ShaderNode *p_program) {
+
- print_line("recr");
String *str=(String*)p_str;
*str=dump_node_code(p_program,0);
return OK;
-
-
}
@@ -283,6 +312,7 @@ MainLoop* test() {
if (cmdlargs.empty()) {
//try editor!
+ print_line("usage: godot -test shader_lang <shader>");
return NULL;
}
@@ -303,38 +333,29 @@ MainLoop* test() {
code+=c;
}
- int errline;
- int errcol;
- String error;
- print_line(SL::lex_debug(code));
- Error err = SL::compile(code,ShaderLanguage::SHADER_MATERIAL_FRAGMENT,NULL,NULL,&error,&errline,&errcol);
+ SL sl;
+ print_line("tokens:\n\n"+sl.token_debug(code));
- if (err) {
+ Map<StringName,Map<StringName,SL::DataType> > dt;
+ dt["fragment"]["ALBEDO"]=SL::TYPE_VEC3;
- print_line("Error: "+itos(errline)+":"+itos(errcol)+" "+error);
- return NULL;
- }
+ Set<String> rm;
+ rm.insert("popo");
- print_line("Compile OK! - pretty printing");
+ Error err = sl.compile(code,dt,rm);
- String rcode;
- err = SL::compile(code,ShaderLanguage::SHADER_MATERIAL_FRAGMENT,recreate_code,&rcode,&error,&errline,&errcol);
+ if (err) {
- if (!err) {
- print_line(rcode);
+ print_line("Error at line: "+rtos(sl.get_error_line())+": "+sl.get_error_text());
+ return NULL;
+ } else {
+ String code;
+ recreate_code(&code,sl.get_shader());
+ print_line("code:\n\n"+code);
}
- ShaderCompilerGLES2 comp;
- String codeline,globalsline;
- SL::VarInfo vi;
- vi.name="mongs";
- vi.type=SL::TYPE_VEC3;
-
-
- ShaderCompilerGLES2::Flags fl;
- comp.compile(code,ShaderLanguage::SHADER_MATERIAL_FRAGMENT,codeline,globalsline,fl);
-
return NULL;
}
+
}