0 registered members (),
728
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
replacing a mesh
#342595
09/29/10 15:56
09/29/10 15:56
|
Joined: May 2002
Posts: 7,441
ventilator
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2002
Posts: 7,441
|
i would like to replace a mesh with a new mesh (a simple triangle in my example) but can't get it working. in all my tries the triangle either doesn't show up at all or is huge and garbled. what am i doing wrong? it's the first time i use a8 and i haven't looked into this mesh stuff for a long time.
#include <acknex.h>
#include <default.c>
#include <stdio.h>
#include <d3d9.h>
void create_mesh(ENTITY *entity)
{
printf("%d", (long)ent_status(entity, 1));
int num_faces = 1;
int num_vertices = 3;
D3DVERTEX pvb[3];
WORD pib[3];
DWORD pab[1];
pvb[0].x = 0.0;
pvb[0].y = 0.0;
pvb[0].z = -8.0;
pvb[0].nx = 0.0;
pvb[0].ny = 0.0;
pvb[0].nz = 1.0;
pvb[0].u1 = 0.0;
pvb[0].v1 = 0.0;
pvb[0].u2 = 0.0;
pvb[0].v2 = 0.0;
pvb[0].x3 = 0.0;
pvb[0].y3 = 0.0;
pvb[0].z3 = 0.0;
pvb[0].w3 = 0.0;
pvb[0].tu4 = 0.0;
pvb[0].tv4 = 0.0;
pvb[1].x = 8.0;
pvb[1].y = 0.0;
pvb[1].z = -8.0;
pvb[1].nx = 0.0;
pvb[1].ny = 0.0;
pvb[1].nz = 1.0;
pvb[1].u1 = 0.0;
pvb[1].v1 = 0.0;
pvb[1].u2 = 0.0;
pvb[1].v2 = 0.0;
pvb[1].x3 = 0.0;
pvb[1].y3 = 0.0;
pvb[1].z3 = 0.0;
pvb[1].w3 = 0.0;
pvb[1].tu4 = 0.0;
pvb[1].tv4 = 0.0;
pvb[2].x = 0.0;
pvb[2].y = 8.0;
pvb[2].z = -8.0;
pvb[2].nx = 0.0;
pvb[2].ny = 0.0;
pvb[2].nz = 1.0;
pvb[2].u1 = 0.0;
pvb[2].v1 = 0.0;
pvb[2].u2 = 0.0;
pvb[2].v2 = 0.0;
pvb[2].x3 = 0.0;
pvb[2].y3 = 0.0;
pvb[2].z3 = 0.0;
pvb[2].w3 = 0.0;
pvb[2].tu4 = 0.0;
pvb[2].tv4 = 0.0;
pib[0] = 0;
pib[1] = 1;
pib[2] = 2;
pab[0] = 0;
LPD3DXMESH pmesh;
D3DXCreateMeshFVF(num_faces, num_vertices, D3DXMESH_MANAGED, D3DFVF_D3DVERTEX, (LPDIRECT3DDEVICE9)pd3ddev, &pmesh);
D3DVERTEX *pnewvb; pmesh->LockVertexBuffer(0, (void**)&pnewvb);
WORD *pnewib; pmesh->LockIndexBuffer(0, (void**)&pnewib);
DWORD *pnewab; pmesh->LockAttributeBuffer(0, &pnewab);
memcpy(pnewvb, pvb, sizeof(D3DVERTEX) * num_vertices);
memcpy(pnewib, pib, sizeof(WORD) * num_faces * 3);
memcpy(pnewab, pab, sizeof(DWORD) * num_faces);
pmesh->UnlockVertexBuffer();
pmesh->UnlockIndexBuffer();
pmesh->UnlockAttributeBuffer();
ent_setmesh(entity, pmesh, 0, 0);
printf("%d", (long)ent_status(entity, 1));
}
void initialize()
{
you = ent_create(CUBE_MDL, vector(0, 0, 0), NULL);
set(you, FLAG8);
ent_clone(you);
create_mesh(you);
}
void main()
{
video_mode = 10;
level_load("");
initialize();
}
|
|
|
Re: replacing a mesh
[Re: ventilator]
#342616
09/29/10 17:37
09/29/10 17:37
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Sorry dude, I cant SEE anything 'wrong' in the code...
I tried in A7 (with .tu4 & .tv4 commented out) and it works a treat.
I tried in A8 (with .tu4 & .tv4 both commented out and back in), and it crashes out in either case....
FYI : Tried with A7 comm, and A8 free. Both on the same 'junky' machine.
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: replacing a mesh
[Re: ventilator]
#342627
09/29/10 18:17
09/29/10 18:17
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
FYI :: My 3D-Panel contribution doesnt work in A8 either, but it HEAVILY uses target_map too. And I believe that target_map is commercial or higher only, and I only have A8-free...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Re: replacing a mesh
[Re: EvilSOB]
#342669
09/29/10 22:18
09/29/10 22:18
|
Joined: Sep 2003
Posts: 5,900 Bielefeld, Germany
Pappenheimer
Senior Expert
|
Senior Expert
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
|
Tested both with A8.02 Pro: ventilator's code gives a printf 8, and after ok, a printf 3, but I don't see anything. EvilSOB's 3D-Panel contribution runs without problems, although I'm not sure whether all buttons are doing what they are supposed to do.
Last edited by Pappenheimer; 09/29/10 22:32.
|
|
|
Re: replacing a mesh
[Re: Pappenheimer]
#342705
09/30/10 09:30
09/30/10 09:30
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
I think my buttons behaving oddly was I known issue in A8. Good to know all mesh-related stuff works "OK" A8.
Thanks dude...
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
|