0 registered members (),
1,251
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
D3DVERTEX Pointer help
#300033
11/29/09 04:20
11/29/09 04:20
|
Joined: Jan 2009
Posts: 34
DrunkenPirate
OP
Newbie
|
OP
Newbie
Joined: Jan 2009
Posts: 34
|
Hello, I have searched the forums and read all the documentation but I'm still having trouble figuring out the D3DVERTEX pointer in lite-c. I've attempted calling this code:
ENTITY* terrain = ent_create("maps/default.hmp",nullvector,NULL);
CONTACT* c = ent_getvertex(ent,NULL,1);
D3DVERTEX* vertexlst = ent_setvertex(ent,c,1);
...
debug_output = vertexlst[2].x;
But every time vertexlst[2].x returns a 0. vertexlst[1] always returns the right value but its the only thing in the array. I'm guessing it's because i'm just grabbing '1' of the mesh when I call ent_getvertex. Should I loop through by calling "ent_status(terrain,1)" to get the total vertices's and create my own array? E.G...
vert = ent_status(terrain,1);
for (a=0;a < vert;a++) {
CONTACT* c = ent_getvertex(ent,NULL,a);
D3DVERTEX* verttmp = ent_setvertex(ent,c,a);
vertlst[a] = verttmp[1];
}
Or am I just doing something wrong?
|
|
|
Re: D3DVERTEX Pointer help
[Re: Spirit]
#300125
11/29/09 23:09
11/29/09 23:09
|
Joined: Jan 2009
Posts: 34
DrunkenPirate
OP
Newbie
|
OP
Newbie
Joined: Jan 2009
Posts: 34
|
Thank you! I misunderstood the manual. EDIT: Okay, I believe I have it working for anyone that needs it:
VECTOR* pos = nullvector;
D3DVERTEX* vertlst;
CONTACT* c_tmp = ent_getvertex(terrain,NULL,1);
CONTACT* c = ent_setvertex(terrain,c_tmp,1);
vertlst = c.v;
var a, maxVert = ent_status(terrain,1);
while(1) {
for (a=0;a < maxVert;a++) {
vec_set(pos,vector(vertlst[a].x,vertlst[a].z,vertlst[a].y));
draw_point3d(pos.x,vector(50,255,50),100,1);
}
wait(1);
}
I noticed a typo in the manual I think. It says to swap x,y coordinates when converting d3dvertex positions to engine positions but it is in fact the y,z coordinates that need to be swapped.
Last edited by DrunkenPirate; 11/30/09 00:06.
|
|
|
|