當前位置: 首頁>>代碼示例>>Java>>正文


Java Vector2f類代碼示例

本文整理匯總了Java中org.lwjgl.util.vector.Vector2f的典型用法代碼示例。如果您正苦於以下問題:Java Vector2f類的具體用法?Java Vector2f怎麽用?Java Vector2f使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Vector2f類屬於org.lwjgl.util.vector包,在下文中一共展示了Vector2f類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: convertDataToArrays

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
private static float convertDataToArrays(List<Vertex> vertices, List<Vector2f> textures,
		List<Vector3f> normals, float[] verticesArray, float[] texturesArray,
		float[] normalsArray) {
	float furthestPoint = 0;
	for (int i = 0; i < vertices.size(); i++) {
		Vertex currentVertex = vertices.get(i);
		if (currentVertex.getLength() > furthestPoint) {
			furthestPoint = currentVertex.getLength();
		}
		Vector3f position = currentVertex.getPosition();
		Vector2f textureCoord = textures.get(currentVertex.getTextureIndex());
		Vector3f normalVector = normals.get(currentVertex.getNormalIndex());
		verticesArray[i * 3] = position.x;
		verticesArray[i * 3 + 1] = position.y;
		verticesArray[i * 3 + 2] = position.z;
		texturesArray[i * 2] = textureCoord.x;
		texturesArray[i * 2 + 1] = 1 - textureCoord.y;
		normalsArray[i * 3] = normalVector.x;
		normalsArray[i * 3 + 1] = normalVector.y;
		normalsArray[i * 3 + 2] = normalVector.z;
	}
	return furthestPoint;
}
 
開發者ID:marcioz98,項目名稱:MRCEngine,代碼行數:24,代碼來源:OBJFileLoader.java

示例2: onHit

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
@Override
public void onHit (DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
    ShipAPI source = projectile.getSource();
    
    if (target instanceof ShipAPI && !shieldHit) {
        ShipAPI ship = (ShipAPI) target;
        String id = ship.getFleetMemberId();
        
        //((MS_TAGSystemEffect) projectile.getWeapon().getEffectPlugin()).putTELEMETRY(ship);
        if (!ship.isAlive() || ship.isAlly() || ship.getOwner() == source.getOwner()) {
            return;
        }
        
        if(affected.containsKey(ship)) {
            ((MS_TAGSystemEffect) projectile.getWeapon().getEffectPlugin()).putTELEMETRY(ship, affected.get(ship) + debuffDuration);
        } else {
            ((MS_TAGSystemEffect) projectile.getWeapon().getEffectPlugin()).putTELEMETRY(ship, debuffDuration);
        }
    }
}
 
開發者ID:MShadowy,項目名稱:shadowyards,代碼行數:21,代碼來源:MS_TAGOnHitEffect.java

示例3: onHit

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
@Override
public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
    if (point == null) {
        return;
    }
    if (target instanceof ShipAPI) {
        ShipAPI ship = (ShipAPI) target;

        if ((shieldHit || ship.getVariant().getHullMods().contains("tem_latticeshield") && ((!ShadowyardsModPlugin.templarsExist || TEM_LatticeShield.shieldLevel(ship) > 0f) || !ship.getVariant().getHullMods().contains("tem_latticeshield")))) {
        } else {
            engine.addSmoothParticle(point, new Vector2f(), 300f, 1f, 0.75f, new Color(100, 255, 200, 255));
            float emp = projectile.getEmpAmount() * 0.15f;
            float dam = projectile.getDamageAmount() * 0.2f;
            for (int x = 0; x < 2; x++) {
                engine.spawnEmpArc(projectile.getSource(), point, projectile.getDamageTarget(), projectile.getDamageTarget(), DamageType.ENERGY, dam, emp, 100000f, null, 20f, new Color(100, 255, 200, 255), new Color(200, 255, 255, 255));
            }
            Global.getSoundPlayer().playSound("ms_lemp_shot_impact", 1f, 1f, point, new Vector2f());
        }
    }
}
 
開發者ID:MShadowy,項目名稱:shadowyards,代碼行數:21,代碼來源:MS_PolarizerSmallOnHitEffect.java

