Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,089 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Terrain is now water - ideas to view from underneath? #326203
05/31/10 06:56
05/31/10 06:56
Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sub_Game Offline OP
Newbie
Sub_Game  Offline OP
Newbie

Joined: Jan 2010
Posts: 40
Adelaide, Australia
I have successfully created a rolling sea by manipulating terrain vertices within lite-c

I now need to view that sea from underneath but of course terrain is invisable from underneath. I am thinking of using a set of sprites that 'hug' the terrain vertices. Before I start with that challenging code, does anyone have any ideas of a better way to do it?



Last edited by Sub_Game; 05/31/10 07:03.

A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm
Re: Terrain is now water - ideas to view from underneath? [Re: Sub_Game] #326204
05/31/10 07:03
05/31/10 07:03
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Will you only view it from below or will you go above the terrain also?

I'm sure you could just flip the normals.

Re: Terrain is now water - ideas to view from underneath? [Re: DJBMASTER] #326211
05/31/10 08:29
05/31/10 08:29
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Use a shader with the:

CullMode = none;

Re: Terrain is now water - ideas to view from underneath? [Re: Widi] #326213
05/31/10 08:45
05/31/10 08:45
Joined: Apr 2010
Posts: 265
V
Vinous_Beret Offline
Member
Vinous_Beret  Offline
Member
V

Joined: Apr 2010
Posts: 265
why not use fog??

Re: Terrain is now water - ideas to view from underneath? [Re: Vinous_Beret] #327378
06/06/10 08:28
06/06/10 08:28
Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sub_Game Offline OP
Newbie
Sub_Game  Offline OP
Newbie

Joined: Jan 2010
Posts: 40
Adelaide, Australia
Thanks for the response guys.

I've used a set of animated model tiles to create the near-view waves and a terrain for the distance. It looks great but now I can't determine the height of the water as the waves animate! c_trace just remembers the first frame and ignores the subsequent animation.

Widi - I haven't played with shaders yet. Does the CullMode = none make terrain observable from underneath?


A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm
Re: Terrain is now water - ideas to view from underneath? [Re: Sub_Game] #327419
06/06/10 11:06
06/06/10 11:06
Joined: Aug 2007
Posts: 1,922
Schweiz
Widi Offline
Serious User
Widi  Offline
Serious User

Joined: Aug 2007
Posts: 1,922
Schweiz
Yes, it makes polygons are visible from both site. You can use the following material or only copy the effect in your own material:
Code:
material mat_bump
{
   effect = "
	technique t0
	{
		pass p0
		{
			CullMode = None;
		}
	}
        ";
}


There is also a good project called "mystymood" that have moving mirroring water and a terrain.

Last edited by Widi; 06/06/10 11:07.
Re: Terrain is now water - ideas to view from underneath? [Re: Sub_Game] #329367
06/19/10 11:44
06/19/10 11:44
Joined: Sep 2006
Posts: 36
Tempe, AZ
B
bpc31 Offline
Newbie
bpc31  Offline
Newbie
B

Joined: Sep 2006
Posts: 36
Tempe, AZ
Hi Sub_Game,
Would you be willing to post the code you used to create your rolling sea? I'm trying to create lake ripples for my boat racing game...Thanks in advance! -Bruce

