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
2 registered members (AndrewAMD, Nymphodora), 1,592 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 5 1 2 3 4 5
Re: placing models on the terrain [Re: tindust] #170548
12/02/07 01:15
12/02/07 01:15
Joined: Mar 2005
Posts: 969
ch
Loopix Offline
User
Loopix  Offline
User

Joined: Mar 2005
Posts: 969
ch
"use_box" in c_trace will simply trace in a "thicker" ray(multiple rays) but still hit the terrains polygons and not it's bounding box...as long as my.polygon is set for the terrain.

In the MystyMood object placement I have the following setting (wich works quite well):
Code:
my.z -= c_trace (my.pos, temp, ignore_me + ignore_you + ignore_sprites + ignore_passable);  



Re: placing models on the terrain [Re: Loopix] #170549
12/02/07 01:22
12/02/07 01:22
Joined: Aug 2005
Posts: 312
Sweden
tindust Offline
Senior Member
tindust  Offline
Senior Member

Joined: Aug 2005
Posts: 312
Sweden
OK, that's good to know. I saw the info in the manual, but it didn't have those useful details.
thanks!
cheers

Last edited by tindust; 12/02/07 01:23.
Re: placing models on the terrain [Re: tindust] #170550
12/03/07 17:47
12/03/07 17:47
Joined: Aug 2005
Posts: 312
Sweden
tindust Offline
Senior Member
tindust  Offline
Senior Member

