Skip to content

Commit

Permalink
a simple decor test in maintraj
Browse files Browse the repository at this point in the history
  • Loading branch information
kkevlar committed Aug 9, 2018
1 parent e2adb16 commit f71deb7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
22 changes: 20 additions & 2 deletions src/decor.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,27 @@
#include "decor.h"

void decor_single_sphere(traj_info_t* traj_info, mjvScene* scn, int num)
{
mjvGeom* sphere = scn->geoms + scn->ngeom++;

mjv_initGeom(sphere,
2,
traj_info->decor.size + 3*num,
traj_info->decor.pos + 3*num,
NULL,
traj_info->decor.color + 4*num);

}

void decor_showdecor(traj_info_t* traj_info)

void decor_showdecor(traj_info_t* traj_info, mjvScene* scn)
{
//no idea what to do lel
int i;

for (i = 0; i < traj_info->decor.count && i < DECOR_BUF_SIZE; i++)
{
decor_single_sphere(traj_info, scn, i);
}
}


Expand Down
3 changes: 2 additions & 1 deletion src/decor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#define DECORATE_H

#include "main.h"
#include "mujoco.h"

void decor_showdecor(traj_info_t* traj_info);
void decor_showdecor(traj_info_t* traj_info, mjvScene* scn);

#endif
14 changes: 14 additions & 0 deletions src/main-traj.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,20 @@ void nodes_recolor(traj_info_t* traj_info)

void traj_foreach_frame(traj_info_t* traj_info)
{
traj_info->decor.pos[0] = 0;
traj_info->decor.pos[1] = 0;
traj_info->decor.pos[2] = 1;

traj_info->decor.size[0] = 0.02;
traj_info->decor.size[1] = 0.02;
traj_info->decor.size[2] = 0.02;

traj_info->decor.color[0] = .5;
traj_info->decor.color[1] = .5;
traj_info->decor.color[2] = .5;
traj_info->decor.color[3] = 1;

traj_info->decor.count = 1;

allow_node_transformations(traj_info);

Expand Down
3 changes: 2 additions & 1 deletion src/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ enum pert_type_e
struct _decor_t_
{
int count;
double pos[3 * DECOR_BUF_SIZE];
mjtNum pos[3 * DECOR_BUF_SIZE];
mjtNum size[3 * DECOR_BUF_SIZE];
float color[4 * DECOR_BUF_SIZE];
};
typedef struct _decor_t_ decor_t;
Expand Down
4 changes: 3 additions & 1 deletion src/simulate.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ void reset_traj_info()
traj_info.selection.node_type = NODE_POSITIONAL;
traj_info.selection.jointnum = 34;
traj_info.selection.nodecount = 50;

traj_info.decor.count = 0;

// ik_default_fill_solver_params(&(traj_info.params));

Expand Down Expand Up @@ -1166,7 +1168,7 @@ void render(GLFWwindow* window)
// update scene
mjv_updateScene(m, d, &vopt, &pert, &cam, mjCAT_ALL, &scn);

decor_showdecor(&traj_info);
decor_showdecor(&traj_info, &scn);
// render
mjr_render(rect, &scn, &con);

Expand Down

0 comments on commit f71deb7

Please sign in to comment.