[filax] TerraED Pro

Community Forums/Developer Stations/[filax] TerraED Pro

Murphy(Posted 2006) [#1]
Hi Filax!

Any News on TerraED pro? =)


Filax(Posted 2006) [#2]
Yes ! But i'm desapointed about blitz collisions ....
i have many problems with multiples terrains + camera :(


ShadowTurtle(Posted 2006) [#3]
HideEntity / HideMesh
ShowEntity / ShowMesh

@ filax ^^


Filax(Posted 2006) [#4]
it is not sufficient! the collisions must be disabled
i'm actualy research a function to know if the camera
is under a terrain.


ShadowTurtle(Posted 2006) [#5]
Make Freelook and you see: It is not a bug. This is a feature!

hmpf. okay

double Interpolate (double fA, double fB, double fX)
{
	return (fA * (1 - fX) + fB * fX);
}

double GetHeight (double fx, double fy)
{
	if (fx < 0 || fx > WIDTH)
		return 0.0; // ERROR!


	if (fy < 0 || fy > HEIGHT)
		return 0.0; // ERROR!


	int x = (int) fx;
	int y = (int) fy;

	int x1 = x + 1;
	int y1 = y + 1;

	double dX = fx - (double) x;
	double dY = fy - (double) y;

	double fHeight1 = m_afHeightmap[x + y * WIDTH];
	double fHeight2 = m_afHeightmap[x1 + y * WIDTH];
	double fHeight3 = m_afHeightmap[x + y * WIDTH];
	double fHeight4 = m_afHeightmap[x1 + y1 * WIDTH];

	return Interpolate (Interpolate (fHeight1, fHeight2, dX),
						Interpolate (fHeight3, fHeight4, dX),
						dY);
}


This works like this:

Actual_Height_On_Actual_Camera_Position = Interpolated 1-, 2- 3, or 4- terrain-vertex-height in position of the camera.

If Camera_Y > Actual_Height_On_Actual_Camera_Position Then
... oh my god ...
End If


Here is more information for you: http://www.gamedev.net/community/forums/topic.asp?topic_id=205690


Edit: I think its only fair for posting a optimized sample, too.

//------------------------------------------------------------

//

// example

// -------

//

//      (x0, h0, y0)       (x1, h1, y0)

//          +---------------+         

//          |             ./|         

//          |           . / |         

//          |         .  /  |dy       

//          |       .   /   |         

//          |     .    /    |         

//          |   .     +-----+          ^

//          | .        dx   | (1-dy)   |d_hy =(1-dy)(h1 - h3)

//          +---------------+          v

//     (x0, h2, y1)       (x1, h3, y1)

//

//                     <--->

//                       d_hx = dx(h2-h3)

//

//

//   h = h3 + hx + hy

//

//------------------------------------------------------------


double GetHeight (double fx, double fy)
{	if (fx < 0 || fx > (WIDTH - 1))
		return 0.0; // ERROR!

	if (fy < 0 || fy > (HEIGHT - 1))
		return 0.0; // ERROR!

	int x0 = (int) fx;
	int y0 = (int) fy;
	int x1 = x0 + 1;
	int y1 = y0 + 1;
	double dX = (double) x1 - fx;
	double dY = fy - (double) y0;
	double h0 = g_afHeightMap[x0 + y0 * WIDTH];
	double h1 = g_afHeightMap[x1 + y0 * WIDTH];
	double h2 = g_afHeightMap[x0 + y1 * WIDTH];
	double h3 = g_afHeightMap[x1 + y1 * WIDTH];

 	double h;
	// top left triangle

	// interpolate with origin at (x0), and going towards

	// x1 and x2

	if (dx > dy)
	{
		h = h0 + (1 - dx) * (h1 - h0) + dy * (h2 - h0);
	}
	// bottom right triangle

	// interpolate with origin at (x3), and going towards

	// x2 and x1

	else
	{
		h = h3 + dx * (h3 - h2) + (1 - dy) * (h1 - h3);
	}
	return h;
}



Filax(Posted 2006) [#6]
My problem is not the height but only position X/Z of the camera.


Ross C(Posted 2006) [#7]
Filax, what about using linepick? You set the terrain with a pickmode. Do a linepick straight down from the cameras positions. If nothing is found, then, your below the terrain.


Filax(Posted 2006) [#8]
Yes it's a solution ! but i'm affraid about FPS=>Linepick ?
do you think that line pick is a good solution to keep a
good FPS value ?


jfk EO-11110(Posted 2006) [#9]
You can do this by a calculation since you know the X/Z of the camera, as well as the terrain. All you have to do is multiply the scaling of the terrain with the number of segments, then you'll get the real world size.


Filax(Posted 2006) [#10]
A stuff like this ?

If CameraX>TerPX+TerSize*TerScale and CameraX<TerPX+TerSize*TerScale and Idem for the Z position ?