Page 1 of 1

Endless terrain distortion

Posted: Tue Feb 11, 2014 11:18 pm
by vkreal
I have an endless terrain that looks fine at beginning but when it get further and further the graphic(terrain) becomes distorted. I think the further away precision floating point values for x and y positions fall. Anyone have an ideas or suggestion on how to fix this?

Iforce did you see the same issue with DHS?

I am using code below.

Thanks!!!

Code: Select all

glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, _hillVertices);
glVertexAttribPointer(kCCVertexAttrib_TexCoords, 2, GL_FLOAT, GL_FALSE, 0, _hillTexCoords);
glDrawArrays(GL_TRIANGLE_STRIP, 0, (GLsizei)_nHillVertices);

Re: Endless terrain distortion

Posted: Wed Feb 12, 2014 3:15 am
by iforce2d
No, DHS terrain is not endless.
There is a ShiftOrigin function in b2World which you might find useful: http://code.google.com/p/box2d/source/b ... orld.h#196

Re: Endless terrain distortion

Posted: Wed Feb 12, 2014 4:17 am
by vkreal
THanks for b2World::ShiftOrigin, that will help fix perf on box2d, but prob wont help rendering issue i am having.

Re: Endless terrain distortion

Posted: Sat Nov 01, 2014 5:06 am
by kyle.bong2@gmail.com
Hi all,

You guys have any examples how to use b2World::ShiftOrigin?

Best!

Re: Endless terrain distortion

Posted: Sat Nov 01, 2014 6:55 am
by iforce2d
All it does is move all bodies in the world. You can check out the source code here:
https://code.google.com/p/box2d/source/ ... d.cpp#1258

So if your game starts centered around (0,0) and then the player runs a long way to the right (positive x) then you might want to do world->ShiftOrigin( b2Vec2(100,0) )
After that all the coordinates you use for everything would need to be altered by the same amount.