Jump to content

  • Log In with Google      Sign In   
  • Create Account


ThePointingMan

Member Since 09 Nov 2010
Offline Last Active Jul 24 2014 12:43 PM
-----

Posts I've Made

In Topic: Smoothing out the ray tracing of a surface on a curve

16 October 2013 - 05:14 PM

For the hover mechanic, I shoot a raycast straight down from the center of the ship, if the distance from the start of the ray to where the ray hits is shorter then a specific amount it moves it back up to the minimum distance. As for the physics engine, It seems as though Unity uses the PhysX engine. Unfortunately I can't give you specific pieces of code right now as I am not at my house, but when I return there I will put up some more info on how I am doing everything. I think this first suggestion AllEightUp gave will probably do the trick though! Thanks very much for your input. I'm also thinking of doing something like what rumblesushi suggested, I'm thinking having a raycast at the middle, nose, and back, all checking would probably be best.


In Topic: Depth Transparecy issues.

19 June 2013 - 03:35 AM

So I literally need to just make sure that when something is rendered it is rendered before everything that it needs to cover?


In Topic: Rotation in 3D

15 June 2013 - 02:30 PM

Inverting it seems to have fixed everything! Thanks so much.


In Topic: Rotation in 3D

12 June 2013 - 07:52 PM

In the long run I did end up going for the method you had suggested, but things aren't quite working correctly, I can't pinpoint what the problem is though. It appears as though the camera is rotating around the origin point, but I am fairly certain it should be translating and rotating locally with this code. I'm also not sure whether I set up my matrix properly, I have never manually set the values in a matrix before and I couldn't find the order in which it needs to be filled on msdn.

 

Edit:

{

 I have this feeling it is related to this line here node->Position->Position += (node->Position->Forward * node->Velocity->VelocityPos.z); My guess is that this is permenantly multiplying forward by the distance, while it only needs to be multiplied for this assignment and then go back to not being multiplied.
}

 

Here's what my camera matrix looks like.

//Rotate Dem vectors
				D3DXMATRIX yaw; 
				D3DXMatrixIdentity(&yaw);
				//Programming when you are tired is a bad idea, very important
				D3DXMatrixRotationAxis(&yaw,&ActiveCamera->Up,node->Position->Angle.y*(M_PI/180));

				D3DXVec3TransformCoord(&ActiveCamera->Forward,&ActiveCamera->Forward,&yaw);
				D3DXVec3TransformCoord(&ActiveCamera->Right,&ActiveCamera->Right,&yaw);
				// set the view transform

				// set the projection transform
				node->Camera->mCamera(0,0) = ActiveCamera->Right.x;
				node->Camera->mCamera(1,0) = ActiveCamera->Up.x;
				node->Camera->mCamera(2,0) = ActiveCamera->Forward.x;
				node->Camera->mCamera(3,0) = ActiveCamera->Position.x;
				
				node->Camera->mCamera(0,1) = ActiveCamera->Right.y;
				node->Camera->mCamera(1,1) = ActiveCamera->Up.y;
				node->Camera->mCamera(2,1) = ActiveCamera->Forward.y;
				node->Camera->mCamera(3,1) = ActiveCamera->Position.y;

				node->Camera->mCamera(0,2) = ActiveCamera->Right.z;
				node->Camera->mCamera(1,2) = ActiveCamera->Up.z;
				node->Camera->mCamera(2,2) = ActiveCamera->Forward.z;
				node->Camera->mCamera(3,2) = ActiveCamera->Position.z;




				D3DXMatrixPerspectiveFovLH(&node->Camera->mLense,
										   D3DXToRadian(45),
										   (FLOAT)600 / (FLOAT)600,
										   1.0f,    // the near view-plane
										   1000000.0f);    // the far view-plane
	
			

//This is what the position component looks like

#pragma once
#include "Component.h"
#include "Directx.h"
class PositionComponent : public Component
{
public:
	PositionComponent(unsigned int ID) : 
	  Component(ID)
		  ,Position(0,0,0)
		  ,Forward(0,0,1)
		  ,Up(0,-1,0)
		  ,Right(1,0,0)
		  ,Angle(0,0,0)
	{
	}
	  //I realize now that it would have been better to have made a forward vector, up vector and right vector, thus I will be modifying how everything is moved later, but again I'm rushsian here!
	  //LOL JK QUATERNIANS ALL THE WAY! I don't want none of this Gimball lock crap! TIME TO REWRITE EVERYTHING!
	  ///I dont think I am ready for quaternians :/
	D3DXVECTOR3 Angle;
	D3DXVECTOR3 Position;
	D3DXVECTOR3 Forward;
	D3DXVECTOR3 Up;
	D3DXVECTOR3 Right;

};

This is where every object gets moved

for(auto index = targets.begin(); index != targets.end(); index++)
{
		auto node = static_cast<MoveNode*>(*index);

		node->Position->Position += (node->Position->Forward * node->Velocity->VelocityPos.z);

And here is where the world and view matrix come in

{
		auto node= static_cast<RenderQuadNode*>(*index);
		//Deal with the matrices
		D3DXMATRIX mTranslate;
		D3DXMATRIX mRotateX;
		D3DXMATRIX mRotatey;
		D3DXMATRIX mRotatez;
		D3DXMATRIX mScale; //MAYBEH LAAAAATA
		D3DXMATRIX mWorld;
		//Set All Matrices to a neutral state
		D3DXMatrixIdentity(& mWorld);
		D3DXMatrixIdentity(&mTranslate);
		D3DXMatrixIdentity(& mRotateX);
		D3DXMatrixIdentity(& mRotatey);
		D3DXMatrixIdentity(& mRotatez);
		D3DXMatrixIdentity(& mScale);
		//MoveEverythaaaang
		D3DXMatrixTranslation(&mTranslate,node->Position->Position.x,node->Position->Position.y,node->Position->Position.z);
		//D3DXMatrixRotationX(&mRotateX,node->Position->Angle.x*(M_PI/180));
		
		//Update the world
		mWorld = mRotateX * mRotatey * mRotatez * mTranslate;
		// select which vertex format we are using
		d3d->d3ddev->SetFVF(d3d->FVF);


		//set up camera
		d3d->d3ddev->SetTransform(D3DTS_VIEW, &node->Camera->mCamera);
		
		d3d->d3ddev->SetTransform(D3DTS_PROJECTION, &node->Camera->mLense);


In Topic: Rotation in 3D

10 June 2013 - 06:42 PM

Alright, Thank you all so much! It sounds like Quaternians are the way I will be going, reading up a bit about them, the cpu appears to be able to do quaternian multiplication faster. I've got to admit, I don't quite understand what this ;D3DXVec3Cross and D3DXVec3Normalize function do, as well as, Rotating objects locally. If anyone would like to give some input on any of these things I'd love it, and I will be heading over to msdn! Whenever I try and rotate something that is not the camera it ends up orbiting the center point as well, perhaps when I get the camera fully functional this will become clear though..

Edit: So as far as I can tell, normalizing a vector changes all of the vectors components to their equivalent if the length between the origin point and the vectors current position was 1.

Crossing them treats vec1 and vec 2 as an x,y and gives you a z with a scalar value that gets bigger/smaller depending on the size of the angle between the to.

 

Edit2:Well I am kind of being rushed atm, so I might just have to come back to the quaternian method, as for the most part I have a better understanding of the vector method.


PARTNERS