AI coding help for Celestia?

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 3 months

AI coding help for Celestia?

Post #1by john71 » 29.06.2024, 19:19

ChatGPT, Claude and other AI tools can create almost any code using simple sentences as instructions.

AI can search for errors in the code.

Are the developers of Celestia using this free method to speed up the process?

onetwothree
Site Admin
Posts: 706
Joined: 22.09.2018
With us: 6 years 2 months

Post #2by onetwothree » 30.06.2024, 19:11

First, we develop Celestia for fun, using AI tools is not fun. Second, all that tools consume terrible amount of electricity, so they are no ecological.

Topic author
john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 3 months

Post #3by john71 » 30.06.2024, 19:25

You should try them. They are fun too. I was able to get a working Python script on my first try just by describing it with logical sentences. OK, it is true, you have to be very precise, but the AI wrote 3 pages of code just by using my sentences. ChatGPT4o is the best. Also you can use AIs on simple PCs to find errors in multiple pages of code. It is really like magic. It gives you an advice if you are stuck or you don't have a solution. You can ask anything from it about programming or codes. It will give you concrete solutions, codes. AI=less work.

Topic author
john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 3 months

Post #4by john71 » 01.07.2024, 08:20

"Please write a Celestia 3D .ssc script which puts a new planet between Earth and Mars!"

CHATGPT4o:

"Intermundia" "Sol"
{
Class "planet"
Texture "venus.*"
Radius 3500 # Planet radius in kilometers
Oblateness 0.0
Albedo 0.30
SiderealOrbitPeriod 365.25
RotationPeriod 24.0
Inclination 1.0
OrbitalPlane
{
Inclination 1.0
AscendingNode 0.0
}
EllipticalOrbit
{
Period 1.88
SemiMajorAxis 1.5 # Astronomical Units (AU), between Earth's 1 AU and Mars' 1.52 AU
Eccentricity 0.1
Inclination 1.0
AscendingNode 0.0
ArgOfPericenter 0.0
MeanAnomaly 0.0
}
}

Topic author
john71
Posts: 1009
Joined: 10.08.2016
With us: 8 years 3 months

Post #5by john71 » 07.07.2024, 21:08

I was able to ask the AI deepseek coder v2 on my PC to analyze the winmain.cpp file. The 41231 tokens code was analyzed in little over 10 minutes. It replied this: The code provided is a Windows front-end for the Celestia application, written in C++. It handles initialization, window creation, OpenGL rendering, and user interaction. Below is a summary of its functionality:

1. **Initialization**:
- The `WinMain` function is the entry point for the application.
- It initializes COM (`OleInitialize`), sets up the main window class, registers it, creates the main window, and handles command line arguments.
- It also initializes the Celestia core engine and its renderer.

2. **Window Creation**:
- The `CreateOpenGLWindow` function creates an OpenGL-capable window with a pixel format suitable for rendering.
- It sets up the main window procedure (`MainWindowProc`) to handle messages, including drawing via OpenGL.

3. **Rendering**:
- The application uses OpenGL for rendering 2D and 3D graphics.
- The `appCore->draw()` function is called to render the scene, which includes handling user inputs like mouse movements, button clicks, and keyboard inputs.
- The rendered frames are then swapped using `SwapBuffers(deviceContext)` for display on the screen.

4. **User Interaction**:
- The main window procedure (`MainWindowProc`) handles various messages including key presses, mouse movements, and resize events.
- It also manages context menus triggered by right-clicks or menu item selections.

5. **Menu Handling**:
- Menus are dynamically created based on the current state of Celestia (e.g., planets, moons) via functions like `CreatePlanetarySystemMenu` and `CreateAlternateSurfaceMenu`.
- Menu items are checked or unchecked depending on the application's state to reflect changes in settings or selections.

6. **Script Handling**:
- The code includes functionality to handle script commands triggered by menu items, such as opening URLs or running scripts stored in the application.

7. **Joystick Support**:
- If a joystick is available and configured for use (`useJoystick` flag), it handles joystick axis movements and button presses through `HandleJoystick`.

8. **Configuration Management**:
- Preferences (like window size, render settings) are loaded from the registry at startup using `LoadPreferencesFromRegistry` and saved back to the registry when the application exits via `SavePreferencesToRegistry`.

9. **Error Handling**:
- The application displays error messages in dialog boxes if critical errors occur during initialization or operation.

10. **Extensions and Libraries**:
- The code includes handling for WGL extensions (`InitWGLExtensions`), which are used for hardware-accelerated OpenGL rendering.
- It also integrates with Celestia's core functionalities, such as running scripts and managing simulations.

This comprehensive setup ensures that the application is responsive to user inputs, dynamically reflects changes in its state, and provides a rich graphical experience through OpenGL rendering.


Return to “Development”