0 registered members (),
1,280
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
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
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
ok I understand, similar to the procedural terrains like acropora, right?
|
|
|
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
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
Another possible example is to use the CONTACT* struct pointer, like this: WSAD - moving terrain
#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.
|
|
|
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
OP
Expert
|
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
JibbSmart
Expert
|
Expert
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
MrGuest
Serious User
|
Serious User
Joined: Jul 2008
Posts: 1,178
England
|
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
OP
Expert
|
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!
#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: MrGuest]
#384090
09/29/11 03:32
09/29/11 03:32
|
Joined: Mar 2006
Posts: 3,538 WA, Australia
JibbSmart
Expert
|
Expert
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
OP
Expert
|
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
|
|
|
|