本文整理汇总了Java中org.joml.Vector3f.add方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.add方法的具体用法?Java Vector3f.add怎么用?Java Vector3f.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joml.Vector3f
的用法示例。
在下文中一共展示了Vector3f.add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: update
import org.joml.Vector3f; //导入方法依赖的package包/类
/**
*
* @param screen
* @param viewMatrix
* @param light
*/
public void update(Screen screen, Matrix4f viewMatrix, DirectionalLight light) {
float aspectRatio = (float) screen.getWidth() / (float) screen.getHeight();
// Build view matrix for this shadow cascade.
this.projectionViewMatrix.setPerspective(Screen.FOV, aspectRatio, zNear, zFar);
this.projectionViewMatrix.mul(viewMatrix);
// Calculate frustum corners in space
float maxZ = Float.MIN_VALUE;
float minZ = Float.MAX_VALUE;
for (int i = 0; i < FRUSTUM_CORNERS; i++) {
Vector3f corner = this.frustumCorners[i];
corner.set(0, 0, 0);
this.projectionViewMatrix.frustumCorner(i, corner);
this.centr.add(corner);
this.centr.div(8.0f);
minZ = Math.min(minZ, corner.z);
maxZ = Math.max(maxZ, corner.z);
}
Vector3f lightDir = light.getDirection();
Vector3f lightPosInc = new Vector3f().set(lightDir);
float distance = maxZ - minZ;
lightPosInc.mul(distance);
Vector3f lightPos = new Vector3f();
lightPos.set(this.centr);
lightPos.add(lightPosInc);
updateLightViewMatrix(lightDir, lightPos);
updateLightProjectionMatrix();
}
示例2: getPosition
import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getPosition(Vector3f dst)
{
this.parent.getPosition(dst);
dst.add(super.position);
return dst;
}
示例3: getPosition
import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getPosition(Vector3f dst)
{
this.parent.getPosition(dst);
dst.add(super.position3());
return dst;
}
示例4: takeSamples
import org.joml.Vector3f; //导入方法依赖的package包/类
/**
*
* @param numSamples
* @param viewIncidence
* @param toViewer
* @param smoothReflection
* @param toSource
* @param mean
* @param stdDeviation
* @param ray
* @param surface
* @param rand
* @return
*/
private Vector3f takeSamples(int numSamples, float viewIncidence, Vector3fc toViewer, Vector3fc smoothReflection, Vector3fc toSource, float mean, float stdDeviation, Ray ray, Intersection surface) {
Vector3f microPerpendicular = findPerpendicular(toSource, new Vector3f());
Vector3f microReflection = new Vector3f();
Vector3f rayend = new Vector3f();
Vector3f retRadiance = new Vector3f();
Vector3f diffuse = new Vector3f();
Vector3f specular = new Vector3f();
Vector3f half = new Vector3f();
for(int i=0; i<numSamples; ++i) {
//generate sample direction
float rotation = uniformDistribution(0, 2*PI);
float microAngle = normalDistribution(mean, stdDeviation);
microReflection.set(toSource);
microReflection.rotateAxis(microAngle, microPerpendicular.x, microPerpendicular.y, microPerpendicular.z);
microReflection.rotateAxis(rotation, toSource.x(), toSource.y(), toSource.z() );
//cast ray
Ray sourceRay = new Ray( surface.point, rayend.set(surface.point).add(microReflection) );
sourceRay.depth = 1 + ray.depth;
sourceRay.addBias(surface.normal, 0.0001f);
Intersection source = rayTrace(sourceRay);
//diffuse
float sourceIncidence = Math.max(0, microReflection.dot(surface.normal) );
diffuse.set( source.radiantLght() ).mul(sourceIncidence).mul(surface.object.material.diffuseColour());
//specular
toViewer.half(microReflection, half);
float reflectIncidence = Math.max(0, microReflection.dot(smoothReflection) );
specular.set( source.radiantLght() ).mul(reflectIncidence);
//combining with specular power
float ior = surface.object.material.indexOfRefraction();
float r = surface.object.material.roughness();
float cos0 = saturate( half.dot(toViewer) );
float D = Distribution(surface.normal, half, r);
float G = Geometry(viewIncidence, r)*Geometry(sourceIncidence, r);
float F = Fresnel( cos0, ior);
if( viewIncidence != 0 && sourceIncidence != 0 ) {
float ks = F;
float kd = 1-ks;
retRadiance.add( specular.mul(ks*viewIncidence*G*D/( 4*viewIncidence*sourceIncidence )) );
retRadiance.add( diffuse.mul(kd) );
}
}
return retRadiance;
}