Jump to content

  • Log In with Google      Sign In   
  • Create Account

Enerjak

Member Since 08 Nov 2007
Offline Last Active Apr 18 2016 09:38 PM

Topics I've Started

Direct3D9 Debugging on windows 10.

17 April 2016 - 12:04 AM

Okay, do I have Graphics tools installed: 

 

1453bc6d0b.png

 

I'm trying to use Direct3D9's debugging layer. I've set it up in the control panel as you can see:

 

d469285ec1.png

 

And I have Debugging info enabled in Visual Studio:

 

f53a77a583.png

 

How do I fix this issue? Cause even though that is all set up, nothing gets written to the output window.

 


Need help with an error message virtual studio is giving me.

13 December 2015 - 07:16 PM

I'm not sure if this is the right board to post this in but here goes. I recently got this book from my library: http://www.amazon.com/Real-Time-Rendering-DirectX-HLSL-Programming/dp/0321962729 . I downloaded the code from the companion website, tried to run the demos and got this:

 

7e947aba00.png

 

I attempted to find out what's wrong by doing this:

 

beec1824c3.png

 

But when I try to compile, I get these errors right here: 

2>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4460,5): error MSB3491: Could not write lines to file "Debug\HelloShadersDemo.vcxproj.FileListAbsolute.txt". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.
3>C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(4460,5): error MSB3491: Could not write lines to file "Debug\HelloStructsDemo.vcxproj.FileListAbsolute.txt". The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

I'm not sure what to do. Also, how do I turn those blue things off? those things by the const, sttd, and strs? Thanks in advance.

 


Can someome please tell me why this crashes?

10 August 2015 - 08:02 PM

I want to clear some space from my hard drive. I have a few mp4s I downloaded from youtube and I just don't have time to watch them all. I want to delete them to make space on my hard drive but I don't want to lose them as I might not remember the title of a video of I want to go find it again. So I made this program to find all the files with .mp4 in a directory and write the file names to file so I can delete the .mp4s, thus freeing space in my computer. Problem is....the application crashes with this error: 

 

4f39a60f73.png

 

Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace FileData
{
    class Program
    {
        static void Main(string[] args)
        {
            string fileName = "video_filenames.txt";
            DirectoryInfo di = new DirectoryInfo("C:\\Users\\admin\\Documents");

            if (di != null)
            {
                Console.Write("Directory exists");
                FileInfo[] fi = di.GetFiles("*.mp4");
                string str = "";
                if (fi != null)
                {
                    File.Create(fileName);

                    if (File.Exists(fileName))
                    {
                        foreach (FileInfo file in fi)
                        {
                            str += file.FullName;
                        }
                        
                    }
                    File.WriteAllText(fileName, str + "\n");
                }
            }
        }
    }
}

What should I do?

Some errors in my vector3 class that seem kind of odd.

30 April 2015 - 08:37 PM

I have a vector3 class, and overloaded the "+" operator and the "-" operator but for some reason, when I do this, it causes an error.

Here is my header for the vector3 class.

 

vector3.h:

#pragma once

#include "..//DragPrerequisities.h"

namespace DragonFlyEngine
{
	namespace DragMath
	{
		class Vector3
		{
		protected:
			Real m_xVal;
			Real m_yVal;
			Real m_zVal;
		public:
			Vector3();

			Vector3(Real x,
				Real y,
				Real z);

			Vector3(const Vector3& vec);

			~Vector3(){}

			void setVector(const Vector3 & vec);

			void setVector(Real x, Real y,Real z);

			void setX(Real x);

			void setY(Real y);

			void setZ(Real z);

			void zeroVector();

			Real getX() const;

			Real getY() const;

			Real getZ() const;

			Real getMagnitude() const;

			Real getLength() const;

			Real getDistance(Real x, Real y, Real z);

			Real getDistance(const Vector3 & vec);

			Real getDotProduct(Real x, Real y, Real z);
			
			Real getDotProduct(const Vector3 & vec);

			Vector3 crossProduct(const Vector3 & otherVec);

			Vector3 crossProduct(Real x, Real y, Real z);

			Vector3 getNormal() const;

