Add textured materials to render context, and refactor mjvGeom to refer to those textures.
PiperOrigin-RevId: 648719103 Change-Id: Idb4425bdeea3cbc1133cda3e4366574ed3bb5ccc
This commit is contained in:
committed by
Copybara-Service
parent
af3233f98d
commit
3b73dfe33b
@@ -44,7 +44,7 @@
|
||||
#define mjNIMP 5 // number of solver impedance parameters
|
||||
#define mjNSOLVER 200 // size of one mjData.solver array
|
||||
#define mjNISLAND 20 // number of mjData.solver arrays
|
||||
|
||||
#define mjNTEXMAT 6 // number of textures per material
|
||||
|
||||
//---------------------------------- enum types (mjt) ----------------------------------------------
|
||||
|
||||
|
||||
+67
-61
@@ -15,14 +15,15 @@
|
||||
#ifndef MUJOCO_MJRENDER_H_
|
||||
#define MUJOCO_MJRENDER_H_
|
||||
|
||||
#include <mujoco/mjmodel.h>
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define mjNAUX 10 // number of auxiliary buffers
|
||||
#define mjMAXTEXTURE 1000 // maximum number of textures
|
||||
|
||||
#define mjMAXTEXTURE 100 // maximum number of textures
|
||||
#define mjMAXMATERIAL 100 // maximum number of materials with textures
|
||||
|
||||
//---------------------------------- primitive types (mjt) -----------------------------------------
|
||||
|
||||
@@ -76,92 +77,97 @@ typedef struct mjrRect_ mjrRect;
|
||||
|
||||
//---------------------------------- mjrContext ----------------------------------------------------
|
||||
|
||||
struct mjrContext_ { // custom OpenGL context
|
||||
struct mjrContext_ { // custom OpenGL context
|
||||
// parameters copied from mjVisual
|
||||
float lineWidth; // line width for wireframe rendering
|
||||
float shadowClip; // clipping radius for directional lights
|
||||
float shadowScale; // fraction of light cutoff for spot lights
|
||||
float fogStart; // fog start = stat.extent * vis.map.fogstart
|
||||
float fogEnd; // fog end = stat.extent * vis.map.fogend
|
||||
float fogRGBA[4]; // fog rgba
|
||||
int shadowSize; // size of shadow map texture
|
||||
int offWidth; // width of offscreen buffer
|
||||
int offHeight; // height of offscreen buffer
|
||||
int offSamples; // number of offscreen buffer multisamples
|
||||
float lineWidth; // line width for wireframe rendering
|
||||
float shadowClip; // clipping radius for directional lights
|
||||
float shadowScale; // fraction of light cutoff for spot lights
|
||||
float fogStart; // fog start = stat.extent * vis.map.fogstart
|
||||
float fogEnd; // fog end = stat.extent * vis.map.fogend
|
||||
float fogRGBA[4]; // fog rgba
|
||||
int shadowSize; // size of shadow map texture
|
||||
int offWidth; // width of offscreen buffer
|
||||
int offHeight; // height of offscreen buffer
|
||||
int offSamples; // number of offscreen buffer multisamples
|
||||
|
||||
// parameters specified at creation
|
||||
int fontScale; // font scale
|
||||
int auxWidth[mjNAUX]; // auxiliary buffer width
|
||||
int auxHeight[mjNAUX]; // auxiliary buffer height
|
||||
int auxSamples[mjNAUX]; // auxiliary buffer multisamples
|
||||
int fontScale; // font scale
|
||||
int auxWidth[mjNAUX]; // auxiliary buffer width
|
||||
int auxHeight[mjNAUX]; // auxiliary buffer height
|
||||
int auxSamples[mjNAUX]; // auxiliary buffer multisamples
|
||||
|
||||
// offscreen rendering objects
|
||||
unsigned int offFBO; // offscreen framebuffer object
|
||||
unsigned int offFBO_r; // offscreen framebuffer for resolving multisamples
|
||||
unsigned int offColor; // offscreen color buffer
|
||||
unsigned int offColor_r; // offscreen color buffer for resolving multisamples
|
||||
unsigned int offDepthStencil; // offscreen depth and stencil buffer
|
||||
unsigned int offDepthStencil_r; // offscreen depth and stencil buffer for resolving multisamples
|
||||
unsigned int offFBO; // offscreen framebuffer object
|
||||
unsigned int offFBO_r; // offscreen framebuffer for resolving multisamples
|
||||
unsigned int offColor; // offscreen color buffer
|
||||
unsigned int offColor_r; // offscreen color buffer for resolving multisamples
|
||||
unsigned int offDepthStencil; // offscreen depth and stencil buffer
|
||||
unsigned int offDepthStencil_r; // offscreen depth and stencil buffer for multisamples
|
||||
|
||||
// shadow rendering objects
|
||||
unsigned int shadowFBO; // shadow map framebuffer object
|
||||
unsigned int shadowTex; // shadow map texture
|
||||
unsigned int shadowFBO; // shadow map framebuffer object
|
||||
unsigned int shadowTex; // shadow map texture
|
||||
|
||||
// auxiliary buffers
|
||||
unsigned int auxFBO[mjNAUX]; // auxiliary framebuffer object
|
||||
unsigned int auxFBO_r[mjNAUX]; // auxiliary framebuffer object for resolving
|
||||
unsigned int auxColor[mjNAUX]; // auxiliary color buffer
|
||||
unsigned int auxColor_r[mjNAUX];// auxiliary color buffer for resolving
|
||||
unsigned int auxFBO[mjNAUX]; // auxiliary framebuffer object
|
||||
unsigned int auxFBO_r[mjNAUX]; // auxiliary framebuffer object for resolving
|
||||
unsigned int auxColor[mjNAUX]; // auxiliary color buffer
|
||||
unsigned int auxColor_r[mjNAUX]; // auxiliary color buffer for resolving
|
||||
|
||||
// materials with textures
|
||||
int mat_texid[mjMAXMATERIAL*mjNTEXMAT]; // material texture ids (-1: no texture)
|
||||
int mat_texuniform[mjMAXMATERIAL]; // texture repetition for 2d mapping
|
||||
int mat_texrepeat[mjMAXMATERIAL*2]; // texture repetition for 2d mapping
|
||||
|
||||
// texture objects and info
|
||||
int ntexture; // number of allocated textures
|
||||
int textureType[100]; // type of texture (mjtTexture) (ntexture)
|
||||
unsigned int texture[100]; // texture names
|
||||
int ntexture; // number of allocated textures
|
||||
int textureType[mjMAXTEXTURE]; // type of texture (mjtTexture) (ntexture)
|
||||
unsigned int texture[mjMAXTEXTURE]; // texture names
|
||||
|
||||
// displaylist starting positions
|
||||
unsigned int basePlane; // all planes from model
|
||||
unsigned int baseMesh; // all meshes from model
|
||||
unsigned int baseHField; // all hfields from model
|
||||
unsigned int baseBuiltin; // all buildin geoms, with quality from model
|
||||
unsigned int baseFontNormal; // normal font
|
||||
unsigned int baseFontShadow; // shadow font
|
||||
unsigned int baseFontBig; // big font
|
||||
unsigned int basePlane; // all planes from model
|
||||
unsigned int baseMesh; // all meshes from model
|
||||
unsigned int baseHField; // all height fields from model
|
||||
unsigned int baseBuiltin; // all builtin geoms, with quality from model
|
||||
unsigned int baseFontNormal; // normal font
|
||||
unsigned int baseFontShadow; // shadow font
|
||||
unsigned int baseFontBig; // big font
|
||||
|
||||
// displaylist ranges
|
||||
int rangePlane; // all planes from model
|
||||
int rangeMesh; // all meshes from model
|
||||
int rangeHField; // all hfields from model
|
||||
int rangeBuiltin; // all builtin geoms, with quality from model
|
||||
int rangeFont; // all characters in font
|
||||
int rangePlane; // all planes from model
|
||||
int rangeMesh; // all meshes from model
|
||||
int rangeHField; // all hfields from model
|
||||
int rangeBuiltin; // all builtin geoms, with quality from model
|
||||
int rangeFont; // all characters in font
|
||||
|
||||
// skin VBOs
|
||||
int nskin; // number of skins
|
||||
unsigned int* skinvertVBO; // skin vertex position VBOs (nskin)
|
||||
unsigned int* skinnormalVBO; // skin vertex normal VBOs (nskin)
|
||||
unsigned int* skintexcoordVBO; // skin vertex texture coordinate VBOs (nskin)
|
||||
unsigned int* skinfaceVBO; // skin face index VBOs (nskin)
|
||||
int nskin; // number of skins
|
||||
unsigned int* skinvertVBO; // skin vertex position VBOs (nskin)
|
||||
unsigned int* skinnormalVBO; // skin vertex normal VBOs (nskin)
|
||||
unsigned int* skintexcoordVBO; // skin vertex texture coordinate VBOs (nskin)
|
||||
unsigned int* skinfaceVBO; // skin face index VBOs (nskin)
|
||||
|
||||
// character info
|
||||
int charWidth[127]; // character widths: normal and shadow
|
||||
int charWidthBig[127]; // chacarter widths: big
|
||||
int charHeight; // character heights: normal and shadow
|
||||
int charHeightBig; // character heights: big
|
||||
int charWidth[127]; // character widths: normal and shadow
|
||||
int charWidthBig[127]; // chacarter widths: big
|
||||
int charHeight; // character heights: normal and shadow
|
||||
int charHeightBig; // character heights: big
|
||||
|
||||
// capabilities
|
||||
int glInitialized; // is OpenGL initialized
|
||||
int windowAvailable; // is default/window framebuffer available
|
||||
int windowSamples; // number of samples for default/window framebuffer
|
||||
int windowStereo; // is stereo available for default/window framebuffer
|
||||
int windowDoublebuffer; // is default/window framebuffer double buffered
|
||||
int glInitialized; // is OpenGL initialized
|
||||
int windowAvailable; // is default/window framebuffer available
|
||||
int windowSamples; // number of samples for default/window framebuffer
|
||||
int windowStereo; // is stereo available for default/window framebuffer
|
||||
int windowDoublebuffer; // is default/window framebuffer double buffered
|
||||
|
||||
// framebuffer
|
||||
int currentBuffer; // currently active framebuffer: mjFB_WINDOW or mjFB_OFFSCREEN
|
||||
int currentBuffer; // currently active framebuffer: mjFB_WINDOW or mjFB_OFFSCREEN
|
||||
|
||||
// pixel output format
|
||||
int readPixelFormat; // default color pixel format for mjr_readPixels
|
||||
int readPixelFormat; // default color pixel format for mjr_readPixels
|
||||
|
||||
// depth output format
|
||||
int readDepthMap; // depth mapping: mjDEPTH_ZERONEAR or mjDEPTH_ZEROFAR
|
||||
int readDepthMap; // depth mapping: mjDEPTH_ZERONEAR or mjDEPTH_ZEROFAR
|
||||
};
|
||||
typedef struct mjrContext_ mjrContext;
|
||||
|
||||
|
||||
@@ -230,21 +230,22 @@ struct mjvGeom_ { // abstract geom
|
||||
int objtype; // mujoco object type; mjOBJ_UNKNOWN for decor
|
||||
int objid; // mujoco object id; -1 for decor
|
||||
int category; // visual category
|
||||
int texid; // texture id; -1: no texture
|
||||
int texuniform; // uniform cube mapping
|
||||
int matid; // material id; -1: no textured material
|
||||
int texcoord; // mesh or flex geom has texture coordinates
|
||||
int segid; // segmentation id; -1: not shown
|
||||
|
||||
// OpenGL info
|
||||
float texrepeat[2]; // texture repetition for 2D mapping
|
||||
// spatial transform
|
||||
float size[3]; // size parameters
|
||||
float pos[3]; // Cartesian position
|
||||
float mat[9]; // Cartesian orientation
|
||||
|
||||
// material properties
|
||||
float rgba[4]; // color and transparency
|
||||
float emission; // emission coef
|
||||
float specular; // specular coef
|
||||
float shininess; // shininess coef
|
||||
float reflectance; // reflectance coef
|
||||
|
||||
char label[100]; // text label
|
||||
|
||||
// transparency rendering (set internally)
|
||||
|
||||
Reference in New Issue
Block a user