本文整理汇总了C++中Sensor::getPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Sensor::getPosition方法的具体用法?C++ Sensor::getPosition怎么用?C++ Sensor::getPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sensor
的用法示例。
在下文中一共展示了Sensor::getPosition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//----------------------------------------------------------------------------------------------------------------------
void SMCAgentViz::update()
{
glDisable(GL_DEPTH_TEST);
// data
const ci::Vec2f& pos = m_agent->getPosition();
float angle = m_agent->getAngle();
// Update trajectory
if(!m_paused && m_steps % 2 == 0){
m_traj.push_back(pos);
if(m_traj.size() >= 800)
{
m_traj.pop_front();
}
}
m_steps++;
// pose
m_pTM->setToIdentity();
m_pTM->setTranslate(ci::Vec3f(pos));
m_pTM->rotate(ci::Vec3f(0.0f, 0.0f, 1.0f), angle);
NodeGroup::update();
// draw
glPushAttrib(GL_LIGHTING);
glDisable(GL_LIGHTING);
// Trajectory
ci::ColorA trajCol (235.0/255.0, 89.0/255.0, 55.0/255.0, 1.0);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
int numPoints = m_traj.size();
float lineVerts[numPoints*2];
float colors[numPoints*4];
glVertexPointer(2, GL_FLOAT, 0, lineVerts); // 2d positions
glColorPointer(4, GL_FLOAT, 0, colors); // 4d colors
for(size_t i = 0; i < numPoints; i++)
{
lineVerts[i*2 + 0] = m_traj[i].x;
lineVerts[i*2 + 1] = m_traj[i].y;
float a = (float)i / (float)numPoints;
colors[i*4 + 0] = trajCol[0];
colors[i*4 + 1] = trajCol[1];
colors[i*4 + 2] = trajCol[2];
colors[i*4 + 3] = a;
}
glLineWidth(2.0);
glDrawArrays( GL_LINE_STRIP, 0, numPoints);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glLineWidth(1.0);
// This is in world space
glColor3f(0, 0, 0);
const float velScale = 0.1f;
glLineWidth(2.0);
ci::gl::drawLine(m_agent->getPosition(), m_agent->getPosition() + m_agent->getVelocity() * velScale);
glLineWidth(1.0);
if(m_agent->hasDistanceSensor())
{
DistanceSensor* sensor = m_agent->getDistanceSensor();
float sensedDistance = sensor->getDistance();
glEnable(GL_LINE_STIPPLE);
glLineStipple(2, 0xAAAA);
glColor3f(0.2, 0.2, 0.2);
ci::gl::drawLine(sensor->getPosition(), sensor->getPosition() + sensor->getDirection() * sensedDistance);
glDisable(GL_LINE_STIPPLE);
glColor3f(1,0,0);
if(sensedDistance < sensor->getMaxDistance())
{
drawPoint(ci::Vec3f(sensor->getCollision()), 5.0f);
}
// Sensor in local space
glPushMatrix();
glMultMatrixf(*m_pTM);
glTranslatef(m_agent->getRadius(), 0, 0.001);
float act = m_agent->getDistanceSensor()->getDistanceProportional();
glColor3f(act,act,act);
drawDisk(m_agent->getRadius() / 4.0, 0, 16, 2, GLU_FILL);
glColor3f(0,0,0);
drawDisk(m_agent->getRadius() / 4.0, 0, 16, 2, GLU_SILHOUETTE);
glPopMatrix();
}
if(m_agent->hasGradientSensor())
{
GradientSensor* sensor = m_agent->getGradientSensor();
float s = 1.0f - sensor->getActivation();
// Sensor in local space
//.........这里部分代码省略.........