Search in sources :

Example 1 with Vector2f

use of org.lwjgl.util.vector.Vector2f in project lwjgl by LWJGL.

the class FullScreenWindowedTest method initialize.

/** Initializes the test */
private void initialize() {
    try {
        //find displaymode
        switchMode();
        quadPosition = new Vector2f(100f, 100f);
        quadVelocity = new Vector2f(1.0f, 1.0f);
        reinit();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Vector2f(org.lwjgl.util.vector.Vector2f) PowerManagementEventException(org.lwjgl.opengles.PowerManagementEventException) LWJGLException(org.lwjgl.LWJGLException)

Example 2 with Vector2f

use of org.lwjgl.util.vector.Vector2f in project ImmersiveEngineering by BluSunrize.

the class ModelCoresample method getQuads.

//	@Override
//	public List<BakedQuad> getFaceQuads(EnumFacing p_177551_1_)
//	{
//		return emptyQuads;
//	}
@Override
public List<BakedQuad> getQuads(@Nullable IBlockState blockState, @Nullable EnumFacing side, long rand) {
    if (bakedQuads == null) {
        try {
            bakedQuads = Collections.synchronizedSet(new LinkedHashSet<BakedQuad>());
            float width = .25f;
            float depth = .25f;
            float wOff = (1 - width) / 2;
            float dOff = (1 - depth) / 2;
            int pixelLength = 0;
            HashMap<TextureAtlasSprite, Integer> textureOre = new HashMap();
            if (mineral != null && mineral.oreOutput != null) {
                for (int i = 0; i < mineral.oreOutput.length; i++) if (mineral.oreOutput[i] != null) {
                    int weight = Math.max(2, Math.round(16 * mineral.recalculatedChances[i]));
                    Block b = Block.getBlockFromItem(mineral.oreOutput[i].getItem());
                    IBlockState state = b != null ? b.getStateFromMeta(mineral.oreOutput[i].getMetadata()) : Blocks.STONE.getDefaultState();
                    IBakedModel model = Minecraft.getMinecraft().getBlockRendererDispatcher().getBlockModelShapes().getModelForState(state);
                    if (model != null && model.getParticleTexture() != null)
                        textureOre.put(model.getParticleTexture(), weight);
                    pixelLength += weight;
                }
            } else
                pixelLength = 16;
            TextureAtlasSprite textureStone = ClientUtils.getSprite(new ResourceLocation("blocks/stone"));
            Vector2f[] stoneUVs = { new Vector2f(textureStone.getInterpolatedU(16 * wOff), textureStone.getInterpolatedV(16 * dOff)), new Vector2f(textureStone.getInterpolatedU(16 * wOff), textureStone.getInterpolatedV(16 * (dOff + depth))), new Vector2f(textureStone.getInterpolatedU(16 * (wOff + width)), textureStone.getInterpolatedV(16 * (dOff + depth))), new Vector2f(textureStone.getInterpolatedU(16 * (wOff + width)), textureStone.getInterpolatedV(16 * dOff)) };
            putVertexData(new Vector3f(0, -1, 0), new Vector3f[] { new Vector3f(wOff, 0, dOff), new Vector3f(wOff + width, 0, dOff), new Vector3f(wOff + width, 0, dOff + depth), new Vector3f(wOff, 0, dOff + depth) }, stoneUVs, textureStone);
            putVertexData(new Vector3f(0, 1, 0), new Vector3f[] { new Vector3f(wOff, 1, dOff), new Vector3f(wOff, 1, dOff + depth), new Vector3f(wOff + width, 1, dOff + depth), new Vector3f(wOff + width, 1, dOff) }, stoneUVs, textureStone);
            if (textureOre.isEmpty()) {
                Vector2f[][] uvs = new Vector2f[4][];
                for (int j = 0; j < 4; j++) uvs[j] = new Vector2f[] { new Vector2f(textureStone.getInterpolatedU(j * 4), textureStone.getInterpolatedV(0)), new Vector2f(textureStone.getInterpolatedU(j * 4), textureStone.getInterpolatedV(16)), new Vector2f(textureStone.getInterpolatedU((j + 1) * 4), textureStone.getInterpolatedV(16)), new Vector2f(textureStone.getInterpolatedU((j + 1) * 4), textureStone.getInterpolatedV(0)) };
                putVertexData(new Vector3f(0, 0, -1), new Vector3f[] { new Vector3f(wOff, 0, dOff), new Vector3f(wOff, 1, dOff), new Vector3f(wOff + width, 1, dOff), new Vector3f(wOff + width, 0, dOff) }, uvs[0], textureStone);
                putVertexData(new Vector3f(0, 0, 1), new Vector3f[] { new Vector3f(wOff + width, 0, dOff + depth), new Vector3f(wOff + width, 1, dOff + depth), new Vector3f(wOff, 1, dOff + depth), new Vector3f(wOff, 0, dOff + depth) }, uvs[2], textureStone);
                putVertexData(new Vector3f(-1, 0, 0), new Vector3f[] { new Vector3f(wOff, 0, dOff + depth), new Vector3f(wOff, 1, dOff + depth), new Vector3f(wOff, 1, dOff), new Vector3f(wOff, 0, dOff) }, uvs[3], textureStone);
                putVertexData(new Vector3f(1, 0, 0), new Vector3f[] { new Vector3f(wOff + width, 0, dOff), new Vector3f(wOff + width, 1, dOff), new Vector3f(wOff + width, 1, dOff + depth), new Vector3f(wOff + width, 0, dOff + depth) }, uvs[1], textureStone);
            } else {
                float h = 0;
                for (TextureAtlasSprite sprite : textureOre.keySet()) {
                    int weight = textureOre.get(sprite);
                    int v = weight > 8 ? 16 - weight : 8;
                    Vector2f[][] uvs = new Vector2f[4][];
                    for (int j = 0; j < 4; j++) uvs[j] = new Vector2f[] { new Vector2f(sprite.getInterpolatedU(j * 4), sprite.getInterpolatedV(v)), new Vector2f(sprite.getInterpolatedU(j * 4), sprite.getInterpolatedV(v + weight)), new Vector2f(sprite.getInterpolatedU((j + 1) * 4), sprite.getInterpolatedV(v + weight)), new Vector2f(sprite.getInterpolatedU((j + 1) * 4), sprite.getInterpolatedV(v)) };
                    float h1 = weight / (float) pixelLength;
                    putVertexData(new Vector3f(0, 0, -1), new Vector3f[] { new Vector3f(wOff, h, dOff), new Vector3f(wOff, h + h1, dOff), new Vector3f(wOff + width, h + h1, dOff), new Vector3f(wOff + width, h, dOff) }, uvs[0], sprite);
                    putVertexData(new Vector3f(0, 0, 1), new Vector3f[] { new Vector3f(wOff + width, h, dOff + depth), new Vector3f(wOff + width, h + h1, dOff + depth), new Vector3f(wOff, h + h1, dOff + depth), new Vector3f(wOff, h, dOff + depth) }, uvs[2], sprite);
                    putVertexData(new Vector3f(-1, 0, 0), new Vector3f[] { new Vector3f(wOff, h, dOff + depth), new Vector3f(wOff, h + h1, dOff + depth), new Vector3f(wOff, h + h1, dOff), new Vector3f(wOff, h, dOff) }, uvs[3], sprite);
                    putVertexData(new Vector3f(1, 0, 0), new Vector3f[] { new Vector3f(wOff + width, h, dOff), new Vector3f(wOff + width, h + h1, dOff), new Vector3f(wOff + width, h + h1, dOff + depth), new Vector3f(wOff + width, h, dOff + depth) }, uvs[1], sprite);
                    h += h1;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (bakedQuads != null && !bakedQuads.isEmpty()) {
        List<BakedQuad> quadList = Collections.synchronizedList(Lists.newArrayList(bakedQuads));
        return quadList;
    }
    return emptyQuads;
}
Also used : BakedQuad(net.minecraft.client.renderer.block.model.BakedQuad) UnpackedBakedQuad(net.minecraftforge.client.model.pipeline.UnpackedBakedQuad) IBlockState(net.minecraft.block.state.IBlockState) TextureAtlasSprite(net.minecraft.client.renderer.texture.TextureAtlasSprite) Vector2f(org.lwjgl.util.vector.Vector2f) ResourceLocation(net.minecraft.util.ResourceLocation) Vector3f(org.lwjgl.util.vector.Vector3f) Block(net.minecraft.block.Block) IBakedModel(net.minecraft.client.renderer.block.model.IBakedModel)

Example 3 with Vector2f

use of org.lwjgl.util.vector.Vector2f in project lwjgl by LWJGL.

the class PbufferTest method initialize.

/**
   * Initializes the test
   */
private void initialize() {
    try {
        //find displaymode
        pbuffer = new Pbuffer(512, 512, new PixelFormat(), null, null);
        mode = findDisplayMode(800, 600, 16);
        Display.setDisplayMode(mode);
        // start of in windowed mode
        Display.create();
        //      gl = new GLWindow("Test", 50, 50, mode.width, mode.height, mode.bpp, 0, 0, 0);
        if ((Pbuffer.getCapabilities() & Pbuffer.PBUFFER_SUPPORTED) == 0) {
            System.out.println("No Pbuffer support!");
            System.exit(1);
        }
        System.out.println("Pbuffer support detected");
        glInit();
        initPbuffer();
        Keyboard.create();
        quadPosition = new Vector2f(100f, 100f);
        quadVelocity = new Vector2f(1.0f, 1.0f);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Vector2f(org.lwjgl.util.vector.Vector2f) PixelFormat(org.lwjgl.opengl.PixelFormat) Pbuffer(org.lwjgl.opengl.Pbuffer) LWJGLException(org.lwjgl.LWJGLException)

Example 4 with Vector2f

use of org.lwjgl.util.vector.Vector2f in project lwjgl by LWJGL.

the class FullScreenWindowedTest method initialize.

/**
	 * Initializes the test
	 */
private void initialize() {
    try {
        //find displaymode
        switchMode();
        // start of in windowed mode
        Display.create();
        glInit();
        quadPosition = new Vector2f(100f, 100f);
        quadVelocity = new Vector2f(1.0f, 1.0f);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Vector2f(org.lwjgl.util.vector.Vector2f) LWJGLException(org.lwjgl.LWJGLException)

Aggregations

Vector2f (org.lwjgl.util.vector.Vector2f)4 LWJGLException (org.lwjgl.LWJGLException)3 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 BakedQuad (net.minecraft.client.renderer.block.model.BakedQuad)1 IBakedModel (net.minecraft.client.renderer.block.model.IBakedModel)1 TextureAtlasSprite (net.minecraft.client.renderer.texture.TextureAtlasSprite)1 ResourceLocation (net.minecraft.util.ResourceLocation)1 UnpackedBakedQuad (net.minecraftforge.client.model.pipeline.UnpackedBakedQuad)1 Pbuffer (org.lwjgl.opengl.Pbuffer)1 PixelFormat (org.lwjgl.opengl.PixelFormat)1 PowerManagementEventException (org.lwjgl.opengles.PowerManagementEventException)1 Vector3f (org.lwjgl.util.vector.Vector3f)1