You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							79 lines
						
					
					
						
							3.2 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							79 lines
						
					
					
						
							3.2 KiB
						
					
					
				
								#pragma once
							 | 
						|
								
							 | 
						|
								#include <macros.h>
							 | 
						|
								#include <math/math_defs.h>
							 | 
						|
								
							 | 
						|
								#include <primitive_descriptor.h>
							 | 
						|
								
							 | 
						|
								EXTERN_C_BEGIN
							 | 
						|
								
							 | 
						|
								// forward declaration
							 | 
						|
								struct primitive;
							 | 
						|
								struct primitive_data_center_t;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Create a new primitive data center to hold all data of primitives
							 | 
						|
								 * @return A pointer to the primitive data center
							 | 
						|
								 */
							 | 
						|
								API primitive_data_center_t* create_primitive_data_center() noexcept;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Destroy the primitive data center and collect all primitives' data in it
							 | 
						|
								 * @param[in] data_center The pointer to the primitive data center
							 | 
						|
								 * @note This function will free all the data in the primitive data center, including the primitive data itself.
							 | 
						|
								 */
							 | 
						|
								API void destroy_primitive_data_center(primitive_data_center_t* data_center) noexcept;
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Create a new identity primitive
							 | 
						|
								 * @param[in] data_center The pointer to the primitive data center which will hold the data of new primitive
							 | 
						|
								 * @param[in] type The type of the primitive, which is used to determine the shape of the primitive
							 | 
						|
								 * @return A pointer to the new primitive
							 | 
						|
								 * @note This function will create a new primitive which has the same shape under local and world coord system. Detailly, for
							 | 
						|
								 * each type of primitive:
							 | 
						|
								 * - sphere: Centered at the origin with radius 1.0
							 | 
						|
								 */
							 | 
						|
								API primitive* create_primitive(void* data_center, primitive_type type);
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Destroy a primitive
							 | 
						|
								 * @param[in] primitive_ptr The pointer to the primitive
							 | 
						|
								 */
							 | 
						|
								API void destroy_primitive(primitive* primitive_ptr);
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Apply a scale to a valid primitive
							 | 
						|
								 * @param[in] primitive_ptr The pointer to the primitive
							 | 
						|
								 * @param[in] scale The scale vector, each component is the scale factor along the corresponding axis
							 | 
						|
								 * @note During this function call, the primitive may be changed to a new one, so the pointer to the primitive may be changed or
							 | 
						|
								 * invalidated
							 | 
						|
								 */
							 | 
						|
								API void primitive_apply_scale(primitive* primitive_ptr, vector3d scale);
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Apply a rotation to a valid primitive
							 | 
						|
								 * @param[in] primitive_ptr The pointer to the primitive
							 | 
						|
								 * @param[in] quaternion The quaternion representing the rotation
							 | 
						|
								 * @note During this function call, the primitive may be changed to a new one, so the pointer to the primitive may be changed or
							 | 
						|
								 * invalidated
							 | 
						|
								 * @note The quaternion should be normalized, otherwise the result may be unexpected
							 | 
						|
								 */
							 | 
						|
								API void primitive_apply_rotation(primitive* primitive_ptr, vector4d quaternion);
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Apply a translation to a valid primitive
							 | 
						|
								 * @param[in] primitive_ptr The pointer to the primitive
							 | 
						|
								 * @param[in] translation The translation vector, each component is the translation along the corresponding axis
							 | 
						|
								 * @note During this function call, the primitive may be changed to a new one, so the pointer to the primitive may be changed or
							 | 
						|
								 */
							 | 
						|
								API void primitive_apply_translation(primitive* primitive_ptr, vector3d translation);
							 | 
						|
								
							 | 
						|
								/**
							 | 
						|
								 * @brief Duplicate a primitive
							 | 
						|
								 * @param[in] primitive_ptr The pointer to the primitive
							 | 
						|
								 * @return A new pointer to the duplicated primitive, which is a new object in the memory
							 | 
						|
								 * @note The duplicated primitive initially has the same subface pointers, but after transformations they may be changed
							 | 
						|
								 */
							 | 
						|
								API primitive* duplicate_primitive(const primitive* primitive_ptr);
							 | 
						|
								
							 | 
						|
								EXTERN_C_END
							 |