Getting data from Atlas chunk into instance
by Justin Mosiman · in Torque Game Engine Advanced · 06/04/2007 (8:03 pm) · 8 replies
Hello,
I have added a new piece of data to the chunk of an Atlas resource. Specifically, I added it to the argc AtlasGeomChunk chunk within atlasImportOldChu.cpp, and then it was copied to the AtlasResourceGeomTOC by the code already in atlasImportOldChu, mTOC->instateNewChunk(args,argc,true).
Now that it has been copied to the TOC, how can I access it through an instance of Atlas? I want to be able to get that piece of data in real time if possible.
I'm not asking for specific code, just a general idea of what I need to do. Such as what methods I should look at and if I am on the correct path.
Thank you,
Justin
I have added a new piece of data to the chunk of an Atlas resource. Specifically, I added it to the argc AtlasGeomChunk chunk within atlasImportOldChu.cpp, and then it was copied to the AtlasResourceGeomTOC by the code already in atlasImportOldChu, mTOC->instateNewChunk(args,argc,true).
Now that it has been copied to the TOC, how can I access it through an instance of Atlas? I want to be able to get that piece of data in real time if possible.
I'm not asking for specific code, just a general idea of what I need to do. Such as what methods I should look at and if I am on the correct path.
Thank you,
Justin
#2
Chunks - as you already see, these are the basic leaves of the atlas tree. They hold data for various purposes (texture, geometry).
TOC - these are the indexes of where data can be retrieved from.
Stub - this is the proxy for looking up (and on demand loading) the chunks. Basically, if a stub has no chunk, it can be request loaded, the stub is essentially the mechanism for paging data via calls to enqueue loads etc.
In atlasInstance2 you should see mGeomTOC, that is the geometry TOC for that particular atlasinstance. I added a getter for that into atlasInstance so that I could access it.
Now from that geomTOC, you should look at getStub, getResourceStub and getResourceTOC (although, I might have added any of those myself, so check, but they'll just be getters anyway).
Specifically, you might want to look at AtlasInstanceGeomStub and AtlasResourceGeomStub.
I ran into difficulties when instating new data, I got it instated into the instance, but couldnt get the generation of my LOD'd chunks to work, something about how I was propagating changes up the quadtree wasnt working right.
06/06/2007 (12:51 am)
Its been a while since I was doing atlas stuff, but from memory, I'd suggest looking at a few things:Chunks - as you already see, these are the basic leaves of the atlas tree. They hold data for various purposes (texture, geometry).
TOC - these are the indexes of where data can be retrieved from.
Stub - this is the proxy for looking up (and on demand loading) the chunks. Basically, if a stub has no chunk, it can be request loaded, the stub is essentially the mechanism for paging data via calls to enqueue loads etc.
In atlasInstance2 you should see mGeomTOC, that is the geometry TOC for that particular atlasinstance. I added a getter for that into atlasInstance so that I could access it.
Now from that geomTOC, you should look at getStub, getResourceStub and getResourceTOC (although, I might have added any of those myself, so check, but they'll just be getters anyway).
Specifically, you might want to look at AtlasInstanceGeomStub and AtlasResourceGeomStub.
I ran into difficulties when instating new data, I got it instated into the instance, but couldnt get the generation of my LOD'd chunks to work, something about how I was propagating changes up the quadtree wasnt working right.
#3
If I have read the code correctly, each chunk contains a certain number of vertex arrays. That number depends on the vertex count that was inputted when the atlas map was created. Lets say that I add a new random boolean variable that corresponds to each element of the array. So if the vertCount is 10 (hypothetical example) than I will have 10 different random boolean values for each chunk. If the vertCount is 100 I would have 100 random boolean values for each chunk, etc.
Now lets say that I want to get what each of those boolean values are based off of a position, or I just wanted to output all of the values throughout the whole Atlas file, is that possible?
In the end what I am working on is A* pathfinding for atlas, so I am going to be calculating the slope based off of the vertexes and that will determine if the character can go traverse that area.
Thank you
06/06/2007 (6:19 pm)
I started to look at atlasInstance2, and was able to get the resource stub or instance stub through the GeomTOC, but after that, the furthest that I could get to the chunk was to a class called ChunkType. ChunkType is setup to act as a list, and does not carry the specific information about the chunk (or maybe it does and I just don't understand it enough).If I have read the code correctly, each chunk contains a certain number of vertex arrays. That number depends on the vertex count that was inputted when the atlas map was created. Lets say that I add a new random boolean variable that corresponds to each element of the array. So if the vertCount is 10 (hypothetical example) than I will have 10 different random boolean values for each chunk. If the vertCount is 100 I would have 100 random boolean values for each chunk, etc.
Now lets say that I want to get what each of those boolean values are based off of a position, or I just wanted to output all of the values throughout the whole Atlas file, is that possible?
In the end what I am working on is A* pathfinding for atlas, so I am going to be calculating the slope based off of the vertexes and that will determine if the character can go traverse that area.
Thank you
#4
06/08/2007 (9:20 pm)
Any ideas?
#5
With the following code, I was able to get the x coordinate of a specific chunk, but it isn't the value that I thought it should be:
(being called within a ConsoleMethod so the object is of type AtlasInstance2.
When I get this value, the value of point.x is 640, but the inputted Point2I point is 33, so what is this 640 value?
It could deal with the level 0 within getStub, but for example I tried a 1 and Torque crashed, so what is this 0 level referring to?
Any input is greatly appreciated.
06/10/2007 (5:37 am)
I may have gotten one step closer, but I am in need of some explanation of the way Atlas works.With the following code, I was able to get the x coordinate of a specific chunk, but it isn't the value that I thought it should be:
object->getGeomTOC()->getResourceTOC()->getStub(0,Point2I(33,25))->mChunk->mVert->point.x
(being called within a ConsoleMethod so the object is of type AtlasInstance2.
When I get this value, the value of point.x is 640, but the inputted Point2I point is 33, so what is this 640 value?
It could deal with the level 0 within getStub, but for example I tried a 1 and Torque crashed, so what is this 0 level referring to?
Any input is greatly appreciated.
#6
06/10/2007 (3:20 pm)
Justin, have you possibly looked at adding a whole new TOC to an Atlas file? I know you're looking for an automated solution, but you could probably do what you're thinking with some sort of image mask. Say, create a black and white image that acts as a "collision map" for your terrain. Then just import that as a whole new texture TOC into an Atlas file. If that collision map only ever has pure white or pure black then you could get your boolean value that way.
#7
In terms of the returned point.x there are two possibilities:
1) The point returned is relative to some local origin
2) The chunk stub you are asking for, is in "chunks", i.e. when you ask for a stub, you are asking for that particular leaf of the quadtree.
Now the thing you want to watch out for, is that the geometry for a given stub is either the raw triangle geometry post-decimation (if you go for the lowest level of the quadtree at its leaves) OR it is one of the parent nodes, which would then be a mesh that represents the child nodes of the quadtree at that point (poly reduced).
I think maybe Mark is right, easier to add a new TOC to the atlas file.
06/14/2007 (12:43 am)
Justin, you have to remember that the chunks themselves are decimated and triangle reduced. So its not storing a grid of points for the heightfield in a chunk. If youre trying to save a pathing value per vertex in a grid type fashion, I think your barking up slightly the wrong tree.In terms of the returned point.x there are two possibilities:
1) The point returned is relative to some local origin
2) The chunk stub you are asking for, is in "chunks", i.e. when you ask for a stub, you are asking for that particular leaf of the quadtree.
Now the thing you want to watch out for, is that the geometry for a given stub is either the raw triangle geometry post-decimation (if you go for the lowest level of the quadtree at its leaves) OR it is one of the parent nodes, which would then be a mesh that represents the child nodes of the quadtree at that point (poly reduced).
I think maybe Mark is right, easier to add a new TOC to the atlas file.
#8
Edit: nevermind, I'm going at pathfinding a different way.
06/18/2007 (1:22 am)
Thanks for the ideas. I guess I'll go creating a new TOC route. Is there an article anywhere that has an overview of creating a new TOC? I tried to go through the code within the atlas directory, but that is a lot to grasp.Edit: nevermind, I'm going at pathfinding a different way.
Torque 3D Owner Mark Dynna