本文整理汇总了Java中com.ra4king.opengl.util.math.Vector4类的典型用法代码示例。如果您正苦于以下问题:Java Vector4类的具体用法?Java Vector4怎么用?Java Vector4使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Vector4类属于com.ra4king.opengl.util.math包,在下文中一共展示了Vector4类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadCube
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
public static float[] loadCube(Vector3 sideLength, Vector3 center, boolean interleaved, boolean vec4, Matrix4 modelMatrix) {
float[] buffer = vec4 ? (interleaved ? cubeVec4interleaved : cubeVec4) : (interleaved ? cubeVec3interleaved : cubeVec3);
for(int a = 0; a < cubeData.length / 2; a += 3) {
int position = (a / 3) * ((interleaved ? 3 : 0) + (vec4 ? 4 : 3));
Vector4 pos = new Vector4();
if(modelMatrix == null) {
pos.set(center.x() + cubeData[a] * sideLength.x(), center.y() + cubeData[a + 1] * sideLength.y(), center.z() + cubeData[a + 2] * sideLength.z(), 1);
} else {
modelMatrix.mult4(new Vector4(center.x() + cubeData[a] * sideLength.x(), center.y() + cubeData[a + 1] * sideLength.y(), center.z() + cubeData[a + 2] * sideLength.z(), 1), pos);
}
buffer[position + 0] = pos.x();
buffer[position + 1] = pos.y();
buffer[position + 2] = pos.z();
}
return buffer;
}
示例2: loadPlane
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
public static float[] loadPlane(Vector2 sideLength, Vector3 center, boolean interleaved, boolean vec4, Matrix4 modelMatrix) {
float[] buffer = vec4 ? (interleaved ? planeVec4interleaved : planeVec4) : (interleaved ? planeVec3interleaved : planeVec3);
for(int a = 0; a < planeData.length / 2; a += 3) {
int position = (a / 3) * ((interleaved ? 3 : 0) + (vec4 ? 4 : 3));
Vector4 pos = new Vector4();
if(modelMatrix == null) {
pos.set(center.x() + cubeData[a] * sideLength.x(), center.y() + cubeData[a + 1] * sideLength.y(), center.z() + cubeData[a + 2], 1);
} else {
modelMatrix.mult4(new Vector4(center.x() + cubeData[a] * sideLength.x(), center.y() + cubeData[a + 1] * sideLength.y(), center.z() + cubeData[a + 2], 1), pos);
}
buffer[position + 0] = pos.x();
buffer[position + 1] = pos.y();
buffer[position + 2] = pos.z();
}
return buffer;
}
示例3: PerformanceGraph
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
/**
* Creates a PerformanceGraph at location (x,y) with size (maxSteps*stepWidth, graphHeight).
* The origin (0,0) is at the top left corner of the window.
*
* @param stepValueSupplier The Supplier of the values of each step
* @param maxValue The value to represent as 100%
* @param x The left side of the graph
* @param y The top of the graph
* @param maxSteps The number of steps in the graph
* @param stepWidth The size (in pixels) of each step
* @param graphHeight The height of the graph
* @param color The color of the graph
*/
public PerformanceGraph(float maxValue, int x, int y, int maxSteps, int stepWidth, int graphHeight, Vector4 color, Supplier<? extends Number> stepValueSupplier) {
this.stepValueSupplier = stepValueSupplier;
setMaxValue(maxValue);
setX(x);
setY(y);
this.width = maxSteps * stepWidth;
this.height = graphHeight;
this.maxSteps = maxSteps;
this.stepWidth = stepWidth;
init();
this.setColor(color);
}
示例4: createMaterials
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private void createMaterials() {
ArrayList<MaterialEntry> materials = new ArrayList<>();
materials.add(new MaterialEntry(new Vector4(0.1f, 0.1f, 0.8f, 1), new Vector4(0.8f, 0.8f, 0.8f, 1), 0.1f));
materials.add(new MaterialEntry(new Vector4(0.4f, 0.4f, 0.4f, 1), new Vector4(0.1f, 0.1f, 0.1f, 1), 0.8f));
materials.add(new MaterialEntry(new Vector4(0.05f, 0.05f, 0.05f, 1), new Vector4(0.95f, 0.95f, 0.95f, 1), 0.3f));
materials.add(new MaterialEntry(new Vector4(0.803f, 0.709f, 0.15f, 1), new Vector4(0.803f, 0.709f, 0.15f, 1).mult(0.75f), 0.18f));
materialArrayUniformBuffer = glGenBuffers();
materialTerrainUniformBuffer = glGenBuffers();
FloatBuffer buffer = BufferUtils.createFloatBuffer(materials.size() * MaterialEntry.SIZE / 4);
for(MaterialEntry me : materials)
buffer.put(me.toBuffer());
buffer.flip();
glBindBuffer(GL_UNIFORM_BUFFER, materialArrayUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, buffer, GL_STATIC_DRAW);
MaterialEntry material = new MaterialEntry(new Vector4(0.5f, 0.5f, 0.5f, 1), new Vector4(0.5f, 0.5f, 0.5f, 1), 0.6f);
glBindBuffer(GL_UNIFORM_BUFFER, materialTerrainUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, material.toBuffer(), GL_STATIC_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
示例5: getSphereOrbitPosition
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private Vector3 getSphereOrbitPosition(MatrixStack modelMatrix, Vector3 orbitCenter, Vector3 orbitAxis, float orbitRadius, float orbitAlpha) {
modelMatrix.pushMatrix();
try {
modelMatrix.getTop().translate(orbitCenter);
modelMatrix.getTop().rotateDeg(360 * orbitAlpha, orbitAxis);
Vector3 offsetDir = orbitAxis.copy().cross(new Vector3(0, 1, 0));
if(offsetDir.length() < 0.001f)
offsetDir = orbitAxis.copy().cross(new Vector3(1, 0, 0));
offsetDir.normalize();
modelMatrix.getTop().translate(offsetDir.mult(orbitRadius));
return new Vector3(modelMatrix.getTop().mult(new Vector4(0, 0, 0, 1)));
} finally {
modelMatrix.popMatrix();
}
}
示例6: setSunlightValues
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
public void setSunlightValues(SunlightValue[] values) {
ArrayList<TimedLinearInterpolatorVector<Vector4>.Data> ambient = new ArrayList<>();
ArrayList<TimedLinearInterpolatorVector<Vector4>.Data> light = new ArrayList<>();
ArrayList<TimedLinearInterpolatorVector<Vector4>.Data> background = new ArrayList<>();
for(SunlightValue v : values) {
ambient.add(ambientInterpolator.new Data(v.ambient, v.normTime));
light.add(sunlightInterpolator.new Data(v.sunlightIntensity, v.normTime));
background.add(backgroundInterpolator.new Data(v.backgroundColor, v.normTime));
}
ambientInterpolator.setValues(ambient);
sunlightInterpolator.setValues(light);
backgroundInterpolator.setValues(background);
ArrayList<TimedLinearInterpolatorf.Data> maxIntensity = new ArrayList<>();
maxIntensity.add(maxIntensityInterpolator.new Data(1, 0));
maxIntensityInterpolator.setValues(maxIntensity, false);
}
示例7: setupHDRLighting
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private void setupHDRLighting() {
SunlightValueHDR values[] = {
new SunlightValueHDR(0.0f / 24.0f, new Vector4(0.6f, 0.6f, 0.6f, 1.0f), new Vector4(1.8f, 1.8f, 1.8f, 1.0f), skyDaylightColor, 3.0f),
new SunlightValueHDR(4.5f / 24.0f, new Vector4(0.6f, 0.6f, 0.6f, 1.0f), new Vector4(1.8f, 1.8f, 1.8f, 1.0f), skyDaylightColor, 3.0f),
new SunlightValueHDR(6.5f / 24.0f, new Vector4(0.225f, 0.075f, 0.075f, 1.0f), new Vector4(0.45f, 0.15f, 0.15f, 1.0f), new Vector4(0.5f, 0.1f, 0.1f, 1.0f), 1.5f),
new SunlightValueHDR(8.0f / 24.0f, new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), 1.0f),
new SunlightValueHDR(18.0f / 24.0f, new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), 1.0f),
new SunlightValueHDR(19.5f / 24.0f, new Vector4(0.225f, 0.075f, 0.075f, 1.0f), new Vector4(0.45f, 0.15f, 0.15f, 1.0f), new Vector4(0.5f, 0.1f, 0.1f, 1.0f), 1.5f),
new SunlightValueHDR(20.5f / 24.0f, new Vector4(0.6f, 0.6f, 0.6f, 1.0f), new Vector4(1.8f, 1.8f, 1.8f, 1.0f), skyDaylightColor, 3.0f)
};
lights.setSunlightValues(values);
lights.setPointLightIntensity(0, new Vector4(0.6f, 0.6f, 0.6f, 1));
lights.setPointLightIntensity(1, new Vector4(0, 0, 0.7f, 1));
lights.setPointLightIntensity(2, new Vector4(0.7f, 0, 0, 1));
}
示例8: setupGammaLighting
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private void setupGammaLighting() {
Vector4 sunlight = new Vector4(6.5f, 6.5f, 6.5f, 1.0f);
Vector4 brightAmbient = new Vector4(0.4f, 0.4f, 0.4f, 1.0f);
SunlightValueHDR values[] = {
new SunlightValueHDR(0.0f / 24.0f, brightAmbient, sunlight, new Vector4(0.65f, 0.65f, 1.0f, 1.0f), 10.0f),
new SunlightValueHDR(4.5f / 24.0f, brightAmbient, sunlight, skyDaylightColor, 10.0f),
new SunlightValueHDR(6.5f / 24.0f, new Vector4(0.01f, 0.025f, 0.025f, 1.0f), new Vector4(2.5f, 0.2f, 0.2f, 1.0f), new Vector4(0.5f, 0.1f, 0.1f, 1.0f), 5.0f),
new SunlightValueHDR(8.0f / 24.0f, new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), 3.0f),
new SunlightValueHDR(18.0f / 24.0f, new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), 3.0f),
new SunlightValueHDR(19.5f / 24.0f, new Vector4(0.01f, 0.025f, 0.025f, 1.0f), new Vector4(2.5f, 0.2f, 0.2f, 1.0f), new Vector4(0.5f, 0.1f, 0.1f, 1.0f), 5.0f),
new SunlightValueHDR(20.5f / 24.0f, brightAmbient, sunlight, skyDaylightColor, 10.0f),
};
lights.setSunlightValues(values);
lights.setPointLightIntensity(0, new Vector4(0.6f, 0.6f, 0.6f, 1.0f));
lights.setPointLightIntensity(1, new Vector4(0.0f, 0.0f, 0.7f, 1.0f));
lights.setPointLightIntensity(2, new Vector4(0.7f, 0.0f, 0.0f, 1.0f));
}
示例9: setupDaytimeLighting
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private void setupDaytimeLighting() {
SunlightValue[] values = {
new SunlightValue(0.0f / 24.0f, new Vector4(0.2f, 0.2f, 0.2f, 1.0f), new Vector4(0.6f, 0.6f, 0.6f, 1.0f), skyDaylightColor),
new SunlightValue(4.5f / 24.0f, new Vector4(0.2f, 0.2f, 0.2f, 1.0f), new Vector4(0.6f, 0.6f, 0.6f, 1.0f), skyDaylightColor),
new SunlightValue(6.5f / 24.0f, new Vector4(0.15f, 0.05f, 0.05f, 1.0f), new Vector4(0.3f, 0.1f, 0.10f, 1.0f), new Vector4(0.5f, 0.1f, 0.1f, 1.0f)),
new SunlightValue(8.0f / 24.0f, new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
new SunlightValue(18.0f / 24.0f, new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
new SunlightValue(19.5f / 24.0f, new Vector4(0.15f, 0.05f, 0.05f, 1.0f), new Vector4(0.3f, 0.1f, 0.1f, 1.0f), new Vector4(0.5f, 0.1f, 0.1f, 1.0f)),
new SunlightValue(20.5f / 24.0f, new Vector4(0.2f, 0.2f, 0.2f, 1.0f), new Vector4(0.6f, 0.6f, 0.6f, 1.0f), skyDaylightColor)
};
lights.setSunlightValues(values);
lights.setPointLightIntensity(0, new Vector4(0.2f, 0.2f, 0.2f, 1));
lights.setPointLightIntensity(1, new Vector4(0, 0, 0.3f, 1));
lights.setPointLightIntensity(2, new Vector4(0.3f, 0, 0, 1));
}
示例10: setupNighttimeLighting
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private void setupNighttimeLighting() {
SunlightValue[] values = {
new SunlightValue(0.0f / 24.0f, new Vector4(0.2f, 0.2f, 0.2f, 1.0f), new Vector4(0.6f, 0.6f, 0.6f, 1.0f), skyDaylightColor),
new SunlightValue(4.5f / 24.0f, new Vector4(0.2f, 0.2f, 0.2f, 1.0f), new Vector4(0.6f, 0.6f, 0.6f, 1.0f), skyDaylightColor),
new SunlightValue(6.5f / 24.0f, new Vector4(0.15f, 0.05f, 0.05f, 1.0f), new Vector4(0.3f, 0.1f, 0.10f, 1.0f), new Vector4(0.5f, 0.1f, 0.1f, 1.0f)),
new SunlightValue(8.0f / 24.0f, new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
new SunlightValue(18.0f / 24.0f, new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f), new Vector4(0.0f, 0.0f, 0.0f, 1.0f)),
new SunlightValue(19.5f / 24.0f, new Vector4(0.15f, 0.05f, 0.05f, 1.0f), new Vector4(0.3f, 0.1f, 0.1f, 1.0f), new Vector4(0.5f, 0.1f, 0.1f, 1.0f)),
new SunlightValue(20.5f / 24.0f, new Vector4(0.2f, 0.2f, 0.2f, 1.0f), new Vector4(0.6f, 0.6f, 0.6f, 1.0f), skyDaylightColor)
};
lights.setSunlightValues(values);
lights.setPointLightIntensity(0, new Vector4(0.6f, 0.6f, 0.6f, 1));
lights.setPointLightIntensity(1, new Vector4(0, 0, 0.7f, 1));
lights.setPointLightIntensity(2, new Vector4(0.7f, 0, 0, 1));
}
示例11: getPlane
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private void getPlane(Matrix4 matrix, int row, Vector4 plane) {
int scale = row < 0 ? -1 : 1;
row = Math.abs(row) - 1;
plane.set(matrix.get(3) + scale * matrix.get(row),
matrix.get(7) + scale * matrix.get(row + 4),
matrix.get(11) + scale * matrix.get(row + 8),
matrix.get(15) + scale * matrix.get(row + 12)).normalize();
}
示例12: parseVector4
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
@CopyStruct
public static Vector4 parseVector4(String s) {
String[] comp = StringUtil.split(s, ' ');
if(comp.length != 4)
throw new IllegalArgumentException("invalid Vector4");
Vector4 vec = new Vector4();
vec.x(Float.parseFloat(comp[0]));
vec.y(Float.parseFloat(comp[1]));
vec.z(Float.parseFloat(comp[2]));
vec.w(Float.parseFloat(comp[3]));
return vec;
}
示例13: render
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
@Override
public void render() {
Stopwatch.start("World Render");
worldRenderers[currentWorld].render(Struct.nullStruct(Vector4.class), null, 0, camera);
Stopwatch.stop();
if(showPerformanceGraphs) {
Stopwatch.start("Performance Graphs Render");
performanceGraphUpdate.render();
performanceGraphRender.render();
performanceGraphChunkRenderers.render();
performanceGraphUpdateCompactArray.render();
performanceGraphLightSystemRender.render();
performanceGraphBulletRender.render();
performanceGraphDisplayUpdate.render();
performanceGraphFPS.render();
Stopwatch.stop();
}
font.render(getLastFps() + " FPS", 100, 75, 20, new Vector4(0, 1, 0, 1));
font.render(String.format("Update: %.2f ms", Stopwatch.getTimePerFrame("Update")), 100, 55, 20, new Vector4(0, 0, 1, 1));
font.render(String.format("Render: %.2f ms", Stopwatch.getTimePerFrame("Render")), 100, 35, 20, new Vector4(0, 1, 1, 1));
font.render(String.format("Display.update(): %.2f ms", Stopwatch.getTimePerFrame("Display.update()")), 100, 15, 20, new Vector4(1, 0, 1, 1));
font.render(String.format("Update Compact Array: %.2f ms", Stopwatch.getTimePerFrame("Update Compact Array")), 360, 75, 20, new Vector4(1, 0, 0, 1));
font.render(String.format("Bullet Render: %.2f ms", Stopwatch.getTimePerFrame("BulletRenderer")), 360, 55, 20, new Vector4(1, 1, 1, 1));
font.render(String.format("Light System Render: %.2f ms", Stopwatch.getTimePerFrame("LightSystem render UBO")), 360, 35, 20, new Vector4(1, 1, 0, 1));
font.render(String.format("Chunk Render: %.2f ms", Stopwatch.getTimePerFrame("ChunkRenderers")), 360, 15, 20, new Vector4(0.5f, 0.5f, 0.5f, 1));
font.render("Position: " + camera.getPosition().toString(), 20, Display.getHeight() - 40, 20, new Vector4(1));
int totalChunksRendered = 0, totalBlocksRendered = 0;
for(WorldRenderer renderer : worldRenderers) {
totalChunksRendered += renderer.getChunksRenderedCount();
totalBlocksRendered += renderer.getBlocksRenderedCount();
}
font.render("Chunks visible: " + totalChunksRendered + ", Total cubes rendered: " + totalBlocksRendered, 20, Display.getHeight() - 60, 20, new Vector4(1));
}
示例14: buildLights
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private void buildLights(Matrix4 cameraMatrix) {
LightBlock lightData = new LightBlock(new Vector4(0.2f, 0.2f, 0.2f, 1), 1f / 900f, 2);
lightData.lights[0] = new PerLight(cameraMatrix.mult(new Vector4(-0.2f, 0.5f, 0.5f, 0).normalize()), new Vector4(0.2f, 0.2f, 0.2f, 1));
lightData.lights[1] = new PerLight(cameraMatrix.mult(new Vector4(5, 6, 0.5f, 1)), new Vector4(3.5f, 6.5f, 3, 1).mult(0.5f));
if(showOtherLights)
lightNumBinder.setValue(2);
else
lightNumBinder.setValue(0);
glBindBuffer(GL_UNIFORM_BUFFER, lightUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, lightData.toBuffer(), GL_STREAM_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
示例15: buildLights
import com.ra4king.opengl.util.math.Vector4; //导入依赖的package包/类
private void buildLights(Matrix4 cameraMatrix) {
LightBlock lightData = new LightBlock(new Vector4(0.2f, 0.2f, 0.2f, 1), 1f / 25f, 3);
lightData.lights[0] = new PerLight(cameraMatrix.mult(new Vector4(-0.2f, 0.5f, 0.5f, 0).normalize()), new Vector4(2, 2, 2.5f, 1));
lightData.lights[1] = new PerLight(cameraMatrix.mult(new Vector4(5, 6, 0.5f, 1)), new Vector4(3.5f, 6.5f, 3, 1).mult(1.2f));
lightNumBinder.setValue(2);
glBindBuffer(GL_UNIFORM_BUFFER, lightUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, lightData.toBuffer(), GL_STREAM_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}