Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (7th_zorro, 1 invisible), 581 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[solved]get triangle vertices by hit.triangle? #478819
12/25/19 23:38
12/25/19 23:38
Joined: Jun 2010
Posts: 212
tagimbul Offline OP
Member
tagimbul  Offline OP
Member

Joined: Jun 2010
Posts: 212
hello laugh

i try to read the vertices of a face,
how i can do this with hit.triangle and ent_getvertex() ?

greets tom

Last edited by tagimbul; 12/28/19 13:27.

meine website mit 3dgs sachen =) //noch nicht ganz umgebaut ^^"
http://flashbreaker.com/home.html
und mein YT channel mit diversen game entwicklungs videos, vor allem shader zeugs
https://www.youtube.com/user/tagimbul/videos
Re: get triangle vertices by hit.triangle? [Re: tagimbul] #478820
12/26/19 03:35
12/26/19 03:35
Joined: Jun 2010
Posts: 212
tagimbul Offline OP
Member
tagimbul  Offline OP
Member

Joined: Jun 2010
Posts: 212
i have it laugh
Code
ent_buffers(ent_level,0,0,&vbuffer,&ibuffer,NULL) ;	
v1.x = vbuffer[ibuffer[3*hit.triangle  ] ].x;
v1.y = vbuffer[ibuffer[3*hit.triangle  ] ].z;
v1.z = vbuffer[ibuffer[3*hit.triangle ]  ].y;


now i have the problem to convert the triangels to a normal vector tongue


meine website mit 3dgs sachen =) //noch nicht ganz umgebaut ^^"
http://flashbreaker.com/home.html
und mein YT channel mit diversen game entwicklungs videos, vor allem shader zeugs
https://www.youtube.com/user/tagimbul/videos
Re: get triangle vertices by hit.triangle? [Re: tagimbul] #478822
12/26/19 15:12
12/26/19 15:12
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Hi,
the normal of a triangle can be computed by the cross product of two of its edges. I mean, on an ABC triangle, AB x AC. The result may need to be normalized.

As a unasked tip, It is always good to not to repeat the same operation. It is faster to get a pointer to the D3DVERTEX struct for each vertex.

Code
ent_buffers(ent_level, 0, 0, &vbuffer ,&ibuffer, NULL) ;

short *ibT = ibuffer + (int)hit.triangle * 3;

D3DVERTEX *vbT = vbuffer + *ibT;
v1.x = vbT->x; 
v1.y = vbT->z;
v1.z = vbT->y:

vbT = vbuffer + *(++ibT);
v2.x = vbT->x; 
v2.y = vbT->z;
v2.z = vbT->y:

vbT = vbuffer + *(++ibT);
v3.x = vbT->x; 
v3.y = vbT->z;
v3.z = vbT->y:

vec_diff(e1, v2, v1);
vec_diff(e2, v3, v1);
vec_cross(n0, e1, e2);
vec_normalize(n0, 1);



Salud!

Re: get triangle vertices by hit.triangle? [Re: tagimbul] #478823
12/26/19 21:11
12/26/19 21:11
Joined: Jun 2010
Posts: 212
tagimbul Offline OP
Member
tagimbul  Offline OP
Member

Joined: Jun 2010
Posts: 212
hey thx
i have found a other way

Code
function Triangle_to_normal( VECTOR* n, VECTOR* v1, VECTOR* v2, VECTOR *v3)
{
	
	VECTOR A,B;
	vec_set (A,vec_sub (v2, v1 ));
	vec_set (B,vec_sub (v3, v1 ));
	
	n.x = A.y * B.z - A.z * B.y ;
	n.y = A.x * B.z - A.z * B.x ;
	n.z = A.x * B.y - A.y * B.x ;
	vec_normalize(n.x,1);
}


i dont know why but it works too ^^"


meine website mit 3dgs sachen =) //noch nicht ganz umgebaut ^^"
http://flashbreaker.com/home.html
und mein YT channel mit diversen game entwicklungs videos, vor allem shader zeugs
https://www.youtube.com/user/tagimbul/videos
Re: get triangle vertices by hit.triangle? [Re: tagimbul] #478824
12/26/19 22:35
12/26/19 22:35
Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
txesmi Offline
Serious User
txesmi  Offline
Serious User

Joined: Jun 2007
Posts: 1,337
Hiporope and its pain
Code
	n.x = A.y * B.z - A.z * B.y ;
	n.y = A.x * B.z - A.z * B.x ;
	n.z = A.x * B.y - A.y * B.x ;


well, that is how cross product of 3D vectors is computed wink


Moderated by  old_bill, Tobias 

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