Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (7th_zorro, degenerate_762, AndrewAMD, ozgur), 774 guests, and 0 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 1 of 2 1 2
c_trace problem #399792
04/20/12 08:56
04/20/12 08:56
Joined: Oct 2005
Posts: 57
P
picoder Offline OP
Junior Member
picoder  Offline OP
Junior Member
P

Joined: Oct 2005
Posts: 57
If I change position of a model immediately before tracing, c_trace checks this model according to previous position.

I changed small.c in samples folder for test:
Code:
function main()
{
	level_load("small.hmp"); 
	vec_set(camera.x,nullvector);
	vec_set(camera.pan,nullvector);
	ENTITY* target_ent = ent_create("earth.mdl", vector(0,0,1000), NULL);

	wait(-2);
	vec_set(target_ent.x,vector(100,0,0));

	//if target position bigger than 982, it works.
	c_trace(camera.x,vector(982,0,0),IGNORE_PASSABLE); 
	if (HIT_TARGET)
	{
		if(you==target_ent){beep();}
	}
}



Re: c_trace problem [Re: picoder] #399797
04/20/12 10:19
04/20/12 10:19
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
This is no bug. You need to use c_move to update the position of the collision hull or wait until the end of the frame, then the hull will be updated automatically. You can set f.i. IGNORE_PASSABLE | IGNORE_MODELS | IGNORE_WORLD as the c_move mode, but when you set IGNORE_SPRITES, too (so all possible objects get ignored), then I think the hull won't get updated.

@jcl: I would like to see a function to update the collision hull manually so we don't have to use c_move for this purpose. A moving platform usually does not need collision detection, but its hull has to be updated before the end of the frame so the position/ height of the objects does not lag one frame behind.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: c_trace problem [Re: Superku] #399801
04/20/12 11:39
04/20/12 11:39
Joined: Oct 2005
Posts: 57
P
picoder Offline OP
Junior Member
picoder  Offline OP
Junior Member
P

Joined: Oct 2005
Posts: 57
You can immediately update collision hull (without polygon flag) by model position.

I didn't use c_move in test code but If I increase trace distance, c_trace can hit the target.
Code:
c_trace(camera.x,vector(990,0,0),IGNORE_PASSABLE);


If I need wait until the end of the frame, how does trace hit the target in the above code?





Re: c_trace problem [Re: picoder] #399802
04/20/12 11:53
04/20/12 11:53
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Quote:
You can immediately update collision hull (without polygon flag) by model position.

How do I do that?

EDIT: This should prove all my points:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
///////////////////////////////


void main()
{
	fps_max = 60;
	level_load(NULL);
	player = ent_create(CUBE_MDL,vector(100,50,0),NULL);
	while(1)
	{
		if(key_space) c_move(player,nullvector,vector(0,-100,0),IGNORE_PASSABLE | IGNORE_WORLD | IGNORE_MODELS);
		else player.y = -50;
		c_trace(vector(0,-50,0),vector(200,-50,0),IGNORE_PASSABLE | USE_POLYGON); 
		if(trace_hit) beep();
		if(key_space) c_move(player,nullvector,vector(0,100,0),IGNORE_PASSABLE | IGNORE_WORLD | IGNORE_MODELS);
		else player.y = 50;
		wait(1);
	}
}



Last edited by Superku; 04/20/12 12:02.

"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: c_trace problem [Re: Superku] #399803
04/20/12 12:07
04/20/12 12:07
Joined: Oct 2005
Posts: 57
P
picoder Offline OP
Junior Member
picoder  Offline OP
Junior Member
P

Joined: Oct 2005
Posts: 57
You don't need anything. Please test my sample code.

Code:
function main()
{
	level_load("small.hmp"); 
	vec_set(camera.x,nullvector);
	vec_set(camera.pan,nullvector);
	ENTITY* target_ent = ent_create("earth.mdl", vector(0,0,1000), NULL);

	wait(-2);
	vec_set(target_ent.x,vector(100,0,0));

	//if target position bigger than 982, it works.
	c_trace(camera.x,vector(990,0,0),IGNORE_PASSABLE); 
	if (HIT_TARGET)
	{
		if(you==target_ent){beep();}
	}
}



Edit: If POLYGON flag of your target model is set or there is USE_POLYGON flag in c_trace, you're right. But my problem is different, it's about non-polygonal models.

Last edited by picoder; 04/20/12 12:19.
Re: c_trace problem [Re: picoder] #399811
04/20/12 14:22
04/20/12 14:22
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
This is not a bug - use c_updatehull when you need to update the collision hull.

Re: c_trace problem [Re: jcl] #399813
04/20/12 14:30
04/20/12 14:30
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
There has to be a function that updates the position of the collision mesh at the end of each frame automatically that the engine uses internally (or the mesh's position gets set directly, I don't know). Could you make this function accessible in lite-C (so we can avoid unnecessary c_move calls)?


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: c_trace problem [Re: jcl] #399814
04/20/12 14:31
04/20/12 14:31
Joined: Oct 2005
Posts: 57
P
picoder Offline OP
Junior Member
picoder  Offline OP
Junior Member
P

Joined: Oct 2005
Posts: 57
c_updatehull is very slow because it needs to reload the vertices of the model. But we just want to update position/rotations of collision hull. (especially for polygonal models) We don't want to change collision hull size or shape.

Re: c_trace problem [Re: jcl] #399815
04/20/12 14:42
04/20/12 14:42
Joined: Oct 2005
Posts: 57
P
picoder Offline OP
Junior Member
picoder  Offline OP
Junior Member
P

Joined: Oct 2005
Posts: 57
Originally Posted By: jcl
This is not a bug - use c_updatehull when you need to update the collision hull.


If I need use c_updatehull, how does trace hit the target in below code? (without c_updatehull or c_move)

Code:
function main()
{
	level_load("small.hmp"); 
	vec_set(camera.x,nullvector);
	vec_set(camera.pan,nullvector);
	ENTITY* target_ent = ent_create("earth.mdl", vector(0,0,1000), NULL);

	wait(-2);
	vec_set(target_ent.x,vector(100,0,0));

	//if target position bigger than 982, it works.
	c_trace(camera.x,vector(990,0,0),IGNORE_PASSABLE); 
	if (HIT_TARGET)
	{
		if(you==target_ent){beep();}
	}
}



Re: c_trace problem [Re: picoder] #399905
04/23/12 06:38
04/23/12 06:38
Joined: Jul 2000
Posts: 27,986
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,986
Frankfurt
Superku: Use c_updatehull for this. It's slow because it sorts the entitys' bounding box in the collision tree. But if you don't do it in the script, it's done at the end of the frame anyway. The only difference is that with c_updatehull you can determine the frame for the bounding box.

However, normally you can avoid such a situation anyway by proper coding, f.i. tracing an object before and not after displacing it.

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