Logo

Username:    Password:    Remember me     Signup

Main Menu
 Home
 IRC
 Wiki
 

Welcome

Username:

Password:


Remember me

[ Signup ]
[ Forgot password? ]


ToDo/Bugs/Requests
Total tickets: 263
Open tickets: 119
Not assigned: 123

Online
Guests: 5
Members: 0
On this page: 1
Members: 362, newest: coooolihdbril


Forums
Lightfeather 3D Engine -> Forums -> Programming
<< Previous thread | Next thread >>  

 Getting the number of vertices from a CVertexBuffer

Moderators: Matthias
Go to page -1-2 Next
Author Post
sum1nil
Sat Jun 19 2010, 09:10PM Quote
Sum1nil

Registered Member #284
Joined Wed Mar 11 2009, 11:46PM
posts 21
Hi,

There are, I'm sure better ways to do this, but would this work to get the number of vertices of CVertexBuffer and properly position the next read using getAsVector3df()

Thanks for any help.

<div class='indent'>
void LfBulletLargeTerrainModel::tileLoaded(res::CTerrainTileEvent& event)
{
res::CMesh* tileMesh = event.getMesh();
res::CVertexBuffer* vertices = tileMesh->getVertexBuffer();
lf::u32 jump = vertices->getEntrySize();
lf::s32 size = sizeof(vertices) * jump;
for (lf::s32 i = 0; i < size;)
{

core::vector3d<lf::f32> vec1 = vertices->getAsVector3df(res::EVCT_POSITION, i);
i += jump;
core::vector3d<lf::f32> vec2 = vertices->getAsVector3df(res::EVCT_POSITION, i);
i += jump;
core::vector3d<lf::f32> vec3 = vertices->getAsVector3df(res::EVCT_POSITION, i);
i += jump;
btVector3 pos1 = tk.ConvertToBtVector( vec1 );
btVector3 pos2 = tk.ConvertToBtVector( vec2 );
btVector3 pos3 = tk.ConvertToBtVector( vec3 );
//btVector3 pos4 = tk.ConvertToBtVector( edges[1] );
physicsTerrain->addTriangle(pos1, pos2, pos3, true);

//physicsTerrain->addTriangle(pos4, pos2, pos3, true);
}
int numTriangles = physicsTerrain->getNumTriangles();
printf("Tile Loaded!");
}
</div>
Back to top
Matthias
Sun Jun 20 2010, 02:09AM Quote

Location: Hamburg, Germany
posts 399
you dont need to increase i by "jump" you can increase it simply by 3. something like
for(i = 0; i < vertexbuffer->getVertexCount() - 3;i+=3)
{
core::vector3df vec1 = vertexbuffer->getPosition(i);
core::vector3df vec2 = vertexbuffer->getPosition(i + 1);
core::vector3df vec3 = vertexbuffer->getPosition(i + 2);

}

this is actually a more safe way because it handles the difference between interleaved and non-interleaved vertexbuffers for you. your version would only work for interleaved buffers and non-interleaved is the default in lf.

if you need more detailed information, let me know - this is from my head so it might not be 100% correct.
[ Edited Sun Jun 20 2010, 02:12AM ]
Back to top
Website
sum1nil
Mon Jun 21 2010, 09:45AM Quote
Sum1nil

Registered Member #284
Joined: Wed Mar 11 2009, 11:46PM
posts 21
Hi,
Thanks for the advice, I completely did not see the getVertexCount method; much easier.

I have many more questions, but I want to wait to ask until I can phrase them better.

:)
Back to top
Matthias
Mon Jun 21 2010, 10:14AM Quote

Location: Hamburg, Germany
posts 399
just ask and ill tell you when i dont understand the questions :)
Back to top
Website
sum1nil
Sun Jun 27 2010, 12:04AM Quote
Sum1nil

Registered Member #284
Joined: Wed Mar 11 2009, 11:46PM
posts 21
Hi hope all is well.
I would appreciate info on the large terrain.

