FREESCAPE: working implementation of renderSensorShot for driller and dark

This commit is contained in:
neuromancer 2023-07-28 16:53:33 +02:00
parent f82d0fb2dd
commit ab9a114366
6 changed files with 66 additions and 15 deletions

View File

@ -248,10 +248,7 @@ void FreescapeEngine::checkSensors() {
}
}
void FreescapeEngine::drawSensorShoot(Sensor *sensor) {
assert(sensor);
_gfx->renderSensorShoot(1, sensor->getOrigin(), _position, _viewArea);
}
void FreescapeEngine::drawSensorShoot(Sensor *sensor) {}
void FreescapeEngine::flashScreen(int backgroundColor) {
if (backgroundColor >= 16)

View File

@ -382,7 +382,7 @@ public:
bool _playerWasCrushed;
ObjectArray _sensors;
void checkSensors();
void drawSensorShoot(Sensor *sensor);
virtual void drawSensorShoot(Sensor *sensor);
void takeDamageFromSensor();
bool hasFeature(EngineFeature f) const override;
@ -456,6 +456,7 @@ public:
void gotoArea(uint16 areaID, int entranceID) override;
void drawInfoMenu() override;
void drawSensorShoot(Sensor *sensor) override;
void pressedKey(const int keycode) override;
Common::Error saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave = false) override;
@ -540,6 +541,7 @@ public:
int _lastTenSeconds;
void updateTimeVariables() override;
void drawSensorShoot(Sensor *sensor) override;
void drawDOSUI(Graphics::Surface *surface) override;
void drawZXUI(Graphics::Surface *surface) override;

View File

@ -451,6 +451,24 @@ void DarkEngine::drawFullscreenMessageAndWait(Common::String message) {
delete surface;
}
void DarkEngine::drawSensorShoot(Sensor *sensor) {
Math::Vector3d target;
target = _position;
target.y() = target.y() - _playerHeight;
target.x() = target.x() - 5;
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
target = _position;
target.y() = target.y() - _playerHeight;
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
target = _position;
target.y() = target.y() - _playerHeight;
target.x() = target.x() + 5;
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
}
Common::Error DarkEngine::saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave) {
return Common::kNoError;
}

View File

@ -846,6 +846,28 @@ bool DrillerEngine::onScreenControls(Common::Point mouse) {
return false;
}
void DrillerEngine::drawSensorShoot(Sensor *sensor) {
Math::Vector3d target;
target = _position;
target.y() = target.y() - _playerHeight;
target.x() = target.x() - 5;
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
target = _position;
target.y() = target.y() - _playerHeight;
target.x() = target.x() + 5;
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
target = _position;
target.y() = target.y() + _playerHeight;
target.x() = target.x() - 5;
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
target = _position;
target.y() = target.y() + _playerHeight;
target.x() = target.x() + 5;
_gfx->renderSensorShoot(1, sensor->getOrigin(), target, _viewArea);
}
Common::Error DrillerEngine::saveGameStreamExtended(Common::WriteStream *stream, bool isAutosave) {
for (auto &it : _areaMap) { // All but skip area 255

View File

@ -177,18 +177,22 @@ void OpenGLRenderer::positionCamera(const Math::Vector3d &pos, const Math::Vecto
glTranslatef(-pos.x(), -pos.y(), -pos.z());
}
void OpenGLRenderer::renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d player, const Common::Rect viewArea) {
void OpenGLRenderer::renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d target, const Common::Rect viewArea) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
glColor3ub(255, 255, 255);
glLineWidth(20);
polygonOffset(true);
glEnableClientState(GL_VERTEX_ARRAY);
copyToVertexArray(0, sensor);
copyToVertexArray(1, player);
copyToVertexArray(1, target);
glVertexPointer(3, GL_FLOAT, 0, _verts);
glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_VERTEX_ARRAY);
polygonOffset(false);
glLineWidth(1);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
}
void OpenGLRenderer::renderPlayerShoot(byte color, const Common::Point position, const Common::Rect viewArea) {

View File

@ -162,19 +162,27 @@ void OpenGLShaderRenderer::positionCamera(const Math::Vector3d &pos, const Math:
_mvpMatrix = proj * model;
_mvpMatrix.transpose();
}
void OpenGLShaderRenderer::renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d target, const Common::Rect viewArea) {
glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
glColor3ub(255, 255, 255);
void OpenGLShaderRenderer::renderSensorShoot(byte color, const Math::Vector3d sensor, const Math::Vector3d player, const Common::Rect viewArea) {
/*glColor3ub(255, 255, 255);
glLineWidth(20);
polygonOffset(true);
glEnableClientState(GL_VERTEX_ARRAY);
copyToVertexArray(0, sensor);
copyToVertexArray(1, player);
copyToVertexArray(1, target);
glBindBuffer(GL_ARRAY_BUFFER, _triangleVBO);
glBufferData(GL_ARRAY_BUFFER, 8 * 3 * sizeof(float), _verts, GL_DYNAMIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 3 * sizeof(float), nullptr);
glVertexPointer(3, GL_FLOAT, 0, _verts);
glDrawArrays(GL_LINES, 0, 2);
glDisableClientState(GL_VERTEX_ARRAY);
polygonOffset(false);
glLineWidth(1);*/
glLineWidth(1);
glDisable(GL_BLEND);
glDepthMask(GL_TRUE);
}
// TODO: move inside the shader?