Re: Terrain is now water - ideas to view from underneath? [Re: bpc31] #329461
06/20/10 09:03
06/20/10 09:03
Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sub_Game Offline OP
Newbie
Sub_Game  Offline OP
Newbie

Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sure, here is the code:
Code:
action water_terrain_animate()
{	
	int i; // number of vertices
	int j;
	var wave_cycle=2;
	var wave_cycle_dir=0;

	int vert_x;
  	int vert_y;
  	set(me,PASSABLE | POLYGON);
  	//my_under_waves.tilt = 90;
  	
  	wait(1);
	int num_vertices = ent_status(my_waves,0);
	int num_x_vertices = ent_status(my_waves,2)+1;
	int num_y_vertices = ent_status(my_waves,3)+1;
	
	
	//ent_clone(me);
	
	for(i = 0; i < 64; i++ )
	{	for(j = 0; j < 64; j++ )
		{	//vert_move[i][j][VERT_SPEED]=0;			
			water_vertices_data[i][j][VERT_SPEED]=wave_cycle+random(2)-1;			
			//vert_move[i][j][VERT_SPEED_CHANGE]=random(1)-0.5;
			
    		
		}
		wave_cycle+=wave_cycle_dir;
		if( wave_cycle>0 )wave_cycle_dir--;
		else wave_cycle_dir++;
	}
	
	

	
	//vec_scale(my.scale_x,100);
	//my.scale_z = my.scale_z/10;
	//my.ambient = 100;
	
	while(1)
	{
		//ent_animate(my,"Wave",anim_percentage, ANM_CYCLE);
		
		//anim_percentage += time_step;
		//if(anim_percentage>=100) anim_percentage = 0;
		vert_x=0;
		vert_y=0;
		for (i = num_vertices; i>0; i--) 
		{ 	CONTACT* c = ent_getvertex(my_waves,NULL,i);
			
			water_vertices_data[vert_x][vert_y][VERT_SPEED_CHANGE]=-(c.z- my_waves.z)/8;	
			//if(c.z<= my_waves.z ) vert_move[vert_x][vert_y][VERT_SPEED_CHANGE]++;
			//else if(c.v.y> my_waves.z ) vert_move[vert_x][vert_y][VERT_SPEED_CHANGE]--;
			
			water_vertices_data[vert_x][vert_y][VERT_SPEED]+=water_vertices_data[vert_x][vert_y][VERT_SPEED_CHANGE]/64;
			
			//move the vertice
			
    		c.v.y += water_vertices_data[vert_x][vert_y][VERT_SPEED]*time_step; // raise the vertex (y is the height in DX coorcinates)
    		ent_setvertex(my_waves,c,i);
    		
    		water_vertices_data[vert_x][vert_y][VERT_X] = c.x;
    		water_vertices_data[vert_x][vert_y][VERT_Y] = c.y;
    		water_vertices_data[vert_x][vert_y][VERT_Z] = c.z;
    		
    		//effect(p_trail,1,vector(water_vertices_data[vert_x][vert_y][VERT_X], water_vertices_data[vert_x][vert_y][VERT_Y], 50),vector(0,0,10));
    		
    		//effect(p_trail,1,vector(c.x, c.y, c.z),vector(0,10,10));
    		
    		//advance the vert_x & vert_y (for my info)
    		vert_x++;
    		if(vert_x >= num_x_vertices)
    		{	vert_x=0;
    			vert_y++;
			}
  		}
		

		wait(1);
	}
	
}



And the code to calculate the height at any given point:
Code:
function average_height(var av_x, var av_y, var vert_x, var vert_y)
{	var av_height = 0;
	var side_x;
	var side_y;
	var calc_tl_x;
	var calc_tl_y;
	var calc_br_x;
	var calc_br_y;
	var calc_face_tri;
	var calc_my_tri;
	var calc_avheight_x;
	var calc_avheight_y;
	var calc_ratio;
	var calc_length1;
	var calc_length2;
		
		vert_x = 0;
		vert_y = 0;
		while(1)
		{	if(av_x > water_vertices_data[vert_x][vert_y][VERT_X])
			{	break;
			}
			else vert_x++;
		}
		while(1)
		{	if(av_y < water_vertices_data[vert_x][vert_y][VERT_Y])
			{	break;
			}
			else vert_y++;
		}
	
	
	calc_tl_x = water_vertices_data[vert_x][vert_y-1][VERT_X];
	calc_tl_y = water_vertices_data[vert_x][vert_y-1][VERT_Y];
	calc_br_x = water_vertices_data[vert_x-1][vert_y][VERT_X];
	calc_br_y = water_vertices_data[vert_x-1][vert_y][VERT_Y];
	
	calc_face_tri = (calc_tl_x-calc_tl_y)-(calc_br_x-calc_br_y);
	calc_my_tri = (calc_tl_x-calc_tl_y)-(av_x-av_y);
	
	if(calc_my_tri > calc_face_tri )
	{	side_x = av_x - av_y + water_vertices_data[vert_x-1][vert_y][VERT_Y];
		calc_ratio = (side_x - water_vertices_data[vert_x-1][vert_y][VERT_X])/(water_vertices_data[vert_x][vert_y][VERT_X] - water_vertices_data[vert_x-1][vert_y][VERT_X]);
		calc_avheight_x = (water_vertices_data[vert_x][vert_y][VERT_Z] - water_vertices_data[vert_x-1][vert_y][VERT_Z])*calc_ratio + water_vertices_data[vert_x-1][vert_y][VERT_Z];

		
		side_y = av_y - av_x + water_vertices_data[vert_x][vert_y-1][VERT_X];
		calc_ratio = (side_y - water_vertices_data[vert_x][vert_y-1][VERT_Y])/(water_vertices_data[vert_x][vert_y][VERT_Y] - water_vertices_data[vert_x][vert_y-1][VERT_Y]);
		calc_avheight_y = (water_vertices_data[vert_x][vert_y][VERT_Z] - water_vertices_data[vert_x][vert_y-1][VERT_Z])*calc_ratio + water_vertices_data[vert_x][vert_y-1][VERT_Z];

		
		calc_length1 = vec_dist(vector(side_x,water_vertices_data[vert_x-1][vert_y][VERT_Y], 0),vector(water_vertices_data[vert_x][vert_y-1][VERT_X], side_y, 0 ));
		calc_length2 = vec_dist(vector(side_x,water_vertices_data[vert_x-1][vert_y][VERT_Y], 0),vector(av_x, av_y, 0 ));
		calc_ratio = calc_length2/calc_length1;
		
		av_height = -(calc_avheight_x-calc_avheight_y)*calc_ratio + calc_avheight_x;
	}
	else
	{	side_x = av_x - av_y + water_vertices_data[vert_x-1][vert_y-1][VERT_Y];
		calc_ratio = (side_x - water_vertices_data[vert_x-1][vert_y-1][VERT_X])/(water_vertices_data[vert_x][vert_y-1][VERT_X] - water_vertices_data[vert_x-1][vert_y-1][VERT_X]);
		calc_avheight_x = (water_vertices_data[vert_x][vert_y-1][VERT_Z] - water_vertices_data[vert_x-1][vert_y-1][VERT_Z])*calc_ratio + water_vertices_data[vert_x-1][vert_y-1][VERT_Z];
		
		side_y = av_y - av_x + water_vertices_data[vert_x-1][vert_y-1][VERT_X];
		calc_ratio = (side_y - water_vertices_data[vert_x-1][vert_y-1][VERT_Y])/(water_vertices_data[vert_x-1][vert_y][VERT_Y] - water_vertices_data[vert_x-1][vert_y-1][VERT_Y]);
		calc_avheight_y = (water_vertices_data[vert_x-1][vert_y][VERT_Z] - water_vertices_data[vert_x-1][vert_y-1][VERT_Z])*calc_ratio + water_vertices_data[vert_x-1][vert_y-1][VERT_Z];
		//effect(p_debris,1,vector(water_vertices_data[vert_x][vert_y][VERT_X], side_y, calc_avheight_y),vector(0,0,10));
		
		calc_length1 = vec_dist(vector(side_x,water_vertices_data[vert_x-1][vert_y-1][VERT_Y], 0),vector(water_vertices_data[vert_x-1][vert_y-1][VERT_X], side_y, 0 ));
		calc_length2 = vec_dist(vector(side_x,water_vertices_data[vert_x-1][vert_y-1][VERT_Y], 0),vector(av_x, av_y, 0 ));
		calc_ratio = calc_length2/calc_length1;
		
		av_height = -(calc_avheight_x-calc_avheight_y)*calc_ratio + calc_avheight_x;
	}	

	return av_height;
}



