6 registered members (AndrewAMD, Ayumi, degenerate_762, 7th_zorro, VoroneTZ, HoopyDerFrood),
1,268
guests, and 6
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: How to create 3D mesh?
[Re: Andre_Fernando]
#355435
01/26/11 21:55
01/26/11 21:55
|
Joined: Apr 2005
Posts: 4,506 Germany
fogman
Expert
|
Expert
Joined: Apr 2005
Posts: 4,506
Germany
|
I can´t give you any advice, because I´m just fiddling around, too. But I can give you a hint: Do a forum search for LPD3DXMESH (without date range).
no science involved
|
|
|
Re: How to create 3D mesh?
[Re: Pappenheimer]
#355554
01/27/11 21:14
01/27/11 21:14
|
Joined: Apr 2005
Posts: 4,506 Germany
fogman
Expert
|
Expert
Joined: Apr 2005
Posts: 4,506
Germany
|
Yes, exactly. You should search your way through msdn also: http://msdn.microsoft.com/en-us/library/bb174069(v=vs.85).aspx
no science involved
|
|
|
Re: How to create 3D mesh?
[Re: Andre_Fernando]
#356087
01/30/11 21:00
01/30/11 21:00
|
Joined: Oct 2004
Posts: 900 Lgh
rojart
User
|
User
Joined: Oct 2004
Posts: 900
Lgh
|
Here is an example that shows you step by step how it works, maybe it helps.
#include <default.c>
#include <d3d9.h>
#define NVB 9 // Vertices
#define NIB 42 // Indexes
#define NAB 14 // Attributes
LPD3DXMESH pMesh;
D3DVERTEX pvb[NVB];
short pib[NIB];
long pab[NAB];
ENTITY* ent;
MATERIAL* m2sided ={effect="technique TS{pass p0{CullMode=1;}}";}
function recreate_mesh(ENTITY *entity)
{
//printf("Total number of mesh vertices = %d", (long)ent_status(entity, 1));
int num_triangles = NAB;
int num_vertices = NVB;
// Vertices
pvb[0].x = -8;pvb[0].y = 8;pvb[0].z = -8; // 1
pvb[1].x = 8;pvb[1].y = 8;pvb[1].z = -8; // 2
pvb[2].x = 8;pvb[2].y = 8;pvb[2].z = 8; // 3
pvb[3].x = -8;pvb[3].y = 8;pvb[3].z = 8; // 4
pvb[4].x = -8;pvb[4].y = -8;pvb[4].z = -8; // 5
pvb[5].x = 8;pvb[5].y = -8;pvb[5].z = -8; // 6
pvb[6].x = 8;pvb[6].y = -8;pvb[6].z = 8; // 7
pvb[7].x = -8;pvb[7].y = -8;pvb[7].z = 8; // 8
pvb[8].x = 0;pvb[8].y = 32;pvb[8].z = 0; // 9
// Triangles / Attributes
pib[ 0] = 6;pib[ 1] = 2;pib[ 2] = 7; pab[ 0] = 0;
pib[ 3] = 3;pib[ 4] = 7;pib[ 5] = 2; pab[ 1] = 1;
pib[ 6] = 7;pib[ 7] = 3;pib[ 8] = 4; pab[ 2] = 2;
pib[ 9] = 0;pib[10] = 4;pib[11] = 3; pab[ 3] = 0;
pib[12] = 4;pib[13] = 0;pib[14] = 5; pab[ 4] = 1;
pib[15] = 1;pib[16] = 5;pib[17] = 0; pab[ 5] = 2;
pib[18] = 5;pib[19] = 1;pib[20] = 6; pab[ 6] = 0;
pib[21] = 2;pib[22] = 6;pib[23] = 1; pab[ 7] = 1;
pib[24] = 7;pib[25] = 4;pib[26] = 6; pab[ 8] = 2;
pib[27] = 5;pib[28] = 6;pib[29] = 4; pab[ 9] = 0;
pib[30] = 3;pib[31] = 8;pib[32] = 0; pab[10] = 1;
pib[33] = 2;pib[34] = 8;pib[35] = 3; pab[11] = 2;
pib[36] = 1;pib[37] = 8;pib[38] = 2; pab[12] = 0;
pib[39] = 0;pib[40] = 8;pib[41] = 1; pab[13] = 1;
D3DXCreateMesh(num_triangles, num_vertices, D3DXMESH_MANAGED , pvertexdecl, pd3ddev, &pMesh);
D3DVERTEX *pnewvb; pMesh->LockVertexBuffer(0, (void**)&pnewvb);
short *pnewib; pMesh->LockIndexBuffer(0, (void**)&pnewib);
long *pnewab; pMesh->LockAttributeBuffer(0, &pnewab);
memcpy(pnewvb, pvb, num_vertices*ent_status(entity,22));
memcpy(pnewib, pib, num_triangles*3*sizeof(short));
memcpy(pnewab, pab, num_triangles*sizeof(long));
pMesh->UnlockVertexBuffer();
pMesh->UnlockIndexBuffer();
pMesh->UnlockAttributeBuffer();
//int entBuffer = ent_buffers(entity,0,0,&pnewvb,&pnewib,&pnewab);
//printf("Number of triangles of the mesh = %i", entBuffer);
ent_setmesh(entity, pMesh, 0, 0);
//printf("ent_setmesh(entity, pMesh, 0, 0);");
//int entBuffer = ent_buffers(entity,0,0,&pnewvb,&pnewib,&pnewab);
//printf("Number of triangles of the mesh = %i", entBuffer);
//printf("Total number of mesh vertices = %d", (long)ent_status(entity, 1));
}
function create_mesh()
{
ent = ent_create(CUBE_MDL, 0, 0);
ent_setskin(ent, bmap_fill(bmap_createblack(32,32,16),COLOR_RED,100), 1);
ent_setskin(ent, bmap_fill(bmap_createblack(32,32,16),COLOR_GREEN,100), 2);
ent_setskin(ent, bmap_fill(bmap_createblack(32,32,16),COLOR_BLUE,100), 3);
set(ent, LIGHT);
ent.material = m2sided;
//printf("Total number of model skins = %d", (long)ent_status(ent, 8));
ent_clone(ent);
recreate_mesh(ent);
wait_for(recreate_mesh);
ent_getvertex(ent,NULL,ent_status(ent,0));
c_setminmax(ent);
//printf("Total number of model skins = %d", (long)ent_status(ent, 8));
}
function main()
{
vec_set(sky_color,COLOR_BLACK);
level_load("");
vec_set(camera.x,vector(-100,0,10));
create_mesh();
wait_for(create_mesh);
//printf("Total number of mesh vertices = %d", (long)ent_status(ent, 1));
while(1){
ent.pan += 3*time_step;
wait(1);
}
}
function on_esc_event()
{
pMesh = ent_getmesh(ent,0,0);
pMesh->Release();
ent_setmesh(ent,NULL,0,0);wait(1);
sys_exit("");
}
|
|
|
Re: How to create 3D mesh?
[Re: 3run]
#356982
02/04/11 22:03
02/04/11 22:03
|
Joined: Oct 2007
Posts: 5,210 Ä°stanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,210
Ä°stanbul, Turkey
|
yes actually it's pretty easy check min_x,y,z and max_x,y,z
3333333333
|
|
|
|