2 registered members (dr_panther, 1 invisible),
643
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
raise vertices of terrain
#437267
02/13/14 12:36
02/13/14 12:36
|
Joined: Dec 2003
Posts: 1,225 germany
gri
OP
Serious User
|
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 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: Superku]
#437271
02/13/14 13:13
02/13/14 13:13
|
Joined: Dec 2003
Posts: 1,225 germany
gri
OP
Serious User
|
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.
var vertex_num = ent_nextvertex(you,hit.x);
When using
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: Superku]
#437288
02/13/14 18:32
02/13/14 18:32
|
Joined: Dec 2003
Posts: 1,225 germany
gri
OP
Serious User
|
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
ENTITY* e = ent_create("terrain.hmp", vector(100,0,0),NULL);
now this code make the c_trace
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
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
Senior Expert
|
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
OP
Serious User
|
OP
Serious User
Joined: Dec 2003
Posts: 1,225
germany
|
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
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
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: Superku]
#437294
02/13/14 20:35
02/13/14 20:35
|
Joined: Sep 2003
Posts: 6,861 Kiel (Germany)
Superku
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
|
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
OP
Serious User
|
OP
Serious User
Joined: Dec 2003
Posts: 1,225
germany
|
hey Superku, youre right ! It works when I call c_updatehull after creating.
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)
|
|
|
|