2011-08-03 20:05:33 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2007, 2010 - Bit-Blot
|
|
|
|
|
|
|
|
This file is part of Aquaria.
|
|
|
|
|
|
|
|
Aquaria is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
|
|
|
See the GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
#include "Quad.h"
|
|
|
|
#include "Core.h"
|
2016-07-09 02:18:40 +00:00
|
|
|
#include "RenderBase.h"
|
2023-07-10 15:23:19 +00:00
|
|
|
#include "RenderGrid.h"
|
2011-08-03 20:05:33 +00:00
|
|
|
#include <assert.h>
|
|
|
|
|
|
|
|
Quad::Quad(const std::string &tex, const Vector &pos)
|
|
|
|
: RenderObject()
|
|
|
|
{
|
|
|
|
initQuad();
|
2023-07-10 15:23:19 +00:00
|
|
|
renderBorderColor = Vector(1,1,1);
|
2011-08-03 20:05:33 +00:00
|
|
|
position = pos;
|
|
|
|
setTexture(tex);
|
|
|
|
}
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
Quad::Quad() : RenderObject()
|
|
|
|
{
|
|
|
|
initQuad();
|
|
|
|
}
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
Quad::~Quad()
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
deleteGrid();
|
|
|
|
}
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
void Quad::initQuad()
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
addType(SCO_QUAD);
|
|
|
|
borderAlpha = 0.5;
|
|
|
|
repeatToFillScale = Vector(1,1);
|
|
|
|
|
|
|
|
autoWidth = autoHeight = 0;
|
|
|
|
|
|
|
|
renderBorder = false;
|
|
|
|
renderCenter = true;
|
|
|
|
width = 2; height = 2;
|
|
|
|
|
|
|
|
upperLeftTextureCoordinates = Vector(0,0);
|
|
|
|
lowerRightTextureCoordinates = Vector(1,1);
|
|
|
|
renderQuad = true;
|
|
|
|
grid = NULL;
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
void Quad::deleteGrid()
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
delete grid;
|
|
|
|
grid = NULL;
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
void Quad::destroy()
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
deleteGrid();
|
|
|
|
RenderObject::destroy();
|
|
|
|
}
|
2022-09-14 03:11:56 +00:00
|
|
|
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
RenderGrid *Quad::setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, float dgtm, bool dgo)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
RenderGrid *g = createGrid(x, y);
|
|
|
|
if(g)
|
|
|
|
g->setSegs(dgox, dgoy, dgmx, dgmy, dgtm, dgo);
|
|
|
|
return g;
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
RenderGrid *Quad::createGrid(int xd, int yd)
|
2022-09-23 16:10:44 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
delete grid;
|
|
|
|
return (grid = xd && yd
|
|
|
|
? new RenderGrid(xd, yd)
|
|
|
|
: NULL);
|
2022-09-23 16:10:44 +00:00
|
|
|
}
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
void Quad::setDrawGridAlpha(size_t x, size_t y, float alpha)
|
2022-09-23 16:10:44 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
if(grid)
|
|
|
|
grid->setAlpha(x, y, alpha);
|
2022-09-23 16:10:44 +00:00
|
|
|
}
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
void Quad::setStripPoints(bool vert, const Vector *points, size_t n)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
if(grid)
|
|
|
|
grid->setStripPoints(vert, points, n);
|
|
|
|
}
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
void Quad::resetGrid()
|
|
|
|
{
|
|
|
|
if(grid)
|
|
|
|
grid->reset();
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
|
2022-09-24 02:57:08 +00:00
|
|
|
void Quad::_renderBorder(const RenderState& rs, Vector color, float borderalpha) const
|
|
|
|
{
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
|
|
|
|
if (rs.forceRenderCenter || renderCenter)
|
|
|
|
{
|
|
|
|
glColor4f(color.x, color.y, color.z, borderalpha*alpha.x*alphaMod);
|
|
|
|
glPointSize(16);
|
|
|
|
glBegin(GL_POINTS);
|
|
|
|
glVertex2f(0,0);
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
glColor4f(color.x, color.y, color.z, alpha.x*alphaMod);
|
|
|
|
glLineWidth(2);
|
|
|
|
const float _w2 = width*0.5f;
|
|
|
|
const float _h2 = height*0.5f;
|
|
|
|
glBegin(GL_LINES);
|
|
|
|
glVertex2f(-_w2, _h2);
|
|
|
|
glVertex2f(_w2, _h2);
|
|
|
|
glVertex2f(_w2, -_h2);
|
|
|
|
glVertex2f(_w2, _h2);
|
|
|
|
glVertex2f(-_w2, -_h2);
|
|
|
|
glVertex2f(-_w2, _h2);
|
|
|
|
glVertex2f(-_w2, -_h2);
|
|
|
|
glVertex2f(_w2, -_h2);
|
|
|
|
glEnd();
|
|
|
|
RenderObject::lastTextureApplied = 0;
|
|
|
|
}
|
|
|
|
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2022-05-19 03:17:00 +00:00
|
|
|
bool Quad::isCoordinateInside(Vector coord, int minSize) const
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2012-01-31 18:25:13 +00:00
|
|
|
Vector realscale = getRealScale();
|
|
|
|
int hw = fabsf((width)*realscale.x)*0.5f;
|
|
|
|
int hh = fabsf((height)*realscale.y)*0.5f;
|
2011-08-03 20:05:33 +00:00
|
|
|
if (hw < minSize)
|
|
|
|
hw = minSize;
|
|
|
|
if (hh < minSize)
|
|
|
|
hh = minSize;
|
|
|
|
|
2012-01-31 18:25:13 +00:00
|
|
|
Vector pos = getRealPosition();
|
|
|
|
|
|
|
|
if (coord.x >= pos.x - hw && coord.x <= pos.x + hw)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2012-01-31 18:25:13 +00:00
|
|
|
if (coord.y >= pos.y - hh && coord.y <= pos.y + hh)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-05-19 03:17:00 +00:00
|
|
|
bool Quad::isCoordinateInsideWorld(const Vector &coord, int minSize) const
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
int hw = fabsf((width)*getRealScale().x)*0.5f;
|
|
|
|
int hh = fabsf((height)*getRealScale().y)*0.5f;
|
|
|
|
if (hw < minSize)
|
|
|
|
hw = minSize;
|
|
|
|
if (hh < minSize)
|
|
|
|
hh = minSize;
|
|
|
|
|
|
|
|
Vector pos = getWorldPosition();
|
|
|
|
if (coord.x >= pos.x + offset.x - hw && coord.x <= pos.x + offset.x + hw)
|
|
|
|
{
|
|
|
|
if (coord.y >= pos.y + offset.y - hh && coord.y <= pos.y + offset.y + hh)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-05-19 03:17:00 +00:00
|
|
|
bool Quad::isCoordinateInsideWorldRect(const Vector &coord, int w, int h) const
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
int hw = w*0.5f;
|
|
|
|
int hh = h*0.5f;
|
|
|
|
|
|
|
|
Vector pos = getWorldPosition();
|
|
|
|
if (coord.x >= pos.x + offset.x - hw && coord.x <= pos.x + offset.x + hw)
|
|
|
|
{
|
|
|
|
if (coord.y >= pos.y + offset.y - hh && coord.y <= pos.y + offset.y + hh)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2022-05-21 14:31:10 +00:00
|
|
|
void Quad::renderGrid(const RenderState& rs) const
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
RenderState rx(rs);
|
|
|
|
rx.color = rs.color * this->color;
|
|
|
|
rx.alpha = rs.alpha * this->alpha.x * this->alphaMod;
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
glPushMatrix();
|
|
|
|
glScalef(width, height, 1);
|
2022-09-25 02:30:38 +00:00
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
grid->render(rx, upperLeftTextureCoordinates, lowerRightTextureCoordinates);
|
2022-09-25 02:30:38 +00:00
|
|
|
|
|
|
|
// debug points
|
|
|
|
if (RenderObject::renderCollisionShape)
|
|
|
|
{
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
2023-07-10 15:23:19 +00:00
|
|
|
grid->renderDebugPoints(rx);
|
2023-05-30 22:55:16 +00:00
|
|
|
RenderObject::lastTextureApplied = 0;
|
2022-09-25 02:30:38 +00:00
|
|
|
}
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
glPopMatrix();
|
2022-09-25 02:30:38 +00:00
|
|
|
}
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
void Quad::repeatTextureToFill(bool on)
|
|
|
|
{
|
2012-02-19 03:57:04 +00:00
|
|
|
repeatTexture = on;
|
|
|
|
refreshRepeatTextureToFill();
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
|
2022-05-19 23:04:19 +00:00
|
|
|
void Quad::onRender(const RenderState& rs) const
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
if (!renderQuad) return;
|
|
|
|
|
2022-05-21 15:31:50 +00:00
|
|
|
const float _w2 = width*0.5f;
|
|
|
|
const float _h2 = height*0.5f;
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
if (!grid)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2022-05-21 15:31:50 +00:00
|
|
|
glBegin(GL_QUADS);
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2022-05-21 15:31:50 +00:00
|
|
|
glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y);
|
|
|
|
glVertex2f(-_w2, +_h2);
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2022-05-21 15:31:50 +00:00
|
|
|
glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y);
|
|
|
|
glVertex2f(+_w2, +_h2);
|
2016-05-05 17:40:28 +00:00
|
|
|
|
2022-05-21 15:31:50 +00:00
|
|
|
glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y);
|
|
|
|
glVertex2f(+_w2, -_h2);
|
2011-08-03 20:05:33 +00:00
|
|
|
|
2022-05-21 15:31:50 +00:00
|
|
|
glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y);
|
|
|
|
glVertex2f(-_w2, -_h2);
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-05-21 15:31:50 +00:00
|
|
|
renderGrid(rs);
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
|
2022-09-24 02:57:08 +00:00
|
|
|
if(renderBorder)
|
|
|
|
_renderBorder(rs, renderBorderColor, borderAlpha);
|
|
|
|
else if(rs.forceRenderBorder)
|
|
|
|
_renderBorder(rs, rs.renderBorderColor, rs.renderBorderAlpha);
|
2011-08-03 20:05:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Quad::flipHorizontal()
|
|
|
|
{
|
|
|
|
RenderObject::flipHorizontal();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Quad::flipVertical()
|
|
|
|
{
|
|
|
|
if (!_fv)
|
|
|
|
{
|
|
|
|
lowerRightTextureCoordinates.y = 0;
|
|
|
|
upperLeftTextureCoordinates.y = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
lowerRightTextureCoordinates.y = 1;
|
|
|
|
upperLeftTextureCoordinates.y = 0;
|
|
|
|
}
|
|
|
|
RenderObject::flipVertical();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Quad::refreshRepeatTextureToFill()
|
|
|
|
{
|
2022-05-20 02:05:54 +00:00
|
|
|
if (repeatTexture && texture)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
upperLeftTextureCoordinates.x = texOff.x;
|
|
|
|
upperLeftTextureCoordinates.y = texOff.y;
|
|
|
|
lowerRightTextureCoordinates.x = (width*scale.x*repeatToFillScale.x)/texture->width + texOff.x;
|
|
|
|
lowerRightTextureCoordinates.y = (height*scale.y*repeatToFillScale.y)/texture->height + texOff.y;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (fabsf(lowerRightTextureCoordinates.x) > 1 || fabsf(lowerRightTextureCoordinates.y)>1)
|
|
|
|
lowerRightTextureCoordinates = Vector(1,1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Quad::reloadDevice()
|
|
|
|
{
|
|
|
|
RenderObject::reloadDevice();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Quad::onUpdate(float dt)
|
|
|
|
{
|
|
|
|
RenderObject::onUpdate(dt);
|
|
|
|
|
|
|
|
if (autoWidth == AUTO_VIRTUALWIDTH)
|
|
|
|
width = core->getVirtualWidth();
|
|
|
|
else if (autoWidth == AUTO_VIRTUALHEIGHT)
|
|
|
|
width = core->getVirtualHeight();
|
|
|
|
|
|
|
|
if (autoHeight == AUTO_VIRTUALWIDTH)
|
|
|
|
height = core->getVirtualWidth();
|
|
|
|
else if (autoHeight == AUTO_VIRTUALHEIGHT)
|
|
|
|
height = core->getVirtualHeight();
|
|
|
|
|
2023-07-10 15:23:19 +00:00
|
|
|
if (grid && alpha.x > 0 && alphaMod > 0)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2023-07-10 15:23:19 +00:00
|
|
|
grid->update(dt);
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Script interface improvements & extensions.
- Pointer typechecks are now enabled by default.
- enabled all script warnings for non-FULL or DEMO builds by default
- Added generic obj_* functions that operate on any type of RenderObject.
These give quite low-level control about the renderer, and are quite
dangerous too.
Subsequently, many functions sharing the same code (*_setPosition, for example)
could be removed, and simply call the generic functions after a type check.
- Added interface function deathNotify(). The original logic of death
notifiers was never used, so i thought i'd make use of it.
This is useful in scripts to safely drop dangling pointers.
- removed sendEntityMessage, entity_setCollideWithAvatar, entity_setTouchDamage,
which were essentially no-ops.
- Replaced all unnecessary luaReturnNum(0) and luaReturnInt(0),
now it does only push a return value on the stack if the function
is actually supposed to have a retun value.
- Allow variadic calling of entity_msg(). Now any parameters can be passed
to the function, and the target entity will receive all of them.
Any values returned from the entity's msg() callback will be returned
by entity_msg() to the original caller. This allows nice RPC-like
entity communication.
- fixed possible crash in debugLog, bone_update, entity_debugText
- added an override function for loadfile() that is case-insensitive like dofile()
- entity_createEntity returns the created entity now
- spawnParticleEffect returns the associated RenderObject
- Added some text rendering functions
- Added beam_setFirer()
- removed the underflow check in avatar_decrLeaches() I added earlier
- added a panic function for Lua.
- added the Lua debug library
- fixed a stupid typo in ScriptObject::isType() that made the type checks a lot less accurate
- misc stuff I forgot
2012-02-05 19:22:54 +00:00
|
|
|
void Quad::setWidthHeight(float w, float h)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
if (h == -1)
|
|
|
|
height = w;
|
|
|
|
else
|
|
|
|
height = h;
|
|
|
|
width = w;
|
|
|
|
}
|
|
|
|
|
Script interface improvements & extensions.
- Pointer typechecks are now enabled by default.
- enabled all script warnings for non-FULL or DEMO builds by default
- Added generic obj_* functions that operate on any type of RenderObject.
These give quite low-level control about the renderer, and are quite
dangerous too.
Subsequently, many functions sharing the same code (*_setPosition, for example)
could be removed, and simply call the generic functions after a type check.
- Added interface function deathNotify(). The original logic of death
notifiers was never used, so i thought i'd make use of it.
This is useful in scripts to safely drop dangling pointers.
- removed sendEntityMessage, entity_setCollideWithAvatar, entity_setTouchDamage,
which were essentially no-ops.
- Replaced all unnecessary luaReturnNum(0) and luaReturnInt(0),
now it does only push a return value on the stack if the function
is actually supposed to have a retun value.
- Allow variadic calling of entity_msg(). Now any parameters can be passed
to the function, and the target entity will receive all of them.
Any values returned from the entity's msg() callback will be returned
by entity_msg() to the original caller. This allows nice RPC-like
entity communication.
- fixed possible crash in debugLog, bone_update, entity_debugText
- added an override function for loadfile() that is case-insensitive like dofile()
- entity_createEntity returns the created entity now
- spawnParticleEffect returns the associated RenderObject
- Added some text rendering functions
- Added beam_setFirer()
- removed the underflow check in avatar_decrLeaches() I added earlier
- added a panic function for Lua.
- added the Lua debug library
- fixed a stupid typo in ScriptObject::isType() that made the type checks a lot less accurate
- misc stuff I forgot
2012-02-05 19:22:54 +00:00
|
|
|
void Quad::setWidth(float w)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
width = w;
|
|
|
|
}
|
|
|
|
|
Script interface improvements & extensions.
- Pointer typechecks are now enabled by default.
- enabled all script warnings for non-FULL or DEMO builds by default
- Added generic obj_* functions that operate on any type of RenderObject.
These give quite low-level control about the renderer, and are quite
dangerous too.
Subsequently, many functions sharing the same code (*_setPosition, for example)
could be removed, and simply call the generic functions after a type check.
- Added interface function deathNotify(). The original logic of death
notifiers was never used, so i thought i'd make use of it.
This is useful in scripts to safely drop dangling pointers.
- removed sendEntityMessage, entity_setCollideWithAvatar, entity_setTouchDamage,
which were essentially no-ops.
- Replaced all unnecessary luaReturnNum(0) and luaReturnInt(0),
now it does only push a return value on the stack if the function
is actually supposed to have a retun value.
- Allow variadic calling of entity_msg(). Now any parameters can be passed
to the function, and the target entity will receive all of them.
Any values returned from the entity's msg() callback will be returned
by entity_msg() to the original caller. This allows nice RPC-like
entity communication.
- fixed possible crash in debugLog, bone_update, entity_debugText
- added an override function for loadfile() that is case-insensitive like dofile()
- entity_createEntity returns the created entity now
- spawnParticleEffect returns the associated RenderObject
- Added some text rendering functions
- Added beam_setFirer()
- removed the underflow check in avatar_decrLeaches() I added earlier
- added a panic function for Lua.
- added the Lua debug library
- fixed a stupid typo in ScriptObject::isType() that made the type checks a lot less accurate
- misc stuff I forgot
2012-02-05 19:22:54 +00:00
|
|
|
void Quad::setHeight(float h)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
|
|
|
height = h;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Quad::onSetTexture()
|
|
|
|
{
|
|
|
|
if (texture)
|
|
|
|
{
|
|
|
|
width = this->texture->width;
|
|
|
|
height = this->texture->height;
|
|
|
|
}
|
2015-03-23 23:06:51 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
width = 64;
|
|
|
|
height = 64;
|
|
|
|
}
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
|
2022-05-18 00:49:14 +00:00
|
|
|
PauseQuad::PauseQuad() : Quad(), pauseLevel(0), positionSnapTo(0)
|
2011-08-03 20:05:33 +00:00
|
|
|
{
|
2013-04-25 00:51:54 +00:00
|
|
|
addType(SCO_PAUSEQUAD);
|
2011-08-03 20:05:33 +00:00
|
|
|
}
|
|
|
|
|
2022-05-18 17:44:42 +00:00
|
|
|
PauseQuad::~PauseQuad()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
void PauseQuad::onUpdate(float dt)
|
|
|
|
{
|
2022-05-18 00:49:14 +00:00
|
|
|
if (positionSnapTo)
|
|
|
|
this->position = *positionSnapTo;
|
|
|
|
|
2011-08-03 20:05:33 +00:00
|
|
|
if (core->particlesPaused <= pauseLevel)
|
|
|
|
{
|
|
|
|
Quad::onUpdate(dt);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-18 00:49:14 +00:00
|
|
|
void PauseQuad::setPositionSnapTo(InterpolatedVector *positionSnapTo)
|
|
|
|
{
|
|
|
|
this->positionSnapTo = positionSnapTo;
|
|
|
|
}
|
2022-05-18 17:44:42 +00:00
|
|
|
|
|
|
|
CollideQuad::CollideQuad()
|
|
|
|
: collideRadius(0)
|
|
|
|
{
|
|
|
|
addType(SCO_COLLIDE_QUAD);
|
|
|
|
}
|
|
|
|
|
|
|
|
CollideQuad::~CollideQuad()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2022-05-19 23:04:19 +00:00
|
|
|
void CollideQuad::renderCollision(const RenderState& rs) const
|
2022-05-18 17:44:42 +00:00
|
|
|
{
|
|
|
|
if (collideRadius > 0)
|
|
|
|
{
|
|
|
|
glPushMatrix();
|
|
|
|
glLoadIdentity();
|
|
|
|
core->setupRenderPositionAndScale();
|
|
|
|
glBindTexture(GL_TEXTURE_2D, 0);
|
|
|
|
glTranslatef(position.x+offset.x, position.y+offset.y, 0);
|
|
|
|
|
|
|
|
glTranslatef(internalOffset.x, internalOffset.y, 0);
|
|
|
|
glEnable(GL_BLEND);
|
|
|
|
|
|
|
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
|
|
glColor4f(1,0,0,0.5);
|
|
|
|
drawCircle(collideRadius, 8);
|
|
|
|
glDisable(GL_BLEND);
|
|
|
|
glTranslatef(offset.x, offset.y,0);
|
|
|
|
glPopMatrix();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|