예제 #1
0
void DrawArrow(const NxVec3& posA, const NxVec3& posB, const NxVec3& color)
{
	NxVec3 vec = posB - posA;
	NxVec3 t0, t1, t2;
	NxNormalToTangents(vec, t1, t2);

	t0 = posB - posA;
	t0.normalize();

	NxVec3 lobe1  = posB - t0*0.15 + t1 * 0.15;
	NxVec3 lobe2  = posB - t0*0.15 - t1 * 0.15;
	NxVec3 lobe3  = posB - t0*0.15 + t2 * 0.15;
	NxVec3 lobe4  = posB - t0*0.15 - t2 * 0.15;

	NxVec3 v3ArrowShape[] = {
		NxVec3(posA), NxVec3(posB),
		NxVec3(posB), NxVec3(lobe1),
		NxVec3(posB), NxVec3(lobe2),
		NxVec3(posB), NxVec3(lobe3),
		NxVec3(posB), NxVec3(lobe4),
	};

	glDisable(GL_LIGHTING);
	glLineWidth(3.0f);
	glColor4f(color.x,color.y,color.z,1.0f);
	glEnableClientState(GL_VERTEX_ARRAY);

	glVertexPointer(3, GL_FLOAT, sizeof(NxVec3), 10, &v3ArrowShape[0].x);

	glDrawArrays(GL_LINES, 0, sizeof(v3ArrowShape)/sizeof(NxVec3));
	glDisableClientState(GL_VERTEX_ARRAY);
	glColor4f(1.0f,1.0f,1.0f,1.0f);
}
예제 #2
0
/**-------------------------------------------------------------------------------
    update

    @brief
    @return void
---------------------------------------------------------------------------------*/
void SensorDecoratorVector::update()
{
	mSensor->update();

	if (getDataValid())
	{
		std::vector<Ogre::Vector3> out;
		getValue(out);
		Ogre::Vector3 pos(out[0].x, out[0].y, out[0].z);
		Ogre::Vector3 force(out[1].x, out[1].y, out[1].z);

		getParentNode()->setPosition(pos);
		setVisible(true);

		Ogre::Vector3 posA(0, 0, 0);
		Ogre::Vector3 posB = force  / force.length() * 5;

		Ogre::Vector3 t0 = posB - posA;
		NxVec3 tan1, tan2;
		NxVec3 v3 = NxOgre::NxConvert<NxVec3, Ogre::Vector3>(t0);
		NxNormalToTangents(v3, tan1, tan2);

		t0.normalise();
		Ogre::Vector3 t1 = NxOgre::NxConvert<Ogre::Vector3, NxVec3>(tan1);
		Ogre::Vector3 t2 = NxOgre::NxConvert<Ogre::Vector3, NxVec3>(tan2);

		Ogre::Vector3 lobe1  = posB - t0 * ARROW_H + t1 * ARROW_H;
		Ogre::Vector3 lobe2  = posB - t0 * ARROW_H - t1 * ARROW_H;
		Ogre::Vector3 lobe3  = posB - t0 * ARROW_H + t2 * ARROW_H;
		Ogre::Vector3 lobe4  = posB - t0 * ARROW_H - t2 * ARROW_H;

		beginUpdate(0);
		position(posA);
		position(posB);
		position(posB);
		position(lobe1);
		position(posB);
		position(lobe2);
		position(posB);
		position(lobe3);
		position(posB);
		position(lobe4);
		end();
	}
	else
	{
		setVisible(false);
	}

	// if drawing is not persistent remove it after one draw
	if (getVisible() && !mPersistent && getDataValid())
	{
		setDataValid(false);
	}

}