File: BasePoint.h

package info (click to toggle)
mercator 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,008 kB
  • sloc: sh: 10,433; cpp: 4,482; makefile: 115
file content (67 lines) | stat: -rw-r--r-- 2,340 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2003 Damien McGinnes, Alistair Riddoch

#ifndef MERCATOR_BASE_POINT_H
#define MERCATOR_BASE_POINT_H

#include <iostream>

namespace Mercator { 

/// \brief Point on the fundamental grid that is used as the basis for terrain.
///
/// The terrain is defined by a sparse grid of evenly spaced points, each of
/// which is defined by an instance of this class. The most fundamental
/// property of each point is its elevation stored as height, as this is also
/// used to seed the random number generators. Additional parameters for
/// roughness and falloff are often specified.
class BasePoint {
  private:
    /// The height at the base point.
    float m_height;
    /// The roughness at the base point.
    float m_roughness;
    /// The falloff at the base point.
    float m_falloff;

  public:
    /// Default height at the base point.
    static const float HEIGHT;
    /// Default roughness at the base point.
    static const float ROUGHNESS;
    /// Default falloff at the base point.
    static const float FALLOFF;

    /// \brief Constructor
    ///
    /// @param h height at the base point.
    /// @param r roughness at the base point.
    /// @param f falloff at the base point.
    explicit BasePoint(float h = HEIGHT,
                       float r = ROUGHNESS,
                       float f = FALLOFF) :
             m_height(h), m_roughness(r), m_falloff(f) {}

    /// Accessor for the height at the base point.
    const float height() const { return m_height; }
    /// Accessor for the height at the base point.
    float & height() { return m_height; }

    /// Accessor for the roughness at the base point.
    const float roughness() const { return m_roughness; }
    /// Accessor for the roughness at the base point.
    float & roughness() { return m_roughness; }

    /// Accessor for the falloff at the base point.
    const float falloff() const { return m_falloff; }
    /// Accessor for the falloff at the base point.
    float & falloff() { return m_falloff; }

    /// Calculate the random seed used at this base point.
    unsigned int seed() const { return (unsigned int)(m_height * 1000.0);}
};

} //namespace Mercator

#endif // MERCATOR_BASE_POINT_H