本文整理汇总了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;
}
示例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);
}
}
}
示例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());
}
}
}
示例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());
}
}
示例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());
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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));
}
示例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;
}
示例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)));
}
}
示例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;
}
示例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);
}