### World Management Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This section details how to create and configure a QWorld object, which is essential for managing physics simulations. ```APIDOC ## World Management ### Description This section details how to create and configure a QWorld object, which is essential for managing physics simulations. ### Create a World ```cpp //Create a world QWorld *world = new QWorld(); // Set the gravity value world->SetGravity(QVector(0.0f, 0.2f)); // Set the iteration count per step of physics in the world. world->SetIterationCount(4); ``` ### Update World ```cpp // Updates the physics simulation of the world as a step. world->Update(); ``` ### QWorld Class **Definition:** qworld.h:51 A QWorld object is required to create a physics simulation. The QWorld class manages the entire physics simulation. ### Methods - **SetIterationCount** (int value) **Definition:** qworld.h:233 QWorld *SetIterationCount(int value) - **SetGravity** (QVector value) **Definition:** qworld.h:184 QWorld *SetGravity(QVector value) - **Update** (void) **Definition:** qworld.cpp:63 void Update() ### Related Structs - [QVector](structQVector.html) (Definition: qvector.h:44) ``` -------------------------------- ### Create and Add QRigidBody Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md Demonstrates the creation of a QRigidBody, attaching a rectangular mesh to it, setting its position and rotation, and finally adding it to the QWorld. ```cpp //Create a Rigid Body QRigidBody *body=new QRigidBody(); // Create a Mesh QMesh * rectMesh=QMesh::CreateWithRect(QVector(rectWidth,rectHeight),QVector(centerPosX,centerPosY)); // Add the Mesh to the Rigid Body body->AddMesh(rectMesh); //Set the Body Position body->SetPosition(QVector(posX,posY) ); //Set the Body Rotation body->SetRotation( radAngle ); // or body->SetRotationDegree(degreeAngle) //Add the Rigid Body to the World world->AddBody(body); ``` -------------------------------- ### Update Physics Simulation Step Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md This snippet shows how to advance the physics simulation by one step using the Update method of the QWorld object. ```cpp world->Update(); // Updates the physics simulation of the world as a step. ``` -------------------------------- ### Create and Configure QWorld Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md This snippet demonstrates how to create a QWorld object, set its gravity, and define the physics iteration count. The QWorld manages all objects and physics steps. ```cpp //Create a world QWorld *world=new QWorld(); // Set the gravity value world->SetGravity(QVector(0.0f,0.2f) ); //Set the iteration count per step of physics in the world. world->SetIterationCount(4); ``` -------------------------------- ### Rigid Body Creation Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html Learn how to create and add a rigid body to the physics world, including defining its shape and properties. ```APIDOC ## Rigid Body Creation ### Description Learn how to create and add a rigid body to the physics world, including defining its shape and properties. ### Create a Rigid Body ```cpp //Create a Rigid Body QRigidBody *body = new QRigidBody(); // Create a Mesh QMesh *rectMesh = QMesh::CreateWithRect(QVector(rectWidth, rectHeight), QVector(centerPosX, centerPosY)); // Add the Mesh to the Rigid Body body->AddMesh(rectMesh); // Set the Body Position body->SetPosition(QVector(posX, posY)); // Set the Body Rotation body->SetRotation(radAngle); // or body->SetRotationDegree(degreeAngle) // Add the Rigid Body to the World world->AddBody(body); ``` ### QRigidBody Class **Definition:** qrigidbody.h:40 QRigidBody is a type of body that is simulated with the dynamics of Rigid body. A rigid body is a type of body that is simulated with the dynamics of Rigid body. ### QBody Methods - **AddMesh** (QMesh *mesh) **Definition:** qbody.cpp:154 QBody *AddMesh(QMesh *mesh) - **SetPosition** (QVector value, bool withPreviousPosition=true) **Definition:** qbody.h:387 QBody *SetPosition(QVector value, bool withPreviousPosition=true) - **SetRotation** (float angleRadian, bool withPreviousRotation=true) **Definition:** qbody.h:432 QBody *SetRotation(float angleRadian, bool withPreviousRotation=true) ### QWorld Method - **AddBody** (QBody *body) **Definition:** qworld.cpp:440 QWorld *AddBody(QBody *body) ### Related Structs - [QMesh](structQMesh.html) (Definition: qmesh.h:49) Every QBody object requires meshes. In other traditional physics engines, the term 'shape' is used in place of mesh. - [QMesh::CreateWithRect](structQMesh.html#a46fdef1c61a493ed8bd1673604152af1) ``` -------------------------------- ### QMesh Creation for Soft Bodies Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html Demonstrates how to create gridded rectangle and polygon meshes for soft body physics simulation using the QMesh class. ```APIDOC ## QMesh Creation for Soft Bodies ### Description This section details the creation of `QMesh` objects, specifically focusing on gridded meshes suitable for soft body physics. It includes examples for creating gridded rectangles and polygons, and adding them to a soft body. ### Create Gridded Rectangle Mesh ```cpp int gridColumnCount = 3; int gridRowCount = 3; // Create a Gridded Rectangle Mesh QMesh *griddedRectMesh = QMesh::CreateWithRect(QVector(width, height), QVector(centerX, centerY), QVector(gridRowCount, gridRowCount)); // Add the Mesh to the Soft Body mySoftBody->AddMesh(griddedRectMesh); ``` ### Create Gridded Polygon Mesh ```cpp int polarGrid = 2; // Create a Gridded Rectangle Mesh QMesh *griddedPolyMesh = QMesh::CreateWithPolygon(64, 12, QVector(centerX, centerY), polarGrid); // Add the Mesh to the Soft Body mySoftBody->AddMesh(griddedPolyMesh); ``` ### Custom Mesh Structures Beyond primitive shapes, `QMesh` allows for custom mesh creation, including defining particles, collision polygons, and spring connections. Complex mesh files can also be loaded from JSON format using the `QMesh Editor`. ``` -------------------------------- ### Create and Add a Joint Between Two Rigid Bodies (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This example shows how to create a QJoint object to connect two rigid bodies (bodyA and bodyB) with specific anchor points in world space. The created joint is then added to the physics world simulation managed by QWorld. ```C++ //Create a Joint [QJoint](classQJoint.html) *joint=new [QJoint](classQJoint.html) (bodyA, anchorWorldPositionA, anchorWorldPositionB, bodyB); //Add the Joint to the World world->[AddJoint](classQWorld.html#a62394f07462a94a489108ae7f0eb99c1)(joint); ``` -------------------------------- ### Create Gridded Polygon Mesh for Soft Body Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md Demonstrates creating a QMesh for a soft body with a polar grid structure using `QMesh::CreateWithPolygon`. ```cpp int polarGrid=2; //Create a Gridded Rectangle Mesh QMesh * griddedPolyMesh=QMesh::CreateWithPolygon(64,12,QVector(centerX,centerY),polarGrid ) //Add the Mesh to the Soft Body mySoftBody->AddMesh(griddedPolyMesh); ``` -------------------------------- ### QJoint for Connecting Rigid Bodies Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html Explains how to create and add `QJoint` objects to connect rigid bodies or connect a rigid body to a world anchor point. ```APIDOC ## QJoint Creation and Usage ### Description This section covers the use of the `QJoint` class to establish constraints between rigid bodies. It demonstrates how to connect two bodies or connect a body to a fixed point in the world. ### Connect Two Rigid Bodies ```cpp // Create a Joint QJoint *joint = new QJoint(bodyA, anchorWorldPositionA, anchorWorldPositionB, bodyB); // Add the Joint to the World world->AddJoint(joint); ``` ### Connect Rigid Body to World Anchor ```cpp // Create a Joint QJoint *mouseJoint = new QJoint(bodyA, anchorWorldPositionA, mousePosition, nullptr); // Add the Joint to the World world->AddJoint(joint); ``` ### QJoint Parameters - **bodyA** (QBody*): The first rigid body to connect. - **anchorWorldPositionA** (QVector): The anchor point on the first body in world coordinates. - **anchorWorldPositionB** (QVector): The anchor point on the second body in world coordinates. - **bodyB** (QBody*): The second rigid body to connect (can be `nullptr` to anchor to the world). - **mousePosition** (QVector): If `bodyB` is `nullptr`, this specifies the world position to anchor to. ### QWorld::AddJoint Method #### Method `QWorld::AddJoint` #### Endpoint `qworld.cpp:726` #### Description Adds a configured `QJoint` object to the physics world. #### Parameters - **joint** (QJoint*): The `QJoint` object to add. #### Return Value `QWorld*`: The `QWorld` object. ``` -------------------------------- ### Create Gridded Rectangular Mesh for Soft Body Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md Shows how to create a QMesh with an internal grid structure suitable for soft bodies, using `QMesh::CreateWithRect` with row and column counts. ```cpp int gridColumnCount=3; int gridRowCount=3; //Create a Gridded Rectangle Mesh QMesh * griddedRectMesh=QMesh::CreateWithRect( QVector(width,height),QVector(centerX,centerY),QVector(gridRowCount,gridRowCount) ); //Add the Mesh to the Soft Body mySoftBody->AddMesh(griddedRectMesh); ``` -------------------------------- ### Create a Soft Body in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html Demonstrates the process of creating a soft body. This involves instantiating a QSoftBody, creating a QMesh to define its shape (e.g., a polygon), adding the mesh to the soft body, setting its position and rotation, and finally adding it to the QWorld simulation. ```cpp //Create a Soft Body [QRigidBody](classQRigidBody.html) *body=new [QSoftBody](classQSoftBody.html)(); // Create a Mesh [QMesh](structQMesh.html) * polygonMesh=[QMesh::CreateWithPolygon](structQMesh.html#a75523f7fed5db8b2e3c6aa6e55afac58)(radius,sideCount,[QVector](structQVector.html)(centerPosX,centerPosY)); // Add the Mesh to the Soft Body body->[AddMesh](classQBody.html#a17bfcd06492a9e566eb930e698b4c3c4)(rectMesh); //Set the Body Position body->[SetPosition](classQBody.html#ae6a1c93344bc3bb6dec7af799322dc06)([QVector](structQVector.html)(posX,posY) ); //Set the Body Rotation body->[SetRotation](classQBody.html#aed4e1d6a40939f66336767b551a9845e)( radAngle ); // or body->SetRotationDegree(degreeAngle) //Add the Soft Body to the World world->[AddBody](classQWorld.html#aaaedfc8a0f251d74fe26cb2f9dcb6a23)(body); ``` -------------------------------- ### Update Quark Physics Simulation Step Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This code demonstrates how to advance the physics simulation by one step using the Update method of the QWorld object. This is a fundamental operation for any physics engine to progress the simulation over time. It requires an initialized QWorld object. ```C++ world->Update(); // Updates the physics simulation of the world as a step. ``` -------------------------------- ### Initialize and Configure Quark Physics World Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This snippet demonstrates how to create a QWorld object, which is essential for managing all physics objects and simulations. It shows how to set the world's gravity and the number of iterations per physics step, which affects simulation accuracy and performance. Dependencies include the QWorld and QVector classes. ```C++ //Create a world QWorld *world=new QWorld(); // Set the gravity value world->SetGravity(QVector(0.0f,0.2f) ); //Set the iteration count per step of physics in the world. world->SetIterationCount(4); ``` -------------------------------- ### Create QJoint Connected to World Space Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md Shows how to create a QJoint that connects a rigid body (`bodyA`) to a specific point in world space by setting the second body to `nullptr`. This is useful for mouse grabbing effects. ```cpp //Create a Joint QJoint *mouseJoint=new QJoint (bodyA, anchorWorldPositionA, mousePosition, nullptr); //Add the Joint to the World world->AddJoint(joint); ``` -------------------------------- ### Create and Add QSoftBody with Polygon Mesh Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md Illustrates the creation of a QSoftBody, attaching a polygon mesh, setting its position and rotation, and adding it to the QWorld. Note: The code snippet provided in the original text incorrectly uses `QRigidBody *body=new QSoftBody();` and `body->AddMesh(rectMesh);` which should ideally be `QSoftBody *softBody = new QSoftBody();` and `softBody->AddMesh(polygonMesh);`. ```cpp //Create a Soft Body QRigidBody *body=new QSoftBody(); // Create a Mesh QMesh * polygonMesh=QMesh::CreateWithPolygon(radius,sideCount,QVector(centerPosX,centerPosY))); // Add the Mesh to the Soft Body body->AddMesh(rectMesh); //Set the Body Position body->SetPosition(QVector(posX,posY) ); //Set the Body Rotation body->SetRotation( radAngle ); // or body->SetRotationDegree(degreeAngle) //Add the Soft Body to the World world->AddBody(body); ``` -------------------------------- ### Create and Add a Joint to a World Anchor Point (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This code demonstrates creating a QJoint that connects a rigid body (bodyA) to a fixed point in the world, effectively creating a constraint anchored in space. This is useful for simulating effects like mouse interaction with rigid bodies. The joint is then added to the QWorld. ```C++ //Create a Joint [QJoint](classQJoint.html) *mouseJoint=new [QJoint](classQJoint.html) (bodyA, anchorWorldPositionA, mousePosition, nullptr); //Add the Joint to the World world->[AddJoint](classQWorld.html#a62394f07462a94a489108ae7f0eb99c1)(joint); ``` -------------------------------- ### Create and Add Spring Between Particles in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md Demonstrates how to create a QSpring object to connect two particles from different soft bodies and add it to the physics world. This is the primary method for establishing distance constraints between particles. ```cpp float length=32.0f; //Create a Spring QSpring *spring=new QSpring (bodyA->GetParticleAt(2), bodyA->GetParticleAt(5), length) //Add the Spring to the World world->AddJoint(spring); ``` -------------------------------- ### Create Gridded Rectangle Mesh for Soft Bodies (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This code demonstrates how to create a gridded rectangle mesh, suitable for soft body physics, using the QMesh class. It specifies dimensions, center position, and grid row/column counts. The created mesh is then added to a soft body object. ```C++ int gridColumnCount=3; int gridRowCount=3; //Create a Gridded Rectangle Mesh [QMesh](structQMesh.html) * griddedRectMesh=[QMesh::CreateWithRect](structQMesh.html#a46fdef1c61a493ed8bd1673604152af1)( [QVector](structQVector.html)(width,height),[QVector](structQVector.html)(centerX,centerY),[QVector](structQVector.html)(gridRowCount,gridRowCount) ); //Add the Mesh to the Soft Body mySoftBody->AddMesh(griddedRectMesh); ``` -------------------------------- ### Create and Add Rigid Body to Quark Physics World Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This snippet illustrates the process of creating a rigid body, defining its shape using a rectangular mesh, setting its position and rotation, and finally adding it to the physics world. It involves creating QRigidBody, QMesh, and QVector objects, and utilizing methods like AddMesh, SetPosition, SetRotation, and AddBody. The QBody class serves as the base for QRigidBody. ```C++ //Create a Rigid Body QRigidBody *body=new QRigidBody(); // Create a Mesh QMesh * rectMesh=QMesh::CreateWithRect(QVector(rectWidth,rectHeight),QVector(centerPosX,centerPosY)); // Add the Mesh to the Rigid Body body->AddMesh(rectMesh); //Set the Body Position body->SetPosition(QVector(posX,posY) ); //Set the Body Rotation body->SetRotation( radAngle ); // or body->SetRotationDegree(degreeAngle) //Add the Rigid Body to the World world->AddBody(body); ``` -------------------------------- ### Create and Add QSpring to World in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This code demonstrates how to create a QSpring object to apply a distance constraint between two particles of a body and then add it to the physics world. The QSpring constructor takes two particle pointers and a length, and AddJoint is a method of the QWorld class. ```cpp //Create a Spring [QSpring](classQSpring.html) *spring=new [QSpring](classQSpring.html) (bodyA->GetParticleAt(2), bodyA->GetParticleAt(5), length) //Add the Spring to the World world->[AddJoint](classQWorld.html#a62394f07462a94a489108ae7f0eb99c1)(spring); ``` -------------------------------- ### Create and Add Spring Between Particle and Space Point in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md Illustrates creating a spring connection between a soft body's particle and a specific point in space. This is achieved by creating a temporary QParticle at the desired world position and using it in the QSpring constructor. ```cpp //Create a particle QParticle *mouseParticle=new QParticle(); mouseParticle->SetPosition( mousePosition ); //Create a Spring QSpring *mouseSpring=new QSpring (bodyA->GetParticleAt(2), mouseParticle, 0.0f); //Add the Spring to the World world->AddJoint(mouseSpring); ``` -------------------------------- ### Create QSpring with Particle and Mouse Position in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This snippet shows how to create a QSpring to connect a body's particle to a dynamic particle, effectively simulating a mouse drag effect. A new QParticle is created, its position is set using SetPosition, and then a QSpring is formed between the body's particle and this new mouse particle. ```cpp //Create a particle [QParticle](classQParticle.html) *mouseParticle=new [QParticle](classQParticle.html)(); mouseParticle->[SetPosition](classQParticle.html#acf21ca1aa9a2c2aabbedb67d7052f1f1)( mousePosition ); //Create a Spring [QSpring](classQSpring.html) *mouseSpring=new [QSpring](classQSpring.html) (bodyA->GetParticleAt(2), mouseParticle, 0.0f); //Add the Spring to the World world->[AddJoint](classQWorld.html#a62394f07462a94a489108ae7f0eb99c1)(mouseSpring); ``` -------------------------------- ### Create a Rectangle Mesh in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This function creates a mesh with a rectangular shape. It allows customization of size, center position, grid density, and whether to enable springs and polygons. The particle radius can also be set. ```cpp static QMesh * CreateWithRect(QVector size, QVector centerPosition=QVector::Zero(), QVector grid=QVector::Zero(), bool enableSprings=true, bool enablePolygons=true, float particleRadius=0.5f) ``` -------------------------------- ### Create Gridded Polygon Mesh for Soft Bodies (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This code snippet illustrates the creation of a gridded polygon mesh for soft body simulations. It uses the QMesh::CreateWithPolygon method, specifying the number of sides, radius, center position, and polar grid density. The resulting mesh is then attached to a soft body. ```C++ int polarGrid=2; //Create a Gridded Rectangle Mesh [QMesh](structQMesh.html) * griddedPolyMesh=[QMesh::CreateWithPolygon](structQMesh.html#a75523f7fed5db8b2e3c6aa6e55afac58)(64,12,[QVector](structQVector.html)(centerX,centerY),polarGrid ) //Add the Mesh to the Soft Body mySoftBody->AddMesh(griddedPolyMesh); ``` -------------------------------- ### Create a Polygon Mesh in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This function creates a mesh with a convex polygon shape. It takes parameters for radius, number of sides, center position, and optional grid and spring/polygon enabling flags. The particle radius can also be adjusted. ```cpp static QMesh * CreateWithPolygon(float radius, int sideCount, QVector centerPosition=QVector::Zero(), int polarGrid=-1, bool enableSprings=true, bool enablePolygons=true, float particleRadius=0.5f) ``` -------------------------------- ### Create and Add QJoint between Two Bodies Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md This snippet illustrates how to create a QJoint to connect two rigid bodies (`bodyA` and `bodyB`) with specified anchor points in world space and add it to the QWorld. ```cpp //Create a Joint QJoint *joint=new QJoint (bodyA, anchorWorldPositionA, anchorWorldPositionB, bodyB); //Add the Joint to the World world->AddJoint(joint); ``` -------------------------------- ### Remove Bodies, Joints, and Springs in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/doxy_pages/getting_started.md Shows how to safely remove bodies, joints, and springs from the QuarkPhysics world. These objects are automatically deleted when the QWorld is destroyed, but explicit removal can be done using dedicated methods. ```cpp //Remove a Body world->RemoveBody(myBody) //Remove a Joint world->RemoveJoint(myJoint) //Remove a Spring world->RemoveSpring(mySpring) ``` -------------------------------- ### Get Methods Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qraycast_8h_source.html Provides methods to retrieve the current state and results of the QRaycast object. ```APIDOC ## Get Methods ### Description These methods allow you to retrieve the current state and the results of the last raycast operation. ### GetContacts #### Method vector * GetContacts() #### Description Returns a pointer to the list of contacts from the last raycast. ### GetPosition #### Method QVector GetPosition() #### Description Returns the current position of the raycast origin. ### GetRotation #### Method float GetRotation() #### Description Returns the current rotation of the raycast. ### GetRayVector #### Method QVector GetRayVector() #### Description Returns the current ray vector (direction and length). ### GetEnabledContainingBodies #### Method bool GetEnabledContainingBodies() #### Description Returns whether the raycast is set to detect bodies containing the origin. ### GetCollidableLayersBit #### Method int GetCollidableLayersBit() #### Description Returns the bitmask for collidable layers. ``` -------------------------------- ### Get Static Friction Coefficient - C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qbody_8h_source.html Returns the static friction coefficient of the body. Static friction is the force that prevents an object from starting to move when at rest. ```cpp float GetStaticFriction(){ return staticFriction; } ``` -------------------------------- ### QWorld: Get Joint Index Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQWorld-members.html Finds the index of a given QJoint object. This is useful when you have a joint pointer and need to reference it by its index, for example, to remove it. ```cpp int GetJointIndex(QJoint* joint); ``` -------------------------------- ### QWorld Constructor Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQWorld.html Initializes a new QWorld object, setting up the physics simulation environment. ```APIDOC ## QWorld() ### Description Creates a new physics simulation world. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters None ### Request Example None ### Response #### Success Response (200) - **QWorld** (object) - A new QWorld instance. #### Response Example None ``` -------------------------------- ### Build Quark Physics Engine Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/index.html This script builds the Quark Physics engine. It requires SFML and CMake to be installed. The script takes a '-r' flag for releasing the build. ```bash ./build.sh -r ``` -------------------------------- ### Initialize and Perform Search - JavaScript Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/search/all_11.html This snippet initializes the search results object and performs a search. It also includes logic to hide loading and no-match indicators. Dependencies include the SearchResults class and DOM elements with IDs 'Loading', 'NoMatches', and 'searchResults'. It outputs search results to the page. ```javascript document.getElementById("Loading").style.display="none"; document.getElementById("NoMatches").style.display="none"; var searchResults = new SearchResults("searchResults"); searchResults.Search(); ``` -------------------------------- ### Remove Physics Objects from QWorld in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/getting_started.html This section details how to safely remove different physics objects from the QWorld simulation. Methods like RemoveBody, RemoveJoint, and RemoveSpring are provided by the QWorld class to detach and manage objects within the simulation. ```cpp //Remove a Body world->[RemoveBody](classQWorld.html#a853c2f727898c3219bded310cbe209bc)(myBody) //Remove a Joint world->[RemoveJoint](classQWorld.html#af8da8c8a5148dd97440b3df30598d131)(myJoint) //Remove a Spring world->[RemoveSpring](classQWorld.html#a354771cf068f3e1d09e4d4274eac0d8f)(mySpring) ``` -------------------------------- ### CMake Project Setup and SFML Dependency Source: https://github.com/erayzesen/quarkphysics/blob/master/CMakeLists.txt Initializes the CMake project and finds the required SFML 2.5 components (graphics, window, system). This is essential for projects using SFML for graphical applications. ```cmake cmake_minimum_required(VERSION 3.5) project(QuarkPhysics VERSION 1.0) find_package(SFML 2.5 COMPONENTS graphics window system REQUIRED) ``` -------------------------------- ### Set and Get Raycast Properties - C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQRaycast.html Provides examples for modifying and retrieving various properties of a QRaycast object, including its position, ray vector, enabled state for containing bodies, and collidable layers bitmask. These methods allow dynamic adjustment of raycast behavior. ```cpp #include #include // Assuming 'myRaycast' is a pointer to a QRaycast object // Setting properties: myRaycast->SetPosition(QVector(5.0f, 5.0f)); myRaycast->SetRayVector(QVector(-1.0f, 0.0f)); myRaycast->SetEnabledContainingBodies(true); myRaycast->SetCollidableLayersBit(2); // Example: only collide with layer 2 // Getting properties: QVector currentPosition = myRaycast->GetPosition(); float currentRotation = myRaycast->GetRotation(); // Note: Rotation is likely derived from rayVector int layersBit = myRaycast->GetCollidableLayersBit(); ``` -------------------------------- ### Initialize and Perform Search Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/search/functions_e.html Creates a new SearchResults object and initiates a search. This snippet first hides loading indicators, then instantiates `SearchResults` and calls its `Search` method. It's a common pattern for setting up and running searches within a web application. ```javascript var searchResults = new SearchResults("searchResults"); searchResults.Search(); ``` -------------------------------- ### QRaycast Constructor Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qraycast_8h_source.html Initializes a QRaycast object with a starting position, ray direction, and an optional flag to enable containing bodies. ```cpp QRaycast(QVector position, QVector rayVector, bool enableContainingBodies=false) ``` -------------------------------- ### JavaScript Initialization for Navigation Tree and Resizable Elements Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQWorld-members.html This JavaScript code initializes the navigation tree for the QWorld class and enables resizable elements within the documentation interface. It uses jQuery to ensure the DOM is ready before executing these initializations. The code includes GPL-v2 license headers. ```javascript /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('classQWorld.html',''); initResizable(); }); /* @license-end */ ``` -------------------------------- ### JavaScript Document Ready Initialization Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/functions_d.html Sets up event listeners and initializes navigation and search functionalities when the document is ready. This includes menu initialization and search index loading. ```javascript $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); ``` -------------------------------- ### Get Total Polygons Area - C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qbody_8h_source.html Calculates and returns the sum of the current areas of all polygons across all meshes within the body. It uses a general method to get the polygon area, reflecting its current state. ```cpp float GetTotalPolygonsArea(){ float res=0.0f; for(auto mesh:_meshes){ res+=mesh->GetPolygonArea(); } return res; } ``` -------------------------------- ### Run Quark Physics on Linux Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/index.html This script compiles and runs the Quark Physics engine directly using GCC on Linux. It requires the '-r' flag for releasing the build. ```bash ./run_linux_fast.sh -r ``` -------------------------------- ### Get Self Collisions Specified Radius (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQSoftBody.html Returns the specified radius used for self-collision detection in the soft body. This radius influences how close parts of the mesh can get before a self-collision is registered. ```C++ float QSoftBody::GetSelfCollisionsSpecifiedRadius( ) const; ``` -------------------------------- ### QPlatformerBody: Walking Movement Settings Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qplatformerbody_8h_source.html Methods to configure the walking speed, acceleration rate, and deceleration rate for the QPlatformerBody. Includes a function to initiate walking in a specified direction. ```cpp class QPlatformerBody { public: // ... other methods ... // Walk QPlatformerBody* SetWalkSpeed(float value); float GetWalkSpeed(); QPlatformerBody* SetWalkAcelerationRate(float value); float GetWalkAcelerationRate(); QPlatformerBody* SetWalkDecelerationRate(float value); float GetWalkDecelerationRate(); QPlatformerBody* Walk(int side); // ... other methods ... }; ``` -------------------------------- ### Get Total Polygons Initial Area - C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qbody_8h_source.html Calculates and returns the sum of the initial areas of all polygons across all meshes within the body. It uses a specific method to get the polygon area, potentially considering initial state. ```cpp float GetTotalPolygonsInitialArea(){ float res=0.0f; for(auto mesh:_meshes){ res+=mesh->GetPolygonArea(mesh->polygon,true); } return res; } ``` -------------------------------- ### JavaScript Initialization for Doxygen Navigation and Resizing Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQGizmoLine-members.html This JavaScript code is part of the Doxygen documentation framework, responsible for initializing the navigation tree and enabling responsive resizing of content areas. It ensures a smooth user experience for browsing documentation. ```javascript $(document).ready(function(){ initNavTree('classQGizmoLine.html',''); initResizable(); }); ``` -------------------------------- ### JavaScript Initialization for Navigation Tree and Resizable Panels Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQObjectPool-members.html Initializes the navigation tree and makes it resizable. This script is typically used in generated documentation to set up the user interface for browsing through classes and files. It relies on jQuery for DOM manipulation. ```javascript /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(document).ready(function(){initNavTree('classQObjectPool.html',''); initResizable(); }); /* @license-end */ ``` -------------------------------- ### Get Moving Floor Snap Offset in C++ Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQPlatformerBody.html Gets the current snap offset for moving floors. This value is used by the QPlatformerBody class to adjust the body's position relative to moving platforms. ```cpp /** * @brief Gets the snap offset for moving floors. * @return The current snap offset value. */ float GetMovingFloorSnapOffset() const; ``` -------------------------------- ### JavaScript Doxygen Navigation Tree Initialization Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQGizmoRect-members.html This JavaScript code initializes the navigation tree for Doxygen documentation. It's responsible for setting up the collapsible and resizable navigation panel, allowing users to browse the project's classes and files. This is a standard Doxygen feature for organizing documentation. ```javascript $(document).ready(function(){ initNavTree('classQGizmoRect.html',''); initResizable(); }); ``` -------------------------------- ### C++: QBody - Get Position Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQRigidBody.html Gets the current position of the QBody in world space. This function returns a QVector representing the body's location. It's a fundamental method for querying a body's state. ```cpp QVector QBody::GetPosition() const { // Implementation details... return QVector(); // Placeholder } ``` -------------------------------- ### C++: QRigidBody - Get Force Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQRigidBody.html Gets the current force vector acting on the QRigidBody. This function is part of the physics simulation properties, returning the accumulated force applied to the body. The output is a QVector representing the force. ```cpp QVector QRigidBody::GetForce() const { // Implementation details... return QVector(); // Placeholder } ``` -------------------------------- ### QRaycast Class Methods Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qraycast_8h_source.html This section details the methods available for the QRaycast class, including constructor, raycasting, and setter methods. ```APIDOC ## QRaycast Class ### Description Provides functionality for performing raycasts in the physics world. ### Methods #### QRaycast(QVector position, QVector rayVector, bool enableContainingBodies=false) ##### Description Constructor for the QRaycast class. ##### Parameters - **position** (QVector) - The starting position of the ray. - **rayVector** (QVector) - The direction and magnitude of the ray. - **enableContainingBodies** (bool) - Optional. Whether to include bodies that contain the ray's origin. Defaults to false. #### static vector< QRaycast::Contact > RaycastTo(QWorld *world, QVector rayPosition, QVector rayVector, int collidableLayers=1, bool enableContainingBodies=false) ##### Description Performs a raycast against the physics world and returns a list of contacts. ##### Parameters - **world** (QWorld*) - The physics world to perform the raycast in. - **rayPosition** (QVector) - The starting position of the ray. - **rayVector** (QVector) - The direction and magnitude of the ray. - **collidableLayers** (int) - Optional. A bitmask to specify which layers the ray should collide with. Defaults to 1. - **enableContainingBodies** (bool) - Optional. Whether to include bodies that contain the ray's origin. Defaults to false. ##### Returns - `vector< QRaycast::Contact >` - A list of contact points found by the raycast. #### QRaycast * SetPosition(QVector value) ##### Description Sets the starting position of the ray. ##### Parameters - **value** (QVector) - The new position for the ray. ##### Returns - `QRaycast*` - A pointer to the QRaycast object for chaining. #### QVector GetRayVector() ##### Description Gets the current ray vector. ##### Returns - `QVector` - The ray vector. #### void SetCollidableLayersBit(int value) ##### Description Sets the bitmask for collidable layers. ##### Parameters - **value** (int) - The bitmask value. ### Members #### bool manualDeletion ##### Description A flag indicating if the object should be manually deleted. ##### Type - `bool` ``` -------------------------------- ### QBody: Get Status Properties (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQSoftBody.html Methods to retrieve the current status of certain QBody properties. This includes checking if features like custom gravity or integrated velocities are enabled, and getting the current velocity limit. ```C++ bool GetIntegratedVelocitiesEnabled(); bool GetCustomGravityEnabled(); float GetVelocityLimit(); float GetEnabled(); ``` -------------------------------- ### Get Layer and Collision Properties Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQSoftBody.html Functions to query the layers the body belongs to and its collision behavior. This includes getting the layers bitmask, collidable layers bitmask, and checking for overlap with specific layers. Returns integers for bitmasks and booleans for overlap checks. ```cpp int GetLayersBit () int GetCollidableLayersBit () bool GetOverlapWithCollidableLayersBit (int layersBit) bool GetOverlapWithLayersBit (int layersBit) ``` -------------------------------- ### JavaScript Navigation Tree and Resizable Initialization Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/functions_w.html Initializes the navigation tree and enables a resizable sidebar for the Doxygen documentation. This code runs when the document is ready, setting up the interactive elements of the documentation interface. ```javascript $(document).ready(function(){ initNavTree('functions_w.html',''); initResizable(); }); ``` -------------------------------- ### JavaScript Initialization for Search and Navigation Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQObjectPool-members.html Initializes the search box and navigation tree for the documentation. It uses jQuery to ensure the DOM is ready before executing the initialization functions. This script is often generated by documentation tools like Doxygen. ```javascript /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ var searchBox = new SearchBox("searchBox", "search",false,'Search','.html'); /* @license-end */ /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); /* @license-end */ ``` -------------------------------- ### Get Body Information from QBody (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQSoftBody-members.html Methods to retrieve specific physical properties or states of a QBody object. This includes getting the initial area of polygons, the current velocity limit, and the world the body belongs to. It also provides access to properties like mass, position, and rotation. ```C++ float GetTotalPolygonsInitialArea(); float GetVelocityLimit(); QWorld* GetWorld(); // Properties like mass, position, rotation are accessed directly or via getters not fully specified. ``` -------------------------------- ### JavaScript Initialization for Search and Navigation (Doxygen) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQGizmo-members.html This JavaScript code initializes the search functionality and navigation tree for a Doxygen-generated documentation site. It sets up event listeners for document ready states to ensure all elements are loaded before initialization. ```javascript var searchBox = new SearchBox("searchBox", "search",false,'Search','.html'); $(function() { initMenu('',true,false,'search.php','Search'); $(document).ready(function() { init_search(); }); }); $(document).ready(function(){ initNavTree('classQGizmo.html',''); initResizable(); }); ``` -------------------------------- ### C++ Class Definitions for Doxygen Graph Legend Example Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/graph_legend.html These C++ class definitions are used as an example to demonstrate how doxygen generates inheritance and usage graphs. They showcase various inheritance types (public, protected, private) and template instantiation, influencing the visual representation in the generated documentation. ```cpp /* * Invisible class because of truncation */ class Invisible { }; /* * Truncated class, inheritance relation is hidden */ class Truncated : public Invisible { }; /* Class not documented with doxygen comments */ class Undocumented { }; /* * Class that is inherited using public inheritance */ class PublicBase : public Truncated { }; /* * A template class */ template class Templ { }; /* * Class that is inherited using protected inheritance */ class ProtectedBase { }; /* * Class that is inherited using private inheritance */ class PrivateBase { }; /* * Class that is used by the Inherited class */ class Used { }; /* * Super class that inherits a number of other classes */ class Inherited : public PublicBase, protected ProtectedBase, private PrivateBase, public Undocumented, public Templ { private: Used *m_usedClass; }; ``` -------------------------------- ### Get Rigidity of QSoftBody (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qsoftbody_8h_source.html Retrieves the rigidity value of the soft body. ```cpp float GetRigidity(){ return rigidity; }; ``` -------------------------------- ### QAABB Class Definition and Methods (C++) Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qaabb_8h_source.html Defines the QAABB class, including its members (minPos, maxPos, size, volume) and methods for initializing, setting, and retrieving bounding box properties. It also includes methods for calculating perimeter, area, center position, volume, checking containment, combining bounding boxes, and fattening the box. ```C++ #ifndef QAABB_H #define QAABB_H #include "qvector.h" #include using namespace std; class QParticle; class QAABB { QVector minPos; QVector maxPos; QVector size; float volume; static float multiplier; public: QAABB(){ QAABB(minPos,maxPos); } QAABB(QVector minPosition, QVector maxPosition ){ minPos=minPosition; maxPos=maxPosition; size=maxPos-minPos; volume=size.x*size.y; }; //General Get Methods QVector GetMin(){ return minPos; } QVector GetMax(){ return maxPos; } QVector GetSize(){ return size; } //General Set Methods QAABB * SetMinMax(QVector minPosition,QVector maxPosition){ minPos=minPosition; maxPos=maxPosition; size=maxPos-minPos; volume=size.x*size.y; return this; } float GetPerimeter() const{ return 2.0f*(size.x+size.y); } float GetArea()const{ return size.x*size.y; } QVector GetCenterPosition()const { return (minPos+maxPos)*0.5f; } float GetVolume() const{ return volume; } double isContain(const QAABB& otherAABB) const { return (minPos.x <= otherAABB.minPos.x) && (minPos.y <= otherAABB.minPos.y) && (maxPos.x >= otherAABB.maxPos.x) && (maxPos.y >= otherAABB.maxPos.y); } static QAABB Combine( QAABB &b1, QAABB &b2){ QAABB output=QAABB(); float minX=b1.minPos.xb2.maxPos.x ? b1.maxPos.x : b2.maxPos.x; float maxY=b1.maxPos.y>b2.maxPos.y ? b1.maxPos.y : b2.maxPos.y; output.SetMinMax(QVector(minX,minY),QVector(maxX,maxY) ); return output; }; void Fatten(float amount){ ``` -------------------------------- ### QWorld - Get Gizmos Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/classQWorld-members.html Retrieves the gizmos associated with the QWorld. ```APIDOC ## GET /qworld/gizmos ### Description Retrieves the gizmos associated with the QWorld. ### Method GET ### Endpoint /qworld/gizmos ### Parameters None ### Request Example None ### Response #### Success Response (200) - **gizmos** (object) - The gizmos object. #### Response Example ```json { "gizmos": {} } ``` ``` -------------------------------- ### QWorld::GetSleepingRotationTolerance Source: https://github.com/erayzesen/quarkphysics/blob/master/documentation/qworld_8h_source.html Gets the current sleeping rotation tolerance threshold. ```APIDOC ## GET /erayzesen/quarkphysics/qworld.h ### Description Gets the current sleeping rotation tolerance threshold. ### Method GET ### Endpoint /erayzesen/quarkphysics/qworld.h ### Response #### Success Response (200) - **tolerance** (float) - The sleeping rotation tolerance. ```