2012-10-26 01:17:35 +00:00
|
|
|
//
|
|
|
|
|
// KRViewport.h
|
|
|
|
|
// KREngine
|
|
|
|
|
//
|
|
|
|
|
// Created by Kearwood Gilbert on 2012-10-25.
|
|
|
|
|
// Copyright (c) 2012 Kearwood Software. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#ifndef KRENGINE_KRVIEWPORT_H
|
|
|
|
|
#define KRENGINE_KRVIEWPORT_H
|
|
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
#include "KREngine-common.h"
|
2012-10-26 01:17:35 +00:00
|
|
|
#include "KRVector2.h"
|
|
|
|
|
#include "KRMat4.h"
|
2012-11-09 09:18:38 +00:00
|
|
|
#include "KRAABB.h"
|
2012-10-26 01:17:35 +00:00
|
|
|
|
2012-11-15 22:05:25 +00:00
|
|
|
class KRLight;
|
|
|
|
|
|
2012-10-26 01:17:35 +00:00
|
|
|
class KRViewport {
|
|
|
|
|
public:
|
|
|
|
|
KRViewport();
|
|
|
|
|
KRViewport(const KRVector2 &size, const KRMat4 &matView, const KRMat4 &matProjection);
|
|
|
|
|
~KRViewport();
|
|
|
|
|
|
|
|
|
|
const KRVector2 &getSize() const;
|
|
|
|
|
const KRMat4 &getViewMatrix() const;
|
|
|
|
|
const KRMat4 &getProjectionMatrix() const;
|
2012-10-26 19:31:27 +00:00
|
|
|
const KRMat4 &getViewProjectionMatrix() const;
|
|
|
|
|
const KRMat4 &getInverseViewMatrix() const;
|
|
|
|
|
const KRMat4 &getInverseProjectionMatrix() const;
|
|
|
|
|
const KRVector3 &getCameraDirection() const;
|
|
|
|
|
const KRVector3 &getCameraPosition() const;
|
|
|
|
|
const int *getFrontToBackOrder() const;
|
|
|
|
|
const int *getBackToFrontOrder() const;
|
2012-10-26 01:17:35 +00:00
|
|
|
void setSize(const KRVector2 &size);
|
|
|
|
|
void setViewMatrix(const KRMat4 &matView);
|
|
|
|
|
void setProjectionMatrix(const KRMat4 &matProjection);
|
2013-04-04 17:53:39 -07:00
|
|
|
float getLODBias() const;
|
|
|
|
|
void setLODBias(float lod_bias);
|
2012-10-26 01:17:35 +00:00
|
|
|
|
|
|
|
|
// Overload assignment operator
|
|
|
|
|
KRViewport& operator=(const KRViewport &v);
|
|
|
|
|
|
2013-04-25 17:23:36 -07:00
|
|
|
unordered_map<KRAABB, int> &getVisibleBounds();
|
2012-11-09 09:18:38 +00:00
|
|
|
|
2012-11-15 22:05:25 +00:00
|
|
|
const std::set<KRLight *> &getVisibleLights();
|
|
|
|
|
void setVisibleLights(const std::set<KRLight *> visibleLights);
|
|
|
|
|
|
2013-04-24 12:48:55 -07:00
|
|
|
bool visible(const KRAABB &b) const;
|
|
|
|
|
float coverage(const KRAABB &b) const;
|
|
|
|
|
|
2012-10-26 01:17:35 +00:00
|
|
|
private:
|
|
|
|
|
KRVector2 m_size;
|
|
|
|
|
KRMat4 m_matView;
|
|
|
|
|
KRMat4 m_matProjection;
|
2012-10-26 19:31:27 +00:00
|
|
|
|
2013-04-04 17:53:39 -07:00
|
|
|
float m_lodBias;
|
2012-10-26 19:31:27 +00:00
|
|
|
|
|
|
|
|
// Derived values
|
|
|
|
|
KRMat4 m_matViewProjection;
|
|
|
|
|
KRMat4 m_matInverseView;
|
|
|
|
|
KRMat4 m_matInverseProjection;
|
|
|
|
|
KRVector3 m_cameraDirection;
|
|
|
|
|
KRVector3 m_cameraPosition;
|
|
|
|
|
|
|
|
|
|
int m_frontToBackOrder[8];
|
|
|
|
|
int m_backToFrontOrder[8];
|
|
|
|
|
|
|
|
|
|
void calculateDerivedValues();
|
2012-11-09 09:18:38 +00:00
|
|
|
|
2013-04-25 17:23:36 -07:00
|
|
|
unordered_map<KRAABB, int> m_visibleBounds; // AABB's that output fragments in the last frame
|
2013-04-24 12:48:55 -07:00
|
|
|
|
|
|
|
|
|
2012-10-26 01:17:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|