News:

Herr Otto Partz says you're all nothing but pipsqueaks!

Main Menu

Side pictures of cars

Started by Duplode, January 19, 2024, 04:16:46 AM

Previous topic - Next topic

Duplode

I have worked out a recipe for making scoreboard side pictures of cars with consistent looks and angles. While not as sleek or convenient as a special purpose tool would be, it is quick enough to do that even a large handful of pictures can be prepared painlessly. The secret sauce is tweaking Stressed so that the default viewing angle is the one we want to use (more on that at the end). I've gone ahead and updated the pictures on the site, so let me know how you like it after a hard refresh -- while consistency requires a few compromises, there might be some room for adjusting the values in the recipe.

So, without further ado, here are the steps:

  • Open the car P3S/3SH in (tweaked) Stressed with a maximised window, select car0 and the chosen paintjob.
  • Take a screenshot of the car (leave some white background around it; no need to crop it precisely) and open it GIMP (or Photoshop, etc.).
  • Use selection by color with zero threshold/fuzziness to pick all the white areas, then use color to alpha to make them transparent (this works great because Stressed renders without blurring and uses #fcfcfc rather than #ffffff for in-game white).
  • Crop the image to the content.
  • Look at the cropped image dimensions and calculate the height : width ratio. (We're aiming for a maximum car size of 360 x 92, so this ratio will guide how we'll scale the image.)
  • If the height : width ratio is smaller than 92/360 = 0.2555..., then proportionally scale the image to a width of 360. Otherwise, proportionally scale it to a height of 92.
  • Enlarge (without scaling) the image/canvas size to 380 width, centering the content horizontally, then enlarge it to 100 height, placing the content 4 pixels above the bottom. (The current size of the images on the site is 380 x 100.)
  • Export the resulting image as a GIF.



Below are the the tweaks in the Stressed code. I picked 10° as the roll angle because that felt like a typical value for the old pics; 15° is an alternative value that might work as well. You'll note I have also changed the y-axis aspect ratio correction factor in the rendering from 0.8 to a more accurate 0.8333... (that's something I probably should make into an actual patch for Stressed). Note that the line numbers in this diff don't necessarily match the current state of the Stressed repository:

diff --git a/stunts/stressed/src/shape/shapeview.cpp b/stunts/stressed/src/shape/shapeview.cpp
index a92c31f..b4ecfb6 100644
--- a/stunts/stressed/src/shape/shapeview.cpp
+++ b/stunts/stressed/src/shape/shapeview.cpp
@@ -135,7 +137,8 @@ void ShapeView::reset()
         0.0f,
         0.0f,
         -distance(VerticesModel::toInternal(bound[2]), VerticesModel::toInternal(bound[5])));
-    m_rotation.rotate(10.0f, 1.0f, 0.0f, 0.0f);
+    m_rotation.rotate(-90.0f, 0.0f, 1.0f, 0.0f);
+    m_rotation.rotate(-10.0f, 0.0f, 0.0f, 1.0f);
   }
 
   QAbstractItemView::reset();
diff --git a/stunts/stressed/src/shape/verticesmodel.cpp b/stunts/stressed/src/shape/verticesmodel.cpp
index f9b7db0..0877e58 100644
--- a/stunts/stressed/src/shape/verticesmodel.cpp
+++ b/stunts/stressed/src/shape/verticesmodel.cpp
@@ -21,7 +21,7 @@
 const int VerticesModel::VAL_MIN;
 const int VerticesModel::VAL_MAX;
 
-const float VerticesModel::Y_RATIO = 0.8f;
+const float VerticesModel::Y_RATIO = 5.0f / 6.0f;
 
 bool VerticesModel::m_weld = false;


Cas

It's very timely that you're posting these ideas now, because I've started working on a procedure to auto-generate car images from 3SH files yesterday. My idea is to use that as part of a new garage program, a more visual one. I could follow your guidelines to make both looks compatible with each other. I still haven't done what Dreadnaut suggested (the SVG idea), but I could use the same code to produce that.
Earth is my country. Science is my religion.

Duplode

Quote from: Cas on January 19, 2024, 06:20:19 PMIt's very timely that you're posting these ideas now, because I've started working on a procedure to auto-generate car images from 3SH files yesterday.

Very nice! The parameters I described above are very much dependent on the use case, and it may make sense for them to be configurable. (For instance, while raising the maximum height somewhat could be helpful, in this case I didn't try that because it would affect layout all over the site.)

Cas

Right. The situation with cars that are a lot bigger than most complicates the thing a little bit. If they are scaled differently, they look weird in the scoreboard, but if they are all scaled the same, the majority of cars will look very small
Earth is my country. Science is my religion.

dreadnaut

Thank you Duplode, that's a smooth new set of side pictures. The tall vs long car size difference will probably remain, not much we can do there. The Monster Truck might look tiny ;D

Overdrijf

Addition: For white cars the selection of the white background doesn't work. So there the trick is that you make the exact same screenshot ofa non-white paintjob, and have both in the same image as different layers. Use the non-white paintjob for the selection, and apply the transparancy on the white one.

Cas

Wasn't the white in Stunts palette #fcfcfc while the background in Stressed is #ffffff?
Earth is my country. Science is my religion.