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 (dr_panther, 1 invisible), 643 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
raise vertices of terrain #437267
02/13/14 12:36
02/13/14 12:36
Joined: Dec 2003
Posts: 1,225
germany
gri Offline OP
Serious User
gri  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,225
germany
hi,

c_trace and ent_setvertex() works nice on a single terrain, created at nullvector position.

But as I ent_create() a terrain 100 quants ahead in y direction, only the very first vertex got raised correctly and after that between the traced vertices and the raised ones exists an offset in y direction.

So I convertet the world/entity coords with vec_for_ent(hit.x,you); and have now the effect that the very first hidden vertex is wrong, but all the following are correct now grin
complete opposite then before.

Without big code - does someone know this behaivior ?


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Re: raise vertices of terrain [Re: gri] #437268
02/13/14 12:42
02/13/14 12:42
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Can you please try to explain the problem again, if necessary in German (sorry non-German-speakers)?

Where is the problem, c_trace not hitting raised vertices or ent_setvertex not working correctly? If the latter is the issue remember there are two ways to do this, either with v.z or v.v.z (or whatever the DirectX vertex struct is called there).


"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: raise vertices of terrain [Re: Superku] #437271
02/13/14 13:13
02/13/14 13:13
Joined: Dec 2003
Posts: 1,225
germany
gri Offline OP
Serious User
gri  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,225
germany
I trace by mousemovement over a whole terrain.

tracing works correct - it hit the traced terrain... I set an entity at this position.

But the hit vertexnumber is wrong.
Code:
var vertex_num = ent_nextvertex(you,hit.x);



When using

Code:
vec_for_ent(hit.x,you);        
var vertex_num = ent_nextvertex(you,hit.x);


the vertexnumber is correct - except the very first hit vertex.

As I said, the terrain is created 100 quants ahead.


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Re: raise vertices of terrain [Re: gri] #437274
02/13/14 15:16
02/13/14 15:16
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
I assume hit.vertex does not work with chunked terrain?
Have you tried calling c_updatehull (before first trace)?


"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: raise vertices of terrain [Re: Superku] #437288
02/13/14 18:32
02/13/14 18:32
Joined: Dec 2003
Posts: 1,225
germany
gri Offline OP
Serious User
gri  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,225
germany

Terrain is a single one and unchuncked.
But its createt not at nullposition, its 100 quants ahead
Code:
ENTITY* e = ent_create("terrain.hmp", vector(100,0,0),NULL);



now this code make the c_trace

Code:
if(mouse_right)
  {	   	
  
  	if(c_trace(from.x,to.x,IGNORE_PASSABLE|SCAN_TEXTURE)>0) // trace from camera into the world
  	{
  	  if(HIT_TARGET)	
  		{
  		  
  		 if((hitx!=hit.x)||(hity!=hit.y))  // hitposition changed since the last frame? 
  		   {
   		 // visualize the hitpoint
   		 if(arrow!=NULL){arrow.lifespan=0;}   		 
   		 BMAP* bm = bmap_create("down.bmp");
   		 arrow = ent_decal(you,bm,5,0);  		 
   		 vec_set(arrow.skill_x,normal.x);
   		 
   		 // backup the actual hitposition
   		 hitx=hit.x;
  		 hity=hit.y; 
  		    
  		 // raise the vertex
  		 vec_for_ent(hit.x,you);  // change world - entity coords    
                 var vertex_num = ent_nextvertex(you,hit.x);
  		 CONTACT* c = ent_getvertex(you,NULL,vertex_num);
                 c.v.y += 1;  // increase the vertex height
                 ent_setvertex(you,c,vertex_num);    // update the mesh	
  			
        }
      }  		
   }  	
  }



this makes the very first shot hit the terrain at a certain point BUT the raised vertex is an other!

all the following shots raises the correct vertices and works like it should.



if I comment out the line
Code:
vec_for_ent(hit.x,you);  // change world - entity coords



so I get the complete opposite behaivior.

The very first shot raises the correct vertex but all following traces raises diffrent vertices with an offset distance.


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Re: raise vertices of terrain [Re: gri] #437289
02/13/14 18:45
02/13/14 18:45
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Terrain is always chunked in A8 and thus normally in world coordinates if I'm not mistaken.
Again, three things:
Checked hit.vertex?
Tried c.z += 1; instead?
(c_updatehull for whatever reason?)

Additionally:
Have you checked the vertex number (displayed)?
You could try to calculate the vertex number manually, I think, should the previous be the problem.
EDIT: You could try to offset the hit position by the negative terrain creation position (terrain.xyz may always be 000, not sure but take care) and grab the closest vertex after that.

You can post a short and simple test project if you like to.

Last edited by Superku; 02/13/14 18:49.

"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: raise vertices of terrain [Re: Superku] #437291
02/13/14 19:39
02/13/14 19:39
Joined: Dec 2003
Posts: 1,225
germany
gri Offline OP
Serious User
gri  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,225
germany
Quote:
You could try to offset the hit position by the negative terrain creation position (terrain.xyz may always be 000, not sure but take care) and grab the closest vertex after that.


yes sure.

I think the
Code:
vec_for_ent(hit.x,you);  // change world - entity coords

should handle this shiftet position of the terrain.

And it works with that like it should but not at the first shot.

Something must happen after the first fail contact.
c.z leads to the same result.

its
Code:
ent_nextvertex(you,hit.x);

that delivers the false vertex number at first shot.

I reduced the code and load an example up... one moment


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Re: raise vertices of terrain [Re: gri] #437292
02/13/14 19:42
02/13/14 19:42
Joined: Dec 2003
Posts: 1,225
germany
gri Offline OP
Serious User
gri  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,225
germany


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Re: raise vertices of terrain [Re: Superku] #437294
02/13/14 20:35
02/13/14 20:35
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Originally Posted By: Superku
Have you tried calling c_updatehull (before first trace)?
...
(c_updatehull for whatever reason?)

Obviously you didn't try it...

EDIT: And hit.vertex alone works for me, too, no ent_nextvertex, no c_updatehull. I don't understand why you wouldn't test this...

Last edited by Superku; 02/13/14 20:39.

"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: raise vertices of terrain [Re: Superku] #437320
02/14/14 07:14
02/14/14 07:14
Joined: Dec 2003
Posts: 1,225
germany
gri Offline OP
Serious User
gri  Offline OP
Serious User

Joined: Dec 2003
Posts: 1,225
germany

hey Superku,

youre right ! It works when I call c_updatehull after creating.

Code:
ENTITY* e = ent_create("terrain.hmp", vector(100,0,0),NULL);
        set(e,POLYGON);
        c_updatehull(e,0);



I thought on object creation the engine does an intern c_updatehull.

Seems not to be. Wow! it works now.

Thank you Superku for your time and the golden hint.


"Make a great game or kill it early" (Bruce Shelley, Ensemble Studios)
Page 1 of 2 1 2

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