			// operators.
			// + operator.
			Vector3 operator + (const Vector3 & vec);

			// - operator.
			Vector3 operator - (const Vector3 & vec);

			// * operator.
			Vector3 operator * (const Vector3 & vec);

			// * operator (for Reals).
			Vector3 operator * (Real scalar);

			// / operator.
			Vector3 operator / (const Vector3 & vec);

			// == operator.
			bool operator == (const Vector3 & vec);

			// != operator.
			bool operator != (const Vector3 & vec);

			// > operator.
			bool operator > (const Vector3 & vec);

			// < operator.
			bool operator < (const Vector3 & vec);

			// >= operator.
			bool operator >= (const Vector3 & vec);

			// <= operator.
			bool operator <= (const Vector3 & vec);

			friend Vector3 operator * (const Vector3 & vec, const Real val);

			friend Vector3 operator / (const Vector3 & vec, const Real val);

		};
	}
}

here's the .cpp file.

 

Vector3.cpp

#include "DragVector3.h"

namespace DragonFlyEngine
{
	namespace DragMath
	{
		Vector3::Vector3()
		{
			m_xVal = 0.0f;
			m_yVal = 0.0f;
		}
		Vector3::Vector3(Real x, Real y,Real z)
		{
			m_xVal = x;
			m_yVal = y;
			m_zVal = z;
		}

		Vector3::Vector3(const Vector3& vec)
		{
			*this = vec;
		}

		void Vector3::zeroVector()
		{
			this->setX(0.0f);
			this->setY(0.0f);
			this->setZ(0.0f);
		}
		void Vector3::setVector(Real x, Real y,Real z)
		{
			this->setX(x);
			this->setY(y);
			this->setZ(z);
		}

		void Vector3::setX(Real x)
		{
			this->m_xVal = x;
		}

		void Vector3::setY(Real y)
		{
			m_yVal = y;
		}

		void Vector3::setZ(Real z)
		{
			m_zVal = z;
		}
		void Vector3::setVector(const Vector3 & vec)
		{
			this->setVector(vec.getX(), vec.getY(),vec.getZ());
		}

		Real Vector3::getX() const
		{
			return m_xVal;
		}

		Real Vector3::getY() const
		{
			return m_yVal;
		}

		Real Vector3::getZ() const
		{
			return m_zVal;
		}
		Real Vector3::getMagnitude() const
		{
			Real xMag = static_cast<Real>(powf(m_xVal, 2));
			Real yMag = static_cast<Real>(powf(m_yVal, 2));
			Real zMag = static_cast<Real>(powf(m_zVal, 2));
			return static_cast<Real>(sqrtf(xMag + yMag + zMag));
		}

		Real Vector3::getLength() const
		{
			return this->getMagnitude();
		}

		Real Vector3::getDistance(Real x, Real y, Real z)
		{
			Real xDist = static_cast<Real>(powf((m_xVal - x), 2));
			Real yDist = static_cast<Real>(powf((m_yVal - y), 2));
			Real zDist = static_cast<Real>(powf((m_zVal - z), 2));
			return static_cast<Real>(sqrtf(xDist + yDist + zDist));
		}

		Real Vector3::getDistance(const Vector3 & vec)
		{
			return this->getDistance(vec.getX(), vec.getY(),vec.getZ());
		}

		Real Vector3::getDotProduct(Real x, Real y, Real z)
		{
			// 		Real magVec = sqrtf(powf(x, 2) + powf(y, 2));
			// 		Real ang = acosf((m_xVal - x) / (m_yVal - y));
			// 		return magVec * this->getMagnitude() * cosf(ang);
			return m_xVal * x + m_yVal * y + m_zVal * z;
		}

		Real Vector3::getDotProduct(const Vector3 & vec)
		{
			return getDotProduct(vec.getX(),
				vec.getY(),
				vec.getZ());
		}

		Vector3 Vector3::getNormal() const
		{
			Real length = 1 / this->getMagnitude();
			assert(length != 0);

			Real normX = m_xVal * length;
			Real normY = m_yVal * length;
			Real normZ = m_zVal * length;
			return Vector3(
				normX,
				normY,
				normZ);
		}

