当前位置: 首页>>代码示例>>Java>>正文


Java Vector3f类代码示例

本文整理汇总了Java中org.joml.Vector3f的典型用法代码示例。如果您正苦于以下问题:Java Vector3f类的具体用法?Java Vector3f怎么用?Java Vector3f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Vector3f类属于org.joml包,在下文中一共展示了Vector3f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renderTile

import org.joml.Vector3f; //导入依赖的package包/类
public void renderTile(Tile tile, int x, int y, Shader shader, Matrix4f world, Camera camera) {
    shader.bind();
    if (tile_textures.containsKey(tile.getTexture() ))
        tile_textures.get(tile.getTexture()).bind(0);

    Matrix4f tile_position = new Matrix4f().translate(new Vector3f(x * 2, y * 2, 0));
    Matrix4f target = new Matrix4f();

    camera.getProjection().mul(world, target);
    target.mul(tile_position);

    shader.setUniform("sampler", 0);
    shader.setUniform("projection", target);

    model.render();
}
 
开发者ID:nitrodragon,项目名称:lwjgl3_stuff,代码行数:17,代码来源:TileRenderer.java

示例2: update

import org.joml.Vector3f; //导入依赖的package包/类
@Override
public void update(float delta, Window window, Camera camera, World world) {
    Vector2f movement = new Vector2f();
    if (window.getInput().isKeyDown(GLFW_KEY_LEFT)) {
        movement.add(-10 * delta, 0);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_RIGHT)) {
        movement.add(10 * delta, 0);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_UP)) {
        movement.add(0, 10 * delta);
    }
    if (window.getInput().isKeyDown(GLFW_KEY_DOWN)) {
        movement.add(0, -10 * delta);
    }
    move(movement);

    if(movement.x != 0|| movement.y != 0) {
        useAnimation(ANIM_WALKING);
    } else {
        useAnimation(ANIM_IDLE);
    }

    camera.getPosition().lerp(transform.pos.mul(-world.getScale(), new Vector3f()), 0.05f);
}
 
开发者ID:nitrodragon,项目名称:lwjgl3_stuff,代码行数:26,代码来源:Player.java

示例3: Cone

import org.joml.Vector3f; //导入依赖的package包/类
/**
 * Creates a new cone at the specified position
 * using the specified rotation, scale and color. 
 * 
 * @param position - Position of the cone.
 * @param rotation - Rotation of the cone.
 * @param scale - Scale of the cone.
 * @param color - Color of the cone.
 */
