peacefulLizard50262

Demoscene Bowling Project

Eğitim
BINANCE:BTCUSDT   Bitcoin / TetherUS
 Introducing the Demoscene Bowling Project

Welcome to my detailed blog post about the Demoscene Bowling project! This project utilizes Pine Script to create a 3D bowling game that can be played within the TradingView platform. In this post, I will provide an in-depth explanation of the major functions used in the script, as well as the overall structure of the project.

Before diving into the details, let's first discuss the basic idea behind this project. The aim is to create a 3D bowling game within the TradingView platform, where users can control the bowling ball and try to knock down the pins. The game uses various mathematical functions and transformations to create a 3D environment and handle user input.

Now let's break down the script and discuss the major functions used in the project.

1. Type Definitions

The script begins by defining various types that will be used throughout the project. These include vector2, vector3, vector4, face, mesh, mesh2d, location, object, poly4, polyg, camera, and mat4. Each type serves a specific purpose in the script, such as representing a point in 3D space, a face in a 3D model, or the properties of the camera used to view the scene.

2. Helper Functions

Next, the script includes a number of helper functions that are used for various purposes, such as converting angles from degrees to radians, normalizing screen coordinates, calculating cross products, and more. These functions are essential for performing various calculations and transformations throughout the script.

3. Transformation Functions

The script includes several functions for creating and applying transformation matrices to the objects in the scene. These functions allow the script to translate, rotate, and scale objects in 3D space, as well as apply perspective transformations to create the appearance of depth in the scene.

4. Processing Functions

The script contains a number of functions for processing the objects in the scene, such as calculating face normals, culling backfaces, and transforming meshes. These functions are used to optimize the scene and ensure that only visible objects are rendered.

5. Rendering Functions

The render function is responsible for drawing the objects in the scene onto the screen. It does this by processing the scene objects, applying the necessary transformations, and then drawing the lines and fills that represent the objects. The script also includes a function for creating the polygons that make up the objects, as well as a function for processing the entire scene and camera.

6. Main Script

The main part of the script sets up the initial objects in the scene, such as the bowling ball and pins, as well as the camera used to view the scene. It then calls the render function to draw the objects onto the screen.

Understanding the File Format for Objects in the Demo Scene Pine Script Project
In my demo scene Pine Script project, we use a custom file format for storing and rendering 3D objects. This format is designed to be lightweight and efficient, allowing us to create complex scenes without sacrificing performance. In this section, we will go into detail about the file format and explain how it works.

Vertex and Face Lists
My file format consists of two main components: a list of vertices (points in 3D space) and a list of faces (triangular polygons connecting the vertices). The vertex list is an array of 4D vectors, while the face list is an array of faces, each containing the indices of three vertices that form the triangle.

For example, here is a vertex list for a ball object in our scene:

ball_vertex_list = array.from(
    vector4.new(0.0, -0.5, 0.0, 1),
    ...
    vector4.new(-0.1702623393030652, -0.35355339059327373, 0.3535533905932738, 1)
)

This list contains the 3D coordinates of each vertex in the ball, represented as a 4D vector (x, y, z, w). The fourth component, w, is set to 1 for all vertices, which allows for homogeneous coordinates and simplifies transformations such as translation and scaling.

The face list for the ball object looks like this:

ball_face_list = array.from(
    face.new(2, 5, 1),
    ...
    face.new(4, 22, 0)
)

Each face is defined by the indices of the three vertices that form its corners. For example, the first face is formed by connecting vertices 2, 5, and 1 from the vertex list.

Creating a Section for the Custom File Format

File Format for 3D Objects
In our demo scene Pine Script project, we use a custom file format to store and render 3D objects efficiently. This format is composed of two main components:

Vertex List: An array of 4D vectors representing the 3D coordinates of each vertex in the object, with the fourth component (w) set to 1 for homogeneous coordinates.
Face List: An array of faces, each containing the indices of three vertices from the vertex list that form a triangular polygon.
By using this lightweight file format, we can create complex 3D scenes while maintaining optimal performance. In the following sections, we will dive deeper into how to create and manipulate objects using this format, as well as how to render them in our Pine Script project.

Limitations: Line Fills and Lighting

While developing the Demoscene Bowling project, one of the challenges encountered was the limitation in the number of line fills available in Pine Script. As a result, the original plan to include dynamic lighting in the scene had to be cut. Despite this limitation, the project still demonstrates the power and flexibility of Pine Script in creating a 3D environment and a functioning game.

The compute_shading function, which is not included in the final script, would have been responsible for calculating the shading of objects in the scene based on the lighting. It takes the face_normal, light source position (ls), camera position (cam_pos), and camera light properties as inputs, and returns the shading value. The function calculates the ambient, diffuse, and specular components of the lighting, and then combines them to determine the overall shading of the objects. This would have added a more realistic appearance to the scene, but due to the limitations in line fills, it was not feasible to implement this feature.


Demoscene and its Connection to Pixar

The Demoscene Bowling project is an excellent example of a demoscene project, which is a subculture that started in the 1980s and focused on creating visually impressive and technically challenging computer animations and graphics. Demoscene projects often pushed the boundaries of what was possible on limited hardware, showcasing the creativity and skill of the developers involved. This project follows in that tradition, as it pushes the capabilities of Pine Script to create a 3D environment and a functioning game within the TradingView platform.

The demoscene culture has had a significant impact on the computer graphics and animation industries, with many talented individuals being directly recruited by major companies such as Pixar. These individuals brought their unique skills and creativity to their new roles, helping to shape the cutting-edge technology and techniques used in computer-generated imagery (CGI) and animation today.

In conclusion, the Demoscene Bowling project is a creative and technically impressive application of Pine Script, demonstrating its potential for creating 3D environments and interactive games. Despite limitations in line fills preventing the inclusion of dynamic lighting, the project still showcases the spirit and ingenuity of the demoscene culture. Furthermore, the connection between the demoscene and major companies like Pixar highlights the importance of this subculture in shaping the computer graphics and animation industries.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.