It seems both the vertex stride and index stride while using CvertexBuffer and CIndexBuffer fixs the distance between (ie. stride) to zero. Although I had thought you'd use like indexStride = 3* sizeof(int). I just don't know ( also please keep in mind I am tring to 'serialize' to a .bullet file the tiles I load in the largeterrain via tileLoad). Bullet uses an IndexedMesh and those meshes are added to the shape being built.

The created physicsTerrian serializes w/o error to disk aka. something.bullet

However, when something.bullet loads, it figues vertex and index stride all by itself and comes up with 12 for the 'triangle' index stride and 16 for the vertex stride. As soon as the vertex stride is used for calculation (this is in bullet), I get the dreaded 'access violation'.

So I just want to make sure that both vertex and index stride in lightfeather are 0 when using a tile event mesh.

I honestly don't know what to do on the bullet end. It seems to make sense; the position vertex size is 3*float=12; the Entrysize is 28 and the proposed stride by bullet is 28 - 12 = 16. The bullet triangle index stride is 3*int=12. It would sem the actual size of the vertex formation from lightfeather is getting sucked along into bullet.

Note: will try to make this more coherent later when I'm not so confused.


Thanks for the tolerance :)

Sorry for the ramble,
Back to top
Matthias
Sun Jun 27 2010, 11:43AM Quote

Location: Hamburg, Germany
posts 399
look at the difference between interleaved and non-interleaved vertexbuffers. its described in cvertexbuffer.h. i think that might be whats confusing you. lf uses non-interleaved buffers by default.
Back to top
Website
sum1nil
Thu Jul 01 2010, 06:28AM Quote
Sum1nil

Registered Member #284
Joined: Wed Mar 11 2009, 11:46PM
posts 21
Hi,
In the mesh passed to the tile load event, I can get a pointer to the indexBuffer. However it has a 'used' variable of 0 and although it has a memory address the values appear to be identical throughout.

Are the indices set later on past the tile load event?

TY
* Put the whole thing over at http://pastebin.com/6LMvwsse
Back to top
Matthias
Thu Jul 01 2010, 02:21PM Quote

Location: Hamburg, Germany
posts 399
yes, the indexes must be filled later because they depend on the LOD of neighboring terrainpatches.
So if the LOD changes, the indexbuffer's contents change as well. Im sorry i forgot to tell you this before.
Back to top
Website
Matthias
Thu Jul 01 2010, 02:35PM Quote

Location: Hamburg, Germany
posts 399
also there are additional indexbuffers used to fill the cracks that appear when two neighboring patches have different LODs.
Back to top
Website
Matthias
Thu Jul 01 2010, 02:47PM Quote

Location: Hamburg, Germany
posts 399
the indexes are set at the end of the call to setupIndexBuffers in CLargeTerrainModel.cpp . maybe you need a callback/event there to setup your physics terrain ?!
Back to top
Website
sum1nil
Sat Jul 03 2010, 05:24PM Quote
Sum1nil

Registered Member #284
Joined: Wed Mar 11 2009, 11:46PM
posts 21
Is the call to setupIndexBuffers the final call setting up the large terrain and/or updating large terrain?

I'll have to study some to figure out setting up callbacks. Maybe setting a global callback somehow for large terrain so everytime it is made/updated the callback executes. I gotz some reading to do. :)

I would say Happy 4th of July, but I think you guys aren't into that much, eh?
Back to top
Go to page -1-2 Next

Jump:     Back to top



Random Image

Latest Forum Posts
calav3ra on 04 Sep : 15:21
You are absolutely right about both parts being wr[more ...]

Matthias on 04 Sep : 10:42
I will have time to look into this and the other t[more ...]

legerdemain on 04 Sep : 06:45
Hi again, i'm trying to track down a strange crash[more ...]

legerdemain on 03 Sep : 11:03
In CGUITextArea.cpp, lines 657-658 and 679-680, th[more ...]

Matthias on 27 Aug : 13:20
Hm.. thats odd - i will look into it. Hope you can[more ...]

Backend
Our headlines can be syndicated by using either our rss or text feeds.
news.xml - news.txt


Render time: 0.2564 second(s).