当前位置: 首页>>代码示例>>Java>>正文


Java Vector2.y方法代码示例

本文整理汇总了Java中com.ra4king.opengl.util.math.Vector2.y方法的典型用法代码示例。如果您正苦于以下问题:Java Vector2.y方法的具体用法?Java Vector2.y怎么用?Java Vector2.y使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.ra4king.opengl.util.math.Vector2的用法示例。


在下文中一共展示了Vector2.y方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onDragRotate

import com.ra4king.opengl.util.math.Vector2; //导入方法依赖的package包/类
public void onDragRotate(Vector2 position) {
	int diffX = (int)(position.x() - startDragMouseLoc.x());
	int diffY = -(int)(position.y() - startDragMouseLoc.y());
	
	switch(rotateMode) {
		case DUAL_AXIS_ROTATE:
			processXYChange(diffX, diffY);
			break;
		case BIAXIAL_ROTATE:
			if(Math.abs(diffX) > Math.abs(diffY))
				processXChange(diffX);
			else
				processYChange(diffY);
			break;
		case XZ_AXIS_ROTATE:
			processXChange(diffX);
			break;
		case Y_AXIS_ROTATE:
			processYChange(diffY);
			break;
		case SPIN_VIEW_AXIS:
			processSpinAxis(diffX);
			break;
	}
}
 
开发者ID:ra4king,项目名称:LWJGL-OpenGL-Utils,代码行数:26,代码来源:MousePoles.java

示例2: mouseMove

import com.ra4king.opengl.util.math.Vector2; //导入方法依赖的package包/类
@Override
public void mouseMove(Vector2 position) {
	if(isDragging) {
		Vector2 diff = new Vector2(position).sub(prevMousePos);
		
		switch(rotateMode) {
			case DUAL_AXIS:
				Quaternion rot = calcRotationQuat(Axis.AXIS_Y, diff.x() * rotateScale);
				rot = calcRotationQuat(Axis.AXIS_X, diff.y() * rotateScale).mult(rot).normalize();
				rotateViewDegrees(rot, false);
				break;
			case BIAXIAL: {
				Vector2 initDiff = new Vector2(position).sub(startDragMousePos);
				
				Axis axis;
				float degAngle;
				if(Math.abs(initDiff.x()) > Math.abs(initDiff.y())) {
					axis = Axis.AXIS_Y;
					degAngle = initDiff.x() * rotateScale;
				} else {
					axis = Axis.AXIS_X;
					degAngle = initDiff.y() * rotateScale;
				}
				
				rotateViewDegrees(calcRotationQuat(axis, degAngle), true);
			}
				break;
			case SPIN:
				rotateViewDegrees(calcRotationQuat(Axis.AXIS_Z, -diff.x() * rotateScale), false);
				break;
		}
		
		prevMousePos.set(position);
	}
}
 
开发者ID:ra4king,项目名称:LWJGL-OpenGL-Utils,代码行数:36,代码来源:MousePoles.java

示例3: parseVector2

import com.ra4king.opengl.util.math.Vector2; //导入方法依赖的package包/类
@CopyStruct
public static Vector2 parseVector2(String s) throws NumberFormatException {
	String[] comp = StringUtil.split(s, ' ');
	if(comp.length != 2)
		throw new IllegalArgumentException("invalid Vector2");
	
	Vector2 vec = new Vector2();
	vec.x(Float.parseFloat(comp[0]));
	vec.y(Float.parseFloat(comp[1]));
	
	return vec;
}
 
开发者ID:ra4king,项目名称:LWJGL-OpenGL-Utils,代码行数:13,代码来源:Utils.java

示例4: init

import com.ra4king.opengl.util.math.Vector2; //导入方法依赖的package包/类
private void init() {
	Vector2 s = portal.getSize();
	
	final float[] portalData = {
	  0, 0, 0,
	  s.x(), 0, 0,
	  0, s.y(), 0,
	  
	  s.x(), s.y(), 0,
	  0, s.y(), 0,
	  s.x(), 0, 0,
	  };
	
	System.out.println(Arrays.toString(portalData));
	
	int vbo = glGenBuffers();
	glBindBuffer(GL_ARRAY_BUFFER, vbo);
	glBufferData(GL_ARRAY_BUFFER, (FloatBuffer)BufferUtils.createFloatBuffer(portalData.length).put(portalData).flip(), GL_STATIC_DRAW);
	
	vao = RenderUtils.glGenVertexArrays();
	RenderUtils.glBindVertexArray(vao);
	
	glEnableVertexAttribArray(0);
	glVertexAttribPointer(0, 3, GL_FLOAT, false, 0, 0);
	
	RenderUtils.glBindVertexArray(0);
	glBindBuffer(GL_ARRAY_BUFFER, 0);
	
	portalProgram = new ShaderProgram(Utils.readFully(Resources.getInputStream("shaders/portal.vert")),
			                                 Utils.readFully(Resources.getInputStream("shaders/portal.frag")));
	
	portalProgram.begin();
	glUniform1i(portalProgram.getUniformLocation("portalTex"), 0);
	glUniform2f(portalProgram.getUniformLocation("size"), s.x(), s.y());
}
 
开发者ID:ra4king,项目名称:OpenGL-Worlds,代码行数:36,代码来源:PortalRenderer.java

示例5: mouseMove

import com.ra4king.opengl.util.math.Vector2; //导入方法依赖的package包/类
@Override
public void mouseMove(Vector2 position) {
	if(isDragging) {
		Vector2 diff = position.copy().sub(prevMousePos);
		
		switch(rotateMode) {
			case DUAL_AXIS:
				Quaternion rot = calcRotationQuat(Axis.AXIS_Y, diff.x() * rotateScale);
				rot = calcRotationQuat(Axis.AXIS_X, diff.y() * rotateScale).mult(rot).normalize();
				rotateViewDegrees(rot, false);
				break;
			case BIAXIAL: {
				Vector2 initDiff = position.copy().sub(startDragMousePos);
				
				Axis axis;
				float degAngle;
				if(Math.abs(initDiff.x()) > Math.abs(initDiff.y())) {
					axis = Axis.AXIS_Y;
					degAngle = initDiff.x() * rotateScale;
				} else {
					axis = Axis.AXIS_X;
					degAngle = initDiff.y() * rotateScale;
				}
				
				rotateViewDegrees(calcRotationQuat(axis, degAngle), true);
			}
				break;
			case SPIN:
				rotateViewDegrees(calcRotationQuat(Axis.AXIS_Z, -diff.x() * rotateScale), false);
				break;
		}
		
		prevMousePos = position.copy();
	}
}
 
开发者ID:ra4king,项目名称:LWJGL-OpenGL-Tutorials,代码行数:36,代码来源:MousePoles.java

示例6: parseVector2

import com.ra4king.opengl.util.math.Vector2; //导入方法依赖的package包/类
public static Vector2 parseVector2(String s) throws NumberFormatException {
	String[] comp = StringUtil.split(s, ' ');
	if(comp.length != 2)
		throw new IllegalArgumentException("invalid Vector2");
	
	Vector2 vec = new Vector2();
	vec.x(Float.parseFloat(comp[0]));
	vec.y(Float.parseFloat(comp[1]));
	
	return vec;
}
 
开发者ID:ra4king,项目名称:LWJGL-OpenGL-Tutorials,代码行数:12,代码来源:Utils.java


注:本文中的com.ra4king.opengl.util.math.Vector2.y方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。