Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Work out the Vertex Positions of the Face your Hitting

Author
Message
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Oct 2013 15:37
The question is the title but for it to work with any object. Any idea's on how to do this?

"Get in the Van!" - Van B
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 2nd Oct 2013 19:11
calculate limb world matrix and use it to transform vertices local position, that's it

Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 2nd Oct 2013 20:01
Haha you said the exact same thing in my other post, but this doesn't help getting vertex positions initially from the face your hitting.

"Get in the Van!" - Van B
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Oct 2013 00:01
well, you haven't explained well what you need.

so:

face - one based index of a hit poly

if object has no indexdata
v0=(face-1)*3+0
v1=(face-1)*3+1
v2=(face-1)*3+2
endif

if object has indexdata
v0=get indexdata((face-1)*3+0)
v1=get indexdata((face-1)*3+1)
v2=get indexdata((face-1)*3+2)
endif

v0,v1 and v2 are the vertices you need

NOTE: none of the above works for dbpro's primitives sphere and cylinder

Phaelax
DBPro Master
23
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 3rd Oct 2013 08:34
Find the vertices based on what information? Basic primitive shape would be possible since you can predict where the verts are relative to the object's origin. More complex shapes or custom shapes would be impossible without having access to the object's vertex data.

chafari
Valued Member
20
Years of Service
User Offline
Joined: 2nd May 2006
Location: Canary Islands
Posted: 3rd Oct 2013 12:17
@Sasuke
Have a look to this example of TheComet that shows you , the vertex of the face you hit. I hope TheComet doesn't mind .

I'm not a grumpy grandpa
Sasuke
20
Years of Service
User Offline
Joined: 2nd Dec 2005
Location: Milton Keynes UK
Posted: 3rd Oct 2013 12:26 Edited at: 3rd Oct 2013 12:29
Quote: "none of the above works for dbpro's primitives sphere and cylinder"


This was the bit I didn't know and thought I was doing something wrong. So avoid using these, cheers

I was wonder if there was something wrong with my code but it returns correctly:


The main problem I'm having is working out the barycentric coordinates because I have no clue how you would account for flipped ploys if you call it that. Take a box for instance, the sides are arranged differently to the top. Is there anyway to account for this?

@chafari, cheers and I've actually looked at that method before. Though actually I never had a problem with getting them, I wasn't sure why it wasn't working on everything I used it on.

"Get in the Van!" - Van B
Brendy boy
20
Years of Service
User Offline
Joined: 17th Jul 2005
Location: Croatia
Posted: 3rd Oct 2013 20:45
Quote: "The main problem I'm having is working out the barycentric coordinates because I have no clue how you would account for flipped ploys if you call it that. Take a box for instance, the sides are arranged differently to the top. Is there anyway to account for this?"

1. there are no filpped polys in a box, all the poly point out of the box's center and is a valid box without flipped polys.

2. i'm quite sure the flipping doesn't have any influence on the barycentric coords.

3. as for calculating barycentric coords google is your friend. Here's ane method (C++ code)


if you know anything about vectors in dbpro it should be quite clear to you how to convert that to dbpro code

Login to post a reply

Server time is: 2026-07-06 10:36:31
Your offset time is: 2026-07-06 10:36:31