Kinda messy isn't it! Hope this helps.


A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm
Re: Terrain is now water - ideas to view from underneath? [Re: Sub_Game] #329698
06/22/10 04:21
06/22/10 04:21
Joined: Sep 2006
Posts: 36
Tempe, AZ
B
bpc31 Offline
Newbie
bpc31  Offline
Newbie
B

Joined: Sep 2006
Posts: 36
Tempe, AZ
How are you declaring water_vertices_data? I tried:
var water_vertices_data[3];
but it returns 'dimension of array error' on this line:
water_vertices_data[i][j][VERT_SPEED]=wave_cycle+random(2)-1;

Thanks!

Re: Terrain is now water - ideas to view from underneath? [Re: bpc31] #329717
06/22/10 09:28
06/22/10 09:28
Joined: Jan 2010
Posts: 40
Adelaide, Australia
Sub_Game Offline OP
Newbie
Sub_Game  Offline OP
Newbie

Joined: Jan 2010
Posts: 40
Adelaide, Australia
In the declaration section:
Code:
ENTITY* my_waves;

#define VERT_X					0
#define VERT_Y					1
#define VERT_Z					2
#define VERT_SPEED				3
#define VERT_SPEED_CHANGE			4
#define MAX_VERT_DATA				5

var water_vertices_data[64][64][MAX_VERT_DATA];


The terain is 64 x 64 verticies in this case. Modify as required for your terrain size. You will also need to modify the following loop values in water_terrain_animate() for the size of your terrain:
Code:
for(i = 0; i < 64; i++ )
	{	for(j = 0; j < 64; j++ )
		{	//vert_move[i][j][VERT_SPEED]=0;			
			water_vertices_data[i][j][VERT_SPEED]=wave_cycle+random(2)-1;			
			//vert_move[i][j][VERT_SPEED_CHANGE]=random(1)-0.5;
			
    		
		}
		wave_cycle+=wave_cycle_dir;
		if( wave_cycle>0 )wave_cycle_dir--;
		else wave_cycle_dir++;
	}



Also in my initialisation function:
Code:
my_waves = ent_create("waves/WaterTerrain1.hmp", vector(0, 0, 0), water_terrain_animate);



My new system using animated models seems to work better but I haven't finished it yet. It is real complicated and needs serious simplification.

Hope this helps.


A7 Commercial
First person submarine combat simulator project
http://alexanderforeman.webs.com/fightersubgame.htm
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1