Java 类com.badlogic.gdx.math.Matrix4 实例源码
项目:Tower-Defense-Galaxy
文件:EnemySpawner.java
public void tick(float delta, GameScreen screen) {
if (!started && screen.isPaused()) {
started = true;
prevTime = System.currentTimeMillis();
}
if (spawns != null && enemyIndex < spawns.size() && System.currentTimeMillis() > prevTime + spawns.get(enemyIndex).getDelay()) {
prevTime = System.currentTimeMillis();
String name = spawns.get(enemyIndex).getName();
ModelInstance instance;
try {
Class<?> c = enemyClasses.get(name);
Constructor constructor = c.getConstructor(Matrix4.class, Map.class, btCollisionWorld.class, IntMap.class, List.class, Map.class);
enemies.add((Enemy) constructor.newInstance(new Matrix4().setToTranslation(pos), models, world, entity, path, sounds));
} catch (Exception e) {
Gdx.app.log("EnemySpawner spawn enemy", e.toString());
}
enemyIndex++;
}
//for (Enemy enemy : enemies)
// enemy.tick(delta, path);
}
项目:Tower-Defense-Galaxy
文件:Basic.java
public Basic(Matrix4 transform, double speeed, int hp, int health, int range, float coolDown, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionWorld world, IntMap<Entity> entities, List<Vector3> path, Map<String, Sound> sounds) {
super(transform, speeed, hp, health, range, coolDown, types, effects, instance, new btCompoundShape(), world, entities, ATTACK_ANIMATION, ATTACK_OFFSET, path, sounds);
((btCompoundShape)shape).addChildShape(new Matrix4(new Vector3(0, 30, 0), new Quaternion().setEulerAngles(0, 0, 0), new Vector3(1, 1, 1)), new btBoxShape(new Vector3(75, 30, 90)));
//System.out.println(getModelInstance().getAnimation("Spider_Armature|walk_ani_vor").id);
listener = new AnimationController.AnimationListener() {
@Override
public void onEnd(AnimationController.AnimationDesc animationDesc) {
}
@Override
public void onLoop(AnimationController.AnimationDesc animationDesc) {
}
};
//animation.setAnimation("Spider_Armature|walk_ani_vor");
//animation.animate("Spider_Armature|walk_ani_vor", -1);
//animation.action("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
//animation.animate("Spider_Armature|Attack", 0, 1000, 1, 1, listener, 0);
//animation.queue("Spider_Armature|walk_ani_vor", 0, 1000, -1, 1, listener, 0);
}
项目:cocos2d-java
文件:Director.java
public static void GLToClipTransform(Matrix4 transformOut) {
if(null == transformOut) return;
Director director = Director.getInstance();
Matrix4 projection = director.getMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_PROJECTION);
Matrix4 modelview = director.getMatrix(MATRIX_STACK_TYPE.MATRIX_STACK_MODELVIEW);
// System.out.println(projection);
// System.out.println(modelview);
//?
transformOut.set(projection);
transformOut.mul(modelview);
// *transformOut = projection * modelview;
}
项目:cocos2d-java
文件:Camera.java
/**
* Gets the camera's view matrix.
*
* @return The camera view matrix.
*/
public Matrix4 getViewMatrix() {
// Mat4 viewInv(getNodeToWorldTransform());
_viewInv.set(getNodeToWorldTransform());
// static int count = sizeof(float) * 16;
// if (memcmp(viewInv.m, _viewInv.m, count) != 0)
// {
_viewProjectionDirty = true;
_frustumDirty = true;
// _viewInv = viewInv;
// _view = viewInv.getInversed();
_view.set(_viewInv).inv();
// }
return _view;
// ViewPort vp;
// com.badlogic.gdx.graphics.glutils
}
项目:libgdx_ui_editor
文件:EditingZone.java
public void drawBg(Batch batch, float parentAlpha) {
batch.end();
Gdx.gl.glLineWidth(1.0f);
Gdx.gl.glEnable(GL20.GL_BLEND);
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA);
shapeRenderer.setProjectionMatrix(getStage().getCamera().combined);
Matrix4 matrix = batch.getTransformMatrix();
shapeRenderer.setTransformMatrix(matrix);
shapeRenderer.begin(ShapeRenderer.ShapeType.Filled);
BG.a = parentAlpha;
shapeRenderer.setColor(BG);
shapeRenderer.rect(getX(), getY(), getWidth(), getHeight());
shapeRenderer.end();
Gdx.gl.glDisable(GL20.GL_BLEND);
batch.begin();
batch.setColor(Color.WHITE.r, Color.WHITE.g, Color.WHITE.b, Color.WHITE.a * parentAlpha);
}
项目:StreetCampusFighter
文件:GameScreen.java
public GameScreen(){
spriteBatch = new SpriteBatch(); // buffer ok
texture = new Texture(Gdx.files.internal("bg/gameBG.jpg"));
viewMatrix = new Matrix4(); // matriz de visualização
tranMatrix = new Matrix4(); // matriz de escala
// camera
camera = new PerspectiveCamera(67.0f, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.near = 0.1f;
camera.far = 1000f;
camera.position.set(0, 5, 10);
camera.lookAt(0, 5, 0);
camera.update();
// ambiente
environment = new Environment();
environment.set(new ColorAttribute(ColorAttribute.AmbientLight, 1,1,1,1));
// renderizador
modelBatch = new ModelBatch();
p1 = new Player(1);
p2 = new Player(2);
}
项目:arcadelegends-gg
文件:LevelScreen.java
public LevelScreen(String mapName, float rot) {
this.rot = rot;
this.mapName = mapName;
this.inputMapper = new InputMapper(AL.getInputConfig());
inputMapper.registerInputHanlder(IInputConfig.InputKeys.up, new MoveEventHandler(new Vector2(0, 1)));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.down, new MoveEventHandler(new Vector2(0, -1)));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.right, new MoveEventHandler(new Vector2(1, 0)));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.left, new MoveEventHandler(new Vector2(-1, 0)));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability1, new AbillityEventHandler(Character.ABILITY_1));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability2, new AbillityEventHandler(Character.ABILITY_2));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability3, new AbillityEventHandler(Character.ABILITY_3));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.ability4, new AbillityEventHandler(Character.ABILITY_4));
inputMapper.registerInputHanlder(IInputConfig.InputKeys.trait, new AbillityEventHandler(Character.TRAIT));
rotationMatrix = new Matrix4().rotate(Vector3.X, rot);
cameraVector = new Vector3(0, 1, 1);
cameraVector.mul(rotationMatrix);
invRotationMatrix = rotationMatrix.cpy().inv();
lastMousePos = new Vector2(Gdx.input.getX(), Gdx.input.getY());
tempVec = new Vector3();
}
项目:GDX-Engine
文件:FreeCamera.java
/**
* Update camera's matrix
*/
private void UpdateViewMatrix()
{
Matrix4 cameraRotation = new Matrix4();
cameraRotation = Utils.createRotate(updownRot, leftrightRot, 0f, cameraRotation);
Vector3 cameraOriginalTarget = new Vector3(0, 0, -1);
Vector3 cameraOriginalUpVector = new Vector3(0, 1, 0);
// cameraRotation.rotate(1, 0, 0, cameraOriginalTarget.x);
Vector3 cameraRotatedTarget = Utils.Transform(cameraOriginalTarget, cameraRotation);
Vector3 cameraFinalTarget = Utils.addVector(position,cameraRotatedTarget);
up.set(Utils.Transform(cameraOriginalUpVector, cameraRotation));
view.setToLookAt(position, cameraFinalTarget, up);
float aspect = viewportWidth / viewportHeight;
projection.setToProjection(Math.abs(near), Math.abs(far), fieldOfView, aspect);
combined.set(projection);
Matrix4.mul(combined.val, view.val);
invProjectionView.set(combined);
Matrix4.inv(invProjectionView.val);
frustum.update(invProjectionView);
}
项目:GDX-Engine
文件:BaseCamera.java
public void updateFrustum()
{
invProjectionView.set(combined);
Matrix4.inv(invProjectionView.val);
frustum.update(invProjectionView);
needUpdateFrustum = false;
}
项目:school-game
文件:IngameMenu.java
/**
* Initialisierung.
*
* @param game Zugriff auf die Spielinstanz
* @param level Zugriff auf die aktive Levelinstanz
*/
public IngameMenu(SchoolGame game, Level level)
{
this.game = game;
this.level = level;
titleFont = game.getTitleFont();
textFont = game.getDefaultFont();
smallFont = game.getLongTextFont();
selectSound = game.getAudioManager().createSound("menu", "select.wav", true);
changeSound = game.getAudioManager().createSound("menu", "change.wav", true);
batch = new SpriteBatch();
shapeRenderer = new ShapeRenderer();
localeBundle = level.getLocaleBundle();
fontLayout = new GlyphLayout();
projection = new Matrix4();
}
项目:Klooni1010
文件:SpinEffect.java
@Override
public void draw(Batch batch) {
age += Gdx.graphics.getDeltaTime();
final float progress = age * INV_LIFETIME;
final float currentSize = Interpolation.pow2In.apply(size, 0, progress);
final float currentRotation = Interpolation.sine.apply(0, TOTAL_ROTATION, progress);
final Matrix4 original = batch.getTransformMatrix().cpy();
final Matrix4 rotated = batch.getTransformMatrix();
final float disp =
+ 0.5f * (size - currentSize) // the smaller, the more we need to "push" to center
+ currentSize * 0.5f; // center the cell for rotation
rotated.translate(pos.x + disp, pos.y + disp, 0);
rotated.rotate(0, 0, 1, currentRotation);
rotated.translate(currentSize * -0.5f, currentSize * -0.5f, 0); // revert centering for rotation
batch.setTransformMatrix(rotated);
Cell.draw(color, batch, 0, 0, currentSize);
batch.setTransformMatrix(original);
}
项目:GDX-Engine
文件:Utils.java
/**
* Transform a Vector3 using a Transformation Matrix
*
* @param vector
* Vector to transform
* @param transform
* The Transformation matrix
* @return
*/
public static Vector3 Transform(Vector3 vector, Matrix4 transform) {
Vector3 result = new Vector3((vector.x * transform.val[Matrix4.M00])
+ (vector.y * transform.val[Matrix4.M10])
+ (vector.z * transform.val[Matrix4.M20])
+ transform.val[Matrix4.M30],
(vector.x * transform.val[Matrix4.M01])
+ (vector.y * transform.val[Matrix4.M11])
+ (vector.z * transform.val[Matrix4.M21])
+ transform.val[Matrix4.M31],
(vector.x * transform.val[Matrix4.M02])
+ (vector.y * transform.val[Matrix4.M12])
+ (vector.z * transform.val[Matrix4.M22])
+ transform.val[Matrix4.M32]);
return result;
}
项目:Tower-Defense-Galaxy
文件:VRContext.java
public void updateAxesAndPosition() {
Matrix4 matrix = pose.transform;
matrix.getTranslation(position);
xAxis.set(matrix.val[Matrix4.M00], matrix.val[Matrix4.M10], matrix.val[Matrix4.M20]).nor();
yAxis.set(matrix.val[Matrix4.M01], matrix.val[Matrix4.M11], matrix.val[Matrix4.M21]).nor();
zAxis.set(matrix.val[Matrix4.M02], matrix.val[Matrix4.M12], matrix.val[Matrix4.M22]).nor().scl(-1);
matTmp.set(trackerSpaceToWorldspaceRotationOffset);
positionWorld.set(position).mul(matTmp);
positionWorld.add(trackerSpaceOriginToWorldSpaceTranslationOffset);
matTmp.set(trackerSpaceToWorldspaceRotationOffset);
xAxisWorld.set(xAxis).mul(matTmp);
yAxisWorld.set(yAxis).mul(matTmp);
zAxisWorld.set(zAxis).mul(matTmp);
}
项目:Tower-Defense-Galaxy
文件:VRContext.java
static void hmdMat4toMatrix4(HmdMatrix44 hdm, Matrix4 mat) {
float[] val = mat.val;
FloatBuffer m = hdm.m();
val[0] = m.get(0);
val[1] = m.get(4);
val[2] = m.get(8);
val[3] = m.get(12);
val[4] = m.get(1);
val[5] = m.get(5);
val[6] = m.get(9);
val[7] = m.get(13);
val[8] = m.get(2);
val[9] = m.get(6);
val[10] = m.get(10);
val[11] = m.get(14);
val[12] = m.get(3);
val[13] = m.get(7);
val[14] = m.get(11);
val[15] = m.get(15);
}
项目:Tower-Defense-Galaxy
文件:VRContext.java
static void hmdMat34ToMatrix4(HmdMatrix34 hmd, Matrix4 mat) {
float[] val = mat.val;
FloatBuffer m = hmd.m();
val[0] = m.get(0);
val[1] = m.get(4);
val[2] = m.get(8);
val[3] = 0;
val[4] = m.get(1);
val[5] = m.get(5);
val[6] = m.get(9);
val[7] = 0;
val[8] = m.get(2);
val[9] = m.get(6);
val[10] = m.get(10);
val[11] = 0;
val[12] = m.get(3);
val[13] = m.get(7);
val[14] = m.get(11);
val[15] = 1;
}
项目:cocos2d-java
文件:AffineTransform.java
public static Vector2 PointApplyTransform(final Vector2 point, final Matrix4 transform, Vector2 out) {
stackVec3.set(point, 0);
stackVec3.mul(transform);
out.x = stackVec3.x;
out.y = stackVec3.y;
return out;
}
项目:cocos2d-java
文件:AffineTransform.java
public static Vector2 PointApplyTransform(final float pointX, final float pointY, final Matrix4 transform, Vector2 out) {
stackVec3.set(pointX, pointY,0);
stackVec3.mul(transform);
out.x = stackVec3.x;
out.y = stackVec3.y;
return out;
}
项目:cocos2d-java
文件:Director.java
/**获取当前矩阵 矩阵不可修改,只能读取 */
public final Matrix4 getMatrix(MATRIX_STACK_TYPE type) {
switch(type) {
case MATRIX_STACK_MODELVIEW: return _modelViewMatrixStack.peek();
case MATRIX_STACK_PROJECTION: return _projectionMatrixStack.peek();
case MATRIX_STACK_TEXTURE: return _textureMatrixStack.peek();
}
return null;
}
项目:cocos2d-java
文件:Renderer.java
/**
* 相机包含测试
* @param transform 变换
* @param size 尺寸
* @param anchorPointInPoints 锚dian偏移
* @return
*/
public final boolean checkVisibility(final Matrix4 transform, final Size size, final Vector2 anchorPointInPoints) {
final Director director = Director.getInstance();
//If draw to Rendertexture, return true directly.
// only cull the default camera. The culling algorithm is valid for default camera.
if (director.getRunningScene() == null) {// || (scene.getDefaultCamera() != Camera.getVisitingCamera())) {
return true;
}
Vector2 temporigin = director.getVisibleOrigin();
Size tempsize = director.getVisibleSize();
Rect visiableRect = stackRect;
visiableRect.set(temporigin.x, temporigin.y, tempsize.width, tempsize.height);
// transform center point to screen space
float hSizeX = size.width/2;
float hSizeY = size.height/2;
Vector3 v3p = stackVec3.set(hSizeX - anchorPointInPoints.x, hSizeY - anchorPointInPoints.y, 0);
v3p.mul(transform);
// transform.transformPoint(v3p);
Vector2 v2p = Camera.getVisitingCamera().projectGL(v3p);
// convert content size to world coordinates
final float[] val = transform.val;
float wshw = Math.max(Math.abs(hSizeX * val[Matrix4.M00] + hSizeY * val[Matrix4.M10]),
Math.abs(hSizeX * val[Matrix4.M00] - hSizeY * val[Matrix4.M10]));
// std::max(fabsf(hSizeX * transform.m[0] + hSizeY * transform.m[4]), fabsf(hSizeX * transform.m[0] - hSizeY * transform.m[4]));
float wshh = Math.max(Math.abs(hSizeX * val[Matrix4.M01] + hSizeY * val[Matrix4.M11]),
Math.abs(hSizeX * val[Matrix4.M01] - hSizeY * val[Matrix4.M11]));
// std::max(fabsf(hSizeX * transform.m[1] + hSizeY * transform.m[5]), fabsf(hSizeX * transform.m[1] - hSizeY * transform.m[5]));
// enlarge visible rect half size in screen coord
visiableRect.x -= wshw;
visiableRect.y -= wshh;
visiableRect.width += wshw * 2;
visiableRect.height += wshh * 2;
boolean ret = visiableRect.containsPoint(v2p);
// System.out.println("visiableRect = " + visiableRect + " pos = " + v2p);
return ret;
}
项目:cocos2d-java
文件:Widget.java
/**
* @js NA
*/
public void visit(Renderer renderer, Matrix4 parentTransform, int parentFlags) {
if(_visible) {
adaptRenderers();
super.visit(renderer, parentTransform, parentFlags);
}
}
项目:cocos2d-java
文件:Node.java
/**
* Returns the matrix that transform the node's (local) space coordinates into the parent's space coordinates.
* The matrix is in Pixels.
* Note: If ancestor is not a valid ancestor of the node, the API would return the same value as @see getNodeToWorldTransform
*
* @param ancestor The parent's node pointer.
* @since v3.7
* @return The transformation matrix. <b>(pool object)</b>
*/
public final Matrix4 getNodeToParentTransform(Node ancestor) {
final Matrix4 t = poolMatrix_1;
// System.out.println("nodeToParentTransform = " + getNodeToParentTransform() + this);
t.set(getNodeToParentTransform());
// Mat4 t(this.getNodeToParentTransform());
for (Node p = _parent; p != null && p != ancestor ; p = p._parent) {
// t = p.getNodeToParentTransform() * t;
t.mulLeft(p.getNodeToParentTransform());
}
return t;
}
项目:cocos2d-java
文件:Node.java
/**
* Sets the Transformation matrix manually.
*/
public void setNodeToParentTransform(Matrix4 transform) {
_transform.set(transform);
_transformDirty = false;
_transformUpdated = true;
if(_additionalTransform != null) {
if(_additionalTransform[1] == null) {
_additionalTransform[1] = new Matrix4();
}
_additionalTransform[1].set(transform);
}
}
项目:Climatar
文件:DrawableMap.java
@Override
public void draw(Batch batch, float parentAlpha) {
camera.update();
Matrix4 projection = batch.getProjectionMatrix();
// batch.end();
// Gdx.gl.glViewport((int) frame.x, (int) frame.y, (int) frame.width, (int) frame.height);
// batch.setProjectionMatrix(camera.combined);
// batch.begin();
tint.a = parentAlpha;
batch.setColor(tint);
batch.draw(terrain, getX(), getY(), getWidth(), getHeight());
// draw nation layers
if (visibilityLookup.get(Nation.FIRE))
batch.draw(fire, getX(), getY(), getWidth(), getHeight());
if (visibilityLookup.get(Nation.WATER))
batch.draw(water, getX(), getY(), getWidth(), getHeight());
if (visibilityLookup.get(Nation.EARTH))
batch.draw(earth, getX(), getY(), getWidth(), getHeight());
if (visibilityLookup.get(Nation.AIR))
batch.draw(air, getX(), getY(), getWidth(), getHeight());
// batch.end();
// batch.setProjectionMatrix(projection);
// batch.begin();
// Gdx.gl.glViewport(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
}
项目:cocos2d-java
文件:Node.java
/**
* Converts a Vector2 to node (local) space coordinates. The result is in Points.
* <br>返回栈对象
* <b>pool object</b>
*/
public Vector2 convertToNodeSpace( Vector2 worldPoint) {
Matrix4 tmp = getWorldToNodeTransform();
// System.out.println("temp = " + tmp);
final Vector3 ret = poolVector3_1.set(worldPoint.x, worldPoint.y, 0);
ret.mul(tmp);
return poolVector2_1.set(ret.x, ret.y);
}
项目:cocos2d-java
文件:Node.java
/**
* Converts a Vector2 to world space coordinates. The result is in Points.
*/
public Vector2 convertToWorldSpace( Vector2 nodePoint) {
Matrix4 tmp = getNodeToWorldTransform();
final Vector3 ret = poolVector3_1.set(nodePoint.x, nodePoint.y, 0);
poolVector3_1.mul(tmp);
return poolVector2_1.set(ret.x, ret.y);
}
项目:cocos2d-java
文件:Node.java
/**
* Sets an additional transform matrix to the node.
*
* In order to remove it, call it again with the argument `nullptr`
*
* @note The additional transform will be concatenated at the end of getNodeToParentTransform.
* It could be used to simulate `parent-child` relationship between two nodes (e.g. one is in BatchNode, another isn't).
*/
public void setAdditionalTransform(Matrix4 additionalTransform) {
if(additionalTransform == null) {
_additionalTransform = null;
} else {
if(_additionalTransform == null) {
_additionalTransform = new Matrix4[2];
// _additionalTransform[1] is used as a backup for _transform
_additionalTransform[1] = new Matrix4(_transform);
}
_additionalTransform[0] = additionalTransform;
}
_transformUpdated = _additionalTransformDirty = _inverseDirty = true;
}
项目:cocos2d-java
文件:Node.java
protected int processParentFlags( Matrix4 parentTransform, int parentFlags) {
if(_usingNormalizedPosition) {
assert _parent != null: "setNormalizedPosition() doesn't work with orphan nodes";
if ((parentFlags & FLAGS_CONTENT_SIZE_DIRTY) != 0 || _normalizedPositionDirty) {
Size s = _parent.getContentSize();
_position.x = _normalizedPosition.x * s.width;
_position.y = _normalizedPosition.y * s.height;
_transformUpdated = _transformDirty = _inverseDirty = true;
_normalizedPositionDirty = false;
}
}
//remove this two line given that isVisitableByVisitingCamera should not affect the calculation of transform given that we are visiting scene
//without involving view and projection matrix.
// if (!isVisitableByVisitingCamera())
// return parentFlags;
int flags = parentFlags;
flags |= (_transformUpdated ? FLAGS_TRANSFORM_DIRTY : 0);
flags |= (_contentSizeDirty ? FLAGS_CONTENT_SIZE_DIRTY : 0);
if((flags & FLAGS_DIRTY_MASK) != 0) { //
// System.out.println("update >>>>> trans" + getDescription() + _position
// + "\n" + parentTransform);
_modelViewTransform = this.transform(parentTransform);
// System.out.println("trigger trans " + _physicsCallFlag + " / " + _onTransformCallback);
if(_onTransformCallback != null) {//&& !_physicsCallFlag) {
_onTransformCallback.onTransform(this);
}
// Vector3 d = new Vector3();
// _modelViewTransform.getTranslation(d);
// System.out.println("transro m = \n" + _modelViewTransform);
}
_transformUpdated = false;
_contentSizeDirty = false;
return flags;
}
项目:cocos2d-java
文件:Camera.java
/**get view projection matrix*/
public Matrix4 getViewProjectionMatrix() {
getViewMatrix();
if (_viewProjectionDirty) {
_viewProjectionDirty = false;
_viewProjection.set(_projection).mul(_view);
}
return _viewProjection;
}
项目:GDX-Engine
文件:FreeCamera.java
/**
* Move the camera following the new Postion
* @param newPosition
*/
private void AddToCameraPosition(Vector3 newPosition)
{
float moveSpeed = 0.05f;
Matrix4 cameraRotation = new Matrix4();
cameraRotation = Utils.createRotate(updownRot, leftrightRot, 0f, cameraRotation);
Vector3 rotatedVector = Utils.Transform(newPosition, cameraRotation);
position.add(rotatedVector.mul(moveSpeed));
UpdateViewMatrix();
}
项目:GDX-Engine
文件:BaseCamera.java
public Matrix4 getCombined()
{
if(needUpdateProjection)
updateProjection();
if(needUpdateView)
updateViewMatrix();
combined.set(projection);
combined.mul(view);
return combined;
}
项目:GDX-Engine
文件:PhysicsManager.java
/**
* render the Box2d Debugger
*/
public void renderBox2dDebugger() {
if (debugRenderEnabled) {
debugMatrix = new Matrix4(services.getCamera().combined);
debugMatrix.scale(BOX_TO_WORLD, BOX_TO_WORLD, 1f);
debugRender.render(world, debugMatrix);
}
}
项目:arcadelegends-gg
文件:PlayerHelper.java
/**
* Draws the given gradient {@link Texture} to the given {@link FrameBuffer}, using the given {@link Color} with the given percent.
* <p>
* This is achieved via a gradient shader.
*
* @param buffer the {@link FrameBuffer} to be drawn to
* @param color the {@link Color} which should be drawn
* @param gradient the gradient texture which should be drawn
* @param perc the percent the gradient texture should be drawn
* @param projection projection matrix for pixel perfect rendering
*/
private void drawToBuffer(FrameBuffer buffer, Color color, TextureRegion gradient, float perc, Matrix4 projection) {
buffer.begin();
AL.graphics.getGL20().glClearColor(0, 0, 0, 0);
AL.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
shaderBatch.setProjectionMatrix(projection);
shaderBatch.begin();
shaderBatch.setColor(color);
shader.setUniformf("u_gradient", perc);
shaderBatch.draw(gradient, -buffer.getWidth() / 2, -buffer.getHeight() / 2);
shaderBatch.end();
buffer.end();
}
项目:arcadelegends-gg
文件:CharacterRenderer.java
/**
* Draws the given gradient {@link Texture} to the given {@link FrameBuffer}, using the given {@link Color} with the given percent.
* <p>
* This is achieved via a gradient shader.
*
* @param buffer the {@link FrameBuffer} to be drawn to
* @param color the {@link Color} which should be drawn
* @param gradient the gradient texture which should be drawn
* @param perc the percent the gradient texture should be drawn
* @param shaderBatch the {@link SpriteBatch} to use
* @param shader the {@link ShaderProgram} to use
* @param projection projection matrix for pixel perfect rendering
*/
private static void drawToBuffer(FrameBuffer buffer, Color color, Texture gradient, float perc, SpriteBatch shaderBatch, ShaderProgram shader, Matrix4 projection) {
buffer.begin();
AL.graphics.getGL20().glClearColor(0, 0, 0, 0);
AL.graphics.getGL20().glClear(GL20.GL_COLOR_BUFFER_BIT);
shaderBatch.setProjectionMatrix(projection);
shaderBatch.begin();
shaderBatch.setColor(color);
shader.setUniformf("u_gradient", perc);
shaderBatch.draw(gradient, -buffer.getWidth() / 2, -buffer.getHeight() / 2);
shaderBatch.end();
buffer.end();
}
项目:trascendentAR
文件:ARCamera.java
@Override
public void update (boolean updateFrustum) {
view.setToLookAt(position, tmp.set(position).add(direction), up);
combined.set(projection);
Matrix4.mul(combined.val, view.val);
if (updateFrustum) {
invProjectionView.set(combined);
Matrix4.inv(invProjectionView.val);
frustum.update(invProjectionView);
}
}
项目:Tower-Defense-Galaxy
文件:VRCamera.java
@Override
public void update(boolean updateFrustum) {
// get the projection matrix from the HDM
VRSystem.VRSystem_GetProjectionMatrix(eye.index, near, far, projectionMat);
VRContext.hmdMat4toMatrix4(projectionMat, projection);
// get the eye space matrix from the HDM
VRSystem.VRSystem_GetEyeToHeadTransform(eye.index, eyeMat);
VRContext.hmdMat34ToMatrix4(eyeMat, eyeSpace);
invEyeSpace.set(eyeSpace).inv();
// get the pose matrix from the HDM
VRDevice hmd = context.getDeviceByType(VRDeviceType.HeadMountedDisplay);
Vector3 y = hmd.getUp(Space.World);
Vector3 z = hmd.getDirection(Space.World);
Vector3 p = hmd.getPosition(Space.World);
view.idt();
view.setToLookAt(p, tmp.set(p).add(z), y);
position.set(p);
direction.set(z);
up.set(y);
combined.set(projection);
Matrix4.mul(combined.val, invEyeSpace.val);
Matrix4.mul(combined.val, view.val);
if (updateFrustum) {
invProjectionView.set(combined);
Matrix4.inv(invProjectionView.val);
frustum.update(invProjectionView);
}
}
项目:Tower-Defense-Galaxy
文件:AttackingEntity.java
public AttackingEntity(Matrix4 transform, int hp, int health, int range, EnumSet<Types> types, EnumSet<Effects> effects, float coolDown, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, String attackAnimation, Vector3 attackOffset, Map<String, Sound> sounds){
super(transform, hp, health, types, effects, instance, shape, world, entities, sounds);
this.coolDown = coolDown;
this.range = range;
this.attackAnimation = attackAnimation;
this.attackOffset = attackOffset;
callback = new ClosestRayResultCallback(new Vector3(), new Vector3());
}
项目:Tower-Defense-Galaxy
文件:Entity.java
public Entity(Matrix4 transform, int hp, int health, EnumSet<Types> types, EnumSet<Effects> effects, ModelInstance instance, btCollisionShape shape, btCollisionWorld world, IntMap<Entity> entities, Map<String, Sound> sounds){
this.instance = instance;
this.transform = transform;
this.hp = hp;
this.types = types;
this.health = health;
this.effects = effects;
this.sounds = sounds;
animation = new AnimationController(instance);
this.instance.transform.set(transform);
this.shape = shape;
body = new btCollisionObject();
body.setCollisionShape(shape);
body.setWorldTransform(this.instance.transform);
this.world = world;
tempVector = new Vector3();
tempVector2 = new Vector3();
this.entities = entities;
tempQuaternion = new Quaternion();
quaternion = new Quaternion();
if(this instanceof Enemy || this instanceof Projectile)
body.setCollisionFlags(body.getCollisionFlags());
int index = getNextIndex();
entities.put(index, this);
body.setUserValue(index);
world.addCollisionObject(body);
boundingBox = instance.calculateBoundingBox(new BoundingBox());
//for(Node node: instance.nodes)
//System.out.println();
}
项目:Tower-Defense-Galaxy
文件:RectangleRegion.java
@Override
public btCollisionObject createCollisionObject() {
btCollisionObject collisionObject = new btCollisionObject();
collisionObject.setCollisionShape(new btBoxShape(new Vector3(width, height, depth)));
collisionObject.setWorldTransform(new Matrix4().setTranslation(pos));
return collisionObject;
}
项目:Tower-Defense-Galaxy
文件:SphereRegion.java
@Override
public btCollisionObject createCollisionObject() {
btCollisionObject collisionObject = new btCollisionObject();
collisionObject.setCollisionShape(new btSphereShape(radius));
collisionObject.setWorldTransform(new Matrix4().setTranslation(pos));
return collisionObject;
}
项目:Tower-Defense-Galaxy
文件:ProjectileTower.java
@Override
public void attack(ArrayList<Entity> targets) {
super.attack(targets);
try {
Projectile projectile = projectileEntityTemplate.create(new Matrix4(transform), targets.get(0).getTransform().getTranslation(new Vector3()).sub(transform.getTranslation(tempVector)).setLength(1));
if(projectile == null)
Gdx.app.error("ProjectileTower", "Failed to create " + projectileEntityTemplate);
} catch (Exception e) {
Gdx.app.error("ProjectileTower", e.getMessage());
}
}