Notifications
Clear all

[Closed] Bitmap – Texture Coordinates

I’ve corrected your random point in face math

fn random_point_in_random_face obj = 
  (	
  	verts = getface obj	(random 1 obj.numfaces);
  	v1 = getVert obj verts[1];
  	v2 = getVert obj verts[2];
  	v3 = getVert obj verts[3];
  	vec1 = v2 - v1;
  	vec2 = v3 - v1;
  	x = random 0.0 1.0;
  	y = random 0.0 1.0;
  	if x + y >= 1.0 then
  	(	
  		x = 1.0 - x;
  		y = 1.0 - y;
  	)	
  	v1 + (x * vec1 + y * vec2);
  )

you also don’t need the meshop.getBaryCoords call either as you already know this

fn random_point_in_random_face obj &face &bary = 
  (	
	face = (random 1 obj.numfaces);
  	verts = getface obj   face;
  	v1 = getVert obj verts[1];
  	v2 = getVert obj verts[2];
  	v3 = getVert obj verts[3];
  	vec1 = (v2 - v1);
  	vec2 = (v3 - v1);
  	x = random 0.0 1.0;
  	y = random 0.0 1.0;
  
  -- x * vec1 + y * vec2 would generate rand positions in a parallelogram 
  -- so flip back to a triangle
  
  	if x + y >= 1.0 then  
  	(	
  		x = 1.0 - x;
  		y = 1.0 - y;
  	)	
  
  -- barycoords from opposite edges
  
  	bary = [1 - (x + y), x ,y];
  	v1 + x * vec1 + y * vec2;
  )	
Page 2 / 2