示例4: onHit

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
@Override
public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
    // Check if we hit a ship (not its shield)
    if (target instanceof ShipAPI && !shieldHit && Math.random() <= EXTRA_DAMAGE_CHANCE) {
        // Apply extra damage of a random type
        engine.applyDamage(target, point,
                MathUtils.getRandomNumberInRange(MIN_EXTRA_DAMAGE, MAX_EXTRA_DAMAGE),
                TYPES[(int) (Math.random() * TYPES.length)], 0f, false,
                true, projectile.getSource());

        // Spawn visual effects
        engine.spawnExplosion(point, (Vector2f) new Vector2f(target.getVelocity()).scale(.48f), EXPLOSION_COLOR, 39f, 1f);
        float speed = projectile.getVelocity().length();
        float facing = 400f;
        for (int x = 0; x < NUM_PARTICLES; x++) {
            engine.addHitParticle(point, MathUtils.getPointOnCircumference(
                    null, MathUtils.getRandomNumberInRange(speed * .007f, speed * .17f),
                    MathUtils.getRandomNumberInRange(facing - 180f, facing + 180f)),
                    5f, 1f, 1.6f, PARTICLE_COLOR);
        }

        // Sound follows enemy that was hit
        Global.getSoundPlayer().playSound(SOUND_ID, 1.1f, 0.5f, target.getLocation(), target.getVelocity());
    }
}
 
開發者ID:MShadowy,項目名稱:shadowyards,代碼行數:26,代碼來源:MS_WavebeamOnHitEffect.java

示例5: onHit

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
@Override
public void onHit(DamagingProjectileAPI projectile, CombatEntityAPI target, Vector2f point, boolean shieldHit, CombatEngineAPI engine) {
    if (point == null) {
        return;
    }
    if (target instanceof ShipAPI) {
        ShipAPI ship = (ShipAPI) target;

        if ((shieldHit || ship.getVariant().getHullMods().contains("tem_latticeshield") && ((!ShadowyardsModPlugin.templarsExist || TEM_LatticeShield.shieldLevel(ship) > 0f) || !ship.getVariant().getHullMods().contains("tem_latticeshield")))) {            
        } else {
            engine.addSmoothParticle(point, new Vector2f(), 300f, 1f, 0.75f, new Color(100, 255, 200, 255));
            float emp = projectile.getEmpAmount() * 0.15f;
            float dam = projectile.getDamageAmount() * 0.2f;
            for (int x = 0; x < 6; x++) {
                engine.spawnEmpArc(projectile.getSource(), point, projectile.getDamageTarget(), projectile.getDamageTarget(), DamageType.ENERGY, dam, emp, 100000f, null, 20f, new Color(100, 255, 200, 255), new Color(200, 255, 255, 255));
            }
            Global.getSoundPlayer().playSound("ms_hemp_shot_impact", 1f, 1f, point, new Vector2f());
        }
    }
}
 
開發者ID:MShadowy,項目名稱:shadowyards,代碼行數:21,代碼來源:MS_PolarizerOnHitEffect.java

示例6: doOcclusionTest

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
private void doOcclusionTest(Vector2f sunScreenCoords) {
	if(query.isResultReady()){
		int visibleSamples = query.getResult();
		this.coverage = Math.min(visibleSamples / TOTAL_SAMPLES, 1f);
	}
	if (!query.isInUse()) {
		GL11.glColorMask(false, false, false, false);
		GL11.glDepthMask(false);
		query.start();
		OpenGlUtils.enableDepthTesting(true);
		shader.transform.loadVec4(sunScreenCoords.x, sunScreenCoords.y, TEST_QUAD_WIDTH, TEST_QUAD_HEIGHT);
		GL11.glDrawArrays(GL11.GL_TRIANGLE_STRIP, 0, 4);
		query.end();
		GL11.glColorMask(true, true, true, true);
		GL11.glDepthMask(true);
	}
}
 
開發者ID:TheThinMatrix,項目名稱:OcclusionQueries,代碼行數:18,代碼來源:FlareRenderer.java