public Cone(Vector3f position, Quaternionf rotation, float scale, Color color) {
	super();
	
	height = 1;
	radius = 1;
	sides = 10;
	
	generateVertices();
	generateNormals();
	generateTextureCoordinates();
	
	Mesh mesh = new Mesh(cone_positions, cone_texture_coordinates, cone_normals, cone_indices);
	Material mat = new Material();
	
	mat.setAmbientColor(color.toVector4f());
       mat.setDiffuseColor(color.toVector4f());
       mat.setSpecularColor(color.toVector4f());
	
	mesh.setMaterial(mat);
	setMesh(mesh);
	
	setPosition(position.x, position.y, position.z);
	setRotation(rotation);
	setScale(scale);
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:35,代码来源:Cone.java

示例4: processFaceVertex

import org.joml.Vector3f; //导入依赖的package包/类
private static void processFaceVertex(IdxGroup indices, List<Vector2f> textCoordList, List<Vector3f> normList,
                                      List<Integer> indicesList, float[] texCoordArr, float[] normArr) {

    // Set index for vertex coordinates
    int posIndex = indices.idxPos;
    indicesList.add(posIndex);

    // Reorder texture coordinates
    if (indices.idxTextCoord >= 0) {
        Vector2f textCoord = textCoordList.get(indices.idxTextCoord);
        texCoordArr[posIndex * 2] = textCoord.x;
        texCoordArr[posIndex * 2 + 1] = 1 - textCoord.y;
    }
    if (indices.idxVecNormal >= 0) {
        // Reorder vectornormals
        Vector3f vecNorm = normList.get(indices.idxVecNormal);
        normArr[posIndex * 3] = vecNorm.x;
        normArr[posIndex * 3 + 1] = vecNorm.y;
        normArr[posIndex * 3 + 2] = vecNorm.z;
    }
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:22,代码来源:OBJLoader.java

示例5: generateTextureCoordinates

import org.joml.Vector3f; //导入依赖的package包/类
/**
 * Generates the texture coordinates for the sphere.
 * TODO: Switch to using cube mapping:
 * https://www.shaneenishry.com/blog/2014/08/01/planet-generation-part-i/
 */
@Override
public void generateTextureCoordinates() {
	sphere_texture_coordinates = new float[(sphere_positions.length/3)*2];
	
	ArrayList<Vector3f> vertices = new ArrayList<>();
	for (int i = 0; i < sphere_positions.length; i+=3) {
		vertices.add(new Vector3f(sphere_positions[i], sphere_positions[i + 1], sphere_positions[i + 2]));
	}
	
	for (int i = 0, k = 0; k < vertices.size(); i+=2, k++) {
		Vector3f vertex = vertices.get(k);
		
		sphere_texture_coordinates[i] = (float)((Math.atan2(vertex.x, vertex.z) + Math.PI) / Math.PI / 2);
		sphere_texture_coordinates[i + 1] = (float)((Math.acos(vertex.y) + Math.PI) / Math.PI - 1);
	}
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:22,代码来源:Sphere.java

示例6: Cylinder

import org.joml.Vector3f; //导入依赖的package包/类
/**
 * Creates a new cylinder at the specified position
 * using the specified rotation and scale.
 * 
 * @param position - Position of the cylinder.
 * @param rotation - Rotation of the cylinder.
 * @param scale - Scale of the cylinder.
 */
public Cylinder(Vector3f position, Quaternionf rotation, float scale) {
	super();
	
	height = 1;
	radius = 1;
	sides = 10;
	
	generateVertices();
	generateNormals();
	generateTextureCoordinates();
	
	Mesh mesh = new Mesh(cylinder_positions, cylinder_texture_coordinates, cylinder_normals, cylinder_indices);
	Material mat = new Material();
	
	mesh.setMaterial(mat);
	setMesh(mesh);
	
	setPosition(position.x, position.y, position.z);
	setRotation(rotation);
	setScale(scale);
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:30,代码来源:Cylinder.java

示例7: parseLine

import org.joml.Vector3f; //导入依赖的package包/类
public static MD5JointData parseLine(String line) {
    MD5JointData result = null;
    Matcher matcher = PATTERN_JOINT.matcher(line);
    if (matcher.matches()) {
        result = new MD5JointData();
        result.setName(matcher.group(1));
        result.setParentIndex(Integer.parseInt(matcher.group(2)));
        float x = Float.parseFloat(matcher.group(3));
        float y = Float.parseFloat(matcher.group(4));
        float z = Float.parseFloat(matcher.group(5));
        result.setPosition(new Vector3f(x, y, z));

        x = Float.parseFloat(matcher.group(6));
        y = Float.parseFloat(matcher.group(7));
        z = Float.parseFloat(matcher.group(8));
        result.setOrientation(new Vector3f(x, y, z));
    }
    return result;
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:20,代码来源:MD5JointInfo.java

示例8: setupLights

import org.joml.Vector3f; //导入依赖的package包/类
private void setupLights() {
    SceneLight sceneLight = new SceneLight();
    scene.setSceneLight(sceneLight);

    // Ambient Light
    sceneLight.setAmbientLight(new Vector3f(0.3f, 0.3f, 0.3f));
    sceneLight.setSkyBoxLight(new Vector3f(1.0f, 1.0f, 1.0f));

    // Directional Light
    float lightIntensity = 1.0f;
    Vector3f lightDirection = new Vector3f(0, 1, 1);
    DirectionalLight directionalLight = new DirectionalLight(new Vector3f(1, 1, 1), lightDirection, lightIntensity);
    directionalLight.setShadowPosMult(10);
    directionalLight.setOrthoCords(-10.0f, 10.0f, -10.0f, 10.0f, -1.0f, 20.0f);
    sceneLight.setDirectionalLight(directionalLight);
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:17,代码来源:DummyGame.java

示例9: parseLine

import org.joml.Vector3f; //导入依赖的package包/类
public static MD5BaseFrameData parseLine(String line) {
    Matcher matcher = PATTERN_BASEFRAME.matcher(line);
    MD5BaseFrameData result = null;
    if (matcher.matches()) {
        result = new MD5BaseFrameData();
        float x = Float.parseFloat(matcher.group(1));
        float y = Float.parseFloat(matcher.group(2));
        float z = Float.parseFloat(matcher.group(3));
        result.setPosition(new Vector3f(x, y, z));

        x = Float.parseFloat(matcher.group(4));
        y = Float.parseFloat(matcher.group(5));
        z = Float.parseFloat(matcher.group(6));
        result.setOrientation(new Vector3f(x, y, z));
    }

    return result;
}
 
开发者ID:justjanne,项目名称:SteamAudio-Java,代码行数:19,代码来源:MD5BaseFrame.java

示例10: update

import org.joml.Vector3f; //导入依赖的package包/类
@Override
public void update(float delta, Window window, Camera camera, World world) {
	Vector2f movement = new Vector2f();
	if (window.getInput().isKeyDown(GLFW.GLFW_KEY_A)){
		movement.add(-10 * delta, 0);
	}
	
	if (window.getInput().isKeyDown(GLFW.GLFW_KEY_D)){
		movement.add(10 * delta, 0);
	}
	
	if (window.getInput().isKeyDown(GLFW.GLFW_KEY_W)){
		movement.add(0, 10 * delta * JUMP_STRENGTH);
	}
	
	movement.add(0, -10 * delta * GRAVITATION);
	
	move(movement);
	if(movement.y > 0){
		useAnimation(ANIM_JETPACK);
	}else if (movement.x != 0){
		useAnimation(ANIM_WALK);
	}else{		
		useAnimation(ANIM_IDLE);
	}		
	camera.getPosition().lerp(transform.pos.mul(-world.getScale(), new Vector3f()), 0.2f);

	if (window.getInput().isKeyDown(GLFW.GLFW_KEY_SPACE)){
		Rocket rocket = new Rocket(1, transform);
	}

}
 
开发者ID:MarcPopescu-Pfeiffer,项目名称:2DGame,代码行数:33,代码来源:Player.java

示例11: addFaceVertical

import org.joml.Vector3f; //导入依赖的package包/类
public void addFaceVertical(Vector3fc bottomLeft, Vector3fc topRight, Vector2fc texCoordTopLeft, Vector2fc texCoordBottomRight)
{
	int i = this.vertices.size();

	this.addVertex(bottomLeft, new Vector2f(texCoordTopLeft.x(), texCoordBottomRight.y()));
	this.addVertex(new Vector3f(bottomLeft.x(), topRight.y(), bottomLeft.z()), texCoordTopLeft);
	this.addVertex(topRight, new Vector2f(texCoordBottomRight.x(), texCoordTopLeft.y()));
	this.addVertex(new Vector3f(topRight.x(), bottomLeft.y(), topRight.z()), texCoordBottomRight);

	this.addVertexIndex(i, i + 1, i + 2);
	this.addVertexIndex(i, i + 2, i + 3);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:13,代码来源:MeshBuilder.java

示例12: EHGame

import org.joml.Vector3f; //导入依赖的package包/类
public EHGame() {
  renderer = new Renderer();
  camera = new Camera();

  world = new World();
  jumpRequested = false;

  cameraInc = new Vector3f(0,0,0);
  cameraRotInc = new Vector3f(0,0,0);
  playerMovInc = new Vector2f(0,0);
  followCameraInc = new Vector3f(0,0,0);
  playerRotInc = 0;
  freeCamera = false;
  console = new GameConsole();
}
 
开发者ID:adamegyed,项目名称:endless-hiker,代码行数:16,代码来源:EHGame.java

示例13: generateNormals

import org.joml.Vector3f; //导入依赖的package包/类
/**
 * Generates the normals for the Cone.
 */
@Override
public void generateNormals() {
	float[] normals = new float[positions.size()*3];
	
	// TODO: These are not calculated properly, needs refactoring later on.
	// Oskar Mendel - 2017-06-14
	normals[0] = 0;
	normals[1] = -1;
	normals[2] = 0;
	
	for (int i = 3, k = 1; k < positions.size(); i+=3, k++) {
		Vector3f vec = positions.get(k);
		
		float x = vec.x;
		float y = vec.y;
		float z = vec.z;
		float dt = (float) Math.sqrt((x*x)+(y*y)+(z*z));
		
		x = x * (1.0f / dt);
		y = y * (1.0f / dt);
		z = z * (1.0f / dt);
		
		normals[i] = x;
		normals[i + 1] = y;
		normals[i + 2] = z;
	}
	
	cone_normals = normals;
}
 
开发者ID:brokenprogrammer,项目名称:Mass,代码行数:33,代码来源:Cone.java

示例14: getPoint2DFromScreen

import org.joml.Vector3f; //导入依赖的package包/类
public Vector2f getPoint2DFromScreen(float screenX, float screenY, Vector2f dst)
{
	Matrix4fc invertedViewProjection = this.getInvertedViewProjectionMatrix(MAT4);
	Vector2fc screen = this.getScreenOffset(screenX, screenY, VEC2);

	Vector3f near = unproject(invertedViewProjection, this.viewport, screen.x(), screen.y(), 0, VEC3A);
	Vector3f far = unproject(invertedViewProjection, this.viewport, screen.x(), screen.y(), 1, VEC3B);

	float f = (0 - near.z) / (far.z - near.z);
	screenX = (near.x + f * (far.x - near.x));
	screenY = (near.y + f * (far.y - near.y));
	return dst.set(screenX, screenY);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:14,代码来源:ScreenSpace.java

示例15: addFaceHorizontal

import org.joml.Vector3f; //导入依赖的package包/类
public void addFaceHorizontal(Vector3f bottomLeft, Vector3f topRight)
{
	int i = this.vertices.size();

	this.addVertex(bottomLeft, new Vector2f(0F, 0F));
	this.addVertex(new Vector3f(topRight.x(), bottomLeft.y(), bottomLeft.z()), new Vector2f(1F, 0F));
	this.addVertex(topRight, new Vector2f(1F, 1F));
	this.addVertex(new Vector3f(bottomLeft.x(), topRight.y(), topRight.z()), new Vector2f(0F, 1F));

	this.addVertexIndex(i, i + 1, i + 2);
	this.addVertexIndex(i, i + 2, i + 3);
}
 
开发者ID:andykuo1,项目名称:candlelight,代码行数:13,代码来源:MeshBuilder.java


注:本文中的org.joml.Vector3f类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。