Ejemplo n.º 1
0
	bool CSObject::isFacing(vector3df targetposition, float window)
	{
		vector3df lookat = getFacing(targetposition);
		if (
			((getAbsoluteRotation().Y > lookat.Y - window) && (getAbsoluteRotation().Y < lookat.Y + window))
			||
			((lookat.Y > getAbsoluteRotation().Y - window) && (lookat.Y < getAbsoluteRotation().Y + window))
			)
			return true;
		else
			return false;
	}
Ejemplo n.º 2
0
float Object::getRotation()
{
    float result = getAbsoluteRotation();
    if (m_parent)
        result -= m_parent->getAbsoluteRotation();

    return utils::toAngle(result);
}
Ejemplo n.º 3
0
void Object::onDraw()
{
    if (m_image)
    {
		m_image->m_position = getAbsolutePosition();
		m_image->m_angle = 360 - getAbsoluteRotation();
		m_image->m_scale.set(gdata.zoom, gdata.zoom);
        m_image->renderImage(gdata.renderer);
    }
}
Ejemplo n.º 4
0
void Object::syncWithParent()
{
    float   deltaRotation = m_parent->getAbsoluteRotation() - parentPrimalRotation;
    Vector2 deltaPosition = m_parent->getAbsolutePosition() - parentPrimalPosition;

    setAbsoluteRotation(getAbsoluteRotation() + deltaRotation);

    // the rotation will affect the position
    Vector2 rotatedPosition = getAbsolutePosition() + deltaPosition;
    rotatedPosition.rotateAround(deltaRotation,m_parent->getAbsolutePosition());

    setAbsolutePosition(rotatedPosition);

    parentPrimalRotation = m_parent->getAbsoluteRotation();
    parentPrimalPosition = m_parent->getAbsolutePosition();
}
Ejemplo n.º 5
0
void Object::addChild(Object* child)
{
    if (child->m_physicsObject->GetType() != b2_dynamicBody)
    {
        bool alreadyChild = false;
        for (unsigned i = 0; i < m_children.size(); ++i)
        {
            Object* object = m_children.at(i);
            if (object == child) {alreadyChild = true;}
        }

        if (!alreadyChild)
        {
            child->m_parent = this;
            m_children.push_back(child);

            child->parentPrimalRotation = getAbsoluteRotation();
            child->parentPrimalPosition = getAbsolutePosition();
        }
    }
}
Ejemplo n.º 6
0
Vector RenderObject::getNormal()
{
	float a = MathFunctions::toRadians(getAbsoluteRotation().z);
	return Vector(sinf(a),cosf(a));
}