8 #include <hrpModel/Sensor.h> 24 m_useAbsTransformToDraw =
true;
29 Rs = hrp::Matrix33::Identity();
30 R = hrp::Matrix33::Identity();
63 Eigen::Vector3f
n,
v[3];
66 float red[] = {1,0,0,1};
67 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, red);
69 float gray[] = {0.8,0.8,0.8,1};
70 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, gray);
72 glBegin(GL_TRIANGLES);
74 coldetModel->getTriangle(
i, vindex[0], vindex[1], vindex[2]);
75 for (
int j=0; j<3; j++){
76 coldetModel->getVertex(vindex[j], v[j][0], v[j][1], v[j][2]);
78 n = (v[1]-v[0]).
cross(v[2]-v[0]);
80 glNormal3fv(n.data());
81 for (
int j=0; j<3; j++){
82 glVertex3fv(v[j].
data());
91 for (
int i=0;
i<3;
i++){
92 for (
int j=0; j<3; j++){
97 T[3] = T[7] = T[11] = 0.0; T[15] = 1.0;
106 int lid = GL_LIGHT0+l->
id;
112 for (
int j=0; j<3; j++){
113 for (
int k=0; k<3; k++){
114 T[j*4+k] = l->
localR(k,j);
118 T[3] = T[7] = T[11] = 0.0; T[15] = 1.0;
121 glEnable(GL_LIGHTING);
123 GLfloat
pos[] = {0,0,0,1};
124 glLightfv(lid, GL_POSITION, pos);
126 glLightfv(lid, GL_DIFFUSE, color);
127 if (l->
type == POINT){
128 glLightf(lid, GL_CONSTANT_ATTENUATION, l->
attenuation[0]);
129 glLightf(lid, GL_LINEAR_ATTENUATION, l->
attenuation[1]);
130 glLightf(lid, GL_QUADRATIC_ATTENUATION, l->
attenuation[2]);
131 }
else if(l->
type == SPOT){
132 glLightf(lid, GL_CONSTANT_ATTENUATION, l->
attenuation[0]);
133 glLightf(lid, GL_LINEAR_ATTENUATION, l->
attenuation[1]);
134 glLightf(lid, GL_QUADRATIC_ATTENUATION, l->
attenuation[2]);
135 glLightf(lid, GL_SPOT_EXPONENT, 20);
138 glLightfv(lid, GL_SPOT_DIRECTION, dir);
139 }
else if(l->
type == DIRECTIONAL){
141 glLightfv(lid, GL_SPOT_DIRECTION, dir);
147 glDisable(GL_LIGHTING);
150 glVertex3f(0,0,0); glVertex3f(0.5, 0, 0);
152 glVertex3f(0,0,0); glVertex3f(0, 0.5, 0);
154 glVertex3f(0,0,0); glVertex3f(0, 0, 0.5);
156 glEnable(GL_LIGHTING);
161 ntri += ((
GLlink *)l)->draw();
185 m_T_j[ 0]=1;m_T_j[ 1]=0;m_T_j[ 2]=0;m_T_j[ 3]=0;
186 m_T_j[ 4]=0;m_T_j[ 5]=1;m_T_j[ 6]=0;m_T_j[ 7]=0;
187 m_T_j[ 8]=0;m_T_j[ 9]=0;m_T_j[10]=1;m_T_j[11]=0;
188 m_T_j[12]=aLocal[0]*i_q;
189 m_T_j[13]=aLocal[1]*i_q;
190 m_T_j[14]=aLocal[2]*i_q;
206 memcpy(
m_absTrans, i_trans,
sizeof(
double)*16);
210 std::string
name(i_name);
223 memcpy(o_trans,
m_absTrans,
sizeof(
double)*16);
227 double trans1[16], trans2[16];
232 memcpy(o_trans,
m_trans,
sizeof(
double)*16);
285 m_shapes[
i]->divideLargeTriangles(maxEdgeLen);
294 for (
int i=0;
i<3;
i++){
295 for (
int j=0; j<3; j++){
302 o_min = mi; o_max = ma;
304 for (
int j=0; j<3; j++){
305 if (o_min[j] > mi[j]) o_min[j] = mi[j];
306 if (o_max[j] < ma[j]) o_max[j] = ma[j];
void setAbsTransform(double o_trans[16])
GLcamera * findCamera(const char *i_name)
static void useAbsTransformToDraw()
void divideLargeTriangles(double maxEdgeLen)
ColdetModelPtr coldetModel
const std::vector< GLcamera * > & cameras()
void computeAABB(hrp::Vector3 &o_min, hrp::Vector3 &o_max)
OpenHRP::matrix33 Matrix33
std::vector< Light *> lights
std::vector< GLshape * > m_shapes
hrp::Link * GLlinkFactory()
HRP_UTIL_EXPORT void calcRodrigues(Matrix44 &out_R, const Vector3 &axis, double q)
void addShape(GLshape *shape)
void mulTrans(const double i_m1[16], const double i_m2[16], double o_m[16])
Vector3 cross(const Vector3 &v1, const Vector3 &v2)
std::vector< GLcamera * > m_cameras
void addCamera(GLcamera *camera)
void computeAbsTransform()
std::vector< Sensor *> sensors
void drawSensor(hrp::Sensor *i_sensor)
static bool m_useAbsTransformToDraw
void highlight(bool flag)