//-------------------------------------------------------------- void ofxFatLine::updateVertex(int index){ if (index == 0 && getVertices().size() >1){ updateCap(getVertices()[index+1], getVertices()[index], index); }else if(index == getVertices().size()-1 && getVertices().size() >1) { updateCap(getVertices()[index-1], getVertices()[index], index); }else if ( getVertices().size() >2){ ofVec3f a (getVertices()[index-1] - getVertices()[index]); ofVec3f b (getVertices()[index+1] - getVertices()[index]); float angle = a.angle(b); ofVec3f p = getMidVector(a, b); ///Limits midvector length to avoid strange behaviour when angles are small. float hyp = MIN(a.length(), b.length()); hyp *= hyp; hyp += weights[index] * weights[index]; hyp = sqrt(hyp); //------ bool flip = !sameSideOfLine(p, flippepMidVectors.back(), getVertices()[index-1], getVertices()[index]); float cs = cos(DEG_TO_RAD * (90 - angle*0.5f)); pushNewVertex(getVertices()[index], p, a.cross(ofVec3f(0,0,1).normalized()), b.cross(ofVec3f(0,0,1).normalized()),hyp, index, cs, flip); } }
void alloc_Vertex(lua_State* L, ge_Vertex* vertex){ lua_createtable(L, 0, 0); luaL_setfuncs(L, Vertex_methods, 0); *pushNewVertex(L) = vertex; lua_setfield(L, -2, "vertex"); lua_createtable(L, 0, 0); luaL_setfuncs(L, Vertex_meta, 0); lua_setmetatable(L, -2); }