public override void reset() { base.reset(); Game game = Game.GAME_INSTANCE; Location l = this.getLocation(); l.addYaw(-game.getGamePad().AnalogRightX); l.addPitch(game.getGamePad().AnalogRightY); if (game.getGamePad().AnalogLeftX != 0) { Location clone = l.clone(); clone.addYaw(90); double p = clone.getPitch(); clone.setPitch(0); clone = clone.getRelativeInFacingDirection(-game.getGamePad().AnalogLeftX / 10.0); clone.addYaw(-90); clone.setPitch(p); l.set(clone); } if (game.getGamePad().AnalogLeftY != 0) { Location clone = l.clone(); clone = clone.getRelativeInFacingDirection(-game.getGamePad().AnalogLeftY / 10.0); l.set(clone); } Location newTarget = l.getRelativeInFacingDirection(1); this.getTarget().set(newTarget); newTarget.Dispose(); }
public bool isInButton(Location l) { if (this.sprite == null) { return(false); } if (this.sprite.getTexture() == null) { return(false); } if (this.sprite.getWidth() <= 0) { return(false); } if (this.sprite.getHeight() <= 0) { return(false); } l = l.getAbsoluteLocation(); Location sl = this.sprite.getLocation().getAbsoluteLocation(); double minX = sl.getX(); double minY = sl.getY(); double maxX = minX + this.sprite.getWidth(); double maxY = minY + this.sprite.getHeight(); bool xVal = minX <= l.getX() && maxX >= l.getX(); bool yVal = minY <= l.getY() && maxY >= l.getY(); sl.Dispose(); l.Dispose(); return(xVal && yVal); }
public void render(Camera c) { Location l = new Location(); this.render(l.getPositionMatrix(), c); l.Dispose(); }
public override void Dispose() { base.Dispose(); eyeTarget.Dispose(); eyeTarget = null; target = null; }
public static bool isHitting(BoundingBox box1, BoundingBox box2) { Location box1RefinedMin = box1.getRefinedMinPoint(); Location box1RefinedMax = box1.getRefinedMaxPoint(); Location box2RefinedMin = box2.getRefinedMinPoint(); Location box2RefinedMax = box2.getRefinedMaxPoint(); Location box1Min = box1RefinedMin.getAbsoluteLocation(); Location box1Max = box1RefinedMax.getAbsoluteLocation(); Location box2Min = box2RefinedMin.getAbsoluteLocation(); Location box2Max = box2RefinedMax.getAbsoluteLocation(); double myMinX = box1Min.getX(); double myMinY = box1Min.getY(); double myMinZ = box1Min.getZ(); double myMaxX = box1Max.getX(); double myMaxY = box1Max.getY(); double myMaxZ = box1Max.getZ(); double notMinX = box2Min.getX(); double notMinY = box2Min.getY(); double notMinZ = box2Min.getZ(); double notMaxX = box2Max.getX(); double notMaxY = box2Max.getY(); double notMaxZ = box2Max.getZ(); box1RefinedMin.Dispose(); box1RefinedMax.Dispose(); box2RefinedMin.Dispose(); box2RefinedMax.Dispose(); box1Min.Dispose(); box1Max.Dispose(); box2Min.Dispose(); box2Max.Dispose(); bool myXInside = (myMinX >= notMinX && myMinX <= notMaxX) || (myMaxX >= notMinX && myMaxX <= notMaxX); bool myYInside = (myMinY >= notMinY && myMinY <= notMaxY) || (myMaxY >= notMinY && myMaxY <= notMaxY); bool myZinside = (myMinZ >= notMinZ && myMinZ <= notMaxZ) || (myMaxZ >= notMinZ && myMaxZ <= notMaxZ); if (myXInside && myYInside && myZinside) { return(true); } bool notXInside = (notMinX >= myMinX && notMinX <= myMaxX) || (notMaxX >= myMinX && notMaxX <= myMaxX); bool notYInside = (notMinY >= myMinY && notMinY <= myMaxY) || (notMaxY >= myMinY && notMaxY <= myMaxY); bool notZInside = (notMinZ >= myMinZ && notMinZ <= myMaxZ) || (notMaxZ >= myMinZ && notMaxZ <= myMaxZ); if (notXInside && notYInside && notZInside) { return(true); } return(false); }
public double getDistanceZ(Location between) { Location abs = this.getAbsoluteLocation(); Location bAbs = between.getAbsoluteLocation(); double dist = bAbs.z - abs.z; abs.Dispose(); bAbs.Dispose(); return(dist); }
public Location getAbsoluteLocation() { if (this.getOwner() != null && this.getOwner().getParent() != null) { Location parentAbs = this.getOwner().getParent().getLocation().getAbsoluteLocation(); Location l = this.clone().add(parentAbs); parentAbs.Dispose(); //if(!this.Equals(this.getOwner().getLocation())) l.add (this); return(l); } return(this.clone()); }
public Matrix4 getPositionalMatrix(Matrix4 offset) { lock (this.location) { Location l = this.getLocation().clone(); Matrix4 positionMatrix = Matrix4.Transformation( l.getAsVector(), l.getRotationQuaternion(), new Vector3((float)this.scaleX, (float)this.scaleY, (float)this.scaleZ) ); l.Dispose(); return(offset * positionMatrix); } }
public Matrix4 getViewMatrix() { if(!this.vmnr) return this.viewMatrix; Location l = this.getLocation().clone(); Location t = this.getTarget().clone(); this.viewMatrix = Matrix4.LookAt( l.getAsVector(), t.getAsVector(), new Vector3(0,1,0) ); l.Dispose(); t.Dispose(); return this.viewMatrix; }
public double determineYaw(Location target, double offset = 90) { double dX = this.getDistanceX(target); double dZ = this.getDistanceZ(target); double yaw = Math.Atan2(dZ, dX); yaw = (-MathUtils.toDegrees(yaw)) + offset; if (this.getOwner() != null && this.getOwner().getParent() != null) { Location pAbs = this.getOwner().getParent().getLocation().getAbsoluteLocation(); yaw -= pAbs.getYaw(); pAbs.Dispose(); } return(yaw); }
public double getDistance(Location between) { Location abs = this.getAbsoluteLocation(); Location bAbs = between.getAbsoluteLocation(); double dist = Math.Sqrt( Math.Pow(abs.x - bAbs.x, 2) + Math.Pow(abs.y - bAbs.y, 2) + Math.Pow(abs.z - bAbs.z, 2) ); abs.Dispose(); bAbs.Dispose(); return(dist); }
public double determinePitch(Location target, double offset = 90) { double dX = this.getDistanceX(target); double dY = this.getDistanceY(target); double dZ = this.getDistanceZ(target); double pitch = Math.Atan2(Math.Sqrt(dZ * dZ + dX * dX), dY) + Math.PI; pitch = MathUtils.toDegrees(pitch) + offset; if (this.getOwner() != null && this.getOwner().getParent() != null) { Location pAbs = this.getOwner().getParent().getLocation().getAbsoluteLocation(); pitch -= pAbs.getPitch(); pAbs.Dispose(); } return(pitch); }
//Main Thread Method public void updateTexture() { if (Chat.getFrameBuffer(false) == null) { return; } if (Chat.getFrameBuffer(false).getFrameBuffer() == null) { return; } List <Model> models = new List <Model>(); Camera talkerCamera = new Camera(); ChatMessage cm; if ((cm = getCurrentMessage()) != null) { lock (cm) { Talkable talker = cm.getTalker(); Model m = talker.getModel(); talkerCamera.getTarget().set(m.getLocation()); talkerCamera.getTarget().addY(1.75); Location j = talkerCamera.getTarget().getAbsoluteLocation(); j.addYaw(-23); Location q = j.getRelativeInFacingDirection(3); j.Dispose(); //j.addX(-1.25).addY(0).addZ(2.8); talkerCamera.getLocation().set(q); q.Dispose(); lock (m) { models.Add(talker.getModel()); } } } Color oldSky = DisplayManager.getDisplayManager().getClearColor(); lock (talkerCamera) { DisplayManager.getDisplayManager().setClearColor(Color.RED.clone().setAlpha(0)); DisplayManager.getDisplayManager().renderToBuffer(Chat.getFrameBuffer().getFrameBuffer(), models, talkerCamera); DisplayManager.getDisplayManager().setClearColor(oldSky); } talkerCamera.Dispose(); }
public virtual void Dispose() { foreach (Animation a in this.getAnimations()) { a.Dispose(); } velocity.Dispose(); if (controller != null) { controller.Dispose(); } scene.removeEntity(this); this.model.Dispose(); scene = null; model = null; controller = null; velocity = null; }
public Location[] getAbsoluteMinMaxPoints() { /* * This will check children for their min X Y and Z values RELATIVE TO THIS OBJECT * THE RETURNED VALUE WILL BE RELATIVE TO THIS OBJECT, EXAMPLE; * THIS OBJECT IS AT 14, 14, 14 * THIS MIN POINT IS -4, -2, -4 (MAKING ITS ABS POSITION AT 10, 12, 10) * THE CHILD IS AT 3, 3, 3 OF THIS, MAKING ITS ABS 17, 17, 17 * THE CHILD MIN POINT IS -6, -6, -6 OF IT, MAKING ITS POSITION RELATIVE TO ITS OBJECT -3, -3, -3 * THAT MAKES THE RELATAIVE MIN POINT -4, -3, -4 (X FROM THIS MIN, Y FROM CHILD MIN, Z FROM THIS MIN) * THAT MAKES THE ABSOLUTE MIN POINT AT 10, 11, 10 * * RETURNS ARRAY TO INCREASE EFFICIENCY, BE SURE TO DISPOSE BOTH * getAbsoluteMinMaxPoints()[0] = min_point; * getAbsoluteMinMaxPoints()[1] = max_point; */ double minX = (this.min == null ? 0 : this.min.getX()); double minY = (this.min == null ? 0 : this.min.getY()); double minZ = (this.min == null ? 0 : this.min.getZ()); double maxX = (this.max == null ? 0 : this.max.getX()); double maxY = (this.max == null ? 0 : this.max.getY()); double maxZ = (this.max == null ? 0 : this.max.getZ()); foreach (Model child in this.children) { Location[] minMaxPoints = child.getAbsoluteMinMaxPoints(); Location minPoint = minMaxPoints[0]; Location maxPoint = minMaxPoints[1]; minPoint.add(child.getLocation()); maxPoint.add(child.getLocation()); //COMPARE VALUES if (minPoint.getX() < minX) { minX = minPoint.getX(); } if (minPoint.getY() < minY) { minY = minPoint.getY(); } if (minPoint.getZ() < minZ) { minZ = minPoint.getZ(); } //MAX VALUES if (maxPoint.getX() > maxX) { maxX = maxPoint.getX(); } if (maxPoint.getY() > maxY) { maxY = maxPoint.getY(); } if (maxPoint.getZ() > maxZ) { maxZ = maxPoint.getZ(); } //Clean.. soo clean minPoint.Dispose(); maxPoint.Dispose(); } Location aMinPoint = new Location(minX, minY, minZ); Location aMaxPoint = new Location(maxX, maxY, maxZ); return(new Location[] { aMinPoint, aMaxPoint }); }
public virtual void tick() { foreach (AnimationRule rule in this.getAnimationRules()) { lock (rule) { Locateable obj = this.getObject(rule.getObjectID()); if (obj == null) { continue; } if (rule.getAnimationType().Equals(AnimationFramingType.FRAME_BY_FRAME)) { if (this.getFrame() != rule.getFrame()) { continue; } obj.getLocation().set(rule.getTarget()); } else if (rule.getAnimationType().Equals(AnimationFramingType.TWEEN)) { if (frame < rule.getStartFrame()) { continue; } if (frame > (rule.getStartFrame() + rule.getFrame())) { continue; } Location target = rule.getTarget().clone(); target.sub(rule.getStartingPosition()); double amt = 0; int tweenFrame = frame - rule.getStartFrame(); double tf = (double)tweenFrame; double animation_complete_percent = (double)tweenFrame / (double)(rule.getFrame()); double curve = (double)rule.getTweenCurve() / 100.0d; double curve_addition_offset = curve * (1 - animation_complete_percent); amt = tf / (double)rule.getFrame(); target.multiply(amt); Location q = target.clone(); q.multiply(curve_addition_offset); target.add(q); target.add(rule.getStartingPosition()); if (rule.isRelative()) { target.add(rule.originalLocation); } obj.getLocation().set(target); //Target Dispose target.Dispose(); q.Dispose(); } } } frame++; if (frame > this.getTotalFrames()) { if (loop) { frame = 0; } else { this.Dispose(); } } }
public override void Dispose() { base.Dispose(); min.Dispose(); max.Dispose(); }