Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by vicknick. 06/13/24 08:51
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,280 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19059 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 11 1 2 3 4 10 11
Re: Dumb terrain question.. Cannot get it to move... [Re: EvilSOB] #383990
09/27/11 21:35
09/27/11 21:35
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
ok I understand, similar to the procedural terrains like acropora, right?


Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: Dumb terrain question.. Cannot get it to move... [Re: rojart] #383996
09/27/11 22:39
09/27/11 22:39
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
maybe a stupid question (they usually are) why are you trying to move the terrain and not just placing it where it's required on its creation?

Re: Dumb terrain question.. Cannot get it to move... [Re: MrGuest] #383998
09/27/11 23:51
09/27/11 23:51
Joined: Oct 2004
Posts: 900
Lgh
rojart Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Another possible example is to use the CONTACT* struct pointer, like this:

WSAD - moving terrain

Code:
#include <default.c>

function main()
{
   d3d_lines = 3; level_load("");
	
   vec_set(camera.x,vector(-150,0,100));
   vec_set(camera.pan,vector(0,-30,0));
	
   ENTITY* terrain = ent_createterrain(NULL,nullvector,10,10,10);
   ent_setskin(terrain, bmap_fill(bmap_createblack(32,32,16),COLOR_WHITE,100), 1);
	
   you = ent_create(SPHERE_MDL,nullvector,NULL); vec_scale (you.scale_x, 2);
   ent_setskin(you, bmap_fill(bmap_createblack(32,32,16),COLOR_GREEN,100), 1);
	
   while(1){
      int i = ent_status(terrain,0);
      for (; i>0; i--) { 
         CONTACT* c = ent_getvertex(terrain,NULL,i);
         c.v.x += 10 * (key_w - key_s) * time_frame;
         c.v.z += 10 * (key_a - key_d) * time_frame; // Y = Z (DX coordinate system)
         ent_setvertex(terrain,c,i); 
      }
   c_setminmax(terrain);
   wait(1);
   }
}



Last edited by rojart; 09/27/11 23:58.

Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: Dumb terrain question.. Cannot get it to move... [Re: rojart] #384020
09/28/11 10:12
09/28/11 10:12
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
rojart: Yeah, much like that, but generated on-the fly inside the engine.
Each time an entiry/terrain "slab" is moved, I re-generate its vertex
height-maps to match its new locations. (and stitch it to its neibours)

MrGuest: Not so stupid, so think of it like this.
I want to cross a HUGE patch of muddy ground, and Im carrying a couple of planks.
I put one plank down, and walk along it, then I put the other plank down.
Once I step onto it, I pick up the first plank, and carry it to the end of the plank Im now on.
I then put the plank Im carrying down and step onto it, and pick up the other plank.
I now walk to the end of plank Im on and put the plank Im carrying down, ETC.
So you see I can cover a large patch of ground with only two planks.
Thats why I want to recyle my terrains(planks), because if I just keep
creating then destroying terrains, I rapidly run out of (nexus?)memory.

rojart: Nice idea, but no good. See my previous reply to progger...




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Dumb terrain question.. Cannot get it to move... [Re: EvilSOB] #384036
09/28/11 15:26
09/28/11 15:26
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
If you are creating and destroying the same terrains, I doubt it'd be consuming more memory with each creation.


Formerly known as JulzMighty.
I made KarBOOM!
Re: Dumb terrain question.. Cannot get it to move... [Re: JibbSmart] #384040
09/28/11 16:03
09/28/11 16:03
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Originally Posted By: JibbSmart
If you are creating and destroying the same terrains, I doubt it'd be consuming more memory with each creation.
that's what I was thinking, plus the advantage of creating them dynamically would be to allow for a higher number of variances without making all the terrains depending on where the player goes.

this method of reusing and recycling them now seems somewhat redundant and you may aswell make them only once when the game is loaded?

Re: Dumb terrain question.. Cannot get it to move... [Re: MrGuest] #384058
09/28/11 19:13
09/28/11 19:13
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Jibb and Mister... Thats what I USED to think, its logical right?

But NOOOO, its not!

After much discussion with JCL, this is NOT a bug, its just the way things are.

Admittedly we were disussing entities rather than terrain, so I assumed the same.

So I just did a test, to prove the point.

Run this following stand-alone script (A8 only of course), and open your
windows task manager, and watch every byte of memory get (not so) slowly consumed!

Click to reveal..
Code:
#include <acknex.h>
#include <default.c>
//
//
void main()
{
  	wait(1);	level_load(NULL);	wait(1);
	ENTITY* terr = NULL;			var count=0, x;
	BMAP* fake = bmap_createblack(128,128,24);
	//
	while(1)	
	{
		for(x=0; x<10; x++)
		{
			if(!terr)
			{	terr = ent_createterrain(fake, vector(1000,0,0), 128,128,5);
				/*ent_clone(terr);*/			count++;									}	
			else			
			{	ent_remove(terr);		terr = NULL;									}
		}
		//
		draw_text("created/removed = ", 100, 100, COLOR_WHITE);	draw_text(str_for_int(NULL, count), 250, 100, COLOR_WHITE);
		draw_text("nexus = ", 100, 130, COLOR_WHITE);				draw_text(str_for_int(NULL, nexus), 200, 130, COLOR_WHITE);
		draw_text("sys_memory = ", 100, 160, COLOR_WHITE);			draw_text(str_for_int(NULL, sys_memory), 250, 160, COLOR_WHITE);

		wait(1);
	}
}



I dont understand your final statement MrGuest? If I cant MOVE terrains, I CANT re-use them...


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Dumb terrain question.. Cannot get it to move... [Re: EvilSOB] #384067
09/28/11 21:07
09/28/11 21:07
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
I was thinking along the lines of if you're placing them dynamically, you'll only need to do so once for preventing duplication. therefore you'll place them only once without moving them.

Having them created dynamically allows for a greater variation of terrain so I don't get why you'll want to reuse them again and again.


Your example shows a problem with ent_remove for the dynamic terrain, the same test without removing the terrain shows the same memory usage.

Re: Dumb terrain question.. Cannot get it to move... [Re: MrGuest] #384090
09/29/11 03:32
09/29/11 03:32
Joined: Mar 2006
Posts: 3,538
WA, Australia
J
JibbSmart Offline
Expert
JibbSmart  Offline
Expert
J

Joined: Mar 2006
Posts: 3,538
WA, Australia
Have you tried an ent_purge before you ent_remove it?


Formerly known as JulzMighty.
I made KarBOOM!
Re: Dumb terrain question.. Cannot get it to move... [Re: JibbSmart] #384095
09/29/11 07:48
09/29/11 07:48
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline OP
Expert
EvilSOB  Offline OP
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Jibb: ent_purge makes no significant change.

MrGuest: My expample was meant to show that creating a terrain and deleting it
later does NOT release all its used memory. And that is their limitation.
Youve got to realise that the plan is to have a never-ending world,
so that means that level_load never gets used, except when entering or leaving the world.
And the terrains Im creating are FLAT and I apply my own height-map to the vertices
during run time. And when the terrain is too far away to be seen, it gets put
into 'limbo' as a spare. When it gets pulled out of limbo for re-use,
it gets a DIFFERENT height-map applied.
So Im not re-using the terrain SHAPE, just the entity itself.


"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Page 2 of 11 1 2 3 4 10 11

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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