int CableParticleConnection::AddContact(PhysicsManager* manager)
{
	float length = getCurrentLength();

	// Disregard anything past 2nd decimal place
	float checkLength = length;
	//checkLength = floorf(length * 100.0f) / 100.0f;	

	// Do nothing if length is less than max
	if (checkLength < m_maxLength) return 0;

	ParticleContact* contact = new ParticleContact();
	contact->setFirstParticle(mp_first);
	contact->setSecondParticle(mp_second);

	Vector3 normal = mp_second->getPosition() - mp_first->getPosition();
	contact->setContactNormal(normal.normalize());

	contact->setPenetrationDepth(length - m_maxLength);

	contact->setRestitution(m_restitution);

	manager->addContact(contact);
	return 1;
}
Esempio n. 2
0
void Integer::draw(QPainter *painter, qint32 x, qint32 y)
{
    if(this->align == Defination::ALIGN_LEFT)
    {
        qint32 temp = value;
        for(qint32 i = getCurrentLength()-1;i>=0;i--)
        {
            number->draw(painter, x + i * 20, y, temp % 10);
            temp /= 10;
        }
    }
    else
    {
        qint32 temp = value;
        for(qint32 i = integerLength-1; i>=0; i--)
        {
            number->draw(painter, x+ i * 20, y, temp % 10);
            temp /= 10;
            if(temp == 0 && !fillZero)
            {
                break;
            }
        }
    }
}
void KamehamehaRenderer::draw()
{
    m_kkhStatus->currentIntensity = getCurrentIntensity();

    if (!m_active) {
        return;
    }

    float t = m_ticker.tick();

    m_rctx->modelViewMatrix.PushMatrix();
    {
        float length = getCurrentLength();
        float radius = getCurrentRadius();

        GLFrame f;
        f.SetOrigin(XV3toM3D(m_origin + m_forward * length));
        f.SetForwardVector(XV3toM3D(-m_forward));
        m_rctx->modelViewMatrix.MultMatrix(f);

        float planeColor[] = { 0.95f, 1.0f, 1.0f, 1.5f };

        glUseProgram(s_shaderID);
        glUniformMatrix4fv(glGetUniformLocation(s_shaderID, "mvMatrix"), 1, GL_FALSE, m_rctx->transform.GetModelViewMatrix());
        glUniformMatrix4fv(glGetUniformLocation(s_shaderID, "pMatrix"), 1, GL_FALSE, m_rctx->transform.GetProjectionMatrix());
        glUniform4fv(glGetUniformLocation(s_shaderID, "vColor"), 1, planeColor);

        drawBeam(radius, length);
        //glutSolidSphere(radius, 64, 64);
    }
    m_rctx->modelViewMatrix.PopMatrix();

    if (t > m_lifeTime) {
        m_active = false;
    }

    drawIntensityText();
}