本文整理汇总了Java中org.joml.Vector4f类的典型用法代码示例。如果您正苦于以下问题:Java Vector4f类的具体用法?Java Vector4f怎么用?Java Vector4f使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector4f类属于org.joml包,在下文中一共展示了Vector4f类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ShadowCascade
import org.joml.Vector4f; //导入依赖的package包/类
/**
*
* @param zNear
* @param zFar
*/
public ShadowCascade(float zNear, float zFar) {
this.zNear = zNear;
this.zFar = zFar;
this.projectionViewMatrix = new Matrix4f();
this.orthoProjectionMatrix = new Matrix4f();
this.lightViewMatrix = new Matrix4f();
this.centr = new Vector3f();
this.frustumCorners = new Vector3f[FRUSTUM_CORNERS];
for (int i = 0; i < FRUSTUM_CORNERS; i++) {
frustumCorners[i] = new Vector3f();
}
this.tmpVec = new Vector4f();
}
示例2: readVertexGeometry
import org.joml.Vector4f; //导入依赖的package包/类
protected Vector4f readVertexGeometry(Cursor cursor, Vector4f dst) throws IOException
{
this.consumeHorizontalWhiteSpaces(cursor);
String x = this.readNumber(cursor);
this.consumeHorizontalWhiteSpaces(cursor);
String y = this.readNumber(cursor);
this.consumeHorizontalWhiteSpaces(cursor);
String z = this.readNumber(cursor);
if (x.isEmpty() || y.isEmpty() || z.isEmpty())
{
throw formatError(cursor, "requires at least 3 components");
}
this.consumeHorizontalWhiteSpaces(cursor);
String w = "1";
if (!isVerticalWhiteSpace(cursor.getChar())) w = this.readNumber(cursor);
return dst.set(Float.valueOf(x), Float.valueOf(y), Float.valueOf(z), Float.valueOf(w));
}
示例3: draw
import org.joml.Vector4f; //导入依赖的package包/类
@Override
public void draw(Asset<Mesh> modelMesh, Material material, Matrix4fc transformation)
{
final Program program = this.program.get();
final Mesh mesh = modelMesh.get();
MaterialProperty.MODELVIEWPROJECTION.apply(program,
this.viewProjection.mul(transformation, this.modelViewProjection));
mesh.bind();
{
material.applyOrDefault(MaterialProperty.COLOR, program, new Vector4f(1, 1, 1, 0));
GL11.glDrawElements(GL11.GL_LINE_LOOP, mesh.getVertexCount(), GL11.GL_UNSIGNED_INT, 0);
}
mesh.unbind();
}
示例4: tabToListVertex
import org.joml.Vector4f; //导入依赖的package包/类
/**
* Construct a list of vertex with the vertices of specified item
*
* @param item item
* @return listVertex
*/
public static ArrayList<Vector4f> tabToListVertex(Item item) {
ArrayList<Vector4f> listVertex = new ArrayList<>();
for (int i = 0; i < item.getAppearance().getVertices().length; i += 3) {
Vector4f vec = new Vector4f(item.getAppearance().getVertices()[i], item.getAppearance().getVertices()[i + 1]
, item.getAppearance().getVertices()[i + 2], 1.0f);
if (!isVecAlreadyAdd(listVertex, vec))
listVertex.add(vec);
}
//get Real position of vertex after rotation or translation
for (int i = 0; i < listVertex.size(); i++)
listVertex.set(i, listVertex.get(i).mul(item.getWorldMatrix()));
return listVertex;
}
示例5: setColor
import org.joml.Vector4f; //导入依赖的package包/类
/**
* <p>
* Set a {@code vec3} or {@code vec4} value.
* </p>
*
* @param name The name of the uniform in the shader.
* @param value The value of the uniform.
*/
public final void setColor(String name, Color value)
{
if(!ShaderInternal.hasUniform(asset.shader, name) || !ShaderInternal.getUniformType(asset.shader, name).equals("vec3") && !ShaderInternal.getUniformType(asset.shader, name).equals("vec4"))
{
Logger.logWarning("Shader: " + getShader().getName() + " does not contain a vec3 or vec4 with the name: " + name);
return;
}
String type = ShaderInternal.getUniformType(asset.shader, name);
if(type != null)
{
switch(type)
{
case "vec3":
setVector3f(name, new Vector3f(value.getRed(), value.getGreen(), value.getBlue()));
break;
case "vec4":
setVector4f(name, new Vector4f(value.getRed(), value.getGreen(), value.getBlue(), value.getAlpha()));
break;
}
}
}
示例6: getColor
import org.joml.Vector4f; //导入依赖的package包/类
/**
* <p>
* Get a {@code vec3} or {@code vec4} value.
* </p>
*
* @param name The name of the uniform in the shader.
* @return The value of the uniform.
*/
public final Color getColor(String name)
{
String type = ShaderInternal.getUniformType(asset.shader, name);
if(type != null)
{
switch(type)
{
case "vec3":
Vector3f vec3 = get(Vector3f.class, name);
return new Color(vec3.x, vec3.y, vec3.z);
case "vec4":
Vector4f vec4 = get(Vector4f.class, name);
return new Color(vec4.x, vec4.y, vec4.z, vec4.w);
}
}
return null;
}
示例7: transformQuad
import org.joml.Vector4f; //导入依赖的package包/类
public final UnpackedBakedQuad transformQuad(BakedQuad quad) {
// Fetch required information
final VertexFormat format = quad.getFormat();
final float[][][] vertexData = new float[4][format.getElementCount()][4];
// Objects to be reused in the loop
final Vector4f temp = new Vector4f();
//unpack and transform vertex data
for (int v = 0; v < 4; v++) {
for (int e = 0; e < format.getElementCount(); e++) {
LightUtil.unpack(quad.getVertexData(), vertexData[v][e], format, v, e);
transformUnpackedVertexDataElement(format.getElement(e).getUsage(), vertexData[v][e], temp);
}
}
//create new quad with the transformed vertex data
return new UnpackedBakedQuad(vertexData, quad.getTintIndex(), quad.getFace(), quad.getSprite(), quad.shouldApplyDiffuseLighting(), format);
}
示例8: transformUnpackedVertexDataElement
import org.joml.Vector4f; //导入依赖的package包/类
public final void transformUnpackedVertexDataElement(VertexFormatElement.EnumUsage type, float[] data, Vector4f temp) {
switch (type) {
case POSITION:
case NORMAL:
this.matrices.transform(data[0], data[1], data[2], 1, temp);
data[0] = temp.x;
data[1] = temp.y;
data[2] = temp.z;
break;
case COLOR:
data[0] = getRed();
data[1] = getGreen();
data[2] = getBlue();
data[3] = getAlpha();
break;
}
}
示例9: handleTexture
import org.joml.Vector4f; //导入依赖的package包/类
private static void handleTexture(Mesh mesh, MD5Mesh md5Mesh, Vector4f defaultColour) throws Exception {
String texturePath = md5Mesh.getTexture();
if (texturePath != null && texturePath.length() > 0) {
Texture texture = new Texture(texturePath);
Material material = new Material(texture);
// Handle normal Maps;
int pos = texturePath.lastIndexOf(".");
if (pos > 0) {
String basePath = texturePath.substring(0, pos);
String extension = texturePath.substring(pos, texturePath.length());
String normalMapFileName = basePath + "_local" + extension;
if (Utils.existsResourceFile(normalMapFileName)) {
Texture normalMap = new Texture(normalMapFileName);
material.setNormalMap(normalMap);
}
}
mesh.setMaterial(material);
} else {
mesh.setMaterial(new Material(defaultColour, 1));
}
}
示例10: process
import org.joml.Vector4f; //导入依赖的package包/类
/**
* Constructs and AnimGameItem instace based on a MD5 Model an MD5 Animation
*
* @param md5Model The MD5 Model
* @param animModel The MD5 Animation
* @param defaultColour Default colour to use if there are no textures
* @return
* @throws Exception
*/
public static AnimGameItem process(MD5Model md5Model, MD5AnimModel animModel, Vector4f defaultColour) throws Exception {
List<Matrix4f> invJointMatrices = calcInJointMatrices(md5Model);
List<AnimatedFrame> animatedFrames = processAnimationFrames(md5Model, animModel, invJointMatrices);
List<Mesh> list = new ArrayList<>();
for (MD5Mesh md5Mesh : md5Model.getMeshes()) {
Mesh mesh = generateMesh(md5Model, md5Mesh);
handleTexture(mesh, md5Mesh, defaultColour);
list.add(mesh);
}
Mesh[] meshes = new Mesh[list.size()];
meshes = list.toArray(meshes);
AnimGameItem result = new AnimGameItem(meshes, animatedFrames, invJointMatrices);
return result;
}
示例11: Hud
import org.joml.Vector4f; //导入依赖的package包/类
public Hud(String statusText) throws Exception {
FontTexture fontTexture = new FontTexture(FONT, CHARSET);
this.statusTextItem = new TextItem(statusText, fontTexture);
this.statusTextItem.getMesh().getMaterial().setAmbientColour(new Vector4f(1, 1, 1, 1));
// Create compass
Mesh mesh = OBJLoader.loadMesh("/models/compass.obj");
Material material = new Material();
material.setAmbientColour(new Vector4f(1, 0, 0, 1));
mesh.setMaterial(material);
compassItem = new GameItem(mesh);
compassItem.setScale(40.0f);
// Rotate to transform it to screen coordinates
compassItem.setRotation(0f, 0f, 180f);
// Create list that holds the items that compose the HUD
gameItems = new GameItem[]{statusTextItem, compassItem};
}
示例12: Hud
import org.joml.Vector4f; //导入依赖的package包/类
public Hud(String statusText) throws Exception {
this.statusTextItem = new TextItem(statusText, FONT_TEXTURE, FONT_COLS, FONT_ROWS);
this.statusTextItem.getMesh().getMaterial().setAmbientColour(new Vector4f(1, 1, 1, 1));
// Create compass
Mesh mesh = OBJLoader.loadMesh("/models/compass.obj");
Material material = new Material();
material.setAmbientColour(new Vector4f(1, 0, 0, 1));
mesh.setMaterial(material);
compassItem = new GameItem(mesh);
compassItem.setScale(40.0f);
// Rotate to transform it to screen coordinates
compassItem.setRotation(0f, 0f, 180f);
// Create list that holds the items that compose the HUD
gameItems = new GameItem[]{statusTextItem, compassItem};
}
示例13: Material
import org.joml.Vector4f; //导入依赖的package包/类
/**
* Creates a new Material with the specified reflectance
* and ambient, diffuse and specular colors.
*
* @param ambientColor - Ambient color of this Material.
* @param diffuseColor - Diffuse color of this Material.
* @param specularColor - Specular color of this Material.
* @param reflectance - Reflectance value of this Material.
*/
public Material(Vector4f ambientColor, Vector4f diffuseColor,
Vector4f specularColor, float reflectance) {
this.ambientColor = ambientColor;
this.diffuseColor = diffuseColor;
this.specularColor = specularColor;
this.reflectance = reflectance;
this.texture = null;
}
示例14: getColor
import org.joml.Vector4f; //导入依赖的package包/类
public Vector4f getColor(int x, int y){
return new Vector4f(
getR(x, y),
getG(x, y),
getB(x, y),
getA(x, y));
}
示例15: unproject
import org.joml.Vector4f; //导入依赖的package包/类
public static Vector3f unproject(Matrix4fc invertedViewProjection, ViewPort viewport, float screenX, float screenY, float z, Vector3f dst)
{
Vector4f normalizedDeviceCoords = new Vector4f();
normalizedDeviceCoords.x = (screenX - viewport.getX()) / viewport.getWidth() * 2.0F - 1.0F;
normalizedDeviceCoords.y = (screenY - viewport.getY()) / viewport.getHeight() * 2.0F - 1.0F;
normalizedDeviceCoords.z = 2.0F * z - 1.0F;
normalizedDeviceCoords.w = 1.0F;
Vector4f objectCoords = invertedViewProjection.transform(normalizedDeviceCoords);
if (objectCoords.w != 0.0F) objectCoords.w = 1.0F / objectCoords.w;
return dst.set(objectCoords.x, objectCoords.y, objectCoords.z).mul(objectCoords.w);
}