From 7a10053fb75f33e024482216a9c4c3f89c314b35 Mon Sep 17 00:00:00 2001 From: Juju Adams Date: Sun, 6 Mar 2022 21:19:13 +0000 Subject: [PATCH] Adds quad/triangle test case --- objects/oScene/Create_0.gml | 26 +++++++++++++++++++ .../CardboardSpriteQuad.gml | 16 +++++++----- 2 files changed, 35 insertions(+), 7 deletions(-) diff --git a/objects/oScene/Create_0.gml b/objects/oScene/Create_0.gml index 72e3d9c..a03f82f 100644 --- a/objects/oScene/Create_0.gml +++ b/objects/oScene/Create_0.gml @@ -12,6 +12,32 @@ CardboardSpriteExt(sprHi, 1, 0, 160, 160, 5, 5, 0, 0, c_white, 1); CardboardSpriteExt(sprHi, 1, -160, 0, 160, 5, 5, 0, -90, c_white, 1); CardboardSpriteExt(sprHi, 1, 0, -160, 160, 5, 5, 0, 180, c_white, 1); +CardboardSpriteQuad(sprHi, 0, + -160, -800, 160, + 160, -800, 160, + -160, -480, 0, + 160, -480, 0, + c_aqua, 1); + +CardboardSpriteTriangle(sprHi, 0, + 160, -800, 160, 0, 0, + 480, -800, 160, 1, 0, + 160, -480, 0, 0, 1, + c_aqua, 1); + +CardboardSpriteTriangle(sprHi, 0, + 480, -800, 160, 1, 0, + 160, -480, 0, 0, 1, + 480, -480, 160, 1, 1, + c_aqua, 1); + +CardboardSpriteQuad(sprHi, 0, + 480, -480, 160, + 480, -160, 160, + 160, -480, 0, + 160, -160, 0, + c_aqua, 1); + model = CardboardModelEnd(); //Define a handy draw function that we can call from oRenderer later diff --git a/scripts/CardboardSpriteQuad/CardboardSpriteQuad.gml b/scripts/CardboardSpriteQuad/CardboardSpriteQuad.gml index 3798cad..98e33d3 100644 --- a/scripts/CardboardSpriteQuad/CardboardSpriteQuad.gml +++ b/scripts/CardboardSpriteQuad/CardboardSpriteQuad.gml @@ -16,8 +16,10 @@ /// @param x4 x-coordinate for the bottom-right corner of the texture /// @param y4 y-coordinate for the bottom-right corner of the texture /// @param z4 z-coordinate for the bottom-right corner of the texture +/// @param color Blend color for the sprite (c_white is "no blending") +/// @param alpha Blend alpha for the sprite (0 being transparent and 1 being 100% opacity) -function CardboardSpriteQuad(_sprite, _image, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4) +function CardboardSpriteQuad(_sprite, _image, _x1, _y1, _z1, _x2, _y2, _z2, _x3, _y3, _z3, _x4, _y4, _z4, _color, _alpha) { var _flooredImage = floor(max(0, _image)) mod sprite_get_number(_sprite); var _imageData = global.__cardboardTexturePageIndexMap[? __CARDBOARD_MAX_IMAGES*_sprite + _flooredImage]; @@ -40,13 +42,13 @@ function CardboardSpriteQuad(_sprite, _image, _x1, _y1, _z1, _x2, _y2, _z2, _x3, //Add this sprite to the vertex buffer var _vertexBuffer = global.__cardboardBatchVertexBuffer; - vertex_position_3d(_vertexBuffer, _x1, _y1, _z1); vertex_color(_vertexBuffer, c_white, 1.0); vertex_texcoord(_vertexBuffer, _u0, _v0); - vertex_position_3d(_vertexBuffer, _x2, _y2, _z2); vertex_color(_vertexBuffer, c_white, 1.0); vertex_texcoord(_vertexBuffer, _u1, _v0); - vertex_position_3d(_vertexBuffer, _x3, _y3, _z3); vertex_color(_vertexBuffer, c_white, 1.0); vertex_texcoord(_vertexBuffer, _u0, _v1); + vertex_position_3d(_vertexBuffer, _x1, _y1, _z1); vertex_color(_vertexBuffer, _color, _alpha); vertex_texcoord(_vertexBuffer, _u0, _v0); + vertex_position_3d(_vertexBuffer, _x2, _y2, _z2); vertex_color(_vertexBuffer, _color, _alpha); vertex_texcoord(_vertexBuffer, _u1, _v0); + vertex_position_3d(_vertexBuffer, _x3, _y3, _z3); vertex_color(_vertexBuffer, _color, _alpha); vertex_texcoord(_vertexBuffer, _u0, _v1); - vertex_position_3d(_vertexBuffer, _x2, _y2, _z2); vertex_color(_vertexBuffer, c_white, 1.0); vertex_texcoord(_vertexBuffer, _u1, _v0); - vertex_position_3d(_vertexBuffer, _x4, _y4, _z4); vertex_color(_vertexBuffer, c_white, 1.0); vertex_texcoord(_vertexBuffer, _u1, _v1); - vertex_position_3d(_vertexBuffer, _x3, _y3, _z3); vertex_color(_vertexBuffer, c_white, 1.0); vertex_texcoord(_vertexBuffer, _u0, _v1); + vertex_position_3d(_vertexBuffer, _x2, _y2, _z2); vertex_color(_vertexBuffer, _color, _alpha); vertex_texcoord(_vertexBuffer, _u1, _v0); + vertex_position_3d(_vertexBuffer, _x4, _y4, _z4); vertex_color(_vertexBuffer, _color, _alpha); vertex_texcoord(_vertexBuffer, _u1, _v1); + vertex_position_3d(_vertexBuffer, _x3, _y3, _z3); vertex_color(_vertexBuffer, _color, _alpha); vertex_texcoord(_vertexBuffer, _u0, _v1); if (!global.__cardboardAutoBatching && !global.__cardboardBuildingModel) CardboardBatchForceSubmit(); } \ No newline at end of file