diff options
| author | Juan Linietsky | 2016-09-06 19:31:44 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2016-09-06 19:31:44 -0300 |
| commit | f31400c04d49aee2d2433b5404e2f17cf54da3a1 (patch) | |
| tree | 2d57cf437cce3978b834583334f1b453f4acfa2c /scene/3d/immediate_geometry.cpp | |
| parent | 23ababdcd57079182172b1c5467fcd6bb0f303d3 (diff) | |
| download | godot-f31400c04d49aee2d2433b5404e2f17cf54da3a1.tar.gz godot-f31400c04d49aee2d2433b5404e2f17cf54da3a1.tar.zst godot-f31400c04d49aee2d2433b5404e2f17cf54da3a1.zip | |
Diffstat (limited to 'scene/3d/immediate_geometry.cpp')
| -rw-r--r-- | scene/3d/immediate_geometry.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp index e83fa69b4..c9319904b 100644 --- a/scene/3d/immediate_geometry.cpp +++ b/scene/3d/immediate_geometry.cpp @@ -102,7 +102,7 @@ DVector<Face3> ImmediateGeometry::get_faces(uint32_t p_usage_flags) const { -void ImmediateGeometry::add_sphere(int p_lats,int p_lons,float p_radius) { +void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool p_add_uv) { for(int i = 1; i <= p_lats; i++) { double lat0 = Math_PI * (-0.5 + (double) (i - 1) / p_lats); @@ -132,6 +132,10 @@ void ImmediateGeometry::add_sphere(int p_lats,int p_lons,float p_radius) { }; #define ADD_POINT(m_idx)\ + if (p_add_uv) {\ + set_uv(Vector2(Math::atan2(v[m_idx].x,v[m_idx].z)/Math_PI * 0.5+0.5,v[m_idx].y*0.5+0.5));\ + set_tangent(Plane(Vector3(-v[m_idx].z,v[m_idx].y,v[m_idx].x),1)); \ + }\ set_normal(v[m_idx]);\ add_vertex(v[m_idx]*p_radius); @@ -156,7 +160,7 @@ void ImmediateGeometry::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_uv","uv"),&ImmediateGeometry::set_uv); ObjectTypeDB::bind_method(_MD("set_uv2","uv"),&ImmediateGeometry::set_uv2); ObjectTypeDB::bind_method(_MD("add_vertex","pos"),&ImmediateGeometry::add_vertex); - ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius"),&ImmediateGeometry::add_sphere); + ObjectTypeDB::bind_method(_MD("add_sphere","lats","lons","radius","add_uv"),&ImmediateGeometry::add_sphere,DEFVAL(true)); ObjectTypeDB::bind_method(_MD("end"),&ImmediateGeometry::end); ObjectTypeDB::bind_method(_MD("clear"),&ImmediateGeometry::clear); |
