Show shadowmap.cpp syntax highlighted
/***************************************************************************
shadowmap.cpp - shadowmapmanager
-------------------
begin : Mon Oct 03 2005
copyright : (C) 2005 by Arcadia Design s.r.l.
email : dariodeledda@hotmail.com
***************************************************************************
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the NeoEngine, NeoDevOpenGL, shadowmap.h
The Initial Developer of the Original Code is Dario Deledda.
Portions created by Dario Deledda are Copyright (C) 2005
Arcadia Design s.r.l. . All Rights Reserved.
***************************************************************************/
#include "shadowmap.h"
using namespace NeoEngine;
void calcFocusedLightVolumePoints( Vector3d points, Matrix invEyeProjView,
Vector3d lightDir, AABB sceneAABox)
{
Vector3d pts[8];
}
//void calcAABoxPoints(Vector3d *points, const AABB &b) {
void calcAABoxPoints(Vector3d *points) {
//generate 8 corners of the box
/*
copyVector3Values(points[0],b.min[0],b.min[1],b.min[2]);// 7+------+6
copyVector3Values(points[1],b.max[0],b.min[1],b.min[2]);// /| /|
copyVector3Values(points[2],b.max[0],b.max[1],b.min[2]);// / | / |
copyVector3Values(points[3],b.min[0],b.max[1],b.min[2]);// / 4+---/--+5
copyVector3Values(points[4],b.min[0],b.min[1],b.max[2]);// 3+------+2 / y z
copyVector3Values(points[5],b.max[0],b.min[1],b.max[2]);// | / | / | /
copyVector3Values(points[6],b.max[0],b.max[1],b.max[2]);// |/ |/ |/
copyVector3Values(points[7],b.min[0],b.max[1],b.max[2]);// 0+------+1 *---x
*/
Vector3d realDim(1.0f,1.0f,1.0f);
Vector3d translation(0.0f,0.0f,0.0f);
Vector3d ptrOut[8];
points[0]= Vector3d(-realDim.x, -realDim.y, -realDim.z)+translation;
points[1]= Vector3d( realDim.x, -realDim.y, -realDim.z)+translation;
points[2]= Vector3d( realDim.x, realDim.y, -realDim.z)+translation;
points[3]= Vector3d(-realDim.x, realDim.y, -realDim.z)+translation;
points[4]= Vector3d(-realDim.x, -realDim.y, realDim.z)+translation;
points[5]= Vector3d( realDim.x, -realDim.y, realDim.z)+translation;
points[6]= Vector3d( realDim.x, realDim.y, realDim.z)+translation;
points[7]= Vector3d(-realDim.x, realDim.y, realDim.z)+translation;
}
void calcViewFrustumWorldCoord(Vector3d *points, const Matrix &invEyeProjView) {
/*
const struct AABox box = {
{-1, -1, -1},
{1, 1, 1}
};
calcAABoxPoints(points,box); //calc unit cube corner points
*/
calcAABoxPoints(points);
int i;
for(i = 0; i < 8; i++) {
points[i]=invEyeProjView*points[i]; //camera to world frame
}
}
// 7+------+6
// /| /|
// / | / |
// / 4+---/--+5
// 3+------+2 / y z
// | / | / | /
// |/ |/ |/
// 0+------+1 *---x
void calcViewFrustObject(Frustum *pkFrustum, Vector3d *p) {
pkFrustum->m_akPlanes[ Frustum::BACK ].Set(p[0],p[1],p[2]); // near plane
pkFrustum->m_akPlanes[ Frustum::FRONT ].Set(p[7],p[6],p[4]); // far plane
pkFrustum->m_akPlanes[ Frustum::LEFT ].Set(p[0],p[3],p[7]); // left plane
pkFrustum->m_akPlanes[ Frustum::RIGHT ].Set(p[1],p[5],p[6]); // right plane
pkFrustum->m_akPlanes[ Frustum::BOTTOM ].Set(p[4],p[5],p[1]); // bottom plane
pkFrustum->m_akPlanes[ Frustum::TOP ].Set(p[6],p[7],p[3]); // top plane
for( int i = 0; i < 6; i++ )
{
pkFrustum->m_aiPVertexSign[i][0] = ( pkFrustum->m_akPlanes[i].m_kNormal.x < 0.0f ) ? 1 : 0; //1 means negative sign
pkFrustum->m_aiPVertexSign[i][1] = ( pkFrustum->m_akPlanes[i].m_kNormal.y < 0.0f ) ? 1 : 0;
pkFrustum->m_aiPVertexSign[i][2] = ( pkFrustum->m_akPlanes[i].m_kNormal.z < 0.0f ) ? 1 : 0;
pkFrustum->m_aiNVertexSign[i][0] = ( pkFrustum->m_akPlanes[i].m_kNormal.x < 0.0f ) ? 0 : 1;
pkFrustum->m_aiNVertexSign[i][1] = ( pkFrustum->m_akPlanes[i].m_kNormal.y < 0.0f ) ? 0 : 1;
pkFrustum->m_aiNVertexSign[i][2] = ( pkFrustum->m_akPlanes[i].m_kNormal.z < 0.0f ) ? 0 : 1;
}
pkFrustum->m_kDirection = pkFrustum->m_akPlanes[ Frustum::BACK ].m_kNormal;
}
/*
void calcFocusedLightVolumePoints(struct VecPoint* points,const Matrix4x4 invEyeProjView,
const Vector3 lightDir,const struct AABox sceneAABox) {
Vector3x8 pts;
struct Object obj = OBJECT_NULL;
calcViewFrustumWorldCoord(pts,invEyeProjView);
calcViewFrustObject(&obj, pts);
clipObjectByAABox(&obj,sceneAABox);
includeObjectLightVolume(points,obj,lightDir,sceneAABox);
emptyObject(&obj);
}
*/
See more files for this project here