-
Notifications
You must be signed in to change notification settings - Fork 2
/
Spheres.java
213 lines (179 loc) · 5.77 KB
/
Spheres.java
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
/*
* The MIT License
*
* Copyright 2020 Studio 42 GmbH (https://www.s42m.de).
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package de.s42.jara.scenes;
import de.s42.jara.Configuration;
import de.s42.jara.SceneLoader;
import de.s42.jara.assets.AssetManager;
import de.s42.jara.core.Color;
import de.s42.jara.enitites.Scene;
import de.s42.jara.core.Vector3;
import de.s42.jara.enitites.Camera;
import de.s42.jara.enitites.primitives.Disc;
import de.s42.jara.enitites.primitives.Sphere;
import de.s42.jara.materials.Material;
import de.s42.jara.materials.RainbowMaterial;
import de.s42.jara.materials.Texture;
/**
*
* @author Benjamin Schiller
*/
public class Spheres implements SceneLoader
{
@Override
public Scene loadScene(AssetManager assets)
{
assert assets != null;
Scene scene = new Scene("Spheres");
Texture background = assets.loadBackground(
AssetManager.Backgrounds.Amsterdam,
0.8, //rampUpBrightness
5.0, //rampUpExponent
2.0 //rampUpScale
);
scene.setBackgroundTextureSmoothing(300.0);
scene.setBackgroundTextureSmoothingRender(300.0);
scene.setBackgroundTexture(background);
scene.setShowDirectBackground(true);
scene.setBackgroundTextureOffsetX(0.65);
//scene.setBackgroundColor(new Color(0.12 * 0.3, 0.11 * 0.3, 0.13 * 0.3, 1.0));
Camera camera = new Camera(
new Vector3(17.0, 7.0, 8.0),
new Vector3(3.5, 3.0, -10.0),
Vector3.UP,
Math.toRadians(75.0),
(double) Configuration.getWidth() / (double) Configuration.getHeight()
);
scene.setCamera(camera);
Material stone = new Material(
Color.Black,
new Color(0.7, 0.7, 0.65, 1.0),
0.0,
1.0,
Material.IOR_STONE
);
Material plasticRed = new Material(
Color.Black,
new Color(0.9, 0.1, 0.1, 1.0),
0.5,
0.3,
Material.IOR_STEEL
);
Material plasticYellow = new Material(
Color.Black,
new Color(0.9, 0.9, 0.1, 1.0),
0.0,
0.2,
Material.IOR_PLASTIC
);
Material mirror = new Material(
Color.Black,
new Color(0.85, 0.83, 0.75, 1.0),
1.0,
0.0,
Material.IOR_STEEL
);
Material steel = new Material(
Color.Black,
new Color(0.85, 0.83, 0.75, 1.0),
1.0,
0.2,
Material.IOR_STEEL
);
Material rainbow = new RainbowMaterial(
Color.Black,
0.0,
0.0,
Material.IOR_GLASS,
0.3, //scale
1.0 //amplitude
);
Material rainbowGlow = new RainbowMaterial(
new Color(1.0, 1.0, 1.0, 1.0),
0.0,
0.0,
Material.IOR_GLASS,
0.16, //scale
0.8 //amplitude
);
Material transparentMaterial = new Material(
Color.Black,
new Color(0.0, 0.0, 0.1, 1.0),
0.0,
0.0,
Material.IOR_GLASS
);
transparentMaterial.transparency = 0.95;
Material transparentRoughMaterial = new Material(
Color.Black,
new Color(0.0, 0.0, 0.1, 1.0),
0.5,
0.2,
Material.IOR_GLASS
);
transparentRoughMaterial.transparency = 0.80;
Material floorMaterial = assets.loadPbrMaterial(AssetManager.Materials.CobbleStone, new Vector3(0.025));
Material pbrMaterial = assets.loadPbrMaterial(AssetManager.Materials.GoldOre, new Vector3(1.0));
Material pbrMaterial2 = assets.loadPbrMaterial(AssetManager.Materials.TerazzoBrickWork, new Vector3(1.0));
Material pbrMaterial3 = assets.loadPbrMaterial(AssetManager.Materials.CastIronRusted, new Vector3(1.0));
Sphere sphere1 = new Sphere(new Vector3(-8.5, -1.0, -9.0), rainbow, 6.0);
scene.add(sphere1);
Sphere sphere2 = new Sphere(new Vector3(4.0, 0.0, 4.0), plasticYellow, 3.0);
//scene.add(sphere2);
Sphere sphere3 = new Sphere(new Vector3(0.0, 5.0, -10.0), transparentMaterial, 3.0);
scene.add(sphere3);
Sphere sphere4 = new Sphere(new Vector3(4.0, -4.0, -14.0), plasticRed, 3.0);
scene.add(sphere4);
Sphere sphere5 = new Sphere(new Vector3(-20.0, -5.0, -50.0), rainbowGlow, 10.0);
//scene.add(sphere5);
Sphere sphere6 = new Sphere(new Vector3(-6.0, -2.0, -22.0), pbrMaterial3, 5.0);
scene.add(sphere6);
Sphere sphere7 = new Sphere(new Vector3(-35.0, 12.0, -150.0), pbrMaterial2, 19.0);
scene.add(sphere7);
Sphere sphere8 = new Sphere(new Vector3(-5.0, 8.0, -6.0), rainbow, 1.0);
scene.add(sphere8);
Sphere sphere9 = new Sphere(new Vector3(-8.0, 9.0, -6.0), stone, 3.0);
scene.add(sphere9);
Sphere sphere10 = new Sphere(new Vector3(5.0, -2.0, -55.0), pbrMaterial, 5.0);
scene.add(sphere10);
Sphere sphere11 = new Sphere(new Vector3(9.0, -4.0, -25.0), transparentRoughMaterial, 3.0);
scene.add(sphere11);
Sphere sphere12 = new Sphere(new Vector3(-50.0, 3.0, -125.0), mirror, 10.0);
scene.add(sphere12);
/*Plane plane = new Plane(
new Vector3(0.0, -7.0, 0.0),
floorMaterial,
new Vector3(0.0, 1.0, 0.0)
);
scene.add(plane);
*/
Disc disc = new Disc(
new Vector3(0.0, -7.0, -50.0),
floorMaterial,
new Vector3(0.0, 1.0, 0.0),
150
);
scene.add(disc);
return scene;
}
}