/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { TargetEntity = TheEntity.GetAttackTarget(); if (TargetEntity == null) { return(false); } if (TargetEntity.GetDistanceSqToEntity(TheEntity) > (double)(Field_48331_g * Field_48331_g)) { return(false); } Vec3D vec3d = RandomPositionGenerator.Func_48620_a(TheEntity, 16, 7, Vec3D.CreateVector(TargetEntity.PosX, TargetEntity.PosY, TargetEntity.PosZ)); if (vec3d == null) { return(false); } else { MovePosX = vec3d.XCoord; MovePosY = vec3d.YCoord; MovePosZ = vec3d.ZCoord; return(true); } }
/// <summary> /// Creates a box from a bottom left and top right point. It is an /// error if the min has any coordinate greater the maximum point. /// </summary> /// <param name="min">The bottom left point.</param> /// <param name="max">The top right point.</param> public BoundingBox3D(Vec3D min, Vec3D max) { Debug.Assert(min.X <= max.X && min.Y <= max.Y && min.Z <= max.Z, "Box3D min >= max"); Min = min; Max = max; }
static public Double Distance(LocationValue l1, LocationValue l2) { Vec3D v1 = new Vec3D(l1); Vec3D v2 = new Vec3D(l2); return(v1.ScalerDistanceTo(v2)); }
public static void UpdateObjectLocation(String objID, Vec3D loc) { if (_objectLocations.ContainsKey(objID)) { _objectLocations[objID].X = loc.X; _objectLocations[objID].Y = loc.Y; _objectLocations[objID].Z = loc.Z; } else { _objectLocations.Add(objID, new Vec3D(loc)); } double dist; foreach (String o in _objectLocations.Keys) { if (o == objID) { continue; } dist = _objectLocations[o].ScalerDistanceTo(loc); SetScalarDistanceBetweenTwoObjects(o, objID, dist); } UpdateOthersForNewLocation(objID); UpdateObjectsInSensorRange(objID); //might be a bit expensive to do this often }
private Vec3D PositionPBC(Vec3D v) { var x = v.x; var y = v.y; var z = v.z; if (x > 1) { x = x - 2; } else if (x < -1) { x = x + 2; } if (y > 1) { y = y - 2; } else if (y < -1) { y = y + 2; } if (z > 1) { z = z - 2; } else if (z < -1) { z = z + 2; } return(new Vec3D(x, y, z)); }
static public VelocityValue ComputeVelocityVector(LocationValue start, LocationValue dest, Double maxSpeed, Double throttle) { Vec3D startVec = new Vec3D(start); Vec3D destVec = new Vec3D(dest); Vec3D velVec; if (LocationIsEqual(start, dest)) { velVec = new Vec3D(0, 0, 0); return(velVec.ToVelocityValue()); } else { velVec = startVec.VectorDistanceTo(destVec); } velVec.Normalize(); velVec = velVec.Multiply(maxSpeed * throttle); //if (System.Double.IsNaN(velVec.X)) //{ // int i = 0; //} return(velVec.ToVelocityValue()); }
public virtual void Draw(Tessellator par1Tessellator, float par2) { Vec3D vec3d = VertexPositions[1].Vector3D.Subtract(VertexPositions[0].Vector3D); Vec3D vec3d1 = VertexPositions[1].Vector3D.Subtract(VertexPositions[2].Vector3D); Vec3D vec3d2 = vec3d1.CrossProduct(vec3d).Normalize(); par1Tessellator.StartDrawingQuads(); if (InvertNormal) { par1Tessellator.SetNormal(-(float)vec3d2.XCoord, -(float)vec3d2.YCoord, -(float)vec3d2.ZCoord); } else { par1Tessellator.SetNormal((float)vec3d2.XCoord, (float)vec3d2.YCoord, (float)vec3d2.ZCoord); } for (int i = 0; i < 4; i++) { PositionTextureVertex positiontexturevertex = VertexPositions[i]; par1Tessellator.AddVertexWithUV((float)positiontexturevertex.Vector3D.XCoord * par2, (float)positiontexturevertex.Vector3D.YCoord * par2, (float)positiontexturevertex.Vector3D.ZCoord * par2, positiontexturevertex.TexturePositionX, positiontexturevertex.TexturePositionY); } par1Tessellator.Draw(); }
public static Vec3D Normalize(Vec3D v) { var result = v; result.Normalize(); return(result); }
public override MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { int l = world.getBlockMetadata(i, j, k) & 7; float f = 0.15F; if (l == 1) { setBlockBounds(0.0F, 0.2F, 0.5F - f, f*2.0F, 0.8F, 0.5F + f); } else if (l == 2) { setBlockBounds(1.0F - f*2.0F, 0.2F, 0.5F - f, 1.0F, 0.8F, 0.5F + f); } else if (l == 3) { setBlockBounds(0.5F - f, 0.2F, 0.0F, 0.5F + f, 0.8F, f*2.0F); } else if (l == 4) { setBlockBounds(0.5F - f, 0.2F, 1.0F - f*2.0F, 0.5F + f, 0.8F, 1.0F); } else { float f1 = 0.1F; setBlockBounds(0.5F - f1, 0.0F, 0.5F - f1, 0.5F + f1, 0.6F, 0.5F + f1); } return base.collisionRayTrace(world, i, j, k, vec3d, vec3d1); }
public void GetScreenVectors(int x, int y, uint size_x, uint size_y, out Vec3D position, out Vec3 direction) { position = new Vec3D(); direction = new Vec3(); Camera_getScreenVectors(GetNativeReference(), x, y, size_x, size_y, ref position, ref direction); }
public void ApplyNewValues() { particlePosition = newParticlePosition; particleVelocity = newParticleVelocity; alpha = newAlpha; theta = newTheta; }
/// <summary> /// Returns whether the EntityAIBase should begin execution. /// </summary> public override bool ShouldExecute() { if (Entity.GetAge() >= 100) { return(false); } if (Entity.GetRNG().Next(120) != 0) { return(false); } Vec3D vec3d = RandomPositionGenerator.Func_48622_a(Entity, 10, 7); if (vec3d == null) { return(false); } else { Field_46098_b = vec3d.XCoord; Field_46099_c = vec3d.YCoord; Field_46097_d = vec3d.ZCoord; return(true); } }
public bool GlobalToWorld(Coordinate converter, Vec3D position) { switch (_mapType) { case MapType.UNKNOWN: { return(false); } case MapType.UTM: UTMPos utmpos = new UTMPos(_metaData.Zone(), _metaData.North(), -(position.z + _origin.z), position.x + _origin.x, position.y + _origin.y); converter.SetUTMPos(utmpos); break; case MapType.GEOCENTRIC: CartPos cartpos = new CartPos(position.x + _origin.x, position.y + _origin.y, position.z + _origin.z); converter.SetCartPos(cartpos); break; } return(true); }
private double Distance2PBC(Vec3D a, Vec3D b) { var dx = b.x - a.x; var dy = b.y - a.y; var dz = b.z - a.z; if (dx > 1) { dx = dx - 2; } else if (dx < -1) { dx = dx + 2; } if (dy > 1) { dy = dy - 2; } else if (dy < -1) { dy = dy + 2; } if (dz > 1) { dz = dz - 2; } else if (dz < -1) { dz = dz + 2; } return(dx * dx + dy * dy + dz * dz); }
/// <summary> /// Gets the vector of the PathPoint associated with the given index. /// </summary> public virtual Vec3D GetVectorFromIndex(Entity par1Entity, int par2) { double d = (double)Points[par2].XCoord + (double)(int)(par1Entity.Width + 1.0F) * 0.5D; double d1 = Points[par2].YCoord; double d2 = (double)Points[par2].ZCoord + (double)(int)(par1Entity.Width + 1.0F) * 0.5D; return(Vec3D.CreateVector(d, d1, d2)); }
public Vec3D getPosition(Entity entity) { double d = points[pathIndex].xCoord + (int)(entity.width + 1.0F) * 0.5D; double d1 = points[pathIndex].yCoord; double d2 = points[pathIndex].zCoord + (int)(entity.width + 1.0F) * 0.5D; return(Vec3D.createVector(d, d1, d2)); }
static public Vec3D Cross(Vec3D a, Vec3D b) { return(new Vec3D( a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x )); }
public void SetPosition() { try{ Vec3D v = GetModel().GetRectangularFromEquatorialCoords(); transform.localPosition = new Vector3((float)v.x, (float)v.y, (float)v.z) * distance; }catch (NullReferenceException n) { } }
public bool GetGroundPosition(Vec3D position, Vec3 direction, out MapPos result, ClampFlags flags = ClampFlags.DEFAULT) { result = new MapPos(); // Coordinate is now in world Cartesian coordinates (Roi Position) Vec3D origo = new Vec3D(0, 0, 0); // Set used origo Intersector isect = new Intersector(); // Check camera frustrum ----------------------------------------------------------- if (_camera != null && _camera.IsValid()) { origo = _camera.Position; if ((flags & ClampFlags.FRUSTRUM_CULL) != 0) { isect.SetCamera(_camera); } } // Adjust intersector to use origo as center position = position - origo; isect.SetStartPosition((Vec3)position); isect.SetDirection(direction); if (isect.Intersect(_currentMap, IntersectQuery.NEAREST_POINT | IntersectQuery.NORMAL | ((flags & ClampFlags.WAIT_FOR_DATA) != 0 ? IntersectQuery.WAIT_FOR_DYNAMIC_DATA : 0), 1, true, origo)) { IntersectorResult res = isect.GetResult(); IntersectorData data = res.GetData(0); result.position = data.position + origo; result.normal = data.normal; result.clamped = true; } isect.Dispose(); // Drop handle and ignore GC if (_topRoi != null) { RoiNode roi = _topRoi.GetClosestRoiNode(result.position); result.node = roi; // Remove roiNode position as offset - Go to local RoiNode based coordinate system if (roi != null && roi.IsValid()) { result.position -= roi.Position; } } return(true); }
public MapLimits(Vec3D lowerLimit, Vec3D higherLimit) { if (lowerLimit == null || higherLimit == null) { throw new ArgumentException("Map limits arguments must be both non null!"); } this.lowerLimit = lowerLimit; this.higherLimit = higherLimit; }
public MovingObjectPosition(int par1, int par2, int par3, int par4, Vec3D par5Vec3D) { TypeOfHit = EnumMovingObjectType.TILE; BlockX = par1; BlockY = par2; BlockZ = par3; SideHit = par4; HitVec = Vec3D.CreateVector(par5Vec3D.XCoord, par5Vec3D.YCoord, par5Vec3D.ZCoord); }
public MovingObjectPosition(int i, int j, int k, int l, Vec3D vec3d) { typeOfHit = EnumMovingObjectType.TILE; blockX = i; blockY = j; blockZ = k; sideHit = l; hitVec = Vec3D.createVector(vec3d.xCoord, vec3d.yCoord, vec3d.zCoord); }
public static Vec3D Lerp(ref Vec3D a, ref Vec3D b, double t) { t = Math.Min(1, Math.Max(0, t)); return(new Vec3D( a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t)); }
public RoiNode GetClosestRoiNode(Vec3D position) { //NodeLock.WaitLockEdit(); RoiNode node = CreateObject(Roi_getClosestRoiNode(GetNativeReference(), ref position)) as RoiNode; //NodeLock.UnLock(); return(node); }
public double Distance(String ob1, String ob2) { if (!AllObjects.ContainsKey(ob1) || !AllObjects.ContainsKey(ob2)) { return(-1); } Vec3D ob1V = new Vec3D(AllObjects[ob1].Location); Vec3D ob2V = new Vec3D(AllObjects[ob2].Location); return(ob1V.ScalerDistanceTo(ob2V)); }
public bool GlobalToWorld(Vec3D global_position, out CartPos result) { Coordinate converter = new Coordinate(); if (!GlobalToWorld(converter, global_position)) { result = null; return(false); } return(converter.GetCartPos(out result)); }
public MapPos GlobalToLocal(Vec3D global_position) { MapPos result = new MapPos(); result.position = global_position; result.local_orientation = GetLocalOrientation(global_position); ToLocal(result); return(result); }
public MapPos WorldToLocal(Vec3D position) { position.z = -position.z; MapPos result = new MapPos(); result.position = position /* - _origin*/; MapToRoi(result); return(result); }
private void doTick() { var arraylist = new ArrayList(); for (Iterator iterator = field_6037_b.keySet().iterator(); iterator.hasNext();) { var s = (string)iterator.next(); int k = ((Integer)field_6037_b.get(s)).intValue(); if (k > 0) { field_6037_b.put(s, Integer.valueOf(k - 1)); } else { arraylist.add(s); } } for (int i = 0; i < arraylist.size(); i++) { field_6037_b.remove(arraylist.get(i)); } AxisAlignedBB.clearBoundingBoxPool(); Vec3D.initialize(); deathTime++; if (deathTime % 20 == 0) { configManager.sendPacketToAllPlayers(new Packet4UpdateTime(worldMngr.getWorldTime())); } worldMngr.tick(); while (worldMngr.func_6156_d()) { ; } worldMngr.updateEntities(); networkServer.func_715_a(); configManager.func_637_b(); entityTracker.updateTrackedEntities(); for (int j = 0; j < field_9010_p.size(); j++) { ((IUpdatePlayerListBox)field_9010_p.get(j)).update(); } try { commandLineParser(); } catch (java.lang.Exception exception) { logger.log(Level.WARNING, "Unexpected exception while parsing console command", exception); } }
public Model3D(Vec3D[] v, Face[] f, string s) { vertices = v; faces = f; numberOfVertices = v.Length; numberOfFaces = f.Length; source = s; totalArea = 0.0; foreach (Face fac in f) totalArea += fac.area; this.TransToCOM(); //this.normalizeScale(); }
public Vec3D LocalToWorld(MapPos mappos) { Vec3D result = mappos.position; RoiNode roi = mappos.node as RoiNode; if (roi != null && roi.IsValid()) { result += roi.Position; } return(new Vec3D(result.x, result.y, -result.z)); }
public Vec3D LocalToWorld(MapPos mappos) { Vec3D result = mappos.position; if (mappos.roiNode != null && mappos.roiNode.IsValid()) { result += mappos.roiNode.Position; } //result += _origin; return(result); }
//get CoM, if it doesn't exist: set it! public Vec3D getCOM() { if (COM != null) return COM; double x = 0, y = 0, z = 0; foreach (Vec3D v in vertices) { x += v.x; y += v.y; z += v.z; } COM = new Vec3D(x / vertices.Length, y / vertices.Length, z / vertices.Length); return COM; }
public virtual float func_494_a(Vec3D vec3d, AxisAlignedBB axisalignedbb) { double d = 1.0D/((axisalignedbb.maxX - axisalignedbb.minX)*2D + 1.0D); double d1 = 1.0D/((axisalignedbb.maxY - axisalignedbb.minY)*2D + 1.0D); double d2 = 1.0D/((axisalignedbb.maxZ - axisalignedbb.minZ)*2D + 1.0D); int i = 0; int j = 0; for (float f = 0.0F; f <= 1.0F; f = (float) (f + d)) { for (float f1 = 0.0F; f1 <= 1.0F; f1 = (float) (f1 + d1)) { for (float f2 = 0.0F; f2 <= 1.0F; f2 = (float) (f2 + d2)) { double d3 = axisalignedbb.minX + (axisalignedbb.maxX - axisalignedbb.minX)*f; double d4 = axisalignedbb.minY + (axisalignedbb.maxY - axisalignedbb.minY)*f1; double d5 = axisalignedbb.minZ + (axisalignedbb.maxZ - axisalignedbb.minZ)*f2; if (rayTraceBlocks(Vec3D.createVector(d3, d4, d5), vec3d) == null) { i++; } j++; } } } return i/(float) j; }
private double getDistanceOfPoint(Vec3D v) { return System.Math.Sqrt(v.x * v.x + v.y * v.y + v.z * v.z); }
private double getDistanceBetweenPoints(Vec3D v1, Vec3D v2) { return System.Math.Sqrt(System.Math.Pow(v1.x - v2.x, 2) + System.Math.Pow(v1.y - v2.y, 2) + System.Math.Pow(v1.z - v2.z, 2)); }
public virtual MovingObjectPosition rayTraceBlocks_do(Vec3D vec3d, Vec3D vec3d1, bool flag) { if (Double.isNaN(vec3d.xCoord) || Double.isNaN(vec3d.yCoord) || Double.isNaN(vec3d.zCoord)) { return null; } if (Double.isNaN(vec3d1.xCoord) || Double.isNaN(vec3d1.yCoord) || Double.isNaN(vec3d1.zCoord)) { return null; } int i = MathHelper.floor_double(vec3d1.xCoord); int j = MathHelper.floor_double(vec3d1.yCoord); int k = MathHelper.floor_double(vec3d1.zCoord); int l = MathHelper.floor_double(vec3d.xCoord); int i1 = MathHelper.floor_double(vec3d.yCoord); int j1 = MathHelper.floor_double(vec3d.zCoord); for (int k1 = 200; k1-- >= 0;) { if (Double.isNaN(vec3d.xCoord) || Double.isNaN(vec3d.yCoord) || Double.isNaN(vec3d.zCoord)) { return null; } if (l == i && i1 == j && j1 == k) { return null; } double d = 999D; double d1 = 999D; double d2 = 999D; if (i > l) { d = l + 1.0D; } if (i < l) { d = l + 0.0D; } if (j > i1) { d1 = i1 + 1.0D; } if (j < i1) { d1 = i1 + 0.0D; } if (k > j1) { d2 = j1 + 1.0D; } if (k < j1) { d2 = j1 + 0.0D; } double d3 = 999D; double d4 = 999D; double d5 = 999D; double d6 = vec3d1.xCoord - vec3d.xCoord; double d7 = vec3d1.yCoord - vec3d.yCoord; double d8 = vec3d1.zCoord - vec3d.zCoord; if (d != 999D) { d3 = (d - vec3d.xCoord)/d6; } if (d1 != 999D) { d4 = (d1 - vec3d.yCoord)/d7; } if (d2 != 999D) { d5 = (d2 - vec3d.zCoord)/d8; } byte byte0 = 0; if (d3 < d4 && d3 < d5) { if (i > l) { byte0 = 4; } else { byte0 = 5; } vec3d.xCoord = d; vec3d.yCoord += d7*d3; vec3d.zCoord += d8*d3; } else if (d4 < d5) { if (j > i1) { byte0 = 0; } else { byte0 = 1; } vec3d.xCoord += d6*d4; vec3d.yCoord = d1; vec3d.zCoord += d8*d4; } else { if (k > j1) { byte0 = 2; } else { byte0 = 3; } vec3d.xCoord += d6*d5; vec3d.yCoord += d7*d5; vec3d.zCoord = d2; } Vec3D vec3d2 = Vec3D.createVector(vec3d.xCoord, vec3d.yCoord, vec3d.zCoord); l = (int) (vec3d2.xCoord = MathHelper.floor_double(vec3d.xCoord)); if (byte0 == 5) { l--; vec3d2.xCoord++; } i1 = (int) (vec3d2.yCoord = MathHelper.floor_double(vec3d.yCoord)); if (byte0 == 1) { i1--; vec3d2.yCoord++; } j1 = (int) (vec3d2.zCoord = MathHelper.floor_double(vec3d.zCoord)); if (byte0 == 3) { j1--; vec3d2.zCoord++; } int l1 = getBlockId(l, i1, j1); int i2 = getBlockMetadata(l, i1, j1); Block block = Block.blocksList[l1]; if (l1 > 0 && block.canCollideCheck(i2, flag)) { MovingObjectPosition movingobjectposition = block.collisionRayTrace(this, l, i1, j1, vec3d, vec3d1); if (movingobjectposition != null) { return movingobjectposition; } } } return null; }
public MovingObjectPosition(Entity entity) { typeOfHit = EnumMovingObjectType.ENTITY; entityHit = entity; hitVec = Vec3D.createVector(entity.posX, entity.posY, entity.posZ); }
private bool isVecInXZ(Vec3D vec3d) { if (vec3d == null) { return false; } else { return vec3d.xCoord >= minX && vec3d.xCoord <= maxX && vec3d.zCoord >= minZ && vec3d.zCoord <= maxZ; } }
void AddTrianglesGroupDoodads(TriangleCollection s, ModelInstance mi, Vec3D world_dir, Vec3D world_off, float rot) { float dx = mi.pos.x; float dy = mi.pos.y; float dz = mi.pos.z; rotate(dx, dz, rot + 90f, out dx, out dz); dx += world_off.x; dy += world_off.y; dz += world_off.z; Quaternion q; q.x = mi.dir.z; q.y = mi.dir.x; q.z = mi.dir.y; q.w = mi.w; Matrix4 rotMatrix = new Matrix4(); rotMatrix.makeQuaternionRotate(q); Model m = mi.model; if (m.boundingTriangles == null) { } else { // We got boiuding stuff, that is better int nBoundingVertices = m.boundingVertices.Length / 3; int[] vertices = new int[nBoundingVertices]; for (uint i = 0; i < nBoundingVertices; i++) { uint off = i * 3; float x = m.boundingVertices[off]; float y = m.boundingVertices[off + 2]; float z = m.boundingVertices[off + 1]; x *= mi.sc; y *= mi.sc; z *= -mi.sc; Vector pos; pos.x = x; pos.y = y; pos.z = z; Vector new_pos = rotMatrix.mutiply(pos); x = pos.x; y = pos.y; z = pos.z; float dir_x = world_dir.z; float dir_y = world_dir.y - 90; float dir_z = -world_dir.x; rotate(z, y, dir_x, out z, out y); rotate(x, y, dir_z, out x, out y); rotate(x, z, dir_y, out x, out z); float xx = x + dx; float yy = y + dy; float zz = -z + dz; float finalx = ChunkReader.ZEROPOINT - zz; float finaly = ChunkReader.ZEROPOINT - xx; float finalz = yy; vertices[i] = s.AddVertex(finalx, finaly, finalz); } int nBoundingTriangles = m.boundingTriangles.Length / 3; for (uint i = 0; i < nBoundingTriangles; i++) { uint off = i * 3; int v0 = vertices[m.boundingTriangles[off]]; int v1 = vertices[m.boundingTriangles[off + 1]]; int v2 = vertices[m.boundingTriangles[off + 2]]; s.AddTriangle(v0, v2, v1, ChunkedTriangleCollection.TriangleFlagModel); } } }
void AddTrianglesGroupDoodads(TriangleCollection s, ModelInstance mi, Vec3D world_dir, Vec3D world_off, float rot) { float dx = mi.pos.x; float dy = mi.pos.y; float dz = mi.pos.z; rotate(dx, dz, rot +90f, out dx, out dz); dx += world_off.x; dy += world_off.y; dz += world_off.z; Quaternion q; q.x = -mi.dir.z; q.y = mi.dir.x; q.z = mi.dir.y; q.w = mi.w; Matrix4 rotMatrix = new Matrix4(); rotMatrix.makeQuaternionRotate(q); Model m = mi.model; if (m.boundingTriangles == null) { /* // /cry no bouding info, revert to normal vertices ModelView mv = m.view[0]; // View number 1 ?!?! int[] vertices = new int[m.vertices.Length / 3]; for (uint i = 0; i < m.vertices.Length / 3; i++) { float x = m.vertices[i * 3]; float y = m.vertices[i * 3 + 2]; float z = m.vertices[i * 3 + 1]; x *= mi.sc; y *= mi.sc; z *= -mi.sc; Vector pos; pos.x = x; pos.y = y; pos.z = z; Vector new_pos = rotMatrix.mutiply(pos); x = pos.x; y = pos.y; z = pos.z; rotate(x, z, (world_dir.y - 90), out x, out z); rotate(y, z, -world_dir.x, out y, out z); rotate(x, y, world_dir.z, out x, out y); float xx = x + dx; float yy = y + dy; float zz = -z + dz; float finalx = ChunkReader.ZEROPOINT - zz; float finaly = ChunkReader.ZEROPOINT - xx; float finalz = yy; vertices[i] = s.AddVertex(finalx, finaly, finalz); } for (int i = 0; i < mv.triangleList.Length / 3; i++) { int off = i * 3; UInt16 vi0 = mv.triangleList[off]; UInt16 vi1 = mv.triangleList[off + 1]; UInt16 vi2 = mv.triangleList[off + 2]; int ind0 = mv.indexList[vi0]; int ind1 = mv.indexList[vi1]; int ind2 = mv.indexList[vi2]; int v0 = vertices[ind0]; int v1 = vertices[ind1]; int v2 = vertices[ind2]; s.AddTriangle(v0, v1, v2, ChunkedTriangleCollection.TriangleFlagModel); } */ } else { // We got boiuding stuff, that is better int nBoundingVertices = m.boundingVertices.Length / 3; int[] vertices = new int[nBoundingVertices]; for (uint i = 0; i < nBoundingVertices; i++) { uint off = i * 3; float x = m.boundingVertices[off]; float y = m.boundingVertices[off + 2]; float z = m.boundingVertices[off + 1]; x *= mi.sc; y *= mi.sc; z *= -mi.sc; Vector pos; pos.x = x; pos.y = y; pos.z = z; Vector new_pos = rotMatrix.mutiply(pos); x = pos.x; y = pos.y; z = pos.z; rotate(x, z, (world_dir.y - 90), out x, out z); rotate(y, z, -world_dir.x, out y, out z); rotate(x, y, world_dir.z, out x, out y); float xx = x + dx; float yy = y + dy; float zz = -z + dz; float finalx = ChunkReader.ZEROPOINT - zz; float finaly = ChunkReader.ZEROPOINT - xx; float finalz = yy; vertices[i] = s.AddVertex(finalx, finaly, finalz); } int nBoundingTriangles = m.boundingTriangles.Length / 3; for (uint i = 0; i < nBoundingTriangles; i++) { uint off = i * 3; int v0 = vertices[m.boundingTriangles[off]]; int v1 = vertices[m.boundingTriangles[off + 1]]; int v2 = vertices[m.boundingTriangles[off + 2]]; s.AddTriangle(v0, v1, v2, ChunkedTriangleCollection.TriangleFlagModel); } } }
public virtual void velocityToAddToEntity(World world, int i, int j, int k, Entity entity, Vec3D vec3d) { }
private bool isVecInXY(Vec3D vec3d) { if (vec3d == null) { return false; } else { return vec3d.xCoord >= minX && vec3d.xCoord <= maxX && vec3d.yCoord >= minY && vec3d.yCoord <= maxY; } }
public virtual MovingObjectPosition rayTraceBlocks(Vec3D vec3d, Vec3D vec3d1) { return rayTraceBlocks_do(vec3d, vec3d1, false); }
public virtual MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { setBlockBoundsBasedOnState(world, i, j, k); vec3d = vec3d.addVector(-i, -j, -k); vec3d1 = vec3d1.addVector(-i, -j, -k); Vec3D vec3d2 = vec3d.getIntermediateWithXValue(vec3d1, minX); Vec3D vec3d3 = vec3d.getIntermediateWithXValue(vec3d1, maxX); Vec3D vec3d4 = vec3d.getIntermediateWithYValue(vec3d1, minY); Vec3D vec3d5 = vec3d.getIntermediateWithYValue(vec3d1, maxY); Vec3D vec3d6 = vec3d.getIntermediateWithZValue(vec3d1, minZ); Vec3D vec3d7 = vec3d.getIntermediateWithZValue(vec3d1, maxZ); if (!isVecInsideYZBounds(vec3d2)) { vec3d2 = null; } if (!isVecInsideYZBounds(vec3d3)) { vec3d3 = null; } if (!isVecInsideXZBounds(vec3d4)) { vec3d4 = null; } if (!isVecInsideXZBounds(vec3d5)) { vec3d5 = null; } if (!isVecInsideXYBounds(vec3d6)) { vec3d6 = null; } if (!isVecInsideXYBounds(vec3d7)) { vec3d7 = null; } Vec3D vec3d8 = null; if (vec3d2 != null && (vec3d8 == null || vec3d.distanceTo(vec3d2) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d2; } if (vec3d3 != null && (vec3d8 == null || vec3d.distanceTo(vec3d3) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d3; } if (vec3d4 != null && (vec3d8 == null || vec3d.distanceTo(vec3d4) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d4; } if (vec3d5 != null && (vec3d8 == null || vec3d.distanceTo(vec3d5) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d5; } if (vec3d6 != null && (vec3d8 == null || vec3d.distanceTo(vec3d6) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d6; } if (vec3d7 != null && (vec3d8 == null || vec3d.distanceTo(vec3d7) < vec3d.distanceTo(vec3d8))) { vec3d8 = vec3d7; } if (vec3d8 == null) { return null; } sbyte byte0 = -1; if (vec3d8 == vec3d2) { byte0 = 4; } if (vec3d8 == vec3d3) { byte0 = 5; } if (vec3d8 == vec3d4) { byte0 = 0; } if (vec3d8 == vec3d5) { byte0 = 1; } if (vec3d8 == vec3d6) { byte0 = 2; } if (vec3d8 == vec3d7) { byte0 = 3; } return new MovingObjectPosition(i, j, k, byte0, vec3d8.addVector(i, j, k)); }
public override void velocityToAddToEntity(World world, int i, int j, int k, Entity entity, Vec3D vec3d) { modelBlock.velocityToAddToEntity(world, i, j, k, entity, vec3d); }
//translate every vertex relative to CoM public void TransToCOM() { Vec3D mean = getCOM(); if (COM.Equals(new Vec3D(0, 0, 0))) { return; } for (int i = 0; i < vertices.Length; i++) { Vec3D v = vertices[i]; v.sub(mean); } COM = new Vec3D(0, 0, 0); }
public MovingObjectPosition func_706_a(Vec3D vec3d, Vec3D vec3d1) { Vec3D vec3d2 = vec3d.getIntermediateWithXValue(vec3d1, minX); Vec3D vec3d3 = vec3d.getIntermediateWithXValue(vec3d1, maxX); Vec3D vec3d4 = vec3d.getIntermediateWithYValue(vec3d1, minY); Vec3D vec3d5 = vec3d.getIntermediateWithYValue(vec3d1, maxY); Vec3D vec3d6 = vec3d.getIntermediateWithZValue(vec3d1, minZ); Vec3D vec3d7 = vec3d.getIntermediateWithZValue(vec3d1, maxZ); if (!isVecInYZ(vec3d2)) { vec3d2 = null; } if (!isVecInYZ(vec3d3)) { vec3d3 = null; } if (!isVecInXZ(vec3d4)) { vec3d4 = null; } if (!isVecInXZ(vec3d5)) { vec3d5 = null; } if (!isVecInXY(vec3d6)) { vec3d6 = null; } if (!isVecInXY(vec3d7)) { vec3d7 = null; } Vec3D vec3d8 = null; if (vec3d2 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d2) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d2; } if (vec3d3 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d3) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d3; } if (vec3d4 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d4) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d4; } if (vec3d5 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d5) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d5; } if (vec3d6 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d6) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d6; } if (vec3d7 != null && (vec3d8 == null || vec3d.squareDistanceTo(vec3d7) < vec3d.squareDistanceTo(vec3d8))) { vec3d8 = vec3d7; } if (vec3d8 == null) { return null; } sbyte byte0 = -1; if (vec3d8 == vec3d2) { byte0 = 4; } if (vec3d8 == vec3d3) { byte0 = 5; } if (vec3d8 == vec3d4) { byte0 = 0; } if (vec3d8 == vec3d5) { byte0 = 1; } if (vec3d8 == vec3d6) { byte0 = 2; } if (vec3d8 == vec3d7) { byte0 = 3; } return new MovingObjectPosition(0, 0, 0, byte0, vec3d8); }
public override MovingObjectPosition collisionRayTrace(World world, int i, int j, int k, Vec3D vec3d, Vec3D vec3d1) { setBlockBoundsBasedOnState(world, i, j, k); return base.collisionRayTrace(world, i, j, k, vec3d, vec3d1); }
private bool isVecInYZ(Vec3D vec3d) { if (vec3d == null) { return false; } else { return vec3d.yCoord >= minY && vec3d.yCoord <= maxY && vec3d.zCoord >= minZ && vec3d.zCoord <= maxZ; } }