本文整理汇总了Java中com.ra4king.opengl.util.math.Matrix3类的典型用法代码示例。如果您正苦于以下问题:Java Matrix3类的具体用法?Java Matrix3怎么用?Java Matrix3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Matrix3类属于com.ra4king.opengl.util.math包,在下文中一共展示了Matrix3类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: drawSphere
import com.ra4king.opengl.util.math.Matrix3; //导入依赖的package包/类
private void drawSphere(MatrixStack modelMatrix, Vector3 position, float radius, MaterialNames material, boolean drawImpostor) {
glBindBufferRange(GL_UNIFORM_BUFFER, materialBlockIndex, materialUniformBuffer, material.ordinal() * materialBlockOffset, MaterialBlock.SIZE);
if(drawImpostor) {
litImpPrograms[currentImpostor.ordinal()].program.begin();
glUniform3(litImpPrograms[currentImpostor.ordinal()].cameraSpherePosUniform, modelMatrix.getTop().mult(new Vector4(position, 1)).toBuffer());
glUniform1f(litImpPrograms[currentImpostor.ordinal()].sphereRadiusUniform, radius);
glBindVertexArray(impostorVAO);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glBindVertexArray(0);
litImpPrograms[currentImpostor.ordinal()].program.end();
}
else {
modelMatrix.pushMatrix();
modelMatrix.getTop().translate(position);
modelMatrix.getTop().scale(radius * 2);
litMeshProgram.program.begin();
glUniformMatrix4(litMeshProgram.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(litMeshProgram.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).inverse().transpose().toBuffer());
sphereMesh.render("lit");
litMeshProgram.program.end();
modelMatrix.popMatrix();
}
glBindBufferBase(GL_UNIFORM_BUFFER, materialBlockIndex, 0);
}
示例2: drawObject
import com.ra4king.opengl.util.math.Matrix3; //导入依赖的package包/类
public void drawObject(Mesh mesh, ProgramData prog, int materialBlockIndex, int materialIndex, MatrixStack modelMatrix) {
glBindBufferRange(GL_UNIFORM_BUFFER, materialBlockIndex, materialUniformBuffer, materialIndex * sizeMaterialBlock, MaterialBlock.SIZE);
prog.program.begin();
glUniformMatrix4(prog.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(prog.normalModelTocameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).inverse().transpose().toBuffer());
mesh.render();
prog.program.end();
glBindBufferBase(GL_UNIFORM_BUFFER, materialBlockIndex, 0);
}
示例3: render
import com.ra4king.opengl.util.math.Matrix3; //导入依赖的package包/类
@Override
public void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MatrixStack modelMatrix = new MatrixStack();
modelMatrix.setTop(viewPole.calcMatrix());
buildLights(modelMatrix.getTop());
nodes.get(0).setOrient(Utils.angleAxisDeg(360 * timer.getAlpha(), new Vector3(0, 1, 0)));
nodes.get(3).setOrient(spinBarOrient.copy().mult(Utils.angleAxisDeg(360 * timer.getAlpha(), new Vector3(0, 0, 1))));
Vector2 displaySize = new Vector2(getWidth() / 2, getHeight());
{
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, new Matrix4().clearToPerspectiveDeg(60, displaySize.x(), displaySize.y(), 1, 1000).toBuffer(), GL_STREAM_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
glViewport(0, 0, (int)displaySize.x(), (int)displaySize.y());
scene.render(modelMatrix.getTop());
if(drawCameraPos) {
modelMatrix.pushMatrix();
modelMatrix.getTop().clearToIdentity();
modelMatrix.getTop().translate(new Vector3(0, 0, -viewPole.getView().radius));
modelMatrix.getTop().scale(0.5f);
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
unlit.begin();
glUniformMatrix4(unlitModelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniform4f(unlitObjectColorUniform, 0.25f, 0.25f, 0.25f, 1);
sphereMesh.render("flat");
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
glUniform4f(unlitObjectColorUniform, 1, 1, 1, 1);
sphereMesh.render("flat");
unlit.end();
modelMatrix.popMatrix();
}
{
Matrix4 persMatrix = new Matrix4().clearToIdentity().set(new Matrix3(persViewPole.calcMatrix()));
persMatrix.mult(new Matrix4().clearToPerspectiveDeg(60, displaySize.x(), displaySize.y(), 1, 1000));
glBindBuffer(GL_UNIFORM_BUFFER, projectionUniformBuffer);
glBufferData(GL_UNIFORM_BUFFER, persMatrix.toBuffer(), GL_STREAM_DRAW);
glBindBuffer(GL_UNIFORM_BUFFER, 0);
}
if(!depthClampProj)
glDisable(GL_DEPTH_CLAMP);
glViewport((int)(displaySize.x() + (getWidth() % 2)), 0, (int)displaySize.x(), (int)displaySize.y());
scene.render(modelMatrix.getTop());
glEnable(GL_DEPTH_CLAMP);
}
示例4: render
import com.ra4king.opengl.util.math.Matrix3; //导入依赖的package包/类
@Override
public void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MatrixStack modelMatrix = new MatrixStack();
modelMatrix.setTop(viewPole.calcMatrix());
Vector4 worldLightPos = calcLightPosition();
Vector4 lightPosCameraSpace = modelMatrix.getTop().mult(worldLightPos);
whiteDiffuseColor.program.begin();
glUniform3(whiteDiffuseColor.lightPosUniform, lightPosCameraSpace.toBuffer());
vertexDiffuseColor.program.begin();
glUniform3(vertexDiffuseColor.lightPosUniform, lightPosCameraSpace.toBuffer());
vertexDiffuseColor.program.end();
whiteDiffuseColor.program.begin();
glUniform4f(whiteDiffuseColor.lightIntensityUniform, 0.8f, 0.8f, 0.8f, 1);
glUniform4f(whiteDiffuseColor.ambientIntensityUniform, 0.2f, 0.2f, 0.2f, 1);
vertexDiffuseColor.program.begin();
glUniform4f(vertexDiffuseColor.lightIntensityUniform, 0.8f, 0.8f, 0.8f, 1);
glUniform4f(vertexDiffuseColor.ambientIntensityUniform, 0.2f, 0.2f, 0.2f, 1);
vertexDiffuseColor.program.end();
{
modelMatrix.pushMatrix();
{
modelMatrix.pushMatrix();
whiteDiffuseColor.program.begin();
glUniformMatrix4(whiteDiffuseColor.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(whiteDiffuseColor.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
planeMesh.render();
whiteDiffuseColor.program.end();
modelMatrix.popMatrix();
}
{
modelMatrix.pushMatrix();
modelMatrix.getTop().mult(objectPole.calcMatrix());
if(drawColoredCyl) {
vertexDiffuseColor.program.begin();
glUniformMatrix4(vertexDiffuseColor.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(vertexDiffuseColor.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
cylinderMesh.render("lit-color");
vertexDiffuseColor.program.end();
} else {
whiteDiffuseColor.program.begin();
glUniformMatrix4(whiteDiffuseColor.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(whiteDiffuseColor.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
cylinderMesh.render("lit");
whiteDiffuseColor.program.end();
}
modelMatrix.popMatrix();
}
if(drawLight) {
modelMatrix.pushMatrix();
modelMatrix.getTop().translate(new Vector3(worldLightPos)).scale(0.1f, 0.1f, 0.1f);
unlit.program.begin();
glUniformMatrix4(unlit.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniform4f(unlit.objectColorUniform, 0.8078f, 0.8706f, 0.9922f, 1);
cubeMesh.render("flat");
unlit.program.end();
modelMatrix.popMatrix();
}
modelMatrix.popMatrix();
}
}
示例5: render
import com.ra4king.opengl.util.math.Matrix3; //导入依赖的package包/类
@Override
public void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MatrixStack modelMatrix = new MatrixStack();
modelMatrix.setTop(viewPole.calcMatrix());
Matrix4 worldToCamMatrix = modelMatrix.getTop();
LightBlock lightData = new LightBlock(new Vector4(0.2f, 0.2f, 0.2f, 1), lightAttenuation);
lightData.lights[0] = new PerLight(worldToCamMatrix.mult(new Vector4(0.707f, 0.707f, 0, 0)), new Vector4(0.6f, 0.6f, 0.6f, 1));
lightData.lights[1] = new PerLight(worldToCamMatrix.mult(calcLightPosition()), new Vector4(0.4f, 0.4f, 0.4f, 1));
glBindBuffer(GL_UNIFORM_BUFFER, lightUniformBuffer);
glBufferSubData(GL_UNIFORM_BUFFER, 0, lightData.toBuffer());
glBindBuffer(GL_UNIFORM_BUFFER, 0);
{
glBindBufferRange(GL_UNIFORM_BUFFER, materialBlockIndex, materialUniformBuffer, MaterialNames.TERRAIN.ordinal() * materialBlockOffset, MaterialBlock.SIZE);
litMeshProgram.program.begin();
glUniformMatrix4(litMeshProgram.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(litMeshProgram.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).inverse().transpose().toBuffer());
planeMesh.render();
litMeshProgram.program.end();
glBindBufferBase(GL_UNIFORM_BUFFER, materialBlockIndex, 0);
}
drawSphere(modelMatrix, new Vector3(0, 10, 0), 4, MaterialNames.BLUE_SHINY, drawImpostor[0]);
drawSphereOrbit(modelMatrix, new Vector3(0, 10, 0), new Vector3(0.6f, 0.8f, 0), 20, sphereTimer.getAlpha(), 2, MaterialNames.DULL_GREY, drawImpostor[1]);
drawSphereOrbit(modelMatrix, new Vector3(-10, 1, 0), new Vector3(0, 1, 0), 10, sphereTimer.getAlpha(), 1, MaterialNames.BLACK_SHINY, drawImpostor[2]);
drawSphereOrbit(modelMatrix, new Vector3(10, 1, 0), new Vector3(0, 1, 0), 10, sphereTimer.getAlpha() * 2, 1, MaterialNames.GOLD_METAL, drawImpostor[3]);
if(drawLights) {
modelMatrix.pushMatrix();
modelMatrix.getTop().translate(new Vector3(calcLightPosition()));
modelMatrix.getTop().scale(0.5f);
unlit.program.begin();
glUniformMatrix4(unlit.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniform4(unlit.objectColorUniform, new Vector4(1).toBuffer());
cubeMesh.render("flat");
unlit.program.end();
modelMatrix.popMatrix();
}
if(drawCameraPos) {
modelMatrix.pushMatrix();
modelMatrix.getTop().clearToIdentity();
modelMatrix.getTop().translate(0, 0, -viewPole.getView().radius);
unlit.program.begin();
glDisable(GL_DEPTH_TEST);
glDepthMask(false);
glUniformMatrix4(unlit.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniform4f(unlit.objectColorUniform, 0.25f, 0.25f, 0.25f, 1);
cubeMesh.render("flat");
glDepthMask(true);
glEnable(GL_DEPTH_TEST);
glUniform4f(unlit.objectColorUniform, 1, 1, 1, 1);
cubeMesh.render("flat");
unlit.program.end();
}
}
示例6: render
import com.ra4king.opengl.util.math.Matrix3; //导入依赖的package包/类
@Override
public void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MatrixStack modelMatrix = new MatrixStack();
modelMatrix.setTop(viewPole.calcMatrix());
Vector4 lightDirCameraSpace = modelMatrix.getTop().mult(lightDirection);
ProgramData whiteDiffuse = showAmbient ? whiteAmbDiffuseColor : whiteDiffuseColor;
ProgramData vertexDiffuse = showAmbient ? vertexAmbDiffuseColor : vertexDiffuseColor;
if(showAmbient) {
whiteDiffuse.program.begin();
glUniform4f(whiteDiffuse.lightIntensityUniform, 0.8f, 0.8f, 0.8f, 1);
glUniform4f(whiteDiffuse.ambientIntensityUniform, 0.2f, 0.2f, 0.2f, 1);
vertexDiffuse.program.begin();
glUniform4f(vertexDiffuse.lightIntensityUniform, 0.8f, 0.8f, 0.8f, 1);
glUniform4f(vertexDiffuse.ambientIntensityUniform, 0.2f, 0.2f, 0.2f, 1);
vertexDiffuse.program.end();
} else {
whiteDiffuse.program.begin();
glUniform4f(whiteDiffuse.lightIntensityUniform, 1, 1, 1, 1);
vertexDiffuse.program.begin();
glUniform4f(vertexDiffuse.lightIntensityUniform, 1, 1, 1, 1);
vertexDiffuse.program.end();
}
whiteDiffuse.program.begin();
glUniform3(whiteDiffuse.dirTolightUniform, lightDirCameraSpace.toBuffer());
vertexDiffuse.program.begin();
glUniform3(vertexDiffuse.dirTolightUniform, lightDirCameraSpace.toBuffer());
vertexDiffuse.program.end();
{
modelMatrix.pushMatrix();
{
modelMatrix.pushMatrix();
whiteDiffuse.program.begin();
glUniformMatrix4(whiteDiffuse.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(whiteDiffuse.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
planeMesh.render();
whiteDiffuse.program.end();
modelMatrix.popMatrix();
}
{
modelMatrix.pushMatrix();
modelMatrix.getTop().mult(objectPole.calcMatrix());
if(drawColoredCyl) {
vertexDiffuse.program.begin();
glUniformMatrix4(vertexDiffuse.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(vertexDiffuse.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
cylinderMesh.render("lit-color");
vertexDiffuse.program.end();
} else {
whiteDiffuse.program.begin();
glUniformMatrix4(whiteDiffuse.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(whiteDiffuse.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
cylinderMesh.render("lit");
whiteDiffuse.program.end();
}
modelMatrix.popMatrix();
}
modelMatrix.popMatrix();
}
}
示例7: render
import com.ra4king.opengl.util.math.Matrix3; //导入依赖的package包/类
@Override
public void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MatrixStack modelMatrix = new MatrixStack();
modelMatrix.setTop(viewPole.calcMatrix());
Vector4 lightDirCameraSpace = modelMatrix.getTop().mult(lightDirection);
whiteDiffuseColor.program.begin();
glUniform3(whiteDiffuseColor.dirTolightUniform, lightDirCameraSpace.toBuffer());
vertexDiffuseColor.program.begin();
glUniform3(vertexDiffuseColor.dirTolightUniform, lightDirCameraSpace.toBuffer());
vertexDiffuseColor.program.end();
{
modelMatrix.pushMatrix();
{
modelMatrix.pushMatrix();
whiteDiffuseColor.program.begin();
glUniformMatrix4(whiteDiffuseColor.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(whiteDiffuseColor.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
glUniform4f(whiteDiffuseColor.lightIntensityUniform, 1, 1, 1, 1);
planeMesh.render();
whiteDiffuseColor.program.end();
modelMatrix.popMatrix();
}
{
modelMatrix.pushMatrix();
modelMatrix.getTop().mult(objectPole.calcMatrix());
if(drawColoredCyl) {
vertexDiffuseColor.program.begin();
glUniformMatrix4(vertexDiffuseColor.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(vertexDiffuseColor.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
glUniform4f(vertexDiffuseColor.lightIntensityUniform, 1, 1, 1, 1);
cylinderMesh.render("lit-color");
vertexDiffuseColor.program.end();
} else {
whiteDiffuseColor.program.begin();
glUniformMatrix4(whiteDiffuseColor.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(whiteDiffuseColor.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
glUniform4f(whiteDiffuseColor.lightIntensityUniform, 1, 1, 1, 1);
cylinderMesh.render("lit");
whiteDiffuseColor.program.end();
}
modelMatrix.popMatrix();
}
modelMatrix.popMatrix();
}
}
示例8: render
import com.ra4king.opengl.util.math.Matrix3; //导入依赖的package包/类
@Override
public void render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
MatrixStack modelMatrix = new MatrixStack();
modelMatrix.setTop(viewPole.calcMatrix());
Vector4 lightDirCameraSpace = modelMatrix.getTop().mult(lightDirection);
whiteDiffuseColor.program.begin();
glUniform3(whiteDiffuseColor.dirTolightUniform, lightDirCameraSpace.toBuffer());
vertexDiffuseColor.program.begin();
glUniform3(vertexDiffuseColor.dirTolightUniform, lightDirCameraSpace.toBuffer());
vertexDiffuseColor.program.end();
{
modelMatrix.pushMatrix();
{
modelMatrix.pushMatrix();
whiteDiffuseColor.program.begin();
glUniformMatrix4(whiteDiffuseColor.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
glUniformMatrix3(whiteDiffuseColor.normalModelToCameraMatrixUniform, false, new Matrix3(modelMatrix.getTop()).toBuffer());
glUniform4f(whiteDiffuseColor.lightIntensityUniform, 1, 1, 1, 1);
planeMesh.render();
whiteDiffuseColor.program.end();
modelMatrix.popMatrix();
}
{
modelMatrix.pushMatrix();
modelMatrix.getTop().mult(objectPole.calcMatrix());
if(scaleCyl)
modelMatrix.getTop().scale(1, 1, 0.2f);
vertexDiffuseColor.program.begin();
glUniformMatrix4(vertexDiffuseColor.modelToCameraMatrixUniform, false, modelMatrix.getTop().toBuffer());
Matrix3 normMatrix = new Matrix3(modelMatrix.getTop());
if(doInvTranspose)
normMatrix.inverse().transpose();
glUniformMatrix3(vertexDiffuseColor.normalModelToCameraMatrixUniform, false, normMatrix.toBuffer());
glUniform4f(vertexDiffuseColor.lightIntensityUniform, 1, 1, 1, 1);
cylinderMesh.render("lit-color");
vertexDiffuseColor.program.end();
modelMatrix.popMatrix();
}
modelMatrix.popMatrix();
}
}