Browse Source

Update lovr.graphics.cylinder and sphere;

bjorn 6 years ago
parent
commit
4581d6bc5e
3 changed files with 170 additions and 87 deletions
  1. 117 42
      api/init.lua
  2. 49 29
      api/lovr/graphics/cylinder.lua
  3. 4 16
      api/lovr/graphics/sphere.lua

+ 117 - 42
api/init.lua

@@ -6981,45 +6981,145 @@ return {
             {
               arguments = {
                 {
-                  name = "x1",
+                  name = "x",
                   type = "number",
-                  description = "The x coordinate of the top of the cylinder."
+                  description = "The x coordinate of the cylinder.",
+                  default = "0"
                 },
                 {
-                  name = "y1",
+                  name = "y",
                   type = "number",
-                  description = "The y coordinate of the top of the cylinder."
+                  description = "The y coordinate of the cylinder.",
+                  default = "0"
                 },
                 {
-                  name = "z1",
+                  name = "z",
                   type = "number",
-                  description = "The z coordinate of the top of the cylinder."
+                  description = "The z coordinate of the cylinder.",
+                  default = "0"
                 },
                 {
-                  name = "x2",
+                  name = "length",
                   type = "number",
-                  description = "The x coordinate of the bottom of the cylinder."
+                  description = "The length of the cylinder, in meters.",
+                  default = "1"
                 },
                 {
-                  name = "y2",
+                  name = "angle",
+                  type = "number",
+                  description = "The rotation of the cylinder around its rotation axis, in radians.",
+                  default = "0"
+                },
+                {
+                  name = "ax",
                   type = "number",
-                  description = "The y coordinate of the bottom of the cylinder."
+                  description = "The x coordinate of the cylinder's axis of rotation.",
+                  default = "0"
                 },
                 {
-                  name = "z2",
+                  name = "ay",
+                  type = "number",
+                  description = "The y coordinate of the cylinder's axis of rotation.",
+                  default = "1"
+                },
+                {
+                  name = "az",
                   type = "number",
-                  description = "The z coordinate of the bottom of the cylinder."
+                  description = "The z coordinate of the cylinder's axis of rotation.",
+                  default = "0"
                 },
                 {
                   name = "r1",
                   type = "number",
-                  description = "The radius of the top of the cylinder.",
+                  description = "The radius of one end of the cylinder.",
                   default = "1"
                 },
                 {
                   name = "r2",
                   type = "number",
-                  description = "The radius of the bottom of the cylinder.",
+                  description = "The radius of the other end of the cylinder.",
+                  default = "1"
+                },
+                {
+                  name = "capped",
+                  type = "boolean",
+                  description = "Whether the top and bottom should be rendered.",
+                  default = "true"
+                },
+                {
+                  name = "segments",
+                  type = "number",
+                  description = "The number of radial segments to use for the cylinder.  If nil, the segment count is automatically determined from the radii.",
+                  default = "nil"
+                }
+              },
+              returns = {}
+            },
+            {
+              arguments = {
+                {
+                  name = "material",
+                  type = "Material",
+                  description = "The Material to apply to the cylinder."
+                },
+                {
+                  name = "x",
+                  type = "number",
+                  description = "The x coordinate of the cylinder.",
+                  default = "0"
+                },
+                {
+                  name = "y",
+                  type = "number",
+                  description = "The y coordinate of the cylinder.",
+                  default = "0"
+                },
+                {
+                  name = "z",
+                  type = "number",
+                  description = "The z coordinate of the cylinder.",
+                  default = "0"
+                },
+                {
+                  name = "length",
+                  type = "number",
+                  description = "The length of the cylinder, in meters.",
+                  default = "1"
+                },
+                {
+                  name = "angle",
+                  type = "number",
+                  description = "The rotation of the cylinder around its rotation axis, in radians.",
+                  default = "0"
+                },
+                {
+                  name = "ax",
+                  type = "number",
+                  description = "The x coordinate of the cylinder's axis of rotation.",
+                  default = "0"
+                },
+                {
+                  name = "ay",
+                  type = "number",
+                  description = "The y coordinate of the cylinder's axis of rotation.",
+                  default = "1"
+                },
+                {
+                  name = "az",
+                  type = "number",
+                  description = "The z coordinate of the cylinder's axis of rotation.",
+                  default = "0"
+                },
+                {
+                  name = "r1",
+                  type = "number",
+                  description = "The radius of one end of the cylinder.",
+                  default = "1"
+                },
+                {
+                  name = "r2",
+                  type = "number",
+                  description = "The radius of the other end of the cylinder.",
                   default = "1"
                 },
                 {
@@ -9946,9 +10046,9 @@ return {
             {
               arguments = {
                 {
-                  name = "texture",
-                  type = "Texture",
-                  description = "The Texture to apply to the sphere."
+                  name = "material",
+                  type = "Material",
+                  description = "The Material to apply to the sphere."
                 },
                 {
                   name = "x",
@@ -10000,31 +10100,6 @@ return {
                 }
               },
               returns = {}
-            },
-            {
-              arguments = {
-                {
-                  name = "transform",
-                  type = "Transform",
-                  description = "The sphere's transform."
-                }
-              },
-              returns = {}
-            },
-            {
-              arguments = {
-                {
-                  name = "texture",
-                  type = "Texture",
-                  description = "The Texture to apply to the sphere."
-                },
-                {
-                  name = "transform",
-                  type = "Transform",
-                  description = "The sphere's transform."
-                }
-              },
-              returns = {}
             }
           }
         },

+ 49 - 29
api/lovr/graphics/cylinder.lua

@@ -3,56 +3,66 @@ return {
   summary = 'Draw a cylinder.',
   description = 'Draws a cylinder.',
   arguments = {
-    {
-      name = 'x1',
+    material = {
+      type = 'Material',
+      description = 'The Material to apply to the cylinder.'
+    },
+    x = {
       type = 'number',
-      description = 'The x coordinate of the top of the cylinder.'
+      default = '0',
+      description = 'The x coordinate of the cylinder.'
     },
-    {
-      name = 'y1',
+    y = {
       type = 'number',
-      description = 'The y coordinate of the top of the cylinder.'
+      default = '0',
+      description = 'The y coordinate of the cylinder.'
     },
-    {
-      name = 'z1',
+    z = {
       type = 'number',
-      description = 'The z coordinate of the top of the cylinder.'
+      default = '0',
+      description = 'The z coordinate of the cylinder.'
     },
-    {
-      name = 'x2',
+    length = {
       type = 'number',
-      description = 'The x coordinate of the bottom of the cylinder.'
+      default = '1',
+      description = 'The length of the cylinder, in meters.'
     },
-    {
-      name = 'y2',
+    angle = {
       type = 'number',
-      description = 'The y coordinate of the bottom of the cylinder.'
+      default = '0',
+      description = 'The rotation of the cylinder around its rotation axis, in radians.'
     },
-    {
-      name = 'z2',
+    ax = {
       type = 'number',
-      description = 'The z coordinate of the bottom of the cylinder.'
+      default = '0',
+      description = 'The x coordinate of the cylinder\'s axis of rotation.'
     },
-    {
-      name = 'r1',
+    ay = {
       type = 'number',
       default = '1',
-      description = 'The radius of the top of the cylinder.'
+      description = 'The y coordinate of the cylinder\'s axis of rotation.'
     },
-    {
-      name = 'r2',
+    az = {
+      type = 'number',
+      default = '0',
+      description = 'The z coordinate of the cylinder\'s axis of rotation.'
+    },
+    r1 = {
       type = 'number',
       default = '1',
-      description = 'The radius of the bottom of the cylinder.'
+      description = 'The radius of one end of the cylinder.'
     },
-    {
-      name = 'capped',
+    r2 = {
+      type = 'number',
+      default = '1',
+      description = 'The radius of the other end of the cylinder.'
+    },
+    capped = {
       type = 'boolean',
       default = 'true',
       description = 'Whether the top and bottom should be rendered.'
     },
-    {
-      name = 'segments',
+    segments = {
       type = 'number',
       default = 'nil',
       description = [[
@@ -61,5 +71,15 @@ return {
       ]]
     }
   },
-  returns = {}
+  returns = {},
+  variants = {
+    {
+      arguments = { 'x', 'y', 'z', 'length', 'angle', 'ax', 'ay', 'az', 'r1', 'r2', 'capped', 'segments' },
+      returns = {}
+    },
+    {
+      arguments = { 'material', 'x', 'y', 'z', 'length', 'angle', 'ax', 'ay', 'az', 'r1', 'r2', 'capped', 'segments' },
+      returns = {}
+    }
+  }
 }

+ 4 - 16
api/lovr/graphics/sphere.lua

@@ -3,13 +3,9 @@ return {
   summary = 'Draw a sphere.',
   description = 'Draws a sphere.',
   arguments = {
-    texture = {
-      type = 'Texture',
-      description = 'The Texture to apply to the sphere.'
-    },
-    transform = {
-      type = 'Transform',
-      description = 'The sphere\'s transform.'
+    material = {
+      type = 'Material',
+      description = 'The Material to apply to the sphere.'
     },
     x = {
       type = 'number',
@@ -59,15 +55,7 @@ return {
       returns = {}
     },
     {
-      arguments = { 'texture', 'x', 'y', 'z', 'size', 'angle', 'ax', 'ay', 'az' },
-      returns = {}
-    },
-    {
-      arguments = { 'transform' },
-      returns = {}
-    },
-    {
-      arguments = { 'texture', 'transform' },
+      arguments = { 'material', 'x', 'y', 'z', 'size', 'angle', 'ax', 'ay', 'az' },
       returns = {}
     }
   }