Modernize struct and enum style in MuJoCo headers.

PiperOrigin-RevId: 936485706
Change-Id: I31864acc4bd44573127d3d04c6b1a23f9d9c4cbc
This commit is contained in:
Kyle Bayes
2026-06-23 00:47:13 -07:00
committed by Copybara-Service
parent afccd36dd4
commit 0fd7bea973
12 changed files with 463 additions and 548 deletions
+24 -29
View File
@@ -26,15 +26,15 @@
//------------------------------------- Contact ----------------------------------------------------
struct mjPreContact_ { // contact parameters set by narrowphase collision functions
typedef struct mjPreContact_ { // contact parameters set by narrowphase collision functions
mjtNum dist;
mjtNum pos[3];
mjtNum normal[3]; // contact normal of the collision
mjtNum tangent[3]; // first tangent direction
};
typedef struct mjPreContact_ mjPreContact;
} mjPreContact;
struct mjContact_ { // result of collision detection functions
typedef struct mjContact_ { // result of collision detection functions
// contact parameters set by narrowphase collision function
mjtNum dist; // distance between nearest points; neg: penetration
mjtNum pos[3]; // position of contact point: midpoint between geoms
@@ -65,41 +65,37 @@ struct mjContact_ { // result of collision detection functions
// address computed by mj_instantiateContact
int efc_address; // address in efc; -1: not included
};
typedef struct mjContact_ mjContact;
} mjContact;
//---------------------------------- diagnostics ---------------------------------------------------
struct mjWarningStat_ { // warning statistics
int lastinfo; // info from last warning
int number; // how many times was warning raised
};
typedef struct mjWarningStat_ mjWarningStat;
typedef struct mjWarningStat_ { // warning statistics
int lastinfo; // info from last warning
int number; // how many times was warning raised
} mjWarningStat;
struct mjTimerStat_ { // timer statistics
mjtNum duration; // cumulative duration
int number; // how many times was timer called
};
typedef struct mjTimerStat_ mjTimerStat;
typedef struct mjTimerStat_ { // timer statistics
mjtNum duration; // cumulative duration
int number; // how many times was timer called
} mjTimerStat;
struct mjSolverStat_ { // per-iteration solver statistics
mjtNum improvement; // cost reduction, scaled by 1/trace(M(qpos0))
mjtNum gradient; // gradient norm (primal only, scaled)
mjtNum lineslope; // slope in linesearch
int nactive; // number of active constraints
int nchange; // number of constraint state changes
int neval; // number of cost evaluations in line search
int nupdate; // number of Cholesky updates in line search
};
typedef struct mjSolverStat_ mjSolverStat;
typedef struct mjSolverStat_ { // per-iteration solver statistics
mjtNum improvement; // cost reduction, scaled by 1/trace(M(qpos0))
mjtNum gradient; // gradient norm (primal only, scaled)
mjtNum lineslope; // slope in linesearch
int nactive; // number of active constraints
int nchange; // number of constraint state changes
int neval; // number of cost evaluations in line search
int nupdate; // number of Cholesky updates in line search
} mjSolverStat;
//---------------------------------- mjData --------------------------------------------------------
struct mjData_ {
typedef struct mjData_ {
// constant sizes
mjtSize narena; // size of the arena in bytes (inclusive of the stack)
mjtSize nbuffer; // size of main buffer in bytes
@@ -411,8 +407,7 @@ struct mjData_ {
// compilation signature
uint64_t signature; // also held by the mjSpec that compiled the model
};
typedef struct mjData_ mjData;
} mjData;
//---------------------------------- callback function types ---------------------------------------
+14 -21
View File
@@ -50,7 +50,7 @@
//---------------------------------- mjLROpt -------------------------------------------------------
struct mjLROpt_ { // options for mj_setLengthRange()
typedef struct mjLROpt_ { // options for mj_setLengthRange()
// flags
int mode; // which actuators to process (mjtLRMode)
int useexisting; // use existing length range if available
@@ -64,26 +64,23 @@ struct mjLROpt_ { // options for mj_setLengthRange()
mjtNum inttotal; // total simulation time interval
mjtNum interval; // evaluation time interval (at the end)
mjtNum tolrange; // convergence tolerance (relative to range)
};
typedef struct mjLROpt_ mjLROpt;
} mjLROpt;
//---------------------------------- mjCache -------------------------------------------------------
struct mjCache_ { // asset cache used by the compiler
typedef struct mjCache_ { // asset cache used by the compiler
void* impl_; // internal pointer to cache
};
typedef struct mjCache_ mjCache;
} mjCache;
//---------------------------------- mjVFS ---------------------------------------------------------
struct mjVFS_ { // virtual file system for loading from memory
typedef struct mjVFS_ { // virtual file system for loading from memory
void* impl_; // internal pointer to VFS memory
};
typedef struct mjVFS_ mjVFS;
} mjVFS;
//---------------------------------- mjOption ------------------------------------------------------
struct mjOption_ { // physics options
typedef struct mjOption_ { // physics options
// timing parameters
mjtNum timestep; // timestep
@@ -126,13 +123,12 @@ struct mjOption_ { // physics options
// sdf collision settings
int sdf_initpoints; // number of starting points for gradient descent
int sdf_iterations; // max number of iterations for gradient descent
};
typedef struct mjOption_ mjOption;
} mjOption;
//---------------------------------- mjVisual ------------------------------------------------------
struct mjVisual_ { // visualization options
typedef struct mjVisual_ { // visualization options
struct { // global parameters
int cameraid; // initial camera id (-1: free)
int orthographic; // is the free camera orthographic (0: no, 1: yes)
@@ -227,25 +223,23 @@ struct mjVisual_ { // visualization options
float bv[4]; // bounding volume
float bvactive[4]; // active bounding volume
} rgba;
};
typedef struct mjVisual_ mjVisual;
} mjVisual;
//---------------------------------- mjStatistic ---------------------------------------------------
struct mjStatistic_ { // model statistics (in qpos0)
typedef struct mjStatistic_ { // model statistics (in qpos0)
mjtNum meaninertia; // mean diagonal inertia
mjtNum meanmass; // mean body mass
mjtNum meansize; // mean body size
mjtNum extent; // spatial extent
mjtNum center[3]; // center of model
};
typedef struct mjStatistic_ mjStatistic;
} mjStatistic;
//---------------------------------- mjModel -------------------------------------------------------
struct mjModel_ {
typedef struct mjModel_ {
// ------------------------------- sizes
// sizes needed at mjModel construction
@@ -896,7 +890,6 @@ struct mjModel_ {
// compilation signature
uint64_t signature; // also held by the mjSpec that compiled this model
};
typedef struct mjModel_ mjModel;
} mjModel;
#endif // MUJOCO_MJMODEL_H_
+12 -18
View File
@@ -24,14 +24,13 @@
//---------------------------------- Resource Provider ---------------------------------------------
struct mjResource_ {
typedef struct mjResource_ {
char* name; // name of resource (filename, etc)
void* data; // opaque data pointer
mjVFS* vfs; // pointer to the VFS
char timestamp[512]; // timestamp of the resource
const struct mjpResourceProvider* provider; // pointer to the provider
};
typedef struct mjResource_ mjResource;
} mjResource;
// callback for opening a resource, returns zero on failure.
// Note: If opening fails, the close callback will not be called. Therefore, the
@@ -60,7 +59,7 @@ typedef int (*mjfUnmountResource)(mjResource* resource);
typedef int (*mjfResourceModified)(const mjResource* resource, const char* timestamp);
// struct describing a single resource provider
struct mjpResourceProvider {
typedef struct mjpResourceProvider {
const char* prefix; // prefix for match against a resource name
mjfOpenResource open; // opening callback
mjfReadResource read; // reading callback
@@ -69,8 +68,7 @@ struct mjpResourceProvider {
mjfUnmountResource unmount; // unmounting callback (optional)
mjfResourceModified modified; // resource modified callback (optional)
void* data; // opaque data pointer (resource invariant)
};
typedef struct mjpResourceProvider mjpResourceProvider;
} mjpResourceProvider;
//---------------------------------- Decoder -------------------------------------------------------
@@ -81,7 +79,7 @@ typedef mjSpec* (*mjfDecode)(mjResource* resource, const mjVFS* vfs);
typedef int (*mjfCanDecode)(const mjResource* resource);
// the struct defining the decoder plugin's interface
struct mjpDecoder {
typedef struct mjpDecoder {
const char* content_type;
const char* extension;
// user-facing functions
@@ -89,21 +87,19 @@ struct mjpDecoder {
mjfDecode decode; // main decoding function
// the caller takes ownership of the spec returned by decode and is responsible
// for cleaning it up
};
typedef struct mjpDecoder mjpDecoder;
} mjpDecoder;
//---------------------------------- Encoder -------------------------------------------------------
typedef int (*mjfEncode)(const mjSpec* s, const mjModel* m, const mjVFS* vfs,
mjResource* resource);
struct mjpEncoder {
typedef struct mjpEncoder {
const char* content_type;
const char* extension;
mjfEncode encode; // Function to encode an mjSpec and mjModel to a mjResource.
mjfCloseResource close_resource; // Function to close/free the resource.
};
typedef struct mjpEncoder mjpEncoder;
} mjpEncoder;
//---------------------------------- Plugins -------------------------------------------------------
@@ -114,7 +110,7 @@ typedef enum mjtPluginCapabilityBit_ {
mjPLUGIN_SDF = 1<<3, // signed distance fields
} mjtPluginCapabilityBit;
struct mjpPlugin_ {
typedef struct mjpPlugin_ {
const char* name; // globally unique name identifying the plugin
int nattribute; // number of configuration attributes
@@ -172,18 +168,16 @@ struct mjpPlugin_ {
// bounding box of implicit surface
void (*sdf_aabb)(mjtNum aabb[6], const mjtNum* attributes);
};
typedef struct mjpPlugin_ mjpPlugin;
} mjpPlugin;
struct mjSDF_ {
typedef struct mjSDF_ {
const mjpPlugin** plugin;
int* id;
mjtSDFType type;
mjtNum* relpos;
mjtNum* relmat;
mjtGeom* geomtype;
};
typedef struct mjSDF_ mjSDF;
} mjSDF;
//------------------------------------ Initialization ----------------------------------------------
+9 -12
View File
@@ -109,21 +109,19 @@ typedef enum mjrMeshPrimitiveType_ { // type of mesh primitive
} mjrMeshPrimitiveType;
struct mjrRect_ { // OpenGL rectangle
typedef struct mjrRect_ { // OpenGL rectangle
int left; // left (usually 0)
int bottom; // bottom (usually 0)
int width; // width (usually buffer width)
int height; // height (usually buffer height)
};
typedef struct mjrRect_ mjrRect;
} mjrRect;
struct mjrVertexAttribute_ { // vertex attribute format specification
const void* bytes; // vertex data
int usage; // mjrVertexAttributeUsage; e.g. position, normal, etc.
int type; // mjrVertexAttributeType; e.g. float3, ubyte4, etc.
};
typedef struct mjrVertexAttribute_ mjrVertexAttribute;
typedef struct mjrVertexAttribute_ { // vertex attribute format specification
const void* bytes; // vertex data
int usage; // mjrVertexAttributeUsage; e.g. position, normal, etc.
int type; // mjrVertexAttributeType; e.g. float3, ubyte4, etc.
} mjrVertexAttribute;
// alias non-rendering types into mjr namespace
@@ -135,7 +133,7 @@ typedef mjvGLCamera mjrCamera;
//---------------------------------- mjrContext ----------------------------------------------------
struct mjrContext_ { // custom OpenGL context
typedef struct mjrContext_ { // custom OpenGL context
// parameters copied from mjVisual
float lineWidth; // line width for wireframe rendering
float shadowClip; // clipping radius for directional lights
@@ -226,8 +224,7 @@ struct mjrContext_ { // custom OpenGL context
// depth output format
int readDepthMap; // depth mapping: mjDEPTH_ZERONEAR or mjDEPTH_ZEROFAR
};
typedef struct mjrContext_ mjrContext;
} mjrContext;
#if defined(__cplusplus)
}
+90 -102
View File
@@ -89,12 +89,11 @@ typedef enum mjrGraphicsApi_ { // underlying graphics API to use for rendering
mjGRAPHICS_API_VULKAN, // vulkan
} mjrGraphicsApi;
struct mjrfContextConfig_ { // parameters for creating filament context (mjrfContext)
typedef struct mjrfContextConfig_ { // parameters for creating filament context (mjrfContext)
int graphics_api; // mjrGraphicsApi; rendering graphics API
mjtBool force_software_rendering; // force backend to use software rendering
void* native_window; // platform-dependent window handle (or nullptr for windowless)
};
typedef struct mjrfContextConfig_ mjrfContextConfig;
} mjrfContextConfig;
// Initializes the mjrfContextConfig to default values.
void mjrf_defaultContextConfig(mjrfContextConfig* config);
@@ -115,29 +114,27 @@ typedef enum mjrDrawMode_ { // how to draw objects in the scene
mjDRAW_MODE_SEGMENTATION_BY_COLOR, // generate visually distinct colors using segmentation id
} mjrDrawMode;
struct mjrfRenderRequest_ { // a single rendering operation
mjrfScene* scene; // scene to render
mjrCamera camera; // camera (viewpoint) from which to render scene
mjrRect viewport; // viewport (rect area) into which to render
mjrfRenderTarget* target; // target used for rendering (or nullptr for window rendering)
int draw_mode; // mjrDrawMode; method to use for drawing objects
mjtBool enable_post_processing; // enable post processing, enabled by default
mjtBool enable_reflections; // enable reflections, enabled by default
mjtBool enable_shadows; // enable shadows, enabled by default
};
typedef struct mjrfRenderRequest_ mjrfRenderRequest;
typedef struct mjrfRenderRequest_ { // a single rendering operation
mjrfScene* scene; // scene to render
mjrCamera camera; // camera (viewpoint) from which to render scene
mjrRect viewport; // viewport (rect area) into which to render
mjrfRenderTarget* target; // target used for rendering (or nullptr for window rendering)
int draw_mode; // mjrDrawMode; method to use for drawing objects
mjtBool enable_post_processing; // enable post processing, enabled by default
mjtBool enable_reflections; // enable reflections, enabled by default
mjtBool enable_shadows; // enable shadows, enabled by default
} mjrfRenderRequest;
// Initializes the mjrfRenderRequest to default values.
void mjrf_defaultRenderRequest(mjrfRenderRequest* request);
struct mjrfReadPixelsRequest_ { // a single read operation
mjrfRenderTarget* target; // render target from which to read the image pixels
void* output; // buffer into which the pixels will be stored
mjtSize num_bytes; // size of output buffer
mjrfCallback read_completed; // callback when read is complete; can use to free output
void* user_data; // user data for read_completed_callback
};
typedef struct mjrfReadPixelsRequest_ mjrfReadPixelsRequest;
typedef struct mjrfReadPixelsRequest_ { // a single read operation
mjrfRenderTarget* target; // render target from which to read the image pixels
void* output; // buffer into which the pixels will be stored
mjtSize num_bytes; // size of output buffer
mjrfCallback read_completed; // callback when read is complete; can use to free output
void* user_data; // user data for read_completed_callback
} mjrfReadPixelsRequest;
// Initializes the mjrfReadPixelsRequest to default values.
void mjrf_defaultReadPixelsRequest(mjrfReadPixelsRequest* request);
@@ -164,10 +161,9 @@ void mjrf_waitForFrame(mjrfContext* ctx, mjrfFrameHandle frame);
// Sets the clear color for the renderer.
void mjrf_setClearColor(mjrfContext* ctx, const float color[3]);
struct mjrfFrameStats_ { // stats for a single frame of rendering
double frame_rate; // frame rate, in frames per second
};
typedef struct mjrfFrameStats_ mjrfFrameStats;
typedef struct mjrfFrameStats_ { // stats for a single frame of rendering
double frame_rate; // frame rate, in frames per second
} mjrfFrameStats;
// Initializes the mjrFrameStats to default values.
void mjrf_defaultFrameStats(mjrfFrameStats* stats);
@@ -184,14 +180,13 @@ void mjrf_getFrameStats(mjrfContext* ctx, mjrfFrameHandle frame, mjrfFrameStats*
// filament's `cmgen` tool to generate a KTX image from your source image. This tool will calculate
// additional data (i.e. the spherical harmonics) and encode that information into the KTX file.
struct mjrfTextureConfig_ { // parameters for creating a texture (mjrfTexture)
int width; // texture width; or number of bytes for compressed data (e.g. KTX)
int height; // texture height; or 0 for compressed data (e.g. KTX)
int format; // mjrPixelFormat; (e.g. RGB8, RGBA8, KTX, etc.)
int color_space; // mjrColorSpace; (e.g. LINEAR, sRGB, etc.)
int sampler_type; // mjrSamplerType; texture sampler (e.g. 2D, cube, etc.)
};
typedef struct mjrfTextureConfig_ mjrfTextureConfig;
typedef struct mjrfTextureConfig_ { // parameters for creating a texture (mjrfTexture)
int width; // width; or number of bytes for compressed data (e.g. KTX)
int height; // height; or 0 for compressed data (e.g. KTX)
int format; // mjrPixelFormat; (e.g. RGB8, RGBA8, KTX, etc.)
int color_space; // mjrColorSpace; (e.g. LINEAR, sRGB, etc.)
int sampler_type; // mjrSamplerType; texture sampler (e.g. 2D, cube, etc.)
} mjrfTextureConfig;
// Initializes the mjrfTextureConfig to default values.
void mjrf_defaultTextureConfig(mjrfTextureConfig* config);
@@ -204,13 +199,12 @@ mjrfTexture* mjrf_createTexture(mjrfContext* ctx,
// Destroys the texture.
void mjrf_destroyTexture(mjrfTexture* texture);
struct mjrfTextureData_ { // binary data for a texture (mjrfTexture)
const void* bytes; // pointer to image data, or nullptr for empty texture
mjtSize num_bytes; // number of bytes in the image data
mjrfCallback release; // callback when data has finished uploading
void* user_data; // user data for release callback
};
typedef struct mjrfTextureData_ mjrfTextureData;
typedef struct mjrfTextureData_ { // binary data for a texture (mjrfTexture)
const void* bytes; // pointer to image data, or nullptr for empty texture
mjtSize num_bytes; // number of bytes in the image data
mjrfCallback release; // callback when data has finished uploading
void* user_data; // user data for release callback
} mjrfTextureData;
// Initializes the mjrfTextureData to default values.
void mjrf_defaultTextureData(mjrfTextureData* data);
@@ -252,22 +246,21 @@ int mjrf_getSamplerType(const mjrfTexture* texture);
// Maximum number of vertex attributes in a mesh.
enum { mjMAX_VERTEX_ATTRIBUTES = 16 };
struct mjrfMeshData_ { // binary data for a mesh (mjrfMesh)
mjtSize num_vertices; // number of vertices; all vertex attributes share this size
int num_attributes; // number of attributes defined
typedef struct mjrfMeshData_ { // binary data for a mesh (mjrfMesh)
mjtSize num_vertices; // number of vertices; all vertex attributes share this size
int num_attributes; // number of attributes defined
mjrVertexAttribute attributes[mjMAX_VERTEX_ATTRIBUTES]; // per-vertex attribute information
mjtBool interleaved; // true if vertex attributes are interleaved
mjtSize num_indices; // number of indices
const void* indices; // indices data array
int index_type; // mjrIndexType; (e.g. UINT16 or UINT32)
int primitive_type; // mjrMeshPrimitiveType; (e.g. TRIANGLES, etc.)
mjtBool compute_bounds; // if true, compute bounds from vertex positions
float bounds_min[3]; // min/max bounds; assume unset if bounds_min == bounds_max
mjtBool interleaved; // true if vertex attributes are interleaved
mjtSize num_indices; // number of indices
const void* indices; // indices data array
int index_type; // mjrIndexType; (e.g. UINT16 or UINT32)
int primitive_type; // mjrMeshPrimitiveType; (e.g. TRIANGLES, etc.)
mjtBool compute_bounds; // if true, compute bounds from vertex positions
float bounds_min[3]; // min/max bounds; assume unset if bounds_min == bounds_max
float bounds_max[3];
mjrfCallback release; // callback when data has finished uploading
void* user_data; // user data for release callback
};
typedef struct mjrfMeshData_ mjrfMeshData;
mjrfCallback release; // callback when data has finished uploading
void* user_data; // user data for release callback
} mjrfMeshData;
// Initializes the mjrfMeshData to default values.
void mjrf_defaultMeshData(mjrfMeshData* data);
@@ -283,9 +276,8 @@ void mjrf_destroyMesh(mjrfMesh* mesh);
// A scene is a collection of entities (Lights and Renderables) that describes what is to be
// rendered.
struct mjrfSceneParams_ { // parameters for creating a scene (mjrfScene)
};
typedef struct mjrfSceneParams_ mjrfSceneParams;
typedef struct mjrfSceneParams_ { // parameters for creating a scene (mjrfScene)
} mjrfSceneParams;
// Initializes the mjrfSceneParams to default values.
void mjrf_defaultSceneParams(mjrfSceneParams* params);
@@ -331,19 +323,18 @@ void mjrf_configureSceneFromModel(mjrfScene* scene, const mjModel* model);
// lights as you want. Each light source (except image based lights) may or may not cast shadows.
// Each shadow-casting light incurs a performance cost.
struct mjrfLightParams_ { // parameters for creating a light (mjrfLight)
int type; // mjrLightType; type of light (e.g. spot, point, image, etc.)
const mjrfTexture* texture; // texture; only for image lights
float color[3]; // RGB color
float intensity; // light intensity, in candela
mjtBool cast_shadows; // if true, cast shadows
float range; // effective range of light, in meters
float spot_cone_angle; // spot light cone angle, in degrees
int shadow_map_size; // size of shadow map texture, 0 to use default size
float bulb_radius; // bulb radius, used for soft shadows
float vsm_blur_width; // variance shadow map blur width
};
typedef struct mjrfLightParams_ mjrfLightParams;
typedef struct mjrfLightParams_ { // parameters for creating a light (mjrfLight)
int type; // mjrLightType; type of light (e.g. spot, point, image, etc.)
const mjrfTexture* texture; // texture; only for image lights
float color[3]; // RGB color
float intensity; // light intensity, in candela
mjtBool cast_shadows; // if true, cast shadows
float range; // effective range of light, in meters
float spot_cone_angle; // spot light cone angle, in degrees
int shadow_map_size; // size of shadow map texture, 0 to use default size
float bulb_radius; // bulb radius, used for soft shadows
float vsm_blur_width; // variance shadow map blur width
} mjrfLightParams;
// Initializes the mjrfLightParams to default values.
void mjrf_defaultLightParams(mjrfLightParams* params);
@@ -385,22 +376,22 @@ int mjrf_getLightType(const mjrfLight* light);
//
// Which lighting model is used is determined by the mjrfMaterial properties.
struct mjrfMaterial_ { // material properties for a renderable (mjrfMaterial)
float color[4]; // object color; defaults to white
int32_t segmentation_id; // ID for segmentation rendering; maps to RGB8 color (i.e. 24 bits)
int32_t island_id; // ID to which the renderable belongs
int sleep_state; // mjtSleepState; sleep state of the renderable
float uv_scale[3]; // scale applied to UV coordinates; defaults to (1,1,1)
float uv_offset[3]; // offset applied to UV coordinates; defaults to (0,0,0)
float scissor[4]; // if non-zero, applies scissor testing when rendering
float metallic; // metallic factory [0, 1]; disabled if < 0
float roughness; // roughness factor [0, 1]; disabled if < 0
float specular; // specular factor [0, 1]; disabled if < 0
float glossiness; // glossiness factor [0, 1]; disabled if < 0
float emissive; // emissive/glow factor [0, 1]; disabled if < 0
float reflectance; // blend factor for reflective surfaces [0, 1]; applies only to planes
mjtBool decor_ux; // for ux elements, does not apply any lighting
mjtBool selected; // for "selected" ux elements, adds additional styling
typedef struct mjrfMaterial_ { // material properties for a renderable (mjrfMaterial)
float color[4]; // object color; defaults to white
int32_t segmentation_id; // ID for segmentation rendering; maps to RGB8 color (i.e. 24 bits)
int32_t island_id; // ID to which the renderable belongs
int sleep_state; // mjtSleepState; sleep state of the renderable
float uv_scale[3]; // scale applied to UV coordinates; defaults to (1,1,1)
float uv_offset[3]; // offset applied to UV coordinates; defaults to (0,0,0)
float scissor[4]; // if non-zero, applies scissor testing when rendering
float metallic; // metallic factory [0, 1]; disabled if < 0
float roughness; // roughness factor [0, 1]; disabled if < 0
float specular; // specular factor [0, 1]; disabled if < 0
float glossiness; // glossiness factor [0, 1]; disabled if < 0
float emissive; // emissive/glow factor [0, 1]; disabled if < 0
float reflectance; // blend factor for reflective surfaces [0, 1]; only for planes
mjtBool decor_ux; // for ux elements, does not apply any lighting
mjtBool selected; // for "selected" ux elements, adds additional styling
const mjrfTexture* color_texture; // color/albedo texture (RGB8)
const mjrfTexture* opacity_texture; // opacity texture (A8)
const mjrfTexture* normal_texture; // normal map texture (RGB8)
@@ -410,18 +401,16 @@ struct mjrfMaterial_ { // material properties for a renderable (mjrfMater
const mjrfTexture* orm_texture; // occlusion/roughness/metallic texture (RGB8)
const mjrfTexture* emissive_texture; // emissive texture (RGB8)
const mjrfTexture* reflection_texture; // reflection texture, for internal use only
};
typedef struct mjrfMaterial_ mjrfMaterial;
} mjrfMaterial;
// Initializes the mjrfMaterial to default values.
void mjrf_defaultMaterial(mjrfMaterial* material);
struct mjrfRenderableParams_ { // parameters for creating a renderable (mjrfRenderable)
mjtBool cast_shadows; // if true, casts shadows
mjtBool receive_shadows; // if true, receives shadows
uint16_t blend_order; // controls draw order for transparent objects [0, 8]
};
typedef struct mjrfRenderableParams_ mjrfRenderableParams;
typedef struct mjrfRenderableParams_ { // parameters for creating a renderable (mjrfRenderable)
mjtBool cast_shadows; // if true, casts shadows
mjtBool receive_shadows; // if true, receives shadows
uint16_t blend_order; // controls draw order for transparent objects [0, 8]
} mjrfRenderableParams;
// Initializes the mjrfRenderableParams to default values.
void mjrf_defaultRenderableParams(mjrfRenderableParams* params);
@@ -462,13 +451,12 @@ void mjrf_setRenderableSize(mjrfRenderable* renderable, const float size[3]);
// A render target is a memory buffer that holds the results of a rendering operation. (This is an
// alternative to rendering directly to the screen.) See mjrf_render for more details.
struct mjrfRenderTargetConfig_ { // parameters for creating a render target (mjrfRenderTarget)
int width; // texture width
int height; // texture height
int color_format; // mjrPixelFormat; pixel format for color buffer
int depth_format; // mjrPixelFormat; pixel format for depth buffer
};
typedef struct mjrfRenderTargetConfig_ mjrfRenderTargetConfig;
typedef struct mjrfRenderTargetConfig_ { // parameters for creating a render target
int width; // texture width
int height; // texture height
int color_format; // mjrPixelFormat; pixel format for color buffer
int depth_format; // mjrPixelFormat; pixel format for depth buffer
} mjrfRenderTargetConfig;
// Initializes the RenderTargetConfig to default values.
void mjrf_defaultRenderTargetConfig(mjrfRenderTargetConfig* config);
+12 -12
View File
@@ -57,13 +57,13 @@ extern "C" {
//-------------------------------- enum types (mjt) ------------------------------------------------
typedef enum mjtGeomInertia_ { // type of inertia inference
typedef enum mjtGeomInertia { // type of inertia inference
mjINERTIA_VOLUME = 0, // mass distributed in the volume
mjINERTIA_SHELL, // mass distributed on the surface
} mjtGeomInertia;
typedef enum mjtMeshInertia_ { // type of mesh inertia
typedef enum mjtMeshInertia { // type of mesh inertia
mjMESH_INERTIA_CONVEX = 0, // convex mesh inertia
mjMESH_INERTIA_EXACT, // exact mesh inertia
mjMESH_INERTIA_LEGACY, // legacy mesh inertia
@@ -71,7 +71,7 @@ typedef enum mjtMeshInertia_ { // type of mesh inertia
} mjtMeshInertia;
typedef enum mjtMeshBuiltin_ { // type of built-in procedural mesh
typedef enum mjtMeshBuiltin { // type of built-in procedural mesh
mjMESH_BUILTIN_NONE = 0, // no built-in mesh
mjMESH_BUILTIN_SPHERE, // sphere
mjMESH_BUILTIN_HEMISPHERE, // hemisphere
@@ -83,7 +83,7 @@ typedef enum mjtMeshBuiltin_ { // type of built-in procedural mesh
} mjtMeshBuiltin;
typedef enum mjtBuiltin_ { // type of built-in procedural texture
typedef enum mjtBuiltin { // type of built-in procedural texture
mjBUILTIN_NONE = 0, // no built-in texture
mjBUILTIN_GRADIENT, // gradient: rgb1->rgb2
mjBUILTIN_CHECKER, // checker pattern: rgb1, rgb2
@@ -91,7 +91,7 @@ typedef enum mjtBuiltin_ { // type of built-in procedural texture
} mjtBuiltin;
typedef enum mjtMark_ { // mark type for procedural textures
typedef enum mjtMark { // mark type for procedural textures
mjMARK_NONE = 0, // no mark
mjMARK_EDGE, // edges
mjMARK_CROSS, // cross
@@ -99,28 +99,28 @@ typedef enum mjtMark_ { // mark type for procedural textures
} mjtMark;
typedef enum mjtLimited_ { // type of limit specification
typedef enum mjtLimited { // type of limit specification
mjLIMITED_FALSE = 0, // not limited
mjLIMITED_TRUE, // limited
mjLIMITED_AUTO, // limited inferred from presence of range
} mjtLimited;
typedef enum mjtAlignFree_ { // whether to align free joints with the inertial frame
typedef enum mjtAlignFree { // whether to align free joints with the inertial frame
mjALIGNFREE_FALSE = 0, // don't align
mjALIGNFREE_TRUE, // align
mjALIGNFREE_AUTO, // respect the global compiler flag
} mjtAlignFree;
typedef enum mjtInertiaFromGeom_ { // whether to infer body inertias from child geoms
typedef enum mjtInertiaFromGeom { // whether to infer body inertias from child geoms
mjINERTIAFROMGEOM_FALSE = 0, // do not use; inertial element required
mjINERTIAFROMGEOM_TRUE, // always use; overwrite inertial element
mjINERTIAFROMGEOM_AUTO // use only if inertial element is missing
} mjtInertiaFromGeom;
typedef enum mjtOrientation_ { // type of orientation specifier
typedef enum mjtOrientation { // type of orientation specifier
mjORIENTATION_QUAT = 0, // quaternion
mjORIENTATION_AXISANGLE, // axis and angle
mjORIENTATION_XYAXES, // x and y axes
@@ -128,13 +128,13 @@ typedef enum mjtOrientation_ { // type of orientation specifier
mjORIENTATION_EULER, // Euler angles
} mjtOrientation;
typedef enum mjtConflict_ { // conflict resolution for attach
typedef enum mjtConflict { // conflict resolution for attach
mjCONFLICT_WARNING = 0, // keep parent, warn on conflict
mjCONFLICT_MERGE, // merge: min/max/error per field
mjCONFLICT_ERROR, // error on any conflict
} mjtConflict;
typedef enum mjtCTimer_ { // compiler timing categories
typedef enum mjtCTimer { // compiler timing categories
// top-level timers (wall-clock)
mjCTIMER_TOTAL = 0, // total compile time
mjCTIMER_ASSETS, // asset compilation
@@ -176,7 +176,7 @@ typedef struct mjsCompiler_ { // compiler options
int inertiagrouprange[2]; // range of geom groups used to compute inertia
mjtByte saveinertial; // save explicit inertial clause for all bodies to XML
int alignfree; // align free joints with inertial frame
int conflict; // conflict resolution for attach (mjtConflict)
int conflict; // conflict resolution for attach (mjtConflict)
mjLROpt LRopt; // options for lengthrange computation
mjString* meshdir; // mesh and hfield directory
mjString* texturedir; // texture directory
+40 -40
View File
@@ -50,7 +50,7 @@ typedef int64_t mjtSize; // used for buffer sizes
//---------------------------------- enum types (mjModel) ------------------------------------------
typedef enum mjtDisableBit_ { // disable default feature bitflags
typedef enum mjtDisableBit { // disable default feature bitflags
mjDSBL_CONSTRAINT = 1<<0, // entire constraint solver
mjDSBL_EQUALITY = 1<<1, // equality constraints
mjDSBL_FRICTIONLOSS = 1<<2, // joint and tendon frictionloss constraints
@@ -76,7 +76,7 @@ typedef enum mjtDisableBit_ { // disable default feature bitflags
} mjtDisableBit;
typedef enum mjtEnableBit_ { // enable optional feature bitflags
typedef enum mjtEnableBit { // enable optional feature bitflags
mjENBL_OVERRIDE = 1<<0, // override contact parameters
mjENBL_ENERGY = 1<<1, // energy computation
mjENBL_FWDINV = 1<<2, // record solver statistics
@@ -88,7 +88,7 @@ typedef enum mjtEnableBit_ { // enable optional feature bitflags
} mjtEnableBit;
typedef enum mjtJoint_ { // type of degree of freedom
typedef enum mjtJoint { // type of degree of freedom
mjJNT_FREE = 0, // global position and orientation (quat) (7)
mjJNT_BALL, // orientation (quat) relative to parent (4)
mjJNT_SLIDE, // sliding distance along body-fixed axis (1)
@@ -96,7 +96,7 @@ typedef enum mjtJoint_ { // type of degree of freedom
} mjtJoint;
typedef enum mjtGeom_ { // type of geometric shape
typedef enum mjtGeom { // type of geometric shape
// regular geom types
mjGEOM_PLANE = 0, // plane
mjGEOM_HFIELD, // height field
@@ -125,13 +125,13 @@ typedef enum mjtGeom_ { // type of geometric shape
} mjtGeom;
typedef enum mjtProjection_ { // type of camera projection
typedef enum mjtProjection { // type of camera projection
mjPROJ_PERSPECTIVE = 0, // perspective
mjPROJ_ORTHOGRAPHIC // orthographic
} mjtProjection;
typedef enum mjtCamLight_ { // tracking mode for camera and light
typedef enum mjtCamLight { // tracking mode for camera and light
mjCAMLIGHT_FIXED = 0, // pos and rot fixed in body
mjCAMLIGHT_TRACK, // pos tracks body, rot fixed in global
mjCAMLIGHT_TRACKCOM, // pos tracks subtree com, rot fixed in body
@@ -140,7 +140,7 @@ typedef enum mjtCamLight_ { // tracking mode for camera and light
} mjtCamLight;
typedef enum mjtLightType_ { // type of light
typedef enum mjtLightType { // type of light
mjLIGHT_SPOT = 0, // spot
mjLIGHT_DIRECTIONAL, // directional
mjLIGHT_POINT, // point
@@ -148,14 +148,14 @@ typedef enum mjtLightType_ { // type of light
} mjtLightType;
typedef enum mjtTexture_ { // type of texture
typedef enum mjtTexture { // type of texture
mjTEXTURE_2D = 0, // 2d texture, suitable for planes and hfields
mjTEXTURE_CUBE, // cube texture, suitable for all other geom types
mjTEXTURE_SKYBOX // cube texture used as skybox
} mjtTexture;
typedef enum mjtTextureRole_ { // role of texture map in rendering
typedef enum mjtTextureRole { // role of texture map in rendering
mjTEXROLE_USER = 0, // unspecified
mjTEXROLE_RGB, // base color (albedo)
mjTEXROLE_OCCLUSION, // ambient occlusion
@@ -170,14 +170,14 @@ typedef enum mjtTextureRole_ { // role of texture map in rendering
} mjtTextureRole;
typedef enum mjtColorSpace_ { // type of color space encoding
typedef enum mjtColorSpace { // type of color space encoding
mjCOLORSPACE_AUTO = 0, // attempts to autodetect color space, defaults to linear
mjCOLORSPACE_LINEAR, // linear color space
mjCOLORSPACE_SRGB // standard RGB color space
} mjtColorSpace;
typedef enum mjtIntegrator_ { // integrator mode
typedef enum mjtIntegrator { // integrator mode
mjINT_EULER = 0, // semi-implicit Euler
mjINT_RK4, // 4th-order Runge Kutta
mjINT_IMPLICIT, // implicit in velocity
@@ -185,27 +185,27 @@ typedef enum mjtIntegrator_ { // integrator mode
} mjtIntegrator;
typedef enum mjtCone_ { // type of friction cone
typedef enum mjtCone { // type of friction cone
mjCONE_PYRAMIDAL = 0, // pyramidal
mjCONE_ELLIPTIC // elliptic
} mjtCone;
typedef enum mjtJacobian_ { // type of constraint Jacobian
typedef enum mjtJacobian { // type of constraint Jacobian
mjJAC_DENSE = 0, // dense
mjJAC_SPARSE, // sparse
mjJAC_AUTO // dense if nv<60, sparse otherwise
} mjtJacobian;
typedef enum mjtSolver_ { // constraint solver algorithm
typedef enum mjtSolver { // constraint solver algorithm
mjSOL_PGS = 0, // PGS (dual)
mjSOL_CG, // CG (primal)
mjSOL_NEWTON // Newton (primal)
} mjtSolver;
typedef enum mjtEq_ { // type of equality constraint
typedef enum mjtEq { // type of equality constraint
mjEQ_CONNECT = 0, // connect two bodies at a point (ball joint)
mjEQ_WELD, // fix relative position and orientation of two bodies
mjEQ_JOINT, // couple the values of two scalar joints with cubic
@@ -217,7 +217,7 @@ typedef enum mjtEq_ { // type of equality constraint
} mjtEq;
typedef enum mjtWrap_ { // type of tendon wrap object
typedef enum mjtWrap { // type of tendon wrap object
mjWRAP_NONE = 0, // null object
mjWRAP_JOINT, // constant moment arm
mjWRAP_PULLEY, // pulley used to split tendon
@@ -227,7 +227,7 @@ typedef enum mjtWrap_ { // type of tendon wrap object
} mjtWrap;
typedef enum mjtTrn_ { // type of actuator transmission
typedef enum mjtTrn { // type of actuator transmission
mjTRN_JOINT = 0, // force on joint
mjTRN_JOINTINPARENT, // force on joint, expressed in parent frame
mjTRN_SLIDERCRANK, // force via slider-crank linkage
@@ -239,7 +239,7 @@ typedef enum mjtTrn_ { // type of actuator transmission
} mjtTrn;
typedef enum mjtDyn_ { // type of actuator dynamics
typedef enum mjtDyn { // type of actuator dynamics
mjDYN_NONE = 0, // no internal dynamics; ctrl specifies force
mjDYN_INTEGRATOR, // integrator: da/dt = u
mjDYN_FILTER, // linear filter: da/dt = (u-a) / tau
@@ -250,7 +250,7 @@ typedef enum mjtDyn_ { // type of actuator dynamics
} mjtDyn;
typedef enum mjtGain_ { // type of actuator gain
typedef enum mjtGain { // type of actuator gain
mjGAIN_FIXED = 0, // fixed gain
mjGAIN_AFFINE, // const + kp*length + kv*velocity
mjGAIN_MUSCLE, // muscle FLV curve computed by mju_muscleGain()
@@ -259,7 +259,7 @@ typedef enum mjtGain_ { // type of actuator gain
} mjtGain;
typedef enum mjtBias_ { // type of actuator bias
typedef enum mjtBias { // type of actuator bias
mjBIAS_NONE = 0, // no bias
mjBIAS_AFFINE, // const + kp*length + kv*velocity
mjBIAS_MUSCLE, // muscle passive force computed by mju_muscleBias()
@@ -268,7 +268,7 @@ typedef enum mjtBias_ { // type of actuator bias
} mjtBias;
typedef enum mjtObj_ { // type of MujoCo object
typedef enum mjtObj { // type of MujoCo object
mjOBJ_UNKNOWN = 0, // unknown object type
mjOBJ_BODY, // body
mjOBJ_XBODY, // body, used to access regular frame instead of i-frame
@@ -305,7 +305,7 @@ typedef enum mjtObj_ { // type of MujoCo object
} mjtObj;
typedef enum mjtSensor_ { // type of sensor
typedef enum mjtSensor { // type of sensor
// common robotic sensors, attached to a site
mjSENS_TOUCH = 0, // scalar contact normal forces summed over sensor zone
mjSENS_ACCELEROMETER, // 3D linear acceleration, in local frame
@@ -381,7 +381,7 @@ typedef enum mjtSensor_ { // type of sensor
} mjtSensor;
typedef enum mjtStage_ { // computation stage
typedef enum mjtStage { // computation stage
mjSTAGE_NONE = 0, // no computations
mjSTAGE_POS, // position-dependent computations
mjSTAGE_VEL, // velocity-dependent computations
@@ -389,7 +389,7 @@ typedef enum mjtStage_ { // computation stage
} mjtStage;
typedef enum mjtDataType_ { // data type for sensors
typedef enum mjtDataType { // data type for sensors
mjDATATYPE_REAL = 0, // real values, no constraints
mjDATATYPE_POSITIVE, // positive values; 0 or negative: inactive
mjDATATYPE_AXIS, // 3D unit vector
@@ -397,7 +397,7 @@ typedef enum mjtDataType_ { // data type for sensors
} mjtDataType;
typedef enum mjtConDataField_ { // data fields returned by contact sensors
typedef enum mjtConDataField { // data fields returned by contact sensors
mjCONDATA_FOUND = 0, // whether a contact was found
mjCONDATA_FORCE, // contact force
mjCONDATA_TORQUE, // contact torque
@@ -410,7 +410,7 @@ typedef enum mjtConDataField_ { // data fields returned by contact sensors
} mjtConDataField;
typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors
typedef enum mjtRayDataField { // data fields returned by rangefinder sensors
mjRAYDATA_DIST = 0, // distance from ray origin to nearest surface
mjRAYDATA_DIR, // normalized ray direction
mjRAYDATA_ORIGIN, // ray origin
@@ -422,7 +422,7 @@ typedef enum mjtRayDataField_ { // data fields returned by rangefinder sensors
} mjtRayDataField;
typedef enum mjtCamOutBit_ { // camera output type bitflags
typedef enum mjtCamOutBit { // camera output type bitflags
mjCAMOUT_RGB = 1<<0, // RGB image
mjCAMOUT_DEPTH = 1<<1, // depth image (distance from camera plane)
mjCAMOUT_DIST = 1<<2, // distance image (distance from camera origin)
@@ -433,7 +433,7 @@ typedef enum mjtCamOutBit_ { // camera output type bitflags
} mjtCamOutBit;
typedef enum mjtSameFrame_ { // frame alignment of bodies with their children
typedef enum mjtSameFrame { // frame alignment of bodies with their children
mjSAMEFRAME_NONE = 0, // no alignment
mjSAMEFRAME_BODY, // frame is same as body frame
mjSAMEFRAME_INERTIA, // frame is same as inertial frame
@@ -442,7 +442,7 @@ typedef enum mjtSameFrame_ { // frame alignment of bodies with their childr
} mjtSameFrame;
typedef enum mjtSleepPolicy_ { // per-tree sleep policy
typedef enum mjtSleepPolicy { // per-tree sleep policy
mjSLEEP_AUTO = 0, // compiler chooses sleep policy
mjSLEEP_AUTO_NEVER, // compiler sleep policy: never
mjSLEEP_AUTO_ALLOWED, // compiler sleep policy: allowed
@@ -452,7 +452,7 @@ typedef enum mjtSleepPolicy_ { // per-tree sleep policy
} mjtSleepPolicy;
typedef enum mjtLRMode_ { // mode for actuator length range computation
typedef enum mjtLRMode { // mode for actuator length range computation
mjLRMODE_NONE = 0, // do not process any actuators
mjLRMODE_MUSCLE, // process muscle actuators
mjLRMODE_MUSCLEUSER, // process muscle and user actuators
@@ -460,7 +460,7 @@ typedef enum mjtLRMode_ { // mode for actuator length range computation
} mjtLRMode;
typedef enum mjtFlexSelf_ { // mode for flex selfcollide
typedef enum mjtFlexSelf { // mode for flex selfcollide
mjFLEXSELF_NONE = 0, // no self-collisions
mjFLEXSELF_NARROW, // skip midphase, go directly to narrowphase
mjFLEXSELF_BVH, // use BVH in midphase (if midphase enabled)
@@ -469,7 +469,7 @@ typedef enum mjtFlexSelf_ { // mode for flex selfcollide
} mjtFlexSelf;
typedef enum mjtSDFType_ { // signed distance function (SDF) type
typedef enum mjtSDFType { // signed distance function (SDF) type
mjSDFTYPE_SINGLE = 0, // single SDF
mjSDFTYPE_INTERSECTION, // max(A, B)
mjSDFTYPE_MIDSURFACE, // A - B
@@ -480,7 +480,7 @@ typedef enum mjtSDFType_ { // signed distance function (SDF) type
//---------------------------------- enum types (mjData) -------------------------------------------
typedef enum mjtState_ { // state elements
typedef enum mjtState { // state elements
mjSTATE_TIME = 1<<0, // time
mjSTATE_QPOS = 1<<1, // position
mjSTATE_QVEL = 1<<2, // velocity
@@ -508,7 +508,7 @@ typedef enum mjtState_ { // state elements
} mjtState;
typedef enum mjtConstraint_ { // type of constraint
typedef enum mjtConstraint { // type of constraint
mjCNSTR_EQUALITY = 0, // equality constraint
mjCNSTR_FRICTION_DOF, // dof friction
mjCNSTR_FRICTION_TENDON, // tendon friction
@@ -520,7 +520,7 @@ typedef enum mjtConstraint_ { // type of constraint
} mjtConstraint;
typedef enum mjtConstraintState_ { // constraint state
typedef enum mjtConstraintState { // constraint state
mjCNSTRSTATE_SATISFIED = 0, // constraint satisfied, zero cost (limit, contact)
mjCNSTRSTATE_QUADRATIC, // quadratic cost (equality, friction, limit, contact)
mjCNSTRSTATE_LINEARNEG, // linear cost, negative side (friction)
@@ -529,7 +529,7 @@ typedef enum mjtConstraintState_ { // constraint state
} mjtConstraintState;
typedef enum mjtWarning_ { // warning types
typedef enum mjtWarning { // warning types
mjWARN_INERTIA = 0, // (near) singular inertia matrix
mjWARN_CONTACTFULL, // too many contacts in contact list
mjWARN_CNSTRFULL, // too many constraints
@@ -542,7 +542,7 @@ typedef enum mjtWarning_ { // warning types
} mjtWarning;
typedef enum mjtTimer_ { // internal timers
typedef enum mjtTimer { // internal timers
// main api
mjTIMER_STEP = 0, // step
mjTIMER_FORWARD, // forward
@@ -570,7 +570,7 @@ typedef enum mjtTimer_ { // internal timers
} mjtTimer;
typedef enum mjtSleepState_ { // sleep state of an object
typedef enum mjtSleepState { // sleep state of an object
mjS_STATIC = -1, // object is static
mjS_ASLEEP = 0, // object is asleep
mjS_AWAKE = 1 // object is awake
@@ -580,14 +580,14 @@ typedef enum mjtSleepState_ { // sleep state of an object
//---------------------------------- logging -------------------------------------------------------
typedef enum mjtLogLevel_ { // log message severity
typedef enum mjtLogLevel { // log message severity
mjLOG_DEBUG = 0, // internal engine debug trace (opt-in via topic filtering)
mjLOG_INFO, // informational (opt-in via topic filtering)
mjLOG_WARNING, // warning
mjLOG_ERROR, // error
} mjtLogLevel;
typedef enum mjtLogTopic_ { // log topic identifiers
typedef enum mjtLogTopic { // log topic identifiers
mjTOPIC_NONE = 0, // no topic (always passes filtering)
// INFO topics:
mjTOPIC_TIME_STP = 1, // timing diagnostics (step)
+31 -38
View File
@@ -62,7 +62,7 @@
//---------------------------------- primitive types (mjt) -----------------------------------------
typedef enum mjtButton_ { // mouse button
typedef enum mjtButton { // mouse button
mjBUTTON_NONE = 0, // no button
mjBUTTON_LEFT, // left button
mjBUTTON_RIGHT, // right button
@@ -70,7 +70,7 @@ typedef enum mjtButton_ { // mouse button
} mjtButton;
typedef enum mjtEvent_ { // mouse and keyboard event type
typedef enum mjtEvent { // mouse and keyboard event type
mjEVENT_NONE = 0, // no event
mjEVENT_MOVE, // mouse move
mjEVENT_PRESS, // mouse button press
@@ -83,7 +83,7 @@ typedef enum mjtEvent_ { // mouse and keyboard event type
} mjtEvent;
typedef enum mjtItem_ { // UI item type
typedef enum mjtItem { // UI item type
mjITEM_END = -2, // end of definition list (not an item)
mjITEM_SECTION = -1, // section (not an item)
mjITEM_SEPARATOR = 0, // separator
@@ -107,7 +107,7 @@ typedef enum mjtItem_ { // UI item type
} mjtItem;
typedef enum mjtSection_ { // UI section state
typedef enum mjtSection { // UI section state
mjSECT_CLOSED = 0, // closed state (regular section)
mjSECT_OPEN, // open state (regular section)
mjSECT_FIXED // fixed section: always open, no title
@@ -120,7 +120,7 @@ typedef int (*mjfItemEnable)(int category, void* data);
//---------------------------------- mjuiState -----------------------------------------------------
struct mjuiState_ { // mouse and keyboard state
typedef struct mjuiState_ { // mouse and keyboard state
// constants set by user
int nrect; // number of rectangles used
mjrRect rect[mjMAXUIRECT]; // rectangles (index 0: entire window)
@@ -160,33 +160,31 @@ struct mjuiState_ { // mouse and keyboard state
// files dropping (only valid when type == mjEVENT_FILESDROP)
int dropcount; // number of files dropped
const char** droppaths; // paths to files dropped
};
typedef struct mjuiState_ mjuiState;
} mjuiState;
//---------------------------------- mjuiThemeSpacing ----------------------------------------------
struct mjuiThemeSpacing_ { // UI visualization theme spacing
int total; // total width
int scroll; // scrollbar width
int label; // label width
int section; // section gap
int cornersect; // corner radius for section
int cornersep; // corner radius for separator
int itemside; // item side gap
int itemmid; // item middle gap
int itemver; // item vertical gap
int texthor; // text horizontal gap
int textver; // text vertical gap
int linescroll; // number of pixels to scroll
int samples; // number of multisamples
};
typedef struct mjuiThemeSpacing_ mjuiThemeSpacing;
typedef struct mjuiThemeSpacing_ { // UI visualization theme spacing
int total; // total width
int scroll; // scrollbar width
int label; // label width
int section; // section gap
int cornersect; // corner radius for section
int cornersep; // corner radius for separator
int itemside; // item side gap
int itemmid; // item middle gap
int itemver; // item vertical gap
int texthor; // text horizontal gap
int textver; // text vertical gap
int linescroll; // number of pixels to scroll
int samples; // number of multisamples
} mjuiThemeSpacing;
//---------------------------------- mjuiThemeColor ------------------------------------------------
struct mjuiThemeColor_ { // UI visualization theme color
typedef struct mjuiThemeColor_ { // UI visualization theme color
float master[3]; // master background
float thumb[3]; // scrollbar thumb
float secttitle[3]; // section title
@@ -215,8 +213,7 @@ struct mjuiThemeColor_ { // UI visualization theme color
float edit[3]; // edit
float edit2[3]; // edit invalid
float cursor[3]; // edit cursor
};
typedef struct mjuiThemeColor_ mjuiThemeColor;
} mjuiThemeColor;
//---------------------------------- mjuiItem ------------------------------------------------------
@@ -245,7 +242,7 @@ struct mjuiItemEdit_ { // edit-related
};
struct mjuiItem_ { // UI item
typedef struct mjuiItem_ { // UI item
// common properties
int type; // type (mjtItem)
char name[mjMAXUINAME]; // name
@@ -266,13 +263,12 @@ struct mjuiItem_ { // UI item
// internal
mjrRect rect; // rectangle occupied by item
int skip; // item skipped due to closed separator
};
typedef struct mjuiItem_ mjuiItem;
} mjuiItem;
//---------------------------------- mjuiSection ---------------------------------------------------
struct mjuiSection_ { // UI section
typedef struct mjuiSection_ { // UI section
// properties
char name[mjMAXUINAME]; // name
int state; // section state (mjtSection)
@@ -286,13 +282,12 @@ struct mjuiSection_ { // UI section
mjrRect rtitle; // rectangle occupied by title
mjrRect rcontent; // rectangle occupied by content
int lastclick; // last mouse click over this section
};
typedef struct mjuiSection_ mjuiSection;
} mjuiSection;
//---------------------------------- mjUI ----------------------------------------------------------
struct mjUI_ { // entire UI
typedef struct mjUI_ { // entire UI
// constants set by user
mjuiThemeSpacing spacing; // UI theme spacing
mjuiThemeColor color; // UI theme color
@@ -326,20 +321,18 @@ struct mjUI_ { // entire UI
// sections
int nsect; // number of sections in use
mjuiSection sect[mjMAXUISECT]; // preallocated array of sections
};
typedef struct mjUI_ mjUI;
} mjUI;
//---------------------------------- mjuiDef -------------------------------------------------------
struct mjuiDef_ { // table passed to mjui_add()
typedef struct mjuiDef_ { // table passed to mjui_add()
int type; // type (mjtItem); -1: section
char name[mjMAXUINAME]; // name
int state; // state
void* pdata; // pointer to data
char other[mjMAXUITEXT]; // string with type-specific properties
int otherint; // int with type-specific properties
};
typedef struct mjuiDef_ mjuiDef;
} mjuiDef;
#endif // MUJOCO_MJUI_H_
+16 -24
View File
@@ -164,7 +164,7 @@ typedef enum mjtStereo_ { // type of stereo rendering
//---------------------------------- mjvPerturb ----------------------------------------------------
struct mjvPerturb_ { // object selection and perturbation
typedef struct mjvPerturb_ { // object selection and perturbation
int select; // selected body id; non-positive: none
int flexselect; // selected flex id; negative: none
int skinselect; // selected skin id; negative: none
@@ -176,13 +176,12 @@ struct mjvPerturb_ { // object selection and perturbation
mjtNum localpos[3]; // selection point in object coordinates
mjtNum localmass; // spatial inertia at selection point
mjtNum scale; // relative mouse motion-to-space scaling (set by initPerturb)
};
typedef struct mjvPerturb_ mjvPerturb;
} mjvPerturb;
//---------------------------------- mjvCamera -----------------------------------------------------
struct mjvCamera_ { // abstract camera
typedef struct mjvCamera_ { // abstract camera
// type and ids
int type; // camera type (mjtCamera)
int fixedcamid; // fixed camera id
@@ -196,13 +195,12 @@ struct mjvCamera_ { // abstract camera
// orthographic / perspective
int orthographic; // 0: perspective; 1: orthographic
};
typedef struct mjvCamera_ mjvCamera;
} mjvCamera;
//---------------------------------- mjvGLCamera ---------------------------------------------------
struct mjvGLCamera_ { // OpenGL camera
typedef struct mjvGLCamera_ { // OpenGL camera
// camera frame
float pos[3]; // position
float forward[3]; // forward direction
@@ -218,13 +216,12 @@ struct mjvGLCamera_ { // OpenGL camera
// orthographic / perspective
int orthographic; // 0: perspective; 1: orthographic
};
typedef struct mjvGLCamera_ mjvGLCamera;
} mjvGLCamera;
//---------------------------------- mjvGeom -------------------------------------------------------
struct mjvGeom_ { // abstract geom
typedef struct mjvGeom_ { // abstract geom
// type info
int type; // geom type (mjtGeom)
int dataid; // mesh, hfield or plane id; -1: none; mesh: 2*id or 2*id+1 (hull)
@@ -253,13 +250,12 @@ struct mjvGeom_ { // abstract geom
float camdist; // distance to camera (used by sorter)
float modelrbound; // geom rbound from model, 0 if not model geom
mjtByte transparent; // treat geom as transparent
};
typedef struct mjvGeom_ mjvGeom;
} mjvGeom;
//---------------------------------- mjvLight ------------------------------------------------------
struct mjvLight_ { // OpenGL light
typedef struct mjvLight_ { // OpenGL light
int id; // light id, -1 for headlight
float pos[3]; // position rel. to body frame
float dir[3]; // direction rel. to body frame
@@ -276,13 +272,12 @@ struct mjvLight_ { // OpenGL light
float bulbradius; // bulb radius for soft shadows
float intensity; // intensity, in candelas
float range; // range of effectiveness
};
typedef struct mjvLight_ mjvLight;
} mjvLight;
//---------------------------------- mjvOption -----------------------------------------------------
struct mjvOption_ { // abstract visualization options
typedef struct mjvOption_ { // abstract visualization options
int label; // what objects to label (mjtLabel)
int frame; // which frame to show (mjtFrame)
mjtByte geomgroup[mjNGROUP]; // geom visualization by group
@@ -295,13 +290,12 @@ struct mjvOption_ { // abstract visualization options
mjtByte flags[mjNVISFLAG]; // visualization flags (indexed by mjtVisFlag)
int bvh_depth; // depth of the bounding volume hierarchy to be visualized
int flex_layer; // element layer to be visualized for 3D flex
};
typedef struct mjvOption_ mjvOption;
} mjvOption;
//---------------------------------- mjvScene ------------------------------------------------------
struct mjvScene_ { // abstract scene passed to OpenGL renderer
typedef struct mjvScene_ { // abstract scene passed to OpenGL renderer
// abstract geoms
int maxgeom; // size of allocated geom buffer
int ngeom; // number of geoms currently in buffer
@@ -358,13 +352,12 @@ struct mjvScene_ { // abstract scene passed to OpenGL renderer
// geom buffer status
int status; // 0: ok, 1: geoms exhausted, warning issued
};
typedef struct mjvScene_ mjvScene;
} mjvScene;
//---------------------------------- mjvFigure -----------------------------------------------------
struct mjvFigure_ { // abstract 2D figure passed to OpenGL renderer
typedef struct mjvFigure_ { // abstract 2D figure passed to OpenGL renderer
// enable flags
int flg_legend; // show legend
int flg_ticklabel[2]; // show grid tick labels (x,y)
@@ -409,7 +402,6 @@ struct mjvFigure_ { // abstract 2D figure passed to OpenGL rendere
int yaxispixel[2]; // range of y-axis in pixels
float xaxisdata[2]; // range of x-axis in data units
float yaxisdata[2]; // range of y-axis in data units
};
typedef struct mjvFigure_ mjvFigure;
} mjvFigure;
#endif // MUJOCO_MJVISUALIZE_H_