Exemplo n.º 1
0
void DebugRenderer::cube(const Vector3& pos, const Matrix4& rot, float sideLength, const Color32& color)
{
	Vector3 coords[8];

	for (uint i = 0; i < 8; ++i)
		coords[i] = rot.apply((m_cubeCoords[i] * sideLength)) + pos; 

	quad(coords[1], coords[0], coords[3], coords[2], Color32(255, 0, 0, 0));
	quad(coords[4], coords[5], coords[6], coords[7], Color32(0, 255, 0, 0));
	quad(coords[0], coords[1], coords[5], coords[4], Color32(0, 0, 255, 0));
	quad(coords[7], coords[6], coords[2], coords[3], Color32(255, 255, 0, 0));
	quad(coords[5], coords[1], coords[2], coords[6], Color32(255, 0, 255, 0));
	quad(coords[0], coords[4], coords[7], coords[3], color);
}
Exemplo n.º 2
0
bool Branch::makeNewDirection(float angleMul, bool hasReatchedTarget)
{
	if (m_curve)
	{
		if (m_curveTarget == m_curveCount)
			return false;

		Vector3 pos = curvePos();
		Vector3 direction = pos - m_position;

		// rand...

		float x = (s_settings->m_angle + s_settings->m_angleVariation * floatRandom()) * angleMul * 0.005f;
		float y = (s_settings->m_angle + s_settings->m_angleVariation * floatRandom()) * angleMul * 0.005f;
		float z = (s_settings->m_angle + s_settings->m_angleVariation * floatRandom()) * angleMul * 0.005f;

		direction = direction.normalize();
		direction.x += x;
		direction.y += y;
		direction.z += z;
		m_direction = direction.normalize();

		// Set next target if we reatched our target point in the curve

		if (hasReatchedTarget)
			++m_curveTarget;

		return true;
	}



	Matrix4 matrix;

	float angle = (s_settings->m_angle + s_settings->m_angleVariation * floatRandom()) * angleMul;

	if (random() & 1)
		angle = -angle;

	switch (random() %3 )
	{
		case 0 :
		{
			matrix.makeXrotation(angle * (3.1415f / 180.0f));
			//m_direction.y = 1.0f;
			break;
		}

		case 1 :
		{
			matrix.makeYrotation(angle * (3.1415f / 180.0f));
			//m_direction.z = 1.0f;
			break;
		}

		case 2 :
		{
			matrix.makeZrotation(angle * (3.1415f / 180.0f));
			//m_direction.x = 1.0f;
			break;
		}

		default : ZENIC_ASSERT(false);
	}

	m_direction = matrix.apply(m_direction);
	m_direction.y += -s_settings->m_gravity;
	m_direction = m_direction.normalize();

	return true;
}