Determine vertices with normals facing toward/away from a point?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Search this Thread Display Modes
Old 08 August 2014   #1
Determine vertices with normals facing toward/away from a point?

I have something that generally sorta-kinda works, but the results are inconsistent enough that I'm questioning my approach. What am I doing wrong?

fn collectFacingVerts obj tgt = (
	fv = #()
	for f in obj.verts as bitArray do (
		p = polyOp.getVert obj f
		v = p - tgt.pos
		if (intersectRay obj (ray p v)) != undefined do append fv f
	)
	fv
)
 
Old 08 August 2014   #2
for meshes

fn CollectFacingVerts mObj tgt =
(
	for v = 1 to mObj.numverts where (dot (tgt - (getVert mObj v))  (getNormal mObj v)) > 0.0 collect v ;
)	
 
Old 08 August 2014   #3
Thanks! That not only gets more accurate results, but also has the benefit of being much faster!
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 06:59 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.