ThinkC 3D Viewer App project

Relating to ThinkC Development

pfuentes69

Active Tinkerer
Oct 27, 2021
380
293
63
Switzerland
Hey,
my project is starting to look like something...
Screenshot 2022-09-24 at 19.28.51.png

The App is attached here, it would be nice to have some people testing it.
Tomorrow I'll be able to check in some of my Macs. My better 68K Mac is an LC475 with a full 040 at 33MHz... I guess it should be much better in a machine with QuickDraw acceleration or faster CPU.
For now it allows to open a new scene and add objects (predefined and in OBJ files). The objects can be selected and modified (Translation, Scaling, Rotation, Colour). The camera and lights can also be adjusted. It renders in wireframe and polygons.
In my to-do list:
- Read KeyDown events to move the camera using the cursors (help to do this is more than welcome!)
- Manage properly the memory. Now I'm using calloc() and I'm sure there are better ways, so I can load bigger models
- Save and Load scenes (set of objects and camera/lights settings in a file)
- Implement Z-Buffer rendering, using Gouraud and Phong shading (I did this years ago... I guess it will be painfully slow here)

I prefer to clean the code before posting it openly, but if anyone wants to check it out, let me know. It's made with Symantec C++ 7, using OOP.

Cheers!
 

Attachments

  • 3DViewerApp.sit
    322.4 KB · Views: 99
Last edited:

pfuentes69

Active Tinkerer
Oct 27, 2021
380
293
63
Switzerland
Made a new version...
I added keyboard control for the camera, and changed the dialog settings to make it easier to use:
Screenshot 2022-09-25 at 11.14.33.png

I couldn't figure out how to process KeyDown events for the cursors, but I used instead:
- a, d: move sideways
- w, s: move up-down
- r, f: move forward-backwards
- A, D: to change Yaw
- W, S: to change Pitch
(Camera Roll is changed in the dialog)

Testing and feedback would be appreciated!
 

Attachments

  • 3DViewerApp.sit
    363.1 KB · Views: 80
  • Like
Reactions: Mu0n

pfuentes69

Active Tinkerer
Oct 27, 2021
380
293
63
Switzerland
I made today some tests...
Rendering the Utah teapot it takes:
- Basilisk (on MacBook Air 1.2GHz i7) = 0.4 Secs (FPU emu)
- LC475 (Full 040 @33MHz): 24 secs (No FPU) and 8 secs (FPU)
- MacMini G4 1.5GHz: 1.8 secs (No FPU, it crashes with FPU)

I couldn't try on the SE/30, but it will take probably too much to render anything but simple models.

Not very useful, but quite fun testing these things...
 
Last edited:

pfuentes69

Active Tinkerer
Oct 27, 2021
380
293
63
Switzerland
I keep advancing (slowly) in my little project.
Made a tool to draw profiles and then generate the 3D model
Screenshot 2022-10-09 at 19.24.09.png

I have some weird issues with complex models... maybe due to poor memory managent
 
  • Like
Reactions: Patrick and Mu0n

Kai Robinson

TinkerDifferent Board President 2023
Staff member
Founder
Sep 2, 2021
1,153
1
1,162
113
42
Worthing, UK
Love that it actually leverages the FPU! I'd be curious to see how fast it runs on a full 68882 equipped 030 machine :)
 

pfuentes69

Active Tinkerer
Oct 27, 2021
380
293
63
Switzerland
Love that it actually leverages the FPU! I'd be curious to see how fast it runs on a full 68882 equipped 030 machine :)
Well... I really enjoy running it in the SE/30...
It's too slow for big 3D models... Redering the Utah teapot takes less than 2 seconds in Basilisk, about 10 secs in the LC475 (33MHz, full 640) and about 3 minutes in the SE/30... But it's quite cool to see the shading using B&W.

The FPU makes a very noticeable difference, but it also gives me a lot of headaches... For example compiling for FPU there are functions such as "fprint("%f", f);" that won't work... and other weird issues with type casting.

I attach here the current version, with the source code. It contains the built apps with and without FPU.
Current functionalities:
- Create a new scene
- Change program settings (File / Preferences)
- Add objects (preset and load OBJ files)
- Select objects in screen clicking with mouse and changing properties
- Change Camera and Lights
- Move camera: Keys Movement: a, d, w, s, r, f. Angle: A, D, W, S
- 3D Spin Tool: Draw a profile and create spin solid. This is just in beta. Saving and loading profiles work. When you preview the solid it will create a file named "debug.txt" that can be added to the scene (it's an OBJ file actually)

In the _obj folder there are some sample models. Some are too big in size and the camera needs to be moved back and/or scale down the model (i.e. put Sx, Sy, Sz to 0.02, for example). There are models (i.e. venus de milo that are too heavy to load)
There are some models that are cool to see rendering...
Screenshot 2022-10-09 at 19.38.59.png


The source is made to compile with Symantec C++ 7.
 

Attachments

  • 3DViewer20221009.sit
    5.2 MB · Views: 79

pfuentes69

Active Tinkerer
Oct 27, 2021
380
293
63
Switzerland
Little improvements... Now the tool to generate solids of revolution can save the models in OBJ format and add it to scenes.
Screenshot 2022-10-15 at 18.55.44.png

Screenshot 2022-10-15 at 18.49.43.png

I also added the possibility to manipulate the selected object with the keys:
- Translation: a, d, w, s, r, f
- Rotation: A, D, W, S, R, F
- Scaling: +, -

The executable and code is attached. I migrated it to CodeWarrior 6, as I was having funky issues when compiling for FPU in Symantec C++ 7.
 

Attachments

  • 3DViewer20221015.sit
    5.4 MB · Views: 77
  • Like
Reactions: kaoshonen