GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
ObjectCreator.hh
Go to the documentation of this file.
1//
2// Copyright (C) 2009 Tero Pulkkinen
3// Released under LGPL License.
4//
5// This file is part of Polygon.
6//
7// Polygon is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Polygon is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU Librry General Public License
18// along with Polygon. If not, see <http://www.gnu.org/licenses/>.
19//
20
21
22#include "VectorTools.hh"
23#include <vector>
24#include "Effect.hh"
25
26namespace OC
27{
28
30{
32};
33struct Line
34{
36};
37struct Quad
38{
40};
42{
43 std::vector<Point> vec;
44};
45struct TriList
46{
47 std::vector<Triangle> vec;
48};
50{
51 std::vector<Quad> vec;
52};
54{
55 std::vector<Line> vec;
56};
57struct Sphere
58{
59 float radius;
61};
62
63
65{
66public:
67 float SphereFunc(Sphere s, Point p);
68 static Point Scale(Point p1, Point p2, float p);
69 static Point Middle(Point p1, Point p2);
70 static Vector Dir(Point p1, Point p2);
71 static Point Dist(Point p, Vector v, float dist);
72 static Point Dist(Point p, Point p2, float dist);
73 static Point Plane2d(Point2d p, Plane pl);
74 static Point2d Rot(float angle_in_rad, float dist);
75 static Point Curve(const CurveIn3d &curve, float x);
76 static Point Intersect(Line l, Sphere s);
78 template<class T>
79 static Point Intersect(Line l, float (*func)(T t, Point p), T t);
80 static Triangle Tri(Point p, Point p2, Point p3);
81 static Triangle Tri(Point p, Vector v1, Vector v2);
82 static Triangle Tri(Line l, Point p);
83 static Line Ln(Point p, Point p2);
84 static Line Ln(Point p, Vector v);
85 static PointList PL(Triangle t);
86 static PointList PL(Line l);
87 static PointList PL(Point p);
88 static void AppendP(PointList &p, Point p1);
89 static void AppendL(LineList &l, Line l1);
90 template<class It>
91 static PointList PL(It beg, It end);
92 static PointList MovePL(const PointList &p, Vector v);
93 static LineList Lines(const PointList &p1, const PointList &p2);
94 static QuadList Quads(const PointList &p1, const PointList &p2);
95 static Quad Q(Point p1, Point p2, Point p3, Point p4);
96};
97
98
99template<class It>
101{
102 PointList p;
103 p.vec = std::vector<Point>(beg,end);
104 return p;
105}
106template<class T>
108{
109 NativeFunction2<T,Point,float> native(func); // (T,Point)->float
110 Curry2a<T,Point,float> curry(native, t); // Point->float
111 Point p = Intersect(l, curry);
112 return p;
113}
114
115
116} // namespace OC
P func(int c, EveryApi &ev)
Definition test.cpp:59
Definition Effect.hh:588
Definition EffectI.hh:49
Definition EffectI.hh:11
Definition Effect.hh:561
Definition ObjectCreator.hh:65
static Point2d Rot(float angle_in_rad, float dist)
Definition ObjectCreator.cc:53
static QuadList Quads(const PointList &p1, const PointList &p2)
Definition ObjectCreator.cc:182
static LineList Lines(const PointList &p1, const PointList &p2)
Definition ObjectCreator.cc:157
float SphereFunc(Sphere s, Point p)
Definition ObjectCreator.cc:66
static void AppendP(PointList &p, Point p1)
Definition ObjectCreator.cc:200
static Line Ln(Point p, Point p2)
Definition ObjectCreator.cc:111
static Point Scale(Point p1, Point p2, float p)
Definition ObjectCreator.cc:28
static Point Curve(const CurveIn3d &curve, float x)
Definition ObjectCreator.cc:61
static Point Plane2d(Point2d p, Plane pl)
Definition ObjectCreator.cc:48
static Quad Q(Point p1, Point p2, Point p3, Point p4)
Definition ObjectCreator.cc:172
static PointList PL(Triangle t)
Definition ObjectCreator.cc:125
static Point Middle(Point p1, Point p2)
Definition ObjectCreator.cc:32
static Vector Dir(Point p1, Point p2)
Definition ObjectCreator.cc:36
static Point Dist(Point p, Vector v, float dist)
Definition ObjectCreator.cc:40
static Point Intersect(Line l, Sphere s)
Definition ObjectCreator.cc:81
static void AppendL(LineList &l, Line l1)
Definition ObjectCreator.cc:205
static Triangle Tri(Point p, Point p2, Point p3)
Definition ObjectCreator.cc:87
static PointList MovePL(const PointList &p, Vector v)
Definition ObjectCreator.cc:147
Definition VectorTools.hh:350
Definition VectorTools.hh:125
Definition ObjectCreator.cc:26
Definition Plane.cc:5
Definition ObjectCreator.hh:54
std::vector< Line > vec
Definition ObjectCreator.hh:55
Definition ObjectCreator.hh:34
Point p1
Definition ObjectCreator.hh:35
Point p2
Definition ObjectCreator.hh:35
Definition ObjectCreator.hh:42
std::vector< Point > vec
Definition ObjectCreator.hh:43
Definition ObjectCreator.hh:50
std::vector< Quad > vec
Definition ObjectCreator.hh:51
Definition ObjectCreator.hh:38
Point p1
Definition ObjectCreator.hh:39
Point p3
Definition ObjectCreator.hh:39
Point p2
Definition ObjectCreator.hh:39
Point p4
Definition ObjectCreator.hh:39
Definition ObjectCreator.hh:58
float radius
Definition ObjectCreator.hh:59
Point center
Definition ObjectCreator.hh:60
Definition ObjectCreator.hh:46
std::vector< Triangle > vec
Definition ObjectCreator.hh:47
Definition ObjectCreator.hh:30
Point p1
Definition ObjectCreator.hh:31
Point p2
Definition ObjectCreator.hh:31
Point p3
Definition ObjectCreator.hh:31
Definition VectorTools.hh:910
Definition Parser.cc:60
Definition GameApi.h:42