		Vector3 Vector3::crossProduct(Real x, Real y, Real z)
		{
			Real crossX = (m_yVal * z) - (m_zVal * y);
			Real crossY = (m_zVal * x) - (m_zVal * z);
			Real crossZ = (m_xVal * y) - (m_yVal * x);

			return Vector3(crossX, crossY, crossZ);
		}

		Vector3 Vector3::crossProduct(const Vector3 & otherVec)
		{
			return crossProduct(
				otherVec.getX(),
				otherVec.getY(),
				otherVec.getZ());
		}
		// operator overloading.
		Vector3 Vector3::operator + (const Vector3 & vec)
		{
			Vector3 temp;
			temp.m_xVal = m_xVal + vec.m_xVal;
			temp.m_yVal = m_yVal + vec.m_yVal;
			temp.m_zVal = m_zVal + vec.m_zVal;

			return temp;
		}

		Vector3 Vector3::operator - (const Vector3 & vec)
		{
			Vector3 temp;
			temp.m_xVal = m_xVal - vec.m_xVal;
			temp.m_yVal = m_yVal - vec.m_yVal;
			temp.m_zVal = m_zVal - vec.m_zVal;
			return temp;
		}

		Vector3 Vector3::operator * (const Vector3 & vec)
		{
			Vector3 temp;
			temp.m_xVal = m_xVal * vec.m_xVal;
			temp.m_yVal = m_yVal * vec.m_yVal;
			temp.m_zVal = m_zVal * vec.m_zVal;

			return temp;
		}

		Vector3 Vector3::operator* (Real scalar)
		{
			Vector3 temp;
			temp.m_xVal = m_xVal * scalar;
			temp.m_yVal = m_yVal * scalar;
			temp.m_zVal = m_zVal * scalar;
			return temp;
		}
		Vector3 Vector3::operator / (const Vector3 & vec)
		{
			Real valX;
			Real valY;
			Real valZ;
			if (vec.m_xVal == 0 && vec.m_yVal == 0 && vec.m_zVal)
			{
				valX = 0;
				valY = 0;
				valZ = 0;
			}
			else
			{
				valX = 1.0f / vec.m_xVal;
				valY = 1.0f / vec.m_yVal;
				valZ = 1.0f / vec.m_zVal; 
			}

			Vector3 temp;
			temp.m_xVal = m_xVal * valX;
			temp.m_yVal = m_yVal * valY;
			temp.m_zVal = m_zVal * valZ;

			return temp;
		}

		bool Vector3::operator != (const Vector3 & vec)
		{
			return (
				m_xVal != vec.m_xVal || 
				m_yVal != vec.m_yVal ||
				m_zVal != vec.m_zVal);
		}

		bool Vector3::operator == (const Vector3 & vec)
		{	
			return (
				m_xVal == vec.m_xVal &&
				m_yVal == vec.m_yVal &&
				m_zVal == vec.m_zVal
				);
		}

		bool Vector3::operator > (const Vector3 & vec)
		{
			return (
				m_xVal > vec.m_xVal && 
				m_yVal > vec.m_yVal &&
				m_zVal > vec.m_zVal);
		}

		bool Vector3::operator < (const Vector3 & vec)
		{
			return (
				m_xVal < vec.m_xVal && 
				m_yVal < vec.m_yVal &&
				m_zVal < vec.m_zVal);
		}

		bool Vector3::operator <= (const Vector3 & vec)
		{
			return (
				m_xVal <= vec.m_xVal && 
				m_yVal <= vec.m_yVal &&
				m_zVal <= vec.m_zVal);
		}

		bool Vector3::operator >= (const Vector3 & vec)
		{
			return (
				m_xVal >= vec.m_xVal && 
				m_yVal >= vec.m_yVal &&
				m_zVal >= vec.m_zVal);
		}
	}
}

And this is how I use the operator:

 

Using the "-" operator.

Vector3 AxisAlignedBoundingBox::getSize() const
	{
		return (m_max - m_min);
	}

Using the "+" operator.

Vector3 AxisAlignedBoundingBox::getCenter() const
	{
		return (m_max + m_min) *0.5f;
	}

And here are the errors visual C++ is giving me:

