Jump to content
OGXbox.com

Meerjel01

Members
  • Posts

    137
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by Meerjel01

  1. It works decently now. Had it crash a bunch of times until I figured what the problem was.
  2. Using Line/Ray casting in the A* system proved to be useful. https://drive.google.com/file/d/1gDh9gUOJqBQjBOJB86Ip1MjBPtac4Va3/view?usp=sharing But the casting isn't that great and I need to figure out why.
  3. Have a look. Crisp Editor
  4. Current Progress Has errors unfortunately but it goes somewhere. Also using line/ray casting to detect if the NPC's path is open.
  5. Made an editor for making node placing and connections files. It's called the Crisp Editor (Cause it's one crispy editor). It's unfinished but it's doing it's job well. I think.
  6. When I was interested in a full 3D game engine for the OG Xbox, I wanted to do a simple technique that Conker Live and Reloaded did with facial expressions. The mouths where 3D, but the eyes where 2D textures with 2 stages. It's not shape group based (I think) but uses bones for the mouths and textures for eyes like the outside and the inside of them. There might be an 8 for this. When I finish my own skinned mesh renderer and animator then I will do this. Seems to be the best looking way to me. Lipsync Oh Wow.mp4
  7. Thank you! Didn't know the tutorial had a typo in it. I tested the code and I think it works better now. But I still think the nodes and their connections are messed up so I'll need to fix those somehow.
  8. A tip for textures. Use dds files for everything cause they're the most built for DirectX applications and games. And even if they take up storage size, they're still optimized for the memory. You might already know this but I felt like adding it here anyway.
  9. I did some changing to the code and it seems to work a bit better now. But it's not predictable enough and it might be the node grid that I made that is not set up correctly. Gonna make a new graph and changing to other parts of the engine's code to make it easier to work with.
  10. Here. // Init the grid then Get A Path 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; CAStarNode* openList = new CAStarNode[numNodes]; CAStarNode* closedList = new CAStarNode[numNodes]; int currentOpenAmount = 0; int currentClosedAmount = 0; openList[0] = *startNode; currentOpenAmount++; while (currentOpenAmount > 0) { if(currentOpenAmount <= 0) break; CAStarNode* currentNode = &openList[currentOpenAmount - 1]; int neighCount = currentNode->numNeighbours; for(int i=0; i < neighCount; i++) { currentNode->neighbours[i].parent = currentNode; currentNode->neighbours[i].gCost = Distance(currentNode->position, currentNode->neighbours[i].position); currentNode->neighbours[i].hCost = Distance(currentNode->position, endNode->position); currentNode->neighbours[i].fCost = currentNode->neighbours[i].gCost + currentNode->neighbours[i].hCost; } // CAStarNode* neigh = currentNode->neighbours; int ending = 0; if(currentNode->id == endNode->id) { CAStarNode* nods = new CAStarNode[numNodes]; int curNods = 0; CAStarNode* curNod = currentNode; bool creating = true; while(creating) { nods[curNods] = *curNod; curNods++; if(curNod->id != startNode->id) curNod = curNod->parent; else creating = false; } if(curNods <= 0) return false; st_path result; result.numCorners = curNods; result.corners = new D3DXVECTOR3[curNods]; for(int n=0; n < curNods; n++) { result.corners[n] = nods[n].position; } // finalPath = CreatePath(startNode, endNode); finalPath = result; return true; } bool picked = false; for(int i=0; i < neighCount; i++) { int sel = 0; for(int x=0; x < neighCount; x++) { if(currentNode->neighbours[x].fCost < currentNode->neighbours[sel].fCost) { sel = x; } } if(CheckInClosedList(closedList, currentClosedAmount, currentNode->neighbours[sel])) { int lar = 0; for(int x=0; x < neighCount; x++) { if(currentNode->neighbours[x].fCost > currentNode->neighbours[lar].fCost) { lar = x; } } currentNode->neighbours[sel].fCost = currentNode->neighbours[lar].fCost + 1; continue; /* currentNode->neighbours[i].gCost = currentNode->gCost + Distance(currentNode->position, currentNode->neighbours[i].position); currentNode->neighbours[i].hCost = Distance(currentNode->neighbours[i].position, endNode->position); currentNode->neighbours[i].fCost = currentNode->neighbours[i].gCost + currentNode->neighbours[i].hCost; currentNode->neighbours[i].parent = currentNode; openList[currentOpenAmount] = currentNode->neighbours[i]; currentOpenAmount++; */ } else { openList[currentOpenAmount] = currentNode->neighbours[sel]; currentOpenAmount++; picked = true; break; } } if(picked == false) { currentOpenAmount--; } closedList[currentClosedAmount] = *currentNode; currentClosedAmount++; } return false; } 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; } I've just come back to this.
  11. I have not gotten the program to work yet and tried multiple types of code. Can someone lend a hand here?
  12. 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.
  13. Tested the code but the result wasn't as expected. I tested it with a small amount of nodes but it should probably work better with more.
  14. 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?
  15. Isn't it different on a 3D environment with multiple floors though?
  16. But I still need to make an A* pathfinding system like how I described it. Maybe a bit like Half-Life's nodegraph system. Good thing they have it in the SDK.
  17. 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.
  18. 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
  19. 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.
  20. 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. 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!
  21. 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.
  22. 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..
  23. 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.
  24. Thank you. Currently I want to implement A* pathfinding to the engine but aren't that lucky with knowing how. Also have you played the demo?

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.