Search in sources :

Example 1 with AxisAngle4f

use of javax.vecmath.AxisAngle4f in project BuildCraft by BuildCraft.

the class BuildCraftBakedModel method createQuadsItemLayer.

public static List<MutableQuad> createQuadsItemLayer(final List<TextureAtlasSprite> sprites) {
    ImmutableList.Builder<ResourceLocation> builder = ImmutableList.builder();
    for (int i = 0; i < sprites.size(); i++) {
        builder.add(new ResourceLocation("buildcraftbakedmodel:spriteindex" + i));
    }
    final ImmutableList<ResourceLocation> locations = builder.build();
    ItemLayerModel model = new ItemLayerModel(locations);
    IBakedModel baked = model.bake(ModelRotation.X0_Y0, DefaultVertexFormats.BLOCK, new Function<ResourceLocation, TextureAtlasSprite>() {

        @Override
        public TextureAtlasSprite apply(ResourceLocation input) {
            return sprites.get(locations.indexOf(input));
        }
    });
    Matrix4f itemToEdge = new Matrix4f();
    itemToEdge.setIdentity();
    itemToEdge.setRotation(new AxisAngle4f(0, 1, 0, (float) (Math.PI / 2)));
    Matrix4f translation = new Matrix4f();
    translation.setIdentity();
    translation.setTranslation(new Vector3f(-15 / 32f, 0, 1));
    translation.mul(itemToEdge);
    List<MutableQuad> mutableQuads = ModelUtil.toMutableQuadList(baked, false);
    for (MutableQuad mutable : mutableQuads) {
        mutable.transform(translation);
        mutable.setTint(-1);
    }
    return mutableQuads;
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) ItemLayerModel(net.minecraftforge.client.model.ItemLayerModel) Matrix4f(javax.vecmath.Matrix4f) ResourceLocation(net.minecraft.util.ResourceLocation) Vector3f(javax.vecmath.Vector3f) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel) AxisAngle4f(javax.vecmath.AxisAngle4f) MutableQuad(buildcraft.lib.client.model.MutableQuad)

Example 2 with AxisAngle4f

use of javax.vecmath.AxisAngle4f in project jwt by emweb.

the class WebGLUtils method rotate.

public static void rotate(Matrix4f m, double angle, double x, double y, double z) {
    Matrix4f t = new Matrix4f();
    t.setIdentity();
    t.setRotation(new AxisAngle4f((float) x, (float) y, (float) z, (float) (angle / 180.0 * 3.141592)));
    m.mul(m, t);
}
Also used : Matrix4f(javax.vecmath.Matrix4f) AxisAngle4f(javax.vecmath.AxisAngle4f)

Example 3 with AxisAngle4f

use of javax.vecmath.AxisAngle4f in project ffx by mjschnie.

the class GraphicsAxis method createAxis.

/**
 * <p>
 * createAxis</p>
 */
