void OnEndUpdate (dFloat timestepInSecunds)
	{
		DemoCamera* const camera = m_scene->GetCamera();

		dMatrix camMatrix(camera->GetNextMatrix());
		dMatrix playerMatrix (m_player->GetNextMatrix());

		dVector frontDir (camMatrix[0]);

		CustomPlayerController* const controller = m_player->m_controller; 
		dFloat height = controller->GetHigh();
		dVector upDir (controller->GetUpDir());

		dVector camOrigin(0.0f); 
		
		if (m_player->m_inputs.m_cameraMode) {
			// set third person view camera
			camOrigin = playerMatrix.TransformVector (upDir.Scale(height));
			camOrigin -= frontDir.Scale (PLAYER_THIRD_PERSON_VIEW_DIST);
		} else {
			// set first person view camera
			camMatrix = camMatrix * playerMatrix;
			camOrigin = playerMatrix.TransformVector (upDir.Scale(height));
		}

		camera->SetNextMatrix (*m_scene, camMatrix, camOrigin);

		// update the shot button
		if (m_shootState) {
			SpawnRandomProp (camera->GetNextMatrix());
		}
	}
Ejemplo n.º 2
0
void SE_Camera::create(const SE_Vector3f& location, const SE_Vector3f& target, float fov, float ratio, float near, float far)
{
    mFrustum.set(fov, ratio, near, far);
    SE_Vector3f zDir = location - target;
    if(zDir.isZero())
    {
        LOGI("### camera direction is zero ####\n");
        zDir.set(0, 0, 1);
    }
    zDir = zDir.normalize();
    SE_Vector3f upDir(0, 1, 0);
    if(upDir == zDir)
    {
        upDir.set(0, 0, -1);
    }
    SE_Vector3f leftDir = upDir.cross(zDir);
    upDir = zDir.cross(leftDir);
    mAxisX = leftDir.normalize();
    mAxisY = upDir.normalize();
    mAxisZ = zDir;
    mLocation = location;
    mChanged = true;
    mViewport.left = 0;
    mViewport.right = 0;
    mViewport.top = 0;
    mViewport.bottom = 0;
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: Climb nodes are centered over the climb surface, the must be
//			shifted away from the climb surface according to the hull size
//			of the NPC using the climb
// Input  :
// Output :
//-----------------------------------------------------------------------------
Vector CAI_Node::GetPosition(int hull)
{
	if (m_eNodeType == NODE_CLIMB) 
	{
		// Shift by the length of the hull and some small fudge
		float  shift  = (0.5*NAI_Hull::Length(hull)) + (NODE_CLIMB_OFFSET);

		Vector offsetDir = Vector(cos(DEG2RAD(m_flYaw)),sin(DEG2RAD(m_flYaw)),0);

		Vector origin;
		if (m_eNodeInfo & bits_NODE_CLIMB_OFF_FORWARD)
		{
			origin = m_vOrigin + (shift * offsetDir);
		}
		else if (m_eNodeInfo & bits_NODE_CLIMB_OFF_LEFT)
		{
			Vector upDir(0,0,1);
			Vector leftDir;
			CrossProduct( offsetDir, upDir, leftDir);
			origin = m_vOrigin - (2 * shift * leftDir) - (shift * offsetDir);
		}
		else if (m_eNodeInfo & bits_NODE_CLIMB_OFF_RIGHT)
		{
			Vector upDir(0,0,1);
			Vector leftDir;
			CrossProduct( offsetDir, upDir, leftDir);
			origin = m_vOrigin + (2 * shift * leftDir) - (shift * offsetDir);
		}
		else 
		{
			origin = m_vOrigin - (shift * offsetDir);
		}

		return Vector( origin.x, origin.y, origin.z + m_flVOffset[hull] );
	}
	else if (m_eNodeType == NODE_GROUND)
	{
		// this is the floor resting position of this hull, adjusted to account for mins.z
		return Vector( m_vOrigin.x, m_vOrigin.y, m_vOrigin.z + m_flVOffset[hull] );
	}
	else
	{
		return m_vOrigin;
	}
}
Ejemplo n.º 4
0
void DownloadsManager::removeDir(QString dirName)
{
    dirName.replace(QRegExp("[<|>|:|\"|/|\\|||?|*]"), "");
    changeToDir(dirName);

    foreach (QString entry, downloadDir.entryList(QDir::NoDotAndDotDot|QDir::Dirs|QDir::Files))
        if (!downloadDir.remove(entry))
            removeDir(entry);

    upDir();

    downloadDir.rmdir(dirName);
}
Ejemplo n.º 5
0
	void SetCamera()
	{
		if (m_player) {
			DemoEntityManager* const scene = (DemoEntityManager*)NewtonWorldGetUserData(GetWorld());
			DemoCamera* const camera = scene->GetCamera();
			dMatrix camMatrix(camera->GetNextMatrix());

			DemoEntity* player = (DemoEntity*)NewtonBodyGetUserData(m_player->GetBody());
			dMatrix playerMatrix(player->GetNextMatrix());

			dFloat height = 2.0f;
			dVector frontDir(camMatrix[0]);
			dVector upDir(0.0f, 1.0f, 0.0f, 0.0f);
			dVector camOrigin = playerMatrix.TransformVector(upDir.Scale(height));
			camOrigin -= frontDir.Scale(PLAYER_THIRD_PERSON_VIEW_DIST);

			camera->SetNextMatrix(*scene, camMatrix, camOrigin);
		}
	}
Ejemplo n.º 6
0
VProjectedWallmark *VWallmarkManager::CreateProjectedWallmark(const hkvVec3& vDestPos, const hkvVec3& vOrigin, float radius, float depth, VTextureObject* pTexture, VIS_TransparencyType drawtype, VColorRef iColor, float rotation, float fLifeTime, float fFadeOutTime)
{
  hkvVec3 dir = vDestPos-vOrigin;
  float fDistance = dir.getLength();
  if (hkvMath::isZero (fDistance)) 
    return NULL;

  dir.normalizeIfNotZero();

  hkvVec3 upDir(0,0,-1.f);
  hkvVec3 rightDir;
  
  if (dir.z >= 0.999f || dir.z <= -0.999f)
  {
    upDir = hkvVec3(1,0,0);
  }
  rightDir = dir.cross(upDir);
  rightDir.normalizeIfNotZero();
  if (rightDir.x==0.f && rightDir.y==0.f && rightDir.z==0.f)
    rightDir.set(0,0,1.f);  

  upDir = rightDir.cross(dir);

  // rotate with angle
  float sina = hkvMath::sinDeg (rotation);
  float cosa = hkvMath::cosDeg (rotation);

  hkvVec3 up1     =  upDir*cosa + rightDir*sina;
  hkvVec3 right1  =  upDir*sina - rightDir*cosa;

  float fConeFactor = fDistance / (2.f * radius);

  VProjectedWallmark* pProjectedWM = new VProjectedWallmark(
    vOrigin,vDestPos,up1,right1,fConeFactor,fConeFactor,depth,pTexture,NULL,
    drawtype,iColor,fLifeTime,fFadeOutTime);
  V_VERIFY_MALLOC(pProjectedWM);

  return pProjectedWM;

}
Ejemplo n.º 7
0
void PerspectiveCamera::mousePressed(CameraScratch &scratch, QMouseEvent *event)
{
    scratch.pickX = event->pos().x();
    scratch.pickY = event->pos().y();

    if (event->button() == Qt::LeftButton) {
        scratch.moveType = MoveType::ROTATING;
    }
    else if (event->button() == Qt::MidButton) {
        scratch.moveType = MoveType::PANNING;

        scratch.origEye = eye();
        //Vector3 f = (lookat() - eye()).normalized();
        //Vector3 s = Vector3::crossProduct(f, upDir());
        scratch.origUp = upDir();
        //origUp = Vector3::crossProduct(s, f);
        scratch.origLeft = leftDir();
    } else if (event->button() == Qt::RightButton) {
        scratch.moveType = MoveType::TRUCKING;
    } else {
        scratch.moveType = MoveType::NOT_MOVING;
    }
}
Ejemplo n.º 8
0
LibraryEntry *LibraryModel::getLibraryNode(const QString &dirPath)
{
    if(_dirMap.contains(dirPath)) {
        return _dirMap[dirPath];
    }

    // We need to create a new dir entry
    LibraryEntry *currentDirEntry;
    QDir currentDir(dirPath);
    if(currentDir.isRoot()) {
        currentDirEntry = new LibraryEntry(currentDir.path().remove(QRegularExpression("/$")),
                                           _dirMap["/"]);
    } else {
        QDir upDir(currentDir);
        upDir.cdUp();
        LibraryEntry *parentEntry = getLibraryNode(upDir.canonicalPath());

        currentDirEntry = new LibraryEntry(currentDir.dirName(), parentEntry);
    }

    _dirMap[dirPath] = currentDirEntry;
    return currentDirEntry;
}
Ejemplo n.º 9
0
QMatrix4x4 PerspectiveCamera::getViewMatrix(int width, int height)
{
    QMatrix4x4 m;
    m.lookAt(eye(), lookat(), upDir());
    return m;
}
void CustomLimitBallAndSocket::SubmitConstraints(dFloat timestep, int threadIndex)
{
	dMatrix matrix0;
	dMatrix matrix1;

	// calculate the position of the pivot point and the Jacobian direction vectors, in global space. 
	CalculateGlobalMatrix(matrix0, matrix1);

	const dVector& p0 = matrix0.m_posit;
	const dVector& p1 = matrix1.m_posit;

	// Restrict the movement on the pivot point along all tree orthonormal direction
	NewtonUserJointAddLinearRow(m_joint, &p0[0], &p1[0], &matrix1.m_front[0]);
	NewtonUserJointAddLinearRow(m_joint, &p0[0], &p1[0], &matrix1.m_up[0]);
	NewtonUserJointAddLinearRow(m_joint, &p0[0], &p1[0], &matrix1.m_right[0]);

	matrix1 = m_rotationOffset * matrix1;

	// handle special case of the joint being a hinge
	if (m_coneAngleCos > 0.9999f) {
		NewtonUserJointAddAngularRow(m_joint, CalculateAngle (matrix0.m_front, matrix1.m_front, matrix1.m_up), &matrix1.m_up[0]);
		NewtonUserJointAddAngularRow(m_joint, CalculateAngle(matrix0.m_front, matrix1.m_front, matrix1.m_right), &matrix1.m_right[0]);

		// the joint angle can be determined by getting the angle between any two non parallel vectors
		dFloat pitchAngle = CalculateAngle (matrix0.m_up, matrix1.m_up, matrix1.m_front);
		if ((m_maxTwistAngle - m_minTwistAngle) < 1.0e-4f) {
			NewtonUserJointAddAngularRow(m_joint, pitchAngle, &matrix1.m_front[0]);
		} else {
			if (pitchAngle > m_maxTwistAngle) {
				pitchAngle -= m_maxTwistAngle;
				NewtonUserJointAddAngularRow(m_joint, pitchAngle, &matrix0.m_front[0]);
				NewtonUserJointSetRowMinimumFriction(m_joint, -0.0f);
			} else if (pitchAngle < m_minTwistAngle) {
				pitchAngle -= m_minTwistAngle;
				NewtonUserJointAddAngularRow(m_joint, pitchAngle, &matrix0.m_front[0]);
				NewtonUserJointSetRowMaximumFriction(m_joint, 0.0f);
			}
		}

	} else {

		const dVector& coneDir0 = matrix0.m_front;
		const dVector& coneDir1 = matrix1.m_front;
		dFloat cosAngle = coneDir0 % coneDir1;
		if (cosAngle <= m_coneAngleCos) {
			dVector lateralDir(coneDir0 * coneDir1);
			dFloat mag2 = lateralDir % lateralDir;
			dAssert(mag2 > 1.0e-4f);
			lateralDir = lateralDir.Scale(1.0f / dSqrt(mag2));

			dQuaternion rot(m_coneAngleHalfCos, lateralDir.m_x * m_coneAngleHalfSin, lateralDir.m_y * m_coneAngleHalfSin, lateralDir.m_z * m_coneAngleHalfSin);
			dVector frontDir(rot.UnrotateVector(coneDir1));
			dVector upDir(lateralDir * frontDir);
			NewtonUserJointAddAngularRow(m_joint, 0.0f, &upDir[0]);
			NewtonUserJointAddAngularRow(m_joint, CalculateAngle(coneDir0, frontDir, lateralDir), &lateralDir[0]);
			NewtonUserJointSetRowMinimumFriction(m_joint, 0.0f);
		}

		//handle twist angle
		dFloat pitchAngle = CalculateAngle (matrix0.m_up, matrix1.m_up, matrix1.m_front);
		if ((m_maxTwistAngle - m_minTwistAngle) < 1.0e-4f) {
			NewtonUserJointAddAngularRow(m_joint, pitchAngle, &matrix1.m_front[0]);
		} else {
			if (pitchAngle > m_maxTwistAngle) {
				pitchAngle -= m_maxTwistAngle;
				NewtonUserJointAddAngularRow(m_joint, pitchAngle, &matrix0.m_front[0]);
				NewtonUserJointSetRowMinimumFriction(m_joint, -0.0f);
			} else if (pitchAngle < m_minTwistAngle) {
				pitchAngle -= m_minTwistAngle;
				NewtonUserJointAddAngularRow(m_joint, pitchAngle, &matrix0.m_front[0]);
				NewtonUserJointSetRowMaximumFriction(m_joint, 0.0f);
			}
		}
	}
}
void dCustomBallAndSocket::SubmitConstraints(dFloat timestep, int threadIndex)
{
	dMatrix matrix0;
	dMatrix matrix1;

	// calculate the position of the pivot point and the Jacobian direction vectors, in global space. 
	CalculateGlobalMatrix(matrix0, matrix1);
	SubmitLinearRows(0x07, matrix0, matrix1);

	const dVector& coneDir0 = matrix0.m_front;
	const dVector& coneDir1 = matrix1.m_front;

	dFloat cosAngleCos = coneDir1.DotProduct3(coneDir0);
	dMatrix coneRotation(dGetIdentityMatrix());
	dVector lateralDir(matrix0.m_up);

	if (cosAngleCos < 0.9999f) {
		lateralDir = coneDir1.CrossProduct(coneDir0);
		dFloat mag2 = lateralDir.DotProduct3(lateralDir);
		if (mag2 > 1.0e-4f) {
			lateralDir = lateralDir.Scale(1.0f / dSqrt(mag2));
			coneRotation = dMatrix(dQuaternion(lateralDir, dAcos(dClamp(cosAngleCos, dFloat(-1.0f), dFloat(1.0f)))), matrix1.m_posit);
		} else {
			lateralDir = matrix0.m_up.Scale (-1.0f);
			coneRotation = dMatrix(dQuaternion(matrix0.m_up, 180 * dDegreeToRad), matrix1.m_posit);
		}
	}

	dVector omega0(0.0f);
	dVector omega1(0.0f);
	NewtonBodyGetOmega(m_body0, &omega0[0]);
	if (m_body1) {
		NewtonBodyGetOmega(m_body1, &omega1[0]);
	}
	dVector relOmega(omega0 - omega1);

	// do twist angle calculations
	dMatrix twistMatrix(matrix0 * (matrix1 * coneRotation).Inverse());
	dFloat twistAngle = m_twistAngle.Update(dAtan2(twistMatrix[1][2], twistMatrix[1][1]));
	if (m_options.m_option0) {
		if ((m_minTwistAngle == 0.0f) && (m_minTwistAngle == 0.0f)) {
			NewtonUserJointAddAngularRow(m_joint, -twistAngle, &matrix0.m_front[0]);
			NewtonUserJointSetRowStiffness(m_joint, m_stiffness);
		} else {
			if (m_options.m_option1) {
				// TODO spring option
				dAssert (0);
			} else {
				SubmitConstraintTwistLimits(matrix0, matrix1, relOmega, timestep);
			}
		}
	} else if (m_options.m_option1) {
		// TODO spring option
		dAssert (0);
	} else if (m_twistFriction > 0.0f) {
		NewtonUserJointAddAngularRow(m_joint, 0, &matrix0.m_front[0]);
		NewtonUserJointSetRowStiffness(m_joint, m_stiffness);

		NewtonUserJointSetRowAcceleration(m_joint, NewtonUserJointCalculateRowZeroAccelaration(m_joint));
		NewtonUserJointSetRowMinimumFriction(m_joint, -m_twistFriction);
		NewtonUserJointSetRowMaximumFriction(m_joint, m_twistFriction);
	}

	// do twist cone angle calculations
	if (m_options.m_option2) {
		if ((m_maxConeAngle == 0.0f)) {
			dMatrix localMatrix(matrix0 * matrix1.Inverse());
			dVector euler0;
			dVector euler1;
			localMatrix.GetEulerAngles(euler0, euler1, m_pitchRollYaw);
			NewtonUserJointAddAngularRow(m_joint, -euler0[1], &matrix1[1][0]);
			NewtonUserJointSetRowStiffness(m_joint, m_stiffness);
			NewtonUserJointAddAngularRow(m_joint, -euler0[2], &matrix1[2][0]);
			NewtonUserJointSetRowStiffness(m_joint, m_stiffness);
		} else {
			if (m_options.m_option3) {
				// TODO spring option
				dAssert(0);
			} else {
				dFloat jointOmega = relOmega.DotProduct3(lateralDir);
				dFloat currentAngle = dAcos(dClamp(cosAngleCos, dFloat(-1.0f), dFloat(1.0f)));
				dFloat coneAngle = currentAngle + jointOmega * timestep;
				if (coneAngle >= m_maxConeAngle) {
					//dQuaternion rot(lateralDir, coneAngle);
					//dVector frontDir(rot.RotateVector(coneDir1));
					//dVector upDir(lateralDir.CrossProduct(frontDir));

					dVector upDir(lateralDir.CrossProduct(coneDir0));
					NewtonUserJointAddAngularRow(m_joint, 0.0f, &upDir[0]);
					NewtonUserJointSetRowAcceleration(m_joint, NewtonUserJointCalculateRowZeroAccelaration(m_joint));
					NewtonUserJointSetRowStiffness(m_joint, m_stiffness);

					NewtonUserJointAddAngularRow(m_joint, 0.0f, &lateralDir[0]);
					NewtonUserJointSetRowStiffness(m_joint, m_stiffness);
					NewtonUserJointSetRowMaximumFriction(m_joint, m_coneFriction);
					const dFloat invtimestep = 1.0f / timestep;
					const dFloat speed = 0.5f * (m_maxConeAngle - currentAngle) * invtimestep;
					const dFloat stopAccel = NewtonUserJointCalculateRowZeroAccelaration(m_joint) + speed * invtimestep;
					NewtonUserJointSetRowAcceleration(m_joint, stopAccel);

				} else if (m_coneFriction != 0) {
					NewtonUserJointAddAngularRow(m_joint, 0.0f, &lateralDir[0]);
					NewtonUserJointSetRowAcceleration(m_joint, NewtonUserJointCalculateRowZeroAccelaration(m_joint));
					NewtonUserJointSetRowMinimumFriction(m_joint, -m_coneFriction);
					NewtonUserJointSetRowMaximumFriction(m_joint, m_coneFriction);

					dVector upDir(lateralDir.CrossProduct(coneDir0));
					NewtonUserJointAddAngularRow(m_joint, 0.0f, &upDir[0]);
					NewtonUserJointSetRowAcceleration(m_joint, NewtonUserJointCalculateRowZeroAccelaration(m_joint));
					NewtonUserJointSetRowMinimumFriction(m_joint, -m_coneFriction);
					NewtonUserJointSetRowMaximumFriction(m_joint, m_coneFriction);
				}
			}
		}
	} else if (m_options.m_option3) {
		// TODO spring option
		dAssert(0);
	} else if (m_coneFriction > 0.0f) {
		NewtonUserJointAddAngularRow(m_joint, 0.0f, &lateralDir[0]);
		NewtonUserJointSetRowAcceleration(m_joint, NewtonUserJointCalculateRowZeroAccelaration(m_joint));
		NewtonUserJointSetRowMinimumFriction(m_joint, -m_coneFriction);
		NewtonUserJointSetRowMaximumFriction(m_joint, m_coneFriction);

		dVector upDir(lateralDir.CrossProduct(coneDir0));
		NewtonUserJointAddAngularRow(m_joint, 0.0f, &upDir[0]);
		NewtonUserJointSetRowAcceleration(m_joint, NewtonUserJointCalculateRowZeroAccelaration(m_joint));
		NewtonUserJointSetRowMinimumFriction(m_joint, -m_coneFriction);
		NewtonUserJointSetRowMaximumFriction(m_joint, m_coneFriction);
	}
}
Ejemplo n.º 12
0
void SeleneDev::CTestNode::Render()
{
	Selene::CGraphics::SVertex pyramidVertices[3];
	Selene::CGraphics::SVertex boxVertices[4];
	Selene::CGraphics::SVertex squaresVertices[12];

	Selene::Color pyramidColor(1.0f, 1.0f, 1.0f, 1.0f);
	Selene::Color boxColor(0.5f, 0.5f, 0.2f, 0.5f);
	Selene::Color squaresColor(1.0f, 1.0f, 1.0f, 0.5f);

	pyramidVertices[0].m_Color = pyramidColor;
	pyramidVertices[0].m_TexCoords = Selene::Vector2(0.0f, 0.0f);
	pyramidVertices[0].m_Coords = Selene::Vector3(0.0f, 1.0f, 0.0f);
	pyramidVertices[0].m_Coords += m_MoonPos;

	pyramidVertices[1].m_Color = pyramidColor;
	pyramidVertices[1].m_TexCoords = Selene::Vector2(0.0f, 1.0f);
	pyramidVertices[1].m_Coords = Selene::Vector3(-1.0f, -1.0f, 0.0f);
	pyramidVertices[1].m_Coords += m_MoonPos;

	pyramidVertices[2].m_Color = pyramidColor;
	pyramidVertices[2].m_TexCoords = Selene::Vector2(1.0f, 1.0f);
	pyramidVertices[2].m_Coords = Selene::Vector3(1.0f, -1.0f, 0.0f);
	pyramidVertices[2].m_Coords += m_MoonPos;


	boxVertices[0].m_Color = boxColor;
	boxVertices[0].m_TexCoords = Selene::Vector2(0.0f, 0.0f);
	boxVertices[0].m_Coords = Selene::Vector3(-1.0f, 1.0f, 0.0f);
	boxVertices[0].m_Coords += m_BoxPos;

	boxVertices[1].m_Color = boxColor;
	boxVertices[1].m_TexCoords = Selene::Vector2(1.0f, 0.0f);
	boxVertices[1].m_Coords = Selene::Vector3(1.0f, 1.0f, 0.0f);
	boxVertices[1].m_Coords += m_BoxPos;

	boxVertices[2].m_Color = boxColor;
	boxVertices[2].m_TexCoords = Selene::Vector2(1.0f, 1.0f);
	boxVertices[2].m_Coords = Selene::Vector3(1.0f, -1.0f, 0.0f);
	boxVertices[2].m_Coords += m_BoxPos;

	boxVertices[3].m_Color = boxColor;
	boxVertices[3].m_TexCoords = Selene::Vector2(0.0f, 1.0f);
	boxVertices[3].m_Coords = Selene::Vector3(-1.0f, -1.0f, 0.0f);
	boxVertices[3].m_Coords += m_BoxPos;

	Selene::Vector3 bottomOffset(0.0f, -0.5f, 0.0f);

	squaresVertices[0].m_Color = squaresColor;
	squaresVertices[0].m_TexCoords = Selene::Vector2(0.0f, 0.0f);
	squaresVertices[0].m_Coords = Selene::Vector3(-5.0f, 0.0f, 5.0f);
	squaresVertices[0].m_Coords += m_SquaresPos + bottomOffset;

	squaresVertices[1].m_Color = squaresColor;
	squaresVertices[1].m_TexCoords = Selene::Vector2(1.0f, 0.0f);
	squaresVertices[1].m_Coords = Selene::Vector3(5.0f, 0.0f, 5.0f);
	squaresVertices[1].m_Coords += m_SquaresPos + bottomOffset;

	squaresVertices[2].m_Color = squaresColor;
	squaresVertices[2].m_TexCoords = Selene::Vector2(1.0f, 1.0f);
	squaresVertices[2].m_Coords = Selene::Vector3(5.0f, 0.0f, -5.0f);
	squaresVertices[2].m_Coords += m_SquaresPos + bottomOffset;

	squaresVertices[3].m_Color = squaresColor;
	squaresVertices[3].m_TexCoords = Selene::Vector2(0.0f, 1.0f);
	squaresVertices[3].m_Coords = Selene::Vector3(-5.0f, 0.0f, -5.0f);
	squaresVertices[3].m_Coords += m_SquaresPos + bottomOffset;

	squaresVertices[4].m_Color = squaresColor;
	squaresVertices[4].m_TexCoords = Selene::Vector2(0.0f, 0.0f);
	squaresVertices[4].m_Coords = Selene::Vector3(-5.0f, 0.0f, -5.0f);
	squaresVertices[4].m_Coords += m_SquaresPos;

	squaresVertices[5].m_Color = squaresColor;
	squaresVertices[5].m_TexCoords = Selene::Vector2(1.0f, 0.0f);
	squaresVertices[5].m_Coords = Selene::Vector3(5.0f, 0.0f, -5.0f);
	squaresVertices[5].m_Coords += m_SquaresPos;

	squaresVertices[6].m_Color = squaresColor;
	squaresVertices[6].m_TexCoords = Selene::Vector2(1.0f, 1.0f);
	squaresVertices[6].m_Coords = Selene::Vector3(5.0f, 10.0f, -5.0f);
	squaresVertices[6].m_Coords += m_SquaresPos;

	squaresVertices[7].m_Color = squaresColor;
	squaresVertices[7].m_TexCoords = Selene::Vector2(0.0f, 1.0f);
	squaresVertices[7].m_Coords = Selene::Vector3(-5.0f, 10.0f, -5.0f);
	squaresVertices[7].m_Coords += m_SquaresPos;

	squaresVertices[8].m_Color = squaresColor;
	squaresVertices[8].m_TexCoords = Selene::Vector2(0.0f, 0.0f);
	squaresVertices[8].m_Coords = Selene::Vector3(-5.0f, 0.0f, -5.0f);
	squaresVertices[8].m_Coords += m_SquaresPos;

	squaresVertices[9].m_Color = squaresColor;
	squaresVertices[9].m_TexCoords = Selene::Vector2(1.0f, 0.0f);
	squaresVertices[9].m_Coords = Selene::Vector3(-5.0f, 10.0f, -5.0f);
	squaresVertices[9].m_Coords += m_SquaresPos;

	squaresVertices[10].m_Color = squaresColor;
	squaresVertices[10].m_TexCoords = Selene::Vector2(1.0f, 1.0f);
	squaresVertices[10].m_Coords = Selene::Vector3(-5.0f, 10.0f, 5.0f);
	squaresVertices[10].m_Coords += m_SquaresPos;

	squaresVertices[11].m_Color = squaresColor;
	squaresVertices[11].m_TexCoords = Selene::Vector2(0.0f, 1.0f);
	squaresVertices[11].m_Coords = Selene::Vector3(-5.0f, 0.0f, 5.0f);
	squaresVertices[11].m_Coords += m_SquaresPos;

	// coordinate axes
	Selene::CGraphics::SVertex xLineVertices[3];
	Selene::CGraphics::SVertex yLineVertices[2];
	Selene::CGraphics::SVertex zLineVertices[2];

	xLineVertices[0].m_Color = Selene::Color(1.0f, 0.0f, 0.0f, 1.0f);
	xLineVertices[0].m_Coords = Selene::Vector3(0.0f, 0.0f, 0.0f);
	xLineVertices[1].m_Color = Selene::Color(1.0f, 0.0f, 0.0f, 1.0f);
	xLineVertices[1].m_Coords = Selene::Vector3(5.0f, 0.0f, 0.0f);
	xLineVertices[2].m_Color = Selene::Color(1.0f, 0.0f, 0.0f, 1.0f);
	xLineVertices[2].m_Coords = Selene::Vector3(0.0f, 0.2f, 0.0f);


	yLineVertices[0].m_Color = Selene::Color(0.0f, 1.0f, 0.0f, 1.0f);
	yLineVertices[0].m_Coords = Selene::Vector3(0.0f, 0.0f, 0.0f);
	yLineVertices[1].m_Color = Selene::Color(0.0f, 1.0f, 0.0f, 1.0f);
	yLineVertices[1].m_Coords = Selene::Vector3(0.0f, 5.0f, 0.0f);

	zLineVertices[0].m_Color = Selene::Color(0.0f, 0.0f, 1.0f, 1.0f);
	zLineVertices[0].m_Coords = Selene::Vector3(0.0f, 0.0f, 0.0f);
	zLineVertices[1].m_Color = Selene::Color(0.0f, 0.0f, 1.0f, 1.0f);
	zLineVertices[1].m_Coords = Selene::Vector3(0.0f, 0.0f, 5.0f);


	//glLoadIdentity();
	//glTranslatef(-1.5f, 0.0f, 0.0f);
	//glRotatef(m_TriangleAngle, 0.0f, 1.0f, 0.0f);

	m_pGraphics->EnableAlphaBlend();
	m_pGraphics->SetAlphaBlendMode(Selene::CGraphics::SBM_SRC_ALPHA,
								   Selene::CGraphics::DBM_ONE_MINUS_SRC_ALPHA);

	m_pGraphics->SetPrimitiveMode(Selene::CGraphics::PM_TRIANGLES);
	//m_pGraphics->SetPrimitiveMode(Selene::CGraphics::PM_LINES);
	m_pGraphics->SetTexture(m_pBoxTex);
	m_pGraphics->StartPrimitives();
	m_pGraphics->Draw(pyramidVertices, 3);
	m_pGraphics->EndPrimitives();

	//glLoadIdentity();
	//glTranslatef(1.5f, 0.0f, 0.0f);
	//glRotatef(m_QuadAngle, 1.0f, 1.0f, 1.0f);

	m_pGraphics->SetPrimitiveMode(Selene::CGraphics::PM_QUADS);
	//m_pGraphics->SetPrimitiveMode(Selene::CGraphics::PM_LINES);
	m_pGraphics->SetTexture(m_pMoonTex);
	m_pGraphics->StartPrimitives();
	m_pGraphics->Draw(boxVertices, 4);
	m_pGraphics->EndPrimitives();

	m_pGraphics->SetPrimitiveMode(Selene::CGraphics::PM_QUADS);
	m_pGraphics->SetTexture(m_pSquaresTex);
	// hack
	glEnable(GL_TEXTURE_2D);
	glBindTexture(GL_TEXTURE_2D, m_pFont->GetTextureID());
	glBegin(Selene::CGraphics::PM_QUADS);
	// end hack
	//m_pGraphics->StartPrimitives();
	m_pGraphics->Draw(squaresVertices, 12);
	m_pGraphics->EndPrimitives();

	//m_pGraphics->SetPrimitiveMode(Selene::CGraphics::PM_TRIANGLES);
	//m_pGraphics->SetTexture(NULL);
	//m_pGraphics->StartPrimitives();
	//m_pGraphics->Draw(xLineVertices, 3);
	//m_pGraphics->EndPrimitives();


	// object rotation test
	Selene::Vector3 rightDir(1.0f, 0.0f, 0.0f);
	Selene::Vector3 upDir(0.0f, 1.0f, 0.0f);
	Selene::Vector3 forwardDir(0.0f, 0.0f, 1.0f);

	Selene::Vector3 lookAt(0.0f, 0.0f, 1.0f);
	Selene::Vector3 pos(0.0f, 0.0f, 0.0f);
	Selene::Vector3 up(0.0f, 1.0f, 0.0f);

	//*
	lookAt = Selene::Vector3(0.0f, 0.0, 0.0f);
	pos = Selene::Vector3(3.0f, 0.0, 4.0f);
	up = Selene::Vector3(0.0f, 1.0, 0.0f);
	//*/

	forwardDir = lookAt - pos;
	forwardDir *= -1.0f;
	forwardDir.Normalize();
	rightDir = up.Cross(forwardDir);
	rightDir.Normalize();
	upDir = forwardDir.Cross(rightDir);
	upDir.Normalize();

	rightDir.Normalize();
	upDir.Normalize();
	forwardDir.Normalize();

	Selene::Matrix4 rotationMatrix;
	//rotationMatrix.m[0][0] = rightDir.m_X;
	//rotationMatrix.m[0][1] = rightDir.m_Y;
	//rotationMatrix.m[0][2] = rightDir.m_Z;
	//rotationMatrix.m[0][3] = 0.0f;

	//rotationMatrix.m[1][0] = upDir.m_X;
	//rotationMatrix.m[1][1] = upDir.m_Y;
	//rotationMatrix.m[1][2] = upDir.m_Z;
	//rotationMatrix.m[1][3] = 0.0f;

	//rotationMatrix.m[2][0] = forwardDir.m_X;
	//rotationMatrix.m[2][1] = forwardDir.m_Y;
	//rotationMatrix.m[2][2] = forwardDir.m_Z;
	//rotationMatrix.m[2][3] = 0.0f;

	//rotationMatrix.m[3][0] = 0.0f;
	//rotationMatrix.m[3][1] = 0.0f;
	//rotationMatrix.m[3][2] = 0.0f;
	//rotationMatrix.m[3][3] = 1.0f;

	rotationMatrix.m[0][0] = rightDir.m_X;
	rotationMatrix.m[0][1] = upDir.m_X;
	rotationMatrix.m[0][2] = forwardDir.m_X;
	rotationMatrix.m[0][3] = 0.0f;

	rotationMatrix.m[1][0] = rightDir.m_Y;
	rotationMatrix.m[1][1] = upDir.m_Y;
	rotationMatrix.m[1][2] = forwardDir.m_Y;
	rotationMatrix.m[1][3] = 0.0f;

	rotationMatrix.m[2][0] = rightDir.m_Z;
	rotationMatrix.m[2][1] = upDir.m_Z;
	rotationMatrix.m[2][2] = forwardDir.m_Z;
	rotationMatrix.m[2][3] = 0.0f;

	rotationMatrix.m[3][0] = 0.0f;
	rotationMatrix.m[3][1] = 0.0f;
	rotationMatrix.m[3][2] = 0.0f;
	rotationMatrix.m[3][3] = 1.0f;

	//rotationMatrix.Transpose();

	//*
	xLineVertices[0].m_Coords *= rotationMatrix;
	xLineVertices[1].m_Coords *= rotationMatrix;
	yLineVertices[0].m_Coords *= rotationMatrix;
	yLineVertices[1].m_Coords *= rotationMatrix;
	zLineVertices[0].m_Coords *= rotationMatrix;
	zLineVertices[1].m_Coords *= rotationMatrix;

	/*/
	Selene::CCamera* pCamera = m_pGraphics->GetActiveCamera();
	float dist = 3.0f;
	xLineVertices[1].m_Coords = pCamera->GetRightDir() * dist;
	yLineVertices[1].m_Coords = pCamera->GetUpDir() * dist;
	zLineVertices[1].m_Coords = pCamera->GetLookDir() * dist;
	//*/

	m_pGraphics->SetPrimitiveMode(Selene::CGraphics::PM_LINES);
	m_pGraphics->SetTexture(NULL);
	m_pGraphics->StartPrimitives();
	m_pGraphics->Draw(xLineVertices, 2);
	m_pGraphics->Draw(yLineVertices, 2);
	m_pGraphics->Draw(zLineVertices, 2);
	m_pGraphics->EndPrimitives();


	CSceneNode::Render();
}