1>c:\users\admin\documents\visual studio 2013\projects\dragonflyengine\dragengine\src\dragaxisalignedboundingbox.cpp(55): error C2678: binary '-' : no operator found which takes a left-hand operand of type 'const DragonFlyEngine::DragMath::Vector3' (or there is no acceptable conversion)
1>          c:\users\admin\documents\visual studio 2013\projects\dragonflyengine\dragengine\inc\math\dragvector3.h(67): could be 'DragonFlyEngine::DragMath::Vector3 DragonFlyEngine::DragMath::Vector3::operator -(const DragonFlyEngine::DragMath::Vector3 &)'
1>          while trying to match the argument list '(const DragonFlyEngine::DragMath::Vector3, const DragonFlyEngine::DragMath::Vector3)'
1>c:\users\admin\documents\visual studio 2013\projects\dragonflyengine\dragengine\src\dragaxisalignedboundingbox.cpp(75): error C2678: binary '+' : no operator found which takes a left-hand operand of type 'const DragonFlyEngine::DragMath::Vector3' (or there is no acceptable conversion)
1>          c:\users\admin\documents\visual studio 2013\projects\dragonflyengine\dragengine\inc\math\dragvector3.h(64): could be 'DragonFlyEngine::DragMath::Vector3 DragonFlyEngine::DragMath::Vector3::operator +(const DragonFlyEngine::DragMath::Vector3 &)'
1>          while trying to match the argument list '(const DragonFlyEngine::DragMath::Vector3, const DragonFlyEngine::DragMath::Vector3)'
========== Build: 0 succeeded, 1 failed, 4 up-to-date, 0 skipped ==========

Look forward to some kind of response. Thank you.


Help with my view-matrix and perspective-matrix calculations.

10 April 2015 - 05:10 PM

As the title says, I need some help with calculating the view matrix and the perspective matrix. here are my matrices.

 

the view matrix: 

	Matrix4x4 Matrix4x4::makeViewMatrixLH(const Vector3 & eye, const Vector3 & at, const Vector3 & up)
	{	
		Matrix4x4 viewMatrix;
		Vector3 norm;
		norm.setX(at.getX() - eye.getX());
		norm.setY(at.getY() - eye.getY());
		norm.setZ(at.getZ() - eye.getZ());

		Vector3 zAxis = MathUtil::normalize(norm);
		Vector3 xAxis = MathUtil::normalize(MathUtil::crossProduct(up, zAxis));
		Vector3 yAxis = MathUtil::crossProduct(zAxis, xAxis);

		viewMatrix.setMatrix(xAxis.getX(), yAxis.getX(), zAxis.getX(), 0,
			xAxis.getY(), yAxis.getY(), zAxis.getZ(), 0,
			zAxis.getZ(), yAxis.getZ(), zAxis.getZ(), 0,
			-MathUtil::dotProduct(xAxis, eye), -MathUtil::dotProduct(yAxis, eye), -MathUtil::dotProduct(zAxis, eye), 1);

		return viewMatrix;
	}

projection-perspective matrix:
 

Matrix4x4 Matrix4x4::makePerspectiveProjectionMatrix(const Real near_plane, const Real far_plane, const Real fov_horiz, const Real fov_vert)
	{
		Matrix4x4 pers;
		Matrix4x4 actPers = pers.identity();
		Real w, h, q;
		w = (Real)1 / tanf(fov_horiz/2.0f);
		h = (Real)1 / tanf(fov_vert/2.0f);
		q = far_plane / (far_plane - near_plane); 
		
		actPers.setValue(0, 0, w);
		actPers.setValue(1, 1, h);
		actPers.setValue(2, 2,q);
		actPers.setValue(3, 2,-q*near_plane);
		actPers.setValue(2, 3, 1.0f);

		return actPers;
	}

I don't really understand the perspective-projection matrix as the D3D matrix function only needs 5 variables, the out-matrix, the field-of-view and the near and far values. This function I got from the Direct3D9 documentation doesn't seem account for the aspect ratio. Maybe it does and I'm not understanding? I wish there was a clear cut way for me to understand calculating my own matrices for the view and projection-perspective. Any advice you can give, please do.

 


PARTNERS