Gamp v0.0.7-67-g7798ac4
Gamp: Graphics, Audio, Multimedia and Processing
Loading...
Searching...
No Matches
model_cobramk3.hpp
Go to the documentation of this file.
1/*
2 * ships.hpp
3 *
4 * Created on: Jan 25, 2026
5 * Author: svenson
6 */
7
8#ifndef MODEL_COBRAMK3_HPP_
9#define MODEL_COBRAMK3_HPP_
10
11#include <cstdio>
12#include <cmath>
13#include <vector>
14
15#include <gamp/graph/Graph.hpp>
18
19using namespace gamp::graph;
20
21namespace models {
22 inline void appendCobraMkIII(std::vector<OutlineShape> &oshapes,
23 const float height=1.0f, const float width=2.0f, const float deep=0.3f) {
24 float twh = width/2.0f;
25 float thh = height/2.0f;
26 float tdh = deep/2.0f;
27
28 float ctrX = 0, ctrY = 0, ctrZ = 0;
29
30 float over = ctrZ + tdh;
31 float overh = over - tdh/2.0f;
32 float under = ctrZ - tdh;
33 float underh = under + tdh/2.0f;
34 Point3f shoot_tl = Point3f(ctrX-width*1/100, ctrY+thh , ctrZ);
35 Point3f shoot_tr = Point3f(ctrX+width*1/100, ctrY+thh , ctrZ);
36 Point3f shoot_br = Point3f(ctrX+width*1/100, ctrY+thh*4/5, ctrZ);
37 Point3f shoot_bl = Point3f(ctrX-width*1/100, ctrY+thh*4/5, ctrZ);
38
39 Point3f ship_top_left = Point3f(ctrX-width*1.5f/10, ctrY+thh*4/5, ctrZ);
40 Point3f ship_top_right = Point3f(ctrX+width*1.5f/10, ctrY+thh*4/5, ctrZ);
41 Point3f ship_bottom_right = Point3f(ctrX+width*2/06, ctrY-thh, overh);
42 Point3f ship_bottom_left = Point3f(ctrX-width*2/06, ctrY-thh, overh);
43
44 Point3f ship_center_top = Point3f(ctrX, ctrZ, over);
45
46 Point3f ship_left = Point3f(ctrX-twh+(width/18), ctrY-thh/2, ctrZ);
47 Point3f ship_right = Point3f(ctrX+twh-(width/18), ctrY-thh/2, ctrZ);
48 // CCW
49 { // Body over
50 OutlineShape oshape;
51 oshape.lineTo(shoot_bl.x, shoot_bl.y, shoot_bl.z);
52 oshape.lineTo(ship_top_left.x, ship_top_left.y, ship_top_left.z);
53 oshape.lineTo(ship_center_top.x, ship_center_top.y, ship_center_top.z);
54 oshape.lineTo(ship_top_right.x, ship_top_right.y, ship_top_right.z);
55 oshape.lineTo(shoot_br.x, shoot_br.y, shoot_br.z);
56 oshape.lineTo(shoot_bl.x, shoot_bl.y, shoot_bl.z);
57 oshape.closePath();
58 oshapes.push_back(oshape);
59 }
60
61 { // Laser
62 OutlineShape oshape;
63 oshape.lineTo(shoot_tl.x, shoot_tl.y, shoot_tl.z);
64 oshape.lineTo(shoot_bl.x, shoot_bl.y, shoot_bl.z);
65 oshape.lineTo(shoot_br.x, shoot_br.y, shoot_br.z);
66 oshape.lineTo(shoot_tr.x, shoot_tr.y, shoot_tr.z);
67 oshape.lineTo(shoot_tl.x, shoot_tl.y, shoot_tl.z);
68 oshape.closePath();
69 oshapes.push_back(oshape);
70 }
71
72 { // right to over body (RTOB)
73 OutlineShape oshape;
74 oshape.lineTo(ship_center_top.x, ship_center_top.y, ship_center_top.z);
75 oshape.lineTo(ship_bottom_right.x, ship_bottom_right.y, ship_bottom_right.z);
76 oshape.lineTo(ship_top_right.x, ship_top_right.y, ship_top_right.z);
77 oshape.lineTo(ship_center_top.x, ship_center_top.y, ship_center_top.z);
78 oshape.closePath();
79 oshapes.push_back(oshape);
80 }
81 { // left to over body (LTOB)
82 OutlineShape oshape;
83 oshape.lineTo(ship_center_top.x, ship_center_top.y, ship_center_top.z);
84 oshape.lineTo(ship_top_left.x, ship_top_left.y, ship_top_left.z);
85 oshape.lineTo(ship_bottom_left.x, ship_bottom_left.y, ship_bottom_left.z);
86 oshape.lineTo(ship_center_top.x, ship_center_top.y, ship_center_top.z);
87 oshape.closePath();
88 oshapes.push_back(oshape);
89 }
90 { // under body
91 OutlineShape oshape;
92 oshape.lineTo(ship_bottom_left.x, ship_bottom_left.y, ship_bottom_left.z);
93 oshape.lineTo(ship_bottom_right.x, ship_bottom_right.y, ship_bottom_right.z);
94 oshape.lineTo(ship_center_top.x, ship_center_top.y, ship_center_top.z);
95 oshape.lineTo(ship_bottom_left.x, ship_bottom_left.y, ship_bottom_left.z);
96 oshape.closePath();
97 oshapes.push_back(oshape);
98 }
99 { // left to LTOB
100 OutlineShape oshape;
101 oshape.lineTo(ship_top_left.x, ship_top_left.y, ship_top_left.z);
102 oshape.lineTo(ship_left.x, ship_left.y, ship_left.z);
103 oshape.lineTo(ship_bottom_left.x, ship_bottom_left.y, ship_bottom_left.z);
104 oshape.lineTo(ship_top_left.x, ship_top_left.y, ship_top_left.z);
105 oshape.closePath();
106 oshapes.push_back(oshape);
107 }
108 { // right to RTOB
109 OutlineShape oshape;
110 oshape.lineTo(ship_top_right.x, ship_top_right.y, ship_top_right.z);
111 oshape.lineTo(ship_bottom_right.x, ship_bottom_right.y, ship_bottom_right.z);
112 oshape.lineTo(ship_right.x, ship_right.y, ship_right.z);
113 oshape.lineTo(ship_top_right.x, ship_top_right.y, ship_top_right.z);
114 oshape.closePath();
115 oshapes.push_back(oshape);
116 }
117 { // left corner
118 OutlineShape oshape;
119 oshape.lineTo(ship_bottom_left.x, ship_bottom_left.y, ship_bottom_left.z);
120 oshape.lineTo(ship_left.x, ship_left.y, ship_left.z);
121 oshape.lineTo(ctrX-twh, ctrY-thh, ctrZ);
122 oshape.lineTo(ship_bottom_left.x, ship_bottom_left.y, ship_bottom_left.z);
123 oshape.closePath();
124 oshapes.push_back(oshape);
125 }
126 { // right corner
127 OutlineShape oshape;
128 oshape.lineTo(ship_bottom_right.x, ship_bottom_right.y, ship_bottom_right.z);
129 oshape.lineTo(ctrX+twh, ctrY-thh, ctrZ);
130 oshape.lineTo(ship_right.x, ship_right.y, ship_right.z);
131 oshape.lineTo(ship_bottom_right.x, ship_bottom_right.y, ship_bottom_right.z);
132 oshape.closePath();
133 oshapes.push_back(oshape);
134 }
135 std::vector<OutlineShape> oshapes_back = oshapes;
136 for(OutlineShape& back : oshapes_back) {
137 for(Outline& o : back.outlines()) {
138 for(Vertex& v : o.vertices()) {
139 v.coord().z = ( (v.coord().z-ctrZ) * -1.0f + ctrZ - 0.001f);// + dz;
140 }
141 }
142 back.normal() *= -1;
143 }
144 oshapes.reserve( oshapes.size() + oshapes_back.size() );
145 for(OutlineShape& o : oshapes_back){
146 oshapes.emplace_back(std::move(o));
147 }
148 { // eliminate the hole down with left and right motor
149 OutlineShape oshape;
150 oshape.lineTo(ctrX+twh, ctrY-thh, ctrZ);
151 oshape.lineTo(ship_bottom_right.x, ship_bottom_right.y, overh);
152 oshape.lineTo(ship_bottom_left.x, ship_bottom_left.y, overh);
153 oshape.lineTo(ctrX-twh, ctrY-thh, ctrZ);
154 oshape.lineTo(ctrX+width/ 7, ctrY-thh, ctrZ);
155 oshape.lineTo(ctrX+width/ 7, ctrY-thh, ctrZ + tdh/4);
156 oshape.lineTo(ctrX+width/26, ctrY-thh, ctrZ + tdh/4);
157 oshape.lineTo(ctrX+width/26, ctrY-thh, ctrZ);
158 oshape.lineTo(ctrX-width/26, ctrY-thh, ctrZ);
159 oshape.lineTo(ctrX-width/26, ctrY-thh, ctrZ + tdh/4);
160 oshape.lineTo(ctrX-width/ 7, ctrY-thh, ctrZ + tdh/4);
161 oshape.lineTo(ctrX-width/ 7, ctrY-thh, ctrZ);
162 oshape.closePath();
163 oshapes.push_back(oshape);
164 }
165 { // eliminate the hole down with left and right motor
166 OutlineShape oshape;
167 oshape.lineTo(ctrX-twh, ctrY-thh, ctrZ);
168 oshape.lineTo(ship_bottom_left.x, ship_bottom_left.y, underh);
169 oshape.lineTo(ship_bottom_right.x, ship_bottom_right.y, underh);
170 oshape.lineTo(ctrX+twh, ctrY-thh, ctrZ);
171 oshape.lineTo(ctrX+width/26, ctrY-thh, ctrZ);
172 oshape.lineTo(ctrX+width/26, ctrY-thh, ctrZ-tdh/4);
173 oshape.lineTo(ctrX+width/ 7, ctrY-thh, ctrZ-tdh/8);
174 oshape.lineTo(ctrX+width/ 7, ctrY-thh, ctrZ);
175 oshape.lineTo(ctrX-width/ 7, ctrY-thh, ctrZ);
176 oshape.lineTo(ctrX-width/ 7, ctrY-thh, ctrZ-tdh/8);
177 oshape.lineTo(ctrX-width/26, ctrY-thh, ctrZ-tdh/4);
178 oshape.lineTo(ctrX-width/26, ctrY-thh, ctrZ);
179 oshape.closePath();
180 oshapes.push_back(oshape);
181 }
182 }
183};
184
185#endif /* INCLUDE_SHIPS_HPP_ */
A Generic shape objects which is defined by a list of Outlines.
void closePath()
Closes the current sub-path segment by drawing a straight line back to the coordinates of the last mo...
void lineTo(float x, float y, float z)
Add a line segment, intersecting the last point and the given point x/y (P1).
Define a single continuous stroke by control vertices.
Definition Outline.hpp:51
value_type z
Definition vec3f.hpp:68
value_type x
Definition vec3f.hpp:66
value_type y
Definition vec3f.hpp:67
Point3F< float > Point3f
Definition vec3f.hpp:437
void appendCobraMkIII(std::vector< OutlineShape > &oshapes, const float height=1.0f, const float width=2.0f, const float deep=0.3f)