Joined: Aug 2005
Posts: 312
Sweden
OK Loopix, I did a few experiments with my altitude radar using c_trace with either USE_BOX or USE_POLYGON. Also found the info on the matter of a "thick" beam (USE_BOX). Got a few interesting results...
The setup used for the experiments is a freely movable user controlled player model that does vertical c_traces in a while loop in order to continuously keep track of its ground altitude (above terrain surface) and sea level (set to z = 0). Everyones passable is off.
When using my original tracing method (using USE_POLYGON) every other c_trace consistently gave result = null and every other c_trace gave a result >= 0. The null results were filtered out using this code snippet:
Code:
c_trace(trace vars, USE_POLYGON);
if(result){//use the result}



The altitude values (filtered results) were consistently 0 when the player model moved along the terrain surface, whereas the sea level altitude changed as expected when moving up the hills down the valleys etc.

Now, when using USE_BOX instead, every c_trace (unfiltered) gave a valid result as predicted and as you said but something odd happens with the result value in that it is fluctuating between -3 and -200 when the player model is moving along the surface of the terrain. Very odd. The result should never be negative if the actual terrain surface is the target of the scan. Somehow the "thick beam" scan does not seem to be accurate, or at least not as accurate as I need it to be.

JazzDude did you get yours to work?

Re: placing models on the terrain [Re: tindust] #170551
12/03/07 18:45
12/03/07 18:45
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
I tried variations of these two methods. Both place the model at 0 rather than on the terrain surface.

But I don't know what I'm doing anyway. Just experimenting.


temp.z -= 500; // trace downwards 500 quants below
result -= c_trace (my.pos,temp,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS|IGNORE_SPRITES|use_box);
my.z = result;


vec_set(temp, my.x);
temp.z -= 500; // trace downwards 500 quants below
target = c_trace (my.x,temp,IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS|IGNORE_SPRITES|use_box);
my.z = target;



Last edited by JazzDude; 12/03/07 19:01.
Re: placing models on the terrain [Re: JazzDude] #170552
12/03/07 19:35
12/03/07 19:35
Joined: Jan 2006
Posts: 968
EpsiloN Offline
User
EpsiloN  Offline
User

Joined: Jan 2006
Posts: 968
Its better to do a trace to determine where the terrain is exactly and after that move the ent downwards (not set its z value) because the collision detection will work and the ent will 'bump' at the terrain,exactly where it should be (possibly a little offseted in x/y if glide is set).
For finding a vertex (also calculating a z value on a certain point of the terrain) theres a solution. Store each vertexs x/y/z coordinates in an array. Check to see where the player is according to this array and you'll get the closest vertex , and can be used to get the closest 4 vertices wich make the polygon. Then , you have the z values of the 4 vertices , you can get the average z between them , and calculate at what z value an ent should be when its in this x/y spot.
Not tested , but it should work , and IMHO its worth a try.


Extensive Multiplayer tutorial:
http://mesetts.com/index.php?page=201
Re: placing models on the terrain [Re: EpsiloN] #170553
12/03/07 20:12
12/03/07 20:12
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Quote:

Its better to do a trace to determine where the terrain is exactly and after that move the ent downwards (not set its z value) because the collision detection will work and the ent will 'bump' at the terrain,exactly where it should be




I appreciate your input. Perhaps you could give me an example. I tried a dozen variations using that suggestion but the model never landed on the surface of the terrain.

I am just trying to set models like trees in a permanent vector--not the player.

My terrain is a model, not HMP, is that the problem?

Re: placing models on the terrain [Re: JazzDude] #170554
12/03/07 21:12
12/03/07 21:12
Joined: Sep 2006
Posts: 188
Latvia
MDI Offline
Member
MDI  Offline
Member

Joined: Sep 2006
Posts: 188
Latvia
First off alll!!! Model rendering time is longer then for terrain and second if you really want use this model putting on terrain you should take out "ignore_models" part then model really should land on this terrain model!

Heres code what im using:
///////////////////////////////////////////////////////////////////////////
function poligoni
{my.polygon = on;
}

function gravito
{
poligoni();
vec_set (temp, my.pos); // kopē modeļa vietu uz temp
temp.z -= 10000; // sagatavo temp.z 10000 zem spēlātāja oriģinālaš vietas
trace_mode = ignore_me + ignore_sprites + ignore_models + use_box; // ignorējam visu lai tikai tiktu uz zemes
my.z -= trace (my.pos, temp); //
}
///////////////////////////////////////////////////
And else in my case if you want model put on terrain nicely model center need be at bottom of model otherwise it sticks in terrain so deep till model center gets reached!

And if you also wishes nice angle for some bushes put this under "my.z -= trace (my.pos, temp);" line:
/////////////////////////////////////////////////
vec_to_angle (my.pan, normal); // un sakārtot to tieši pareizi


P.S. If you have more questions please sure ask!

Last edited by MDI; 12/03/07 21:15.

Latvija rullē
Re: placing models on the terrain [Re: MDI] #170555
12/03/07 22:00
12/03/07 22:00
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
Thanks, MDI. My model origins are on the bottom.

Code:
function village_func()
{
my.polygon = on;
vec_set (temp, my.pos);
temp.z -= 10000;
trace_mode = ignore_me + ignore_sprites + use_box;
my.z -= trace (my.pos, temp );
}
function sioux_camp()
{
temp.x = -96;
temp.y = -1164;
ent_create("tepee_village.mdl",temp,village_func);
}



That didn't produce an error, but it didn't work, either.
Since trace is old syntax, I changed it to this:
Code:
function village_func()
{
my.polygon = on;
vec_set (temp, my.pos);
temp.z -= 10000;
my.z -= c_trace (my.pos, temp, ignore_me + ignore_sprites + use_box );
}


and that didn't work.

Re: placing models on the terrain [Re: JazzDude] #170556
12/03/07 22:26
12/03/07 22:26
Joined: Sep 2003
Posts: 733
Whitefish, Montana
JazzDude Offline OP
User
JazzDude  Offline OP
User

Joined: Sep 2003
Posts: 733
Whitefish, Montana
And this version proves that the c_trace is working ...because it beeps.

Code:
function village_func()
{
my.polygon = on;
vec_set (temp, my.pos);
temp.z -= 1000;
result -= c_trace (my.pos, temp, ignore_me + ignore_sprites + use_box );
if(result){beep();
}
}

function sioux_camp()
{
temp.x = -96;
temp.y = -1164;
temp.z = result;
ent_create("tepee_village.mdl",temp,village_func);
}




But the village is then placed at 0, not on the terrain surface. That seems to indicate that c_trace is identifying 0 as the terrain surface. In this instance the surface is at z = 10.

I'm losing my mind.

placing models on the terrain [Re: JazzDude] #170557
12/03/07 22:48
12/03/07 22:48
Joined: Sep 2006
Posts: 188
Latvia
MDI Offline
Member
MDI  Offline
Member

Joined: Sep 2006
Posts: 188
Latvia
Hmm in main i think you should convert model in hmp format or make new terrain!
And that old sintax works really great too!
function village_func()
{
my.polygon = on;
vec_set (temp, my.pos);
temp.z -= 10000;
trace_mode = ignore_me + ignore_sprites + use_box;
my.z -= trace (my.pos, temp );
}
function sioux_camp()
{
ent_create("tepee_village.mdl",vector(-96,-1164,500),village_func);
}

More easy is give coordinates with vector!
/////////////////////////////////
but how im tried then collision with model is quit unprecise! Possible in some way can do normal collision with models too, but then i need do some experiments!

Last edited by MDI; 12/03/07 22:49.

Latvija rullē
Page 2 of 5 1 2 3 4 5

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