kopia lustrzana https://github.com/jameshball/osci-render
Make objects view more consistently without the need for findZPos
rodzic
e52406aec0
commit
870019980b
|
@ -147,7 +147,7 @@ public:
|
|||
perspectiveEffect,
|
||||
std::vector<EffectParameter*>{
|
||||
new EffectParameter("3D Perspective", "Controls the strength of the 3D perspective projection.", "perspectiveStrength", VERSION_HINT, 1.0, 0.0, 1.0),
|
||||
new EffectParameter("Focal Length", "Controls the focal length of the 3D perspective effect. A higher focal length makes the image look more flat, and a lower focal length makes the image look more 3D.", "perspectiveFocalLength", VERSION_HINT, 1.0, 0.0, 10.0),
|
||||
new EffectParameter("Focal Length", "Controls the focal length of the 3D perspective effect. A higher focal length makes the image look more flat, and a lower focal length makes the image look more 3D.", "perspectiveFocalLength", VERSION_HINT, 2.0, 0.0, 10.0),
|
||||
new EffectParameter("Distance (z)", "Controls how far away the 3D object is drawn away from the camera (the Z position).", "perspectiveZPos", VERSION_HINT, 0.0, -10.0, 10.0),
|
||||
new EffectParameter("Rotate Speed", "Controls how fast the 3D object rotates in the direction determined by the rotation sliders below.", "perspectiveRotateSpeed", VERSION_HINT, 0.0, -1.0, 1.0),
|
||||
new EffectParameter("Rotate X", "Controls the rotation of the object in the X axis.", "perspectiveRotateX", VERSION_HINT, 1.0, -1.0, 1.0),
|
||||
|
|
|
@ -58,11 +58,20 @@ WorldObject::WorldObject(const std::string& obj_string) {
|
|||
// normalising object vertices
|
||||
//
|
||||
double x = 0.0, y = 0.0, z = 0.0;
|
||||
double max = 0.0;
|
||||
for (int i = 0; i < numVertices; i++) {
|
||||
x += vs[i * 3];
|
||||
y += vs[i * 3 + 1];
|
||||
z += vs[i * 3 + 2];
|
||||
}
|
||||
x /= numVertices;
|
||||
y /= numVertices;
|
||||
z /= numVertices;
|
||||
|
||||
double max = 0.0;
|
||||
for (int i = 0; i < numVertices; i++) {
|
||||
vs[i * 3] = vs[i * 3] - x;
|
||||
vs[i * 3 + 1] = vs[i * 3 + 1] - y;
|
||||
vs[i * 3 + 2] = vs[i * 3 + 2] - z;
|
||||
if (std::abs(vs[i * 3]) > max) {
|
||||
max = std::abs(vs[i * 3]);
|
||||
}
|
||||
|
@ -73,14 +82,12 @@ WorldObject::WorldObject(const std::string& obj_string) {
|
|||
max = std::abs(vs[i * 3 + 2]);
|
||||
}
|
||||
}
|
||||
x /= numVertices;
|
||||
y /= numVertices;
|
||||
z /= numVertices;
|
||||
|
||||
for (int i = 0; i < numVertices; i++) {
|
||||
vs[i * 3] = (vs[i * 3] - x) / max;
|
||||
vs[i * 3 + 1] = (vs[i * 3 + 1] - y) / max;
|
||||
vs[i * 3 + 2] = (vs[i * 3 + 2] - z) / max;
|
||||
// scaling down so that it's slightly smaller
|
||||
max = 1.75 * max;
|
||||
|
||||
for (int i = 0; i < vs.size(); i++) {
|
||||
vs[i] /= max;
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Ładowanie…
Reference in New Issue