public void createAxis() {
    Appearance ap = new Appearance();
    Color3f col = new Color3f(Color.lightGray);
    Color3f black = new Color3f(Color.black);
    Color3f white = new Color3f(Color.white);
    Material mat = new Material(col, black, col, white, 50.0f);
    mat.setLightingEnable(true);
    ap.setMaterial(mat);
    // X-Axis
    Cone xcone = new Cone(2.0f, 3.0f, ap);
    xcone.setUserData(this);
    Transform3D xconeT3d = new Transform3D();
    xconeT3d.setTranslation(new Vector3d(10.0f, 0.0f, 0.0f));
    xconeT3d.setRotation(new AxisAngle4f(0.0f, 0.0f, 1.0f, (float) Math.PI / -2.0f));
    TransformGroup xconeTG = new TransformGroup(xconeT3d);
    xconeTG.addChild(xcone);
    Cylinder xcylinder = new Cylinder(1.0f, 9.0f, ap);
    xcylinder.setUserData(this);
    Transform3D xcyT3d = new Transform3D();
    xcyT3d.setTranslation(new Vector3d(4.5, 0.0, 0.0));
    xcyT3d.setRotation(new AxisAngle4f(0.0f, 0.0f, 1.0f, (float) Math.PI / 2.0f));
    TransformGroup xcyTG = new TransformGroup(xcyT3d);
    xcyTG.addChild(xcylinder);
    setCapabilities(xcone, xcylinder);
    addChild(xconeTG);
    addChild(xcyTG);
    // Y-Axis
    Cone ycone = new Cone(2.0f, 3.0f, ap);
    ycone.setUserData(this);
    Transform3D yconeT3d = new Transform3D();
    yconeT3d.setTranslation(new Vector3d(0.0f, 10.0f, 0.0f));
    TransformGroup yconeTG = new TransformGroup(yconeT3d);
    yconeTG.addChild(ycone);
    Cylinder ycylinder = new Cylinder(1.0f, 9.0f, ap);
    ycylinder.setUserData(this);
    Transform3D ycyT3d = new Transform3D();
    ycyT3d.setTranslation(new Vector3d(0.0, 4.5, 0.0));
    TransformGroup ycyTG = new TransformGroup(ycyT3d);
    ycyTG.addChild(ycylinder);
    setCapabilities(ycone, ycylinder);
    addChild(yconeTG);
    addChild(ycyTG);
    // Z-Axis
    Cone zcone = new Cone(2.0f, 3.0f, ap);
    zcone.setUserData(this);
    Transform3D zconeT3d = new Transform3D();
    zconeT3d.setTranslation(new Vector3d(0.0f, 0.0f, 10.0f));
    zconeT3d.setRotation(new AxisAngle4f(1.0f, 0.0f, 0.0f, (float) Math.PI / 2.0f));
    TransformGroup zconeTG = new TransformGroup(zconeT3d);
    zconeTG.addChild(zcone);
    Cylinder zcylinder = new Cylinder(1.0f, 9.0f, ap);
    zcylinder.setUserData(this);
    Transform3D zcyT3d = new Transform3D();
    zcyT3d.setTranslation(new Vector3d(0.0, 0.0, 4.5));
    zcyT3d.setRotation(new AxisAngle4f(1.0f, 0.0f, 0.0f, (float) Math.PI / 2.0f));
    TransformGroup zcyTG = new TransformGroup(zcyT3d);
    zcyTG.addChild(zcylinder);
    setCapabilities(zcone, zcylinder);
    addChild(zconeTG);
    addChild(zcyTG);
    Sphere sphere = new Sphere(1.0f, ap);
    if (!sphere.getShape().getGeometry(0).isCompiled() && !sphere.getShape().getGeometry(0).isLive()) {
        PickTool.setCapabilities(sphere.getShape(), PickTool.INTERSECT_COORD);
    }
    addChild(sphere);
    // Labels
    ap = new Appearance();
    col = new Color3f(Color.green);
    mat = new Material(col, black, col, white, 50.0f);
    mat.setLightingEnable(true);
    ap.setMaterial(mat);
    Font font = new Font("Arial", Font.PLAIN, 4);
    Font3D font3d = new Font3D(font, new FontExtrusion());
    addChild(createAxisLabel("X", font3d, ap, 11.0, 0.0, 0.0));
    addChild(createAxisLabel("Y", font3d, ap, 0.0, 11.0, 0.0));
    addChild(createAxisLabel("Z", font3d, ap, 0.0, 0.0, 11.0));
}
Also used : Cone(com.sun.j3d.utils.geometry.Cone) Font3D(javax.media.j3d.Font3D) Color3f(javax.vecmath.Color3f) Transform3D(javax.media.j3d.Transform3D) Material(javax.media.j3d.Material) Appearance(javax.media.j3d.Appearance) FontExtrusion(javax.media.j3d.FontExtrusion) Font(java.awt.Font) TransformGroup(javax.media.j3d.TransformGroup) Sphere(com.sun.j3d.utils.geometry.Sphere) Cylinder(com.sun.j3d.utils.geometry.Cylinder) Vector3d(javax.vecmath.Vector3d) AxisAngle4f(javax.vecmath.AxisAngle4f)

Aggregations

AxisAngle4f (javax.vecmath.AxisAngle4f)3 Matrix4f (javax.vecmath.Matrix4f)2 MutableQuad (buildcraft.lib.client.model.MutableQuad)1 ImmutableList (com.google.common.collect.ImmutableList)1 Cone (com.sun.j3d.utils.geometry.Cone)1 Cylinder (com.sun.j3d.utils.geometry.Cylinder)1 Sphere (com.sun.j3d.utils.geometry.Sphere)1 Font (java.awt.Font)1 Appearance (javax.media.j3d.Appearance)1 Font3D (javax.media.j3d.Font3D)1 FontExtrusion (javax.media.j3d.FontExtrusion)1 Material (javax.media.j3d.Material)1 Transform3D (javax.media.j3d.Transform3D)1 TransformGroup (javax.media.j3d.TransformGroup)1 Color3f (javax.vecmath.Color3f)1 Vector3d (javax.vecmath.Vector3d)1 Vector3f (javax.vecmath.Vector3f)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 ResourceLocation (net.minecraft.util.ResourceLocation)1