• Create Account

KamRandle

Member Since 14 Aug 2012
Offline Last Active May 25 2015 01:05 PM

Rotating to Match The Rotation Of Something Else

06 May 2015 - 08:59 PM

Hello all!  I am working on a project in Unreal Engine 4 and I am not exactly sure if I am calculating this correctly.  Here is some information on what I am trying to do.  Read all the way down to "What needs to be done?" please.  I would like to tackle one problem at time.  The problem that I am trying to solve right now is rotating a module and moving it so that the attachment points line up correctly and the rotations are the same.  This is what I currently have:

```float ZRotation = FMath::RadiansToDegrees(acosf(FVector::DotProduct(-ThisAttachmentPoint->GetForwardVector().GetSafeNormal(), OtherAttachmentPoint->GetForwardVector().GetSafeNormal()))) * -FMath::Sign(ThisAttachmentPoint->GetForwardVector().X);

```

The way I am moving the object to have the attachment points meet works, but the rotation is proving to be really tricky for me.  I thought that I'd have the object rotate first, then move to line up but while this works some ways, other ways it doesn't.  I thought the process would be:

1. Find the yaw angle between the attachment point's rotation and the object's rotation.
2. Add that result to the rotation.
3. Move the object so that both attachment points line up.

I can't seem to calculate the 'ZRotation' correctly so that it lines up no matter how I rotate the main module that the new module will attach to.  I've also tried this:

```float ZRotation = FMath::RadiansToDegrees(FMath::GetAzimuthAndElevation(OtherAttachmentPoint->GetForwardVector().GetSafeNormal(), FVector::ForwardVector, FVector::ZeroVector, FVector::ZeroVector).X -
FMath::GetAzimuthAndElevation(-ThisAttachmentPoint->GetForwardVector().GetSafeNormal(), FVector::ForwardVector, FVector::ZeroVector, FVector::ZeroVector).X);
```

Any help? Thanks!

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.

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

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!

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!

[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 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(){ }
//Call the type of scene object being created's ReadData method and Read Custom Object Specific Data
}
};
```

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:
{
}
};

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

{
}

{
}
};
```

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

PARTNERS