Panda3D
Loading...
Searching...
No Matches
shadowSource.h
1/**
2 *
3 * RenderPipeline
4 *
5 * Copyright (c) 2014-2016 tobspr <tobias.springer1@gmail.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 *
25 */
26
27
28#ifndef SHADOWSOURCE_H
29#define SHADOWSOURCE_H
30
31#include "pandabase.h"
32#include "luse.h"
33#include "transformState.h"
34#include "look_at.h"
35#include "compose_matrix.h"
36#include "perspectiveLens.h"
37#include "boundingVolume.h"
38#include "boundingSphere.h"
39#include "boundingHexahedron.h"
41
42#include "gpuCommand.h"
43
44/**
45 * @brief This class represents a single shadow source.
46 * @details The ShadowSource can be seen as a Camera. It is used by the Lights
47 * to render their shadows. Each ShadowSource has a position in the atlas,
48 * and a view-projection matrix. The shadow manager regenerates the shadow maps
49 * using the data from the shadow sources.
50 */
52public:
54
55 inline void write_to_command(GPUCommand &cmd) const;
56
57 inline void set_needs_update(bool flag);
58 inline void set_slot(int slot);
59 inline void set_region(const LVecBase4i& region, const LVecBase4& region_uv);
60 inline void set_resolution(size_t resolution);
61 inline void set_perspective_lens(PN_stdfloat fov, PN_stdfloat near_plane,
62 PN_stdfloat far_plane, LVecBase3 pos,
63 LVecBase3 direction);
64 inline void set_matrix_lens(const LMatrix4& mvp);
65
66 inline bool has_region() const;
67 inline bool has_slot() const;
68
69 inline void clear_region();
70
71 inline int get_slot() const;
72 inline bool get_needs_update() const;
73 inline size_t get_resolution() const;
74 inline const LMatrix4& get_mvp() const;
75 inline const LVecBase4i& get_region() const;
76 inline const LVecBase4& get_uv_region() const;
77
78 inline const BoundingSphere& get_bounds() const;
79
80private:
81 int _slot;
82 bool _needs_update;
83 size_t _resolution;
84 LMatrix4 _mvp;
85 LVecBase4i _region;
86 LVecBase4 _region_uv;
87
88 BoundingSphere _bounds;
89};
90
91#include "shadowSource.I"
92
93#endif // SHADOWSOURCE_H
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This defines a bounding sphere, consisting of a center and a radius.
Class for storing data to be transferred to the GPU.
Definition gpuCommand.h:47
RenderPipeline.
size_t get_resolution() const
Returns the resolution of the source.
int get_slot() const
Returns the slot of the shadow source.
void set_resolution(size_t resolution)
Sets the resolution of the source.
void set_perspective_lens(PN_stdfloat fov, PN_stdfloat near_plane, PN_stdfloat far_plane, LVecBase3 pos, LVecBase3 direction)
Setups a perspective lens for the source.
const LMatrix4 & get_mvp() const
Returns the View-Projection matrix of the source.
const LVecBase4i & get_region() const
Returns the assigned region of the source in atlas space.
bool has_region() const
Returns whether the source has a valid region.
ShadowSource()
RenderPipeline.
const LVecBase4 & get_uv_region() const
Returns the assigned region of the source in UV space.
void set_slot(int slot)
Assigns the source a slot.
void set_region(const LVecBase4i &region, const LVecBase4 &region_uv)
Sets the assigned region of the source in atlas and uv space.
void write_to_command(GPUCommand &cmd) const
Writes the source to a GPUCommand.
const BoundingSphere & get_bounds() const
Returns the shadow sources bounds.
void clear_region()
Clears the assigned region of the source.
void set_needs_update(bool flag)
Sets the update flag of the source.
bool get_needs_update() const
RenderPipeline.
bool has_slot() const
Returns whether the source has a slot.
void set_matrix_lens(const LMatrix4 &mvp)
Sets a custom matrix for the source.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.