Jump to content
OGXbox.com

Meerjel01

Members
  • Posts

    211
  • Joined

  • Last visited

  • Days Won

    7

Posts posted by Meerjel01

  1. 1 hour ago, corona2222 said:

    something that helped me understand what was happening to debug and optimize my pathfinding (not A* in my games case) was to render the path points being explored / found in different colours so I could visually see the path, and changed my 'GetPath()' code to be re-entrant so the path is built over a period of time so that I could see the path gradually getting built and the choices it was making and where the (complicated set of rules )code was going wrong. this may help.

    Thanks for the info. I believe it doesn't work correctly cause of the lack of nodes but I will make a line rendering system for the engine anyway. Also need to make a node-grid file generator somehow.

  2. Alright I've finished some code.

    struct st_path
    {
    	int numCorners;
    	D3DXVECTOR3* corners;
    };
    
    class CAStarNode
    {
    public:
    	int id;
    	D3DXVECTOR3 position;
    	int numNeighbours;
    	CAStarNode* neighbours;
    	bool open;
    	bool closed;
    	CAStarNode* parent;
    	
    	float gCost, hCost, fCost;
    
    	CAStarNode()
    	{
    		id = 0;
    		gCost = 0;
    		hCost = 0;
    		fCost = 0;
    		open = false;
    		closed = false;
    		numNeighbours = 0;
    	}
    
    
    
    
    };
    
    class CAStarGrid
    {
    protected:
    	IDirect3DDevice8* directDevice;
    	CAStarNode* nodes;
    	int numNodes;
    
    	D3DXVECTOR3* lines;
    	int numLineIndices;
    public:
    
    	CAStarGrid()
    	{
    		directDevice = NULL;
    		numNodes = 0;
    		numLineIndices = 0;
    	}
    	
    	bool InitGrid(IDirect3DDevice8** device, std::ifstream& file)
    	{
    		directDevice = *device;
    
    		file >> numNodes;
    
    		nodes = new CAStarNode[numNodes];
    
    		for(int i=0; i < numNodes; i++)
    		{
    			nodes[i].id = i;
    			file >> nodes[i].position.x >> nodes[i].position.y >> nodes[i].position.z;
    			
    		}
    
    		
    
    		int numConnections = 0;
    		
    		for(int n=0; n < numNodes; n++)
    		{
    			file >> numConnections;
    			nodes[n].numNeighbours = numConnections;
    			nodes[n].neighbours = new CAStarNode[numConnections];
    			
    			for(int i=0; i < numConnections; i++)
    			{
    				int nod = 0;
    				file >> nod;
    				nodes[n].neighbours[i] = nodes[nod];
    			}
    			
    		}
    		return true;
    	}
    	
    	bool GetPath(D3DXVECTOR3 start, D3DXVECTOR3 end, st_path& finalPath, float maxStartLimit, float maxEndLimit)
    	{
    		CAStarNode startNode = GetNearestNode(start);
    		if(Distance(startNode.position, start) > maxStartLimit)
    			return false;
    		CAStarNode endNode = GetNearestNode(end);
    		if(Distance(endNode.position, end) > maxEndLimit)
    			return false;
    		
    		for(int n=0; n < numNodes; n++)
    		{
    			nodes[n].open = false;
    			nodes[n].closed = false;
    		}
    		
    		startNode.open = true;
    		
    		bool found = false;
    		while (!found)
    		{
    			CAStarNode currentNode = startNode;
    			
    			if(CheckEnd(currentNode.neighbours, currentNode.numNeighbours, endNode))
    			{
    				endNode.parent = &currentNode;
    				found = true;
    				break;
    			}
    			
    			currentNode.closed = true;
    			
    			CAStarNode* neigh = currentNode.neighbours;
    			int neighCount = currentNode.numNeighbours;
    			
    			for(int i=0; i < neighCount; i++)
    			{
    				if(neigh[i].closed)
    				{
    					continue;
    				} else {
    					float gCost = currentNode.gCost + Distance(currentNode.position, neigh[i].position);
    					float hCost = Distance(neigh[i].position, endNode.position);
    					
    					if(!neigh[i].open)
    					{
    						neigh[i].fCost = hCost + gCost;
    						neigh[i].parent = &currentNode;
    						
    						neigh[i].open = true;
    					} else {
    						float newFCost = gCost + hCost;
    						
    						if(neigh[i].fCost > newFCost)
    						{
    							neigh[i].fCost = newFCost;
    							neigh[i].parent = &currentNode;
    						}
    					}
    				}
    			}
    		}
    		
    		finalPath = CreatePath(startNode, endNode);
    		
    		return true;
    	}
    	
    	st_path CreatePath(CAStarNode start, CAStarNode end)
    	{
    		st_path result;
    		result.corners = new D3DXVECTOR3[40];
    		
    		CAStarNode currentNode = end;
    		int current = 0;
    		while(currentNode.id != start.id)
    		{
    			result.corners[current] = currentNode.position;
    			
    			currentNode = *currentNode.parent;
    			current++;
    		}
    		result.numCorners = current;
    		D3DXVECTOR3* temp = new D3DXVECTOR3[current];
    		int c = 0;
    		for(int i=current - 1; i >= 0; i--)
    		{
    			temp[i] = result.corners[c];
    			c++;
    		}
    		// std::reverse(result.corners[0], result.corners[current]);
    		result.corners = temp;
    		delete[] temp;
    
    		return result;
    	}
    	
    	CAStarNode GetNearestNode(D3DXVECTOR3 position)
    	{
    		CAStarNode result;
    		float dist = 1000;
    		for(int n=0; n < numNodes; n++)
    		{
    			float d = Distance(position, nodes[n].position);
    			
    			if(d < dist)
    			{
    				result = nodes[n];
    				dist = d;
    			}
    		}
    		
    		return result;
    	}
    	
    	bool CheckEnd(CAStarNode* neighbours, int numNeighbours, CAStarNode endTarget)
    	{
    		for(int i=0; i < numNeighbours; i++)
    		{
    			if(neighbours[i].id = endTarget.id)
    				return true;
    		}
    		return false;
    	}
    	
    };

    Gonna improve it later after I've done testing it. Any thoughts?

    • Like 2
  3. 6 minutes ago, PRince404 said:

    Meerjel, What do you think of Renderware? Wouldn't it be better to just use an existing Engine that was catered for that specific generation?

    https://archive.org/details/renderwaregraphics3.7sdkandstudio2.01

    https://github.com/Smooth-E/install-renderware

    I know you're enjoying making one from scratch but I think you can should make that engine for modern system rather than for an old 6 Gen system.

    I could use Renderware but I've done a lot of progress on my engine already. I don't know if it'll be a waste if I quit with it. But on other hand I can use it for my Series S games since Unity is dying.

    So Renderware works as it should now? Then I can use that.

  4. Hello. The Grendel Engine (In A Creation) has had a lot of development done with the first NPC programmed in. Now it should follow a path.

    I'm currently stuck in thoughts about my engine's pathfinding which is gonna be an A* system. My plan is to use a connection system for optimization but are stuck on how to implement it. The nodes are scattered around the level and are connected via links to visible and nearby nodes and it creates a path for the NPC to follow from the nearest node (From the NPC) to the point that is nearest the end node. Then when close enough the NPC moves straight to the point (Instead of the end node's own position). This tutorial gave me some insight on it but I need to convert it to use D3DXVECTOR3 coordinates instead.

    Anyone has anything to say to help me here? It's needed for now.

     

    Meerjel01

    • Like 1
  5. My thoughts was that I would tell people to wait with the pirating until it's no longer payable and hope people would respect it or try make it a law and call free copies of the game stealing.

    An older idea was to put up a high enough donation pool to release the game and still get payed for making it.

    I could release it for free but I don't know if I'll get rewarded enough for it.

  6. The game, In A Creation, is still in my head and will continue development even if my Xbox Series S games are of higher priority.

    image.thumb.png.56736f9c388f04b6e4972abcb38352d0.png

     

    Currently in question how to implement the A* system into the engine in an optimized way (Tho I still have an idea for how) and are about to add my first physics object into the game to check if it'll lag.

    I shouldn't use this topic anymore since it was a question if homebrew games can sell originally. But I'll reveal as little as possible anyway!

    • Like 1
  7. From my character collider code. Take a newDirection vector variable and use this for your triangles. (AABB character vs world triangle collision)

    D3DXVECTOR3 TriangleCollision(CTri triangle, D3DXVECTOR3 dir, D3DXVECTOR3 lastPos, D3DXVECTOR3 currentPos) {
    	D3DXVECTOR3 vNorm = GetNormal(triangle);
    	colliding = false;
    
    	triIsGround = false;
    	triIsCeiling = false;
    	triIsWall = false;
    
    	if(CPyhsics::TriangleIntersectAABB(boundingBox, triangle)) {
    	
    		colliding = true;
    
    		triIsGround = CPyhsics::GetGrounded(vNorm, D3DXVECTOR3(0, -1, 0), 0.5);
    		triIsCeiling = CPyhsics::GetGrounded(vNorm, D3DXVECTOR3(0, 1, 0), 0.5);
    		triIsWall = !triIsGround && !triIsCeiling;
    		
    		if(triIsGround)
    			grounded = true;
    
    		D3DXVECTOR3 tempV = NegateVector(vNorm);
    
    		tempV *= D3DXVec3Length(&MultiplyVector(dir, vNorm));
    		D3DXVECTOR3 wallDir = dir - tempV;
    
    		D3DXVECTOR3 closestPtn = CPyhsics::GetClosestPointOnTriangle(currentPos, triangle);
    
    		if(currentPos.y > closestPtn.y)
    			return dir;
    
    		D3DXVECTOR3 newPos = lastPos + wallDir;
    		
    		D3DXVECTOR3 newDir = newPos - lastPos;
    
    		return newDir;
    	}
    	return dir;
    }

    Call it without using + or - btw.

    • Like 1
  8. Know triangle collision? No? Here then!

    static bool AABBTriangleSAT (D3DXVECTOR3 testAxis, Caabb box, D3DXVECTOR3 v0, D3DXVECTOR3 v1, D3DXVECTOR3 v2) {
    	float p0, p1, p2;
    	p0 = D3DXVec3Dot(&v0, &testAxis);
    	p1 = D3DXVec3Dot(&v1, &testAxis);
    	p2 = D3DXVec3Dot(&v2, &testAxis);
    
    
    	float r = box.extents.x * abs(D3DXVec3Dot(&u0, &testAxis)) +
    		box.extents.y * abs(D3DXVec3Dot(&u1, &testAxis)) +
    		box.extents.z * abs(D3DXVec3Dot(&u2, &testAxis));
    
    	return max(-largest(p0, p1, p2), smallest(p0, p1, p2)) > r;
    }
    static bool TriangleIntersectAABB(Caabb box, CTri triangle) {
    	D3DXVECTOR3 v0 = triangle.p0;
    	D3DXVECTOR3 v1 = triangle.p1;
    	D3DXVECTOR3 v2 = triangle.p2;
    
    	v0 -= box.center;
    	v1 -= box.center;
    	v2 -= box.center;
    
    	D3DXVECTOR3 f0 = v1 - v0;
    	D3DXVECTOR3 f1 = v2 - v1;
    	D3DXVECTOR3 f2 = v0 - v2;
    
    		
    
    	D3DXVECTOR3 ax_u0_f0, ax_u0_f1, ax_u0_f2;
    	D3DXVECTOR3 ax_u1_f0, ax_u1_f1, ax_u1_f2;
    	D3DXVECTOR3 ax_u2_f0, ax_u2_f1, ax_u2_f2;
    
    	D3DXVec3Cross(&ax_u0_f0, &u0, &f0);
    	D3DXVec3Cross(&ax_u0_f1, &u0, &f1);
    	D3DXVec3Cross(&ax_u0_f2, &u0, &f2);
    	D3DXVec3Cross(&ax_u1_f0, &u1, &f0);
    	D3DXVec3Cross(&ax_u1_f1, &u1, &f1);
    	D3DXVec3Cross(&ax_u1_f2, &u1, &f2);
    	D3DXVec3Cross(&ax_u2_f0, &u2, &f0);
    	D3DXVec3Cross(&ax_u2_f1, &u2, &f1);
    	D3DXVec3Cross(&ax_u2_f2, &u2, &f2);
    
    	if(AABBTriangleSAT(ax_u0_f0, box, v0, v1, v2) || AABBTriangleSAT(ax_u0_f1, box, v0, v1, v2) || AABBTriangleSAT(ax_u0_f2, box, v0, v1, v2) ||
    			AABBTriangleSAT(ax_u1_f0, box, v0, v1, v2) || AABBTriangleSAT(ax_u1_f1, box, v0, v1, v2) || AABBTriangleSAT(ax_u1_f2, box, v0, v1, v2) ||
    			AABBTriangleSAT(ax_u2_f0, box, v0, v1, v2) || AABBTriangleSAT(ax_u2_f1, box, v0, v1, v2) || AABBTriangleSAT(ax_u2_f2, box, v0, v1, v2)) {
    			return false;
    		}
    
    	D3DXVECTOR3 triNormal = D3DXVECTOR3(0,0,0);
    	D3DXVec3Cross(&triNormal, &f0, &f1);
    
    	if(AABBTriangleSAT(u0, box, v0, v1, v2) || AABBTriangleSAT(u1, box, v0, v1, v2) || AABBTriangleSAT(u2, box, v0, v1, v2)) {
    		return false;
    	}
    
    	if(AABBTriangleSAT(triNormal, box, v0, v1, v2))
    		return false;
    
    
    	return true;
    }

    Collision response soon..

    • Like 1
  9. Well I can't teach by words but I can give code I guess.

    static bool PointIntersectAABB(D3DXVECTOR3 point, Caabb box)
    {
    	return (point.x > box.center.x - box.extents.x && point.x < box.center.x + box.extents.x
    		&& point.y > box.center.y - box.extents.y && point.y < box.center.y + box.extents.y
    		&& point.z > box.center.z - box.extents.z && point.z < box.center.z + box.extents.z);
    }
    static bool AABBIntersectAABB(Caabb box1, Caabb box2)
    {
    	return (abs(box1.center.x - box2.center.x) < (box1.extents.x + box2.extents.x)
    		&& abs(box1.center.y - box2.center.y) < (box1.extents.y + box2.extents.y)
    		&& abs(box1.center.z - box2.center.z) < (box1.extents.z + box2.extents.z));		
    }

    These are from my Physics functions class.

    • Like 1
  10. 4 minutes ago, antonic901 said:

    Maybe you could help me with XBMC rendering in some future. I will need to backport CBaseTexture class from Kodi to backport some features, but I have zero knowledge of DX8 and graphics. I tried blindly copy pasting but result of that was this:

    Screenshot_2023-08-20_23-02-28.png

    Screenshot_2023-08-20_23-02-52.png

    I'm not sure if I can help unless it's simple code. I'm also busy with my own projects so the chance is even smaller. Have you seen the website I've linked to in my XTL tutorial series?

  11. 11 minutes ago, antonic901 said:

    As @Marty said, if you know coding and especially 3D engines, do you a favor and learn Unity/Unreal Engine. Make your money on modern technologies and platforms and then you will have money for living and xbox hobby projects. That's what I'm doing. WEB development for living and XBMC coding in free time.

    It's okay for me even if I get little out of this cause I'm not planning on staying in the game industry my whole career. I want to be a cartoonist artist and make animations and comics. I only do games cause I feel like I need to finish my plans. Sorta getting it over with.

Board Life Status


Board startup date: April 23, 2017 12:45:48
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.