示例7: advanceAndRender

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
private void advanceAndRender(float amount)
{
    // Blinker oscillates between -1 and 1, only drawn above 0
    if (amount > 0f)
    {
        blinkProgress += amount * BLINKS_PER_SECOND * (blinkDirection ? 4f : -4f);
        if ((blinkDirection && blinkProgress > 1f)
                || (!blinkDirection && blinkProgress < -1f))
        {
            blinkProgress = (blinkDirection ? 1f : -1f);
            blinkDirection = !blinkDirection;
        }
    }
 
    if (blinkProgress >= 0f)
    {
        // Render blinker, altering size and intensity based on current blink progress
        sprite.setAlphaMult(Math.min(1f, 0.5f + (blinkProgress / 2f)));
        sprite.setSize(spriteWidth * blinkProgress, spriteHeight * blinkProgress);
        Vector2f loc = MathUtils.getPointOnCircumference(
                bomb.getLocation(), BLINKER_Y_OFFSET, bomb.getFacing());
        sprite.renderAtCenter(loc.x, loc.y);
    }
}
 
開發者ID:MShadowy,項目名稱:shadowyards,代碼行數:25,代碼來源:MS_shamashBombPrimer.java

示例8: accept

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
@Override
public boolean accept(DamagingProjectileAPI proj) {
    // Exclude missiles and our own side's shots
    if (proj.getOwner() == ship.getOwner() && (!(proj instanceof MissileAPI ) || !((MissileAPI) proj).isFizzling()))
    {
        return false;
    }
    
    if (proj instanceof MissileAPI) {
        MissileAPI missile = (MissileAPI) proj;
        if (missile.isFlare()) {
            return false;
        }
    }
    // Only include shots that are on a collision path with us
    // Also ensure they aren't travelling AWAY from us ;)
    return (CollisionUtils.getCollides(proj.getLocation(), Vector2f.add(proj.getLocation(), (Vector2f) new Vector2f(proj.getVelocity()).scale(
                SECONDS_TO_LOOK_AHEAD), null), ship.getLocation(), ship.getCollisionRadius())
            && Math.abs(MathUtils.getShortestRotation(proj.getFacing(), VectorUtils.getAngle(proj.getLocation(), ship.getLocation()))) <= 90f);
}
 
開發者ID:MShadowy,項目名稱:shadowyards,代碼行數:21,代碼來源:MS_woopDriveAI.java

示例9: accept

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
@Override
public boolean accept(DamagingProjectileAPI proj) {// Exclude missiles and our own side's shots
    if (proj.getOwner() == ship.getOwner() && (!(proj instanceof MissileAPI ) || !((MissileAPI) proj).isFizzling()))
    {
        return false;
    }
    
    if (proj instanceof MissileAPI) {
        MissileAPI missile = (MissileAPI) proj;
        if (missile.isFlare()) {
            return false;
        }
    }
    // Only include shots that are on a collision path with us
    // Also ensure they aren't travelling AWAY from us ;)
    return (CollisionUtils.getCollides(proj.getLocation(), Vector2f.add(proj.getLocation(), (Vector2f) new Vector2f(proj.getVelocity()).scale(
                SECONDS_TO_LOOK_AHEAD), null), ship.getLocation(), ship.getCollisionRadius())
            && Math.abs(MathUtils.getShortestRotation(proj.getFacing(), VectorUtils.getAngle(proj.getLocation(), ship.getLocation()))) <= 90f);
}
 
開發者ID:MShadowy,項目名稱:shadowyards,代碼行數:20,代碼來源:MS_drivechargerai.java

示例10: drawLine

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
/**
 * Draws a line from start to end with the given width.
 *
 * @param start The starting point of the line.
 * @param end   The ending point of the line.
 * @param width The thickness of the line.
 */
private void drawLine(Vector2f start, Vector2f end, float width) {
    // Disables textures so we can draw a solid line.
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    // Sets the width.
    GL11.glLineWidth(width);

    // Begins drawing the line.
    GL11.glBegin(GL11.GL_LINES); {
        GL11.glVertex2f(start.x, start.y);
        GL11.glVertex2f(end.x, end.y);
    }
    // Ends drawing the line.
    GL11.glEnd();

    // Enables texturing back on.
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}
 
開發者ID:SerenityEnterprises,項目名稱:SerenityCE,代碼行數:26,代碼來源:TTFFontRenderer.java

示例11: set

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
/**
    * Sets the position of the face on the skybox texture (y-up, y=0 at bottom, x=0 at left).
    * @param face The face to update the position of.
    * @param x The x grid position of the face.
    * @param y The y grid position of the face.
    */
   public void set(final SkyboxFace face, final int x, final int y) {
if(x < 0 || y < 0) {
    return;
}

faceTexturePositions.replace(face, new Vector2f(x, y));
   }
 
