Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 728 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
replacing a mesh #342595
09/29/10 15:56
09/29/10 15:56
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline 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. laugh

Code:
#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 Offline
Expert
EvilSOB  Offline
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: EvilSOB] #342620
09/29/10 18:01
09/29/10 18:01
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
thanks for trying it with a7! looks like a bug then or did anyone use ent_setmesh() successfully with a8?

edit:
i also tried it with a7 now. works without problems. hm...

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 Offline
Expert
EvilSOB  Offline
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 Offline
Senior Expert
Pappenheimer  Offline
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 Offline
Expert
EvilSOB  Offline
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
Re: replacing a mesh [Re: EvilSOB] #342708
09/30/10 10:27
09/30/10 10:27
Joined: May 2002
Posts: 7,441
ventilator Offline OP
Senior Expert
ventilator  Offline OP
Senior Expert

Joined: May 2002
Posts: 7,441
pappenheimer, you should see a small triangle though instead of the cube after the function got executed.

Re: replacing a mesh [Re: ventilator] #342779
09/30/10 21:25
09/30/10 21:25
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
I do not even see the cube. I see it only, when I uncomment the create_mesh.

Re: replacing a mesh [Re: Pappenheimer] #342793
10/01/10 07:27
10/01/10 07:27
Joined: Feb 2010
Posts: 320
TANA/Madagascar
3dgs_snake Offline
Senior Member
3dgs_snake  Offline
Senior Member

Joined: Feb 2010
Posts: 320
TANA/Madagascar
It is not a cube, its a triangle mesh. And you need to press 0 and move the camera backward a litle and then do a slight rotation to see it. I think that if it doesn't give an error with A8, it's ok.

Re: replacing a mesh [Re: 3dgs_snake] #342803
10/01/10 08:34
10/01/10 08:34
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
I know. I made several tests, uncommenting several parts, etc.
Maybe, there is a problem with my grafic card too.
Your advice helped, though. I placed an additional model above the triangle to keep the focus onto the triangle, when looking around with '0'.
I uncommented the printf's and could under certain angles see 'almost' a line at place of the triangle.


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