Jump to content

  • Log In with Google      Sign In   
  • Create Account

KamRandle

Member Since 14 Aug 2012
Offline Last Active Nov 15 2014 04:15 PM

Topics I've Started

Calculating Right Vector from Two Points

22 October 2014 - 08:31 PM

Original Thread from Unreal Engine Forums

 

Hello all! I am working on a water/river mode plugin for the Unreal Engine 4.  It seems to be coming along alright.  I have the base features working except for one partially works.  And that one is moving a spline to adjust the path.  

spline1.png?dl=1

spline2.png?dl=1

 

The problem is that as I extend move it more to the right or left, it gets weird:

spline3.png?dl=1

 

I already know what the problem is:

FVector extendDir = FVector(0, width, 0);

one.Vertex0.Position = v0;
one.Vertex1.Position = v0 + extendDir;
one.Vertex2.Position = v2;

two.Vertex0.Position = one.Vertex2.Position + extendDir;
two.Vertex1.Position = one.Vertex2.Position;
two.Vertex2.Position = one.Vertex1.Position;

It is because I'm extending it on the Y-axis. I did it intentionally for testing purposes. Now that I know that the mesh renders alright, the next thing on my list is to get the right vector of a segment on the spline component so I can extend the mesh in that direction. That way, it will never get squished like that and the width of the mesh will stay constant throughout the whole thing. How would I do this? Is it possible? I've been trying to do this all day. And I cannot use the point's rotation because it has not been rotated, I just moved it. Is there a way to calculate this using the first point and connected point or something? Thanks! smile.png

 


Supporting both DirectX & OpenGL

01 January 2014 - 12:17 PM

Hello!  I re-writing my game engine from scratch and was trying to decide whether I should support DirectX & OpenGL or just DirectX?  I understand that OpenGL is cross-platform while DirectX is restricted to Windows & the Xbox.  I also have a couple more questions:

 

  1. I am developing on Windows using Visual Studio 2013 Ultimate.  If I were to implement OpenGL,  how would I build for different platforms? Example: If I wanted to build on maybe, Linux or Mac.  Would I have to build my project on that operating system?
  2. If I do develop for both API's, how should I setup my project? Should I create two separate projects? Or keep them both separated in one project using enums, and interfaces? Example: 
    enum NXAPIChoice
    {
        NXAPI_DirectX,
        NXAPI_OpenGL,
    }
    
    NXAPIChoice NXGame::DefaultAPI = NXAPIChoice::NXAPI_DirectX;
    
    void NXGame::FinalInitialize()
    {
        int sWidth = 0, sHeight = 0;
    			InitializeWindows(sWidth, sHeight);
    			SetupGPU(sWidth, sHeight);
    
    			//TODO: [HIGH PRIORITY] Initialize Input
    			//TODO: [HIGH PRIORITY] Initialize Audio
    
    			Initialize();
    
    			//TODO: [HIGH PRIORITY] Create & Start GameTime
    }
    
    void NXGame::SetupGPU(int width, int height)
    {
        //stuff...
        NXGPU::Initialize(DefaultAPI, width, height, ...other);
    }
    
    void NXGPU::Initialize(NXAPIChoice choice, int width, int height, ...other)
    {
        if (choice == NXAPIChoice::NXAPI_DirectX)
           InitializeDirect3D(width, height, D3D_FEATURE_LEVEL_11_0, ...other);
        else
           InitializeOpenGL(width, height, GL_VERSION, ...other)
    }
    

    Also if I were to develop for both, and I do have to compile my code on other platforms (linux or mac), will I be able to skip my DirectX code (assuming it would cause errors because DX is not available) and just compile GL code? Is it even worth adding support for both? Thanks! smile.png

[EDIT: Or perhaps, shall I finish my engine with DirectX first (creating empty methods for GL in the process) and just start working on GL support (fill in the empty methods) after DirectX is fully implemented?]


Cannot override virtual methods

31 December 2013 - 09:11 PM

Hello! I have two classes: NXGameObject & NXSceneObject.

class NXGameObject
		{
			public:
				LPCWSTR Name;
				bool RenderToTexture = true;
				bool IsActive = false;
				virtual void NEXENGINE_API Initialize() = 0;
				virtual void NEXENGINE_API Update(NXGameTime*) = 0;
				virtual void NEXENGINE_API Render(NXGameTime*) = 0;
				virtual void NEXENGINE_API RenderDeferred(NXGameTime*){}
				virtual void NEXENGINE_API Dispose() = 0;
		};
	class NXSceneObject : public NXGameObject
		{
			public:
				void Initialize(){}
				void Render(NXGameTime* gameTime){}

				virtual void ReadData(NXBinaryReader* reader){}
				virtual void Update(NXGameTime* gameTime){}
				virtual void Render(NXCamera3D* camera, NXGameTime* gameTime){}
				virtual void Dispose(){}

				NXGameObject* ParentScene;
				map<string, NXSceneObject*> Chlidren;

				bool IsVisible;

				XMMATRIX WorldMatrix() { return XMMatrixScaling(Size.x, Size.y, Size.z) * XMMatrixTranslation(Position.x, Position.y, Position.z) * XMMatrixRotationRollPitchYaw(Rotation.x, Rotation.y, Rotation.z); }
				XMFLOAT3 Position;
			    XMFLOAT3 Rotation;
				XMFLOAT3 Size;
				NXBoundingBox Bounds;

				NXSceneObject(){ }
				NXSceneObject(NXBinaryReader* reader)
				{ //Read Main Data
					IsVisible = reader->ReadBoolean();
					Position = reader->ReadVector3(false);
					Rotation = reader->ReadVector3(false);
					Size = reader->ReadVector3(false);
					Bounds = reader->ReadBoundingBox(false);
//Call the type of scene object being created's ReadData method and Read Custom Object Specific Data
					ReadData(reader);
				}
		};

Now I have a bunch of different classes (player markers, enemy spawn points, etc.) derived from NXSceneObject.  Each class has overrides ReadData(NXBinaryReader*).  Here's an example.

class NXMarker : virtual public NXSceneObject
		{
			public:
				NXMarker(NXBinaryReader* reader) : NXSceneObject(reader)
				{
				}
		};

		class NXPlayerStartMarker : public NXMarker
		{
			public:
				float Health;
				float MoveSpeed;
				bool Realistic;

				NXPlayerStartMarker(NXBinaryReader* reader) : NXMarker(reader)
				{
				}

				void ReadData(NXBinaryReader* reader) override
				{
					Realistic = reader->ReadBoolean();
					Health = reader->ReadFloat();
					MoveSpeed = reader->ReadFloat();
				}
		};

My problem is that, no matter what I try, the classes don't seem to be overriding ReadData and the ReadData method in the created class is not called.  I put breakpoints inside the PlayerStartMarker's ReadData method and it is not called.   I am trying to override the method so that after the main data is read in the NXSceneObject constructed, it'll call whatever type of class is being created's ReadData method.  Sorry if I wasn't clear.  Any help? Thanks! :)


What do you want in a Next Generation Console?

15 March 2013 - 04:57 PM

Hello Fellow Developers!

 

I am working on a product and was wondering what would you like to see in a next generation console?

 

Thanks,

Kammeron Randle


Creating an Open World

26 August 2012 - 12:34 PM

Hello!

I'm developing an open world game and was wondering how I should make the world. Should I make it through code or model the world in 3ds Max? How do developers create their game's world?

Thanks!

PARTNERS