開發者ID:camilne,項目名稱:open-world,代碼行數:14,代碼來源:SkyboxConfiguration.java

示例12: convertDataToArrays

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
private float convertDataToArrays() {
	float furthestPoint = 0;
	for (int i = 0; i < vertices.size(); i++) {
		Vertex currentVertex = vertices.get(i);
		if (currentVertex.getLength() > furthestPoint) {
			furthestPoint = currentVertex.getLength();
		}
		Vector3f position = currentVertex.getPosition();
		Vector2f textureCoord = textures.get(currentVertex.getTextureIndex());
		Vector3f normalVector = normals.get(currentVertex.getNormalIndex());
		verticesArray[i * 3] = position.x;
		verticesArray[i * 3 + 1] = position.y;
		verticesArray[i * 3 + 2] = position.z;
		texturesArray[i * 2] = textureCoord.x;
		texturesArray[i * 2 + 1] = 1 - textureCoord.y;
		normalsArray[i * 3] = normalVector.x;
		normalsArray[i * 3 + 1] = normalVector.y;
		normalsArray[i * 3 + 2] = normalVector.z;
		VertexSkinData weights = currentVertex.getWeightsData();
		jointIdsArray[i * 3] = weights.jointIds.get(0);
		jointIdsArray[i * 3 + 1] = weights.jointIds.get(1);
		jointIdsArray[i * 3 + 2] = weights.jointIds.get(2);
		weightsArray[i * 3] = weights.weights.get(0);
		weightsArray[i * 3 + 1] = weights.weights.get(1);
		weightsArray[i * 3 + 2] = weights.weights.get(2);

	}
	return furthestPoint;
}
 
開發者ID:TheThinMatrix,項目名稱:OpenGL-Animation,代碼行數:30,代碼來源:GeometryLoader.java

示例13: bakeGeometry

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
public void bakeGeometry(List<Vector3f> faces, List<Vector3f> vertexData, List<Vector2f> uvData, List<Vector3f> normalData)
{
	for (Vector3f faceData : faces)
	{
		int vertexIndex = (int) (faceData.getX() - 1);
		int uvIndex = (int) (faceData.getY() - 1);
		int normalIndex = (int) (faceData.getZ() - 1);
		this.vertices.add(new Vertex(vertexData.get(vertexIndex), uvData.get(uvIndex), normalData.get(normalIndex)));
	}
}
 
開發者ID:V0idWa1k3r,項目名稱:VoidApi,代碼行數:11,代碼來源:WavefrontObject.java

示例14: barryCentric

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
public static float barryCentric(Vector3f p1, Vector3f p2, Vector3f p3, Vector2f pos) {
	float det = (p2.z - p3.z) * (p1.x - p3.x) + (p3.x - p2.x) * (p1.z - p3.z);
	float l1 = ((p2.z - p3.z) * (pos.x - p3.x) + (p3.x - p2.x) * (pos.y - p3.z)) / det;
	float l2 = ((p3.z - p1.z) * (pos.x - p3.x) + (p1.x - p3.x) * (pos.y - p3.z)) / det;
	float l3 = 1.0f - l1 - l2;
	return l1 * p1.y + l2 * p2.y + l3 * p3.y;
}
 
開發者ID:Essentria,項目名稱:Elgin-Plant-Game,代碼行數:8,代碼來源:Maths.java

示例15: convertToScreenSpace

import org.lwjgl.util.vector.Vector2f; //導入依賴的package包/類
private Vector2f convertToScreenSpace(Vector3f worldPos, Matrix4f viewMat, Matrix4f projectionMat) {
	Vector4f coords = new Vector4f(worldPos.x, worldPos.y, worldPos.z, 1f);
	Matrix4f.transform(viewMat, coords, coords);
	Matrix4f.transform(projectionMat, coords, coords);
	if (coords.w <= 0) {
		return null;
	}
	//no need for conversion below
	return new Vector2f(coords.x / coords.w, coords.y / coords.w);
}
 
開發者ID:TheThinMatrix,項目名稱:OcclusionQueries,代碼行數:11,代碼來源:FlareManager.java


注:本文中的org.lwjgl.util.vector.Vector2f類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。