Skip to main content
gamedev.net
🔒 Locked

Terrain edit

Started by clouds Oct 25, 2005 at 8:57 AM 6 replies 550+ views
Original Post
clouds
clouds
Hello, I try to make a simple terrain editor, for altering the height values, but I dont find any faster way to detect what vertex I pick. Checking all terrain triangles for intersection with my ray, is not a fast idea. If any one have any better idea i will sincerely apreciate. Thanks.
Magos
Magos
Implement a broad-narrow phase, like an octree. First you check a larger group for intersection. If successful, search its subgroups. Otherwise skip the subgroups.
----------------------------------------MagosX.com
clouds
clouds
I know OpenGl have a nice glReadPixels function, used with glUnProject do the trick, any faster similar way in D3D? Cos i dont want to use the ray triangle instersection checking, even I use and octree, is unusefull, I need to update it every time I change the terrain.
soconne
soconne
Just use one of the terrain editors already out there. I use this one
freeworld3d
Author Freeworld3Dhttp://www.freeworld3d.org
Kalasjniekof
Kalasjniekof
Quote:
Original post by oconnellseanm
Just use one of the terrain editors already out there. I use this one
freeworld3d


The OP says he would like to make one himself. So give him a chance.

@OP: I don't see how glReadPixels() would help. Please explain.

clouds
clouds
well, i use this with opengl and works nice:

VECTOR3 Pick(int mousex, int mousey)
{
GLint viewport[4];
GLdouble modelview[16];
GLdouble projection[16];
GLfloat winX, winY, winZ;
GLdouble posX, posY, posZ;

glGetDoublev( GL_MODELVIEW_MATRIX, modelview );
glGetDoublev( GL_PROJECTION_MATRIX, projection );
glGetIntegerv( GL_VIEWPORT, viewport );

winX = (float)mousex;
winY = (float)(viewport[3]) - (float)mousey;
glReadPixels( mousex, (int)winY, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );

gluUnProject( winX, winY, winZ, modelview, projection, viewport, &posX, &posY, &posZ);

return VECTOR3((float)posX, (float)posY, (float)posZ);
}
clouds
clouds
So, any one can show me the way for D3D to do this?
clouds
clouds
I still looking for a good answer:) thanks.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.