Gamestudio Links
Zorro Links
Newest Posts
Help with plotting multiple ZigZag
by degenerate_762. 04/30/24 23:23
M1 Oversampling
by 11honza11. 04/30/24 08:16
Trading Journey
by howardR. 04/28/24 09:55
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 950 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
How to create 3D mesh? #355335
01/26/11 16:38
01/26/11 16:38
Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Andre_Fernando Offline OP
Newbie
Andre_Fernando  Offline OP
Newbie

Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Hello guys, I'm developing a project there any time and I did want understand how do I do to create a simple cube with the Directx 9. I know to program in Lite-C, but I don't know nothing of Directx 9. Can somebody teach me step by step how work the process of the creation of 3D mesh?

Thanks.

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
F
fogman Offline
Expert
fogman  Offline
Expert
F

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: fogman] #355535
01/27/11 19:16
01/27/11 19:16
Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Andre_Fernando Offline OP
Newbie
Andre_Fernando  Offline OP
Newbie

Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Right, I'm going to search. But what is "LPD3DXMESH"? Is it an important command of Directx?

Re: How to create 3D mesh? [Re: Andre_Fernando] #355536
01/27/11 19:22
01/27/11 19:22
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany

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
F
fogman Offline
Expert
fogman  Offline
Expert
F

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: fogman] #355868
01/29/11 16:36
01/29/11 16:36
Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Andre_Fernando Offline OP
Newbie
Andre_Fernando  Offline OP
Newbie

Joined: Dec 2010
Posts: 16
Brazil, Limeira, SP
Thanks Pappenheimer, I'm studying the code of link you passed for me. It's hard, but I'm going to try.

fogman: Understood, thanks for help! Directx is don't easy. grin

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 Offline
User
rojart  Offline
User

Joined: Oct 2004
Posts: 900
Lgh
Here is an example that shows you step by step how it works, maybe it helps.

Code:
#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("");
}




Regards, Robert

Quote
Everything should be made as simple as possible, but not one bit simpler.
by Albert Einstein

PhysX Preview of Cloth, Fluid and Soft Body

A8.47.1P
Re: How to create 3D mesh? [Re: rojart] #356961
02/04/11 20:54
02/04/11 20:54
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Hey guys, I just wanted to ask is that possible to make an action which will:
* create a box model (with POLYGON flag), size of which will equal to the size of BBOX of the model which called this action.
I need that to make good old style and fast collusions. Is there any way to make something like this? Thank you.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
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 Offline
Senior Expert
Quad  Offline
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
Re: How to create 3D mesh? [Re: Quad] #356985
02/04/11 22:24
02/04/11 22:24
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
So all I need is to create a mesh as rojart showed us, and they make it's size same as models min_x,max_x? laugh


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 1 of 3 1 2 3

Moderated by  HeelX, Spirit 

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