本文整理汇总了Java中org.joml.Vector3f.set方法的典型用法代码示例。如果您正苦于以下问题:Java Vector3f.set方法的具体用法?Java Vector3f.set怎么用?Java Vector3f.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.joml.Vector3f
的用法示例。
在下文中一共展示了Vector3f.set方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readVertexTexture
import org.joml.Vector3f; //导入方法依赖的package包/类
protected Vector3f readVertexTexture(Cursor cursor, Vector3f dst) throws IOException
{
this.consumeHorizontalWhiteSpaces(cursor);
String x = this.readNumber(cursor);
if (x.isEmpty())
{
throw formatError(cursor, "requires at least 1 component");
}
this.consumeHorizontalWhiteSpaces(cursor);
String y = "0";
if (!isVerticalWhiteSpace(cursor.getChar())) y = this.readNumber(cursor);
this.consumeHorizontalWhiteSpaces(cursor);
String z = "0";
if (!isVerticalWhiteSpace(cursor.getChar())) z = this.readNumber(cursor);
return dst.set(Float.valueOf(x), Float.valueOf(y), Float.valueOf(z));
}
示例2: readVertexNormal
import org.joml.Vector3f; //导入方法依赖的package包/类
protected Vector3f readVertexNormal(Cursor cursor, Vector3f 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 3 components");
}
return dst.set(Float.valueOf(x), Float.valueOf(y), Float.valueOf(z));
}
示例3: readVertexParamSpace
import org.joml.Vector3f; //导入方法依赖的package包/类
protected Vector3f readVertexParamSpace(Cursor cursor, Vector3f dst) throws IOException
{
this.consumeHorizontalWhiteSpaces(cursor);
String x = this.readNumber(cursor);
this.consumeHorizontalWhiteSpaces(cursor);
String y = this.readNumber(cursor);
if (x.isEmpty() || y.isEmpty())
{
throw formatError(cursor, "requires at least 2 components");
}
this.consumeHorizontalWhiteSpaces(cursor);
String z = "1";
if (!isVerticalWhiteSpace(cursor.getChar())) z = this.readNumber(cursor);
return dst.set(Float.valueOf(x), Float.valueOf(y), Float.valueOf(z));
}
示例4: 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();
}
示例5: getPoint2DFromScreen
import org.joml.Vector3f; //导入方法依赖的package包/类
public Vector3f getPoint2DFromScreen(float screenX, float screenY, Vector3f 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, 0);
}
示例6: findPerpendicular
import org.joml.Vector3f; //导入方法依赖的package包/类
/**
* @param src
* @param dest
* @return
*/
private Vector3f findPerpendicular(Vector3fc src, Vector3f dest) {
if(src.z() != 0) {
float pz = -src.x()/src.z();
dest.set(1, 0, pz).normalize();
}
else if(src.y() != 0) {
float py = -src.x()/src.y();
dest.set(1, py, 0).normalize();
}
else {
dest.set(0, 1, 0);
}
return dest;
}
示例7: getPosition
import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getPosition(Vector3f dst)
{
return dst.set(this.position);
}
示例8: getScale
import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getScale(Vector3f dst)
{
return dst.set(this.scale);
}
示例9: getPosition
import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getPosition(Vector3f dst)
{
return dst.set(this.position.x(), this.position.y(), 0);
}
示例10: getScale
import org.joml.Vector3f; //导入方法依赖的package包/类
@Override
public Vector3f getScale(Vector3f dst)
{
return dst.set(this.scale.x(), this.scale.y(), 1);
}
示例11: getNormalizedRGB
import org.joml.Vector3f; //导入方法依赖的package包/类
public static Vector3f getNormalizedRGB(int color, Vector3f dst)
{
return dst.set(((color >> 16) & 0xFF) / 255F, ((color >> 8) & 0xFF) / 255F, (color & 0xFF) / 255F);
}
示例12: HSBtoRGB
import org.joml.Vector3f; //导入方法依赖的package包/类
public static Vector3f HSBtoRGB(float hue, float saturation, float brightness, Vector3f dst)
{
int r = 0, g = 0, b = 0;
if (saturation == 0) {
r = g = b = (int) (brightness * 255.0f + 0.5f);
} else {
float h = (hue - (float)Math.floor(hue)) * 6.0f;
float f = h - (float)java.lang.Math.floor(h);
float p = brightness * (1.0f - saturation);
float q = brightness * (1.0f - saturation * f);
float t = brightness * (1.0f - (saturation * (1.0f - f)));
switch ((int) h) {
case 0:
r = (int) (brightness * 255.0f + 0.5f);
g = (int) (t * 255.0f + 0.5f);
b = (int) (p * 255.0f + 0.5f);
break;
case 1:
r = (int) (q * 255.0f + 0.5f);
g = (int) (brightness * 255.0f + 0.5f);
b = (int) (p * 255.0f + 0.5f);
break;
case 2:
r = (int) (p * 255.0f + 0.5f);
g = (int) (brightness * 255.0f + 0.5f);
b = (int) (t * 255.0f + 0.5f);
break;
case 3:
r = (int) (p * 255.0f + 0.5f);
g = (int) (q * 255.0f + 0.5f);
b = (int) (brightness * 255.0f + 0.5f);
break;
case 4:
r = (int) (t * 255.0f + 0.5f);
g = (int) (p * 255.0f + 0.5f);
b = (int) (brightness * 255.0f + 0.5f);
break;
case 5:
r = (int) (brightness * 255.0f + 0.5f);
g = (int) (p * 255.0f + 0.5f);
b = (int) (q * 255.0f + 0.5f);
break;
}
}
return dst.set(r, g, b);
}
示例13: RGBtoHSB
import org.joml.Vector3f; //导入方法依赖的package包/类
public static Vector3f RGBtoHSB(int red, int green, int blue, Vector3f dst)
{
float hue, saturation, brightness;
int cmax = (red > green) ? red : green;
if (blue > cmax) cmax = blue;
int cmin = (red < green) ? red : green;
if (blue < cmin) cmin = blue;
brightness = ((float) cmax) / 255.0f;
if (cmax != 0)
{
saturation = ((float) (cmax - cmin)) / ((float) cmax);
}
else
{
saturation = 0;
}
if (saturation == 0)
{
hue = 0;
}
else
{
float redc = ((float) (cmax - red)) / ((float) (cmax - cmin));
float greenc = ((float) (cmax - green)) / ((float) (cmax - cmin));
float bluec = ((float) (cmax - blue)) / ((float) (cmax - cmin));
if (red == cmax)
{
hue = bluec - greenc;
}
else if (green == cmax)
{
hue = 2.0f + redc - bluec;
}
else
{
hue = 4.0f + greenc - redc;
}
hue = hue / 6.0f;
if (hue < 0)
{
hue = hue + 1.0f;
}
}
return dst.set(hue, saturation, brightness);
}
示例14: 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;
}