Search in sources :

Example 1 with Vec2

use of monkstone.vecmath.vec2.Vec2 in project propane by ruby-processing.

the class Vec3 method toVertexUV.

/**
 * Sends this Vec3D as a processing vertex uv
 *
 * @param context ThreadContext
 * @param args IRubyObject[]
 */
@JRubyMethod(name = "to_vertex_uv", rest = true)
public void toVertexUV(ThreadContext context, IRubyObject... args) {
    int count = args.length;
    double u = 0;
    double v = 0;
    if (count == 3) {
        u = args[1] instanceof RubyFloat ? ((RubyFloat) args[1]).getValue() : ((RubyFixnum) args[1]).getDoubleValue();
        v = args[2] instanceof RubyFloat ? ((RubyFloat) args[2]).getValue() : ((RubyFixnum) args[2]).getDoubleValue();
    }
    if (count == 2) {
        Vec2 texture = (Vec2) args[1].toJava(Vec2.class);
        u = texture.javax();
        v = texture.javay();
    }
    JRender renderer = (JRender) args[0].toJava(JRender.class);
    renderer.vertex(jx, jy, jz, u, v);
}
Also used : Vec2(monkstone.vecmath.vec2.Vec2) RubyFloat(org.jruby.RubyFloat) JRender(monkstone.vecmath.JRender) RubyFixnum(org.jruby.RubyFixnum) JRubyMethod(org.jruby.anno.JRubyMethod)

Aggregations

JRender (monkstone.vecmath.JRender)1 Vec2 (monkstone.vecmath.vec2.Vec2)1 RubyFixnum (org.jruby.RubyFixnum)1 RubyFloat (org.jruby.RubyFloat)1 JRubyMethod (org.jruby.anno.JRubyMethod)1