/// <summary> /// Adds the specified joint to the collection. /// </summary> /// <param name="joint">The joint type.</param> /// <param name="radius">The size of the ellipse</param> /// <param name="brush">The brush used to fill the ellipse.</param> public void AddJoint(JointType joint, double radius, Brush brush) { Brush HAND_BRUSH = new SolidColorBrush(Colors.Green); if (joint == JointType.HandTipLeft || joint == JointType.HandTipRight) { Joints.Add(joint, new Ellipse { Width = radius * 6, Height = radius * 6, Fill = HAND_BRUSH }); } else if (joint != JointType.ThumbLeft && joint != JointType.ThumbRight) { Joints.Add(joint, new Ellipse { Width = 0, Height = 0, Fill = HAND_BRUSH }); } else { Joints.Add(joint, new Ellipse { Width = radius * 3, Height = radius * 3, Fill = brush }); } }
public Pose(string pose) : this() { var poseParse = pose.Substring(0, pose.Length - 1).Split(","); PoseId = Convert.ToInt32(poseParse[1]); int i = 0; for (int j = 2; j < poseParse.Length; j += 2) { var angle = Convert.ToDouble(poseParse[j]); if (angle >= 0) { var joint = new Joint() { ServoId = i, Angle = angle, Duration = Convert.ToInt32((poseParse[j + 1])) }; Joints.Add(joint); } i++; } }
private void SetupJoints() { Joints.Clear(); Joints.Add(JointType.HipCenter, CreateJoint(JointType.HipCenter)); Joints.Add(JointType.HipLeft, CreateJoint(JointType.HipLeft)); Joints.Add(JointType.KneeLeft, CreateJoint(JointType.KneeLeft)); Joints.Add(JointType.AnkleLeft, CreateJoint(JointType.AnkleLeft)); Joints.Add(JointType.FootLeft, CreateJoint(JointType.FootLeft)); Joints.Add(JointType.HipRight, CreateJoint(JointType.HipRight)); Joints.Add(JointType.KneeRight, CreateJoint(JointType.KneeRight)); Joints.Add(JointType.AnkleRight, CreateJoint(JointType.AnkleRight)); Joints.Add(JointType.FootRight, CreateJoint(JointType.FootRight)); Joints.Add(JointType.Spine, CreateJoint(JointType.Spine)); Joints.Add(JointType.ShoulderCenter, CreateJoint(JointType.ShoulderCenter)); Joints.Add(JointType.ShoulderLeft, CreateJoint(JointType.ShoulderLeft)); Joints.Add(JointType.ElbowLeft, CreateJoint(JointType.ElbowLeft)); Joints.Add(JointType.WristLeft, CreateJoint(JointType.WristLeft)); Joints.Add(JointType.HandLeft, CreateJoint(JointType.HandLeft)); Joints.Add(JointType.ShoulderRight, CreateJoint(JointType.ShoulderRight)); Joints.Add(JointType.ElbowRight, CreateJoint(JointType.ElbowRight)); Joints.Add(JointType.WristRight, CreateJoint(JointType.WristRight)); Joints.Add(JointType.HandRight, CreateJoint(JointType.HandRight)); Joints.Add(JointType.Head, CreateJoint(JointType.Head)); }
private void CreateLocalLists() { foreach (Robot robot in BaseFile.Robots) { Robots.Add(robot); } foreach (Weapon weapon in BaseFile.Weapons) { Weapons.Add(weapon); } foreach (Polymodel model in BaseFile.Models) { Models.Add(model); } foreach (JointPos joint in BaseFile.Joints) { Joints.Add(joint); } foreach (ushort bm in BaseFile.ObjBitmaps) { ObjBitmaps.Add(bm); } foreach (ushort bm in BaseFile.ObjBitmapPointers) { ObjBitmapPointers.Add(bm); } }
private void LoadAnimations(Robot robot, Polymodel model) { robot.NumGuns = (sbyte)model.NumGuns; for (int i = 0; i < 8; i++) { robot.GunPoints[i] = model.GunPoints[i]; robot.GunSubmodels[i] = (byte)model.GunSubmodels[i]; } for (int m = 0; m < 9; m++) { for (int f = 0; f < 5; f++) { robot.AnimStates[m, f].NumJoints = 0; robot.AnimStates[m, f].Offset = 0; } } if (!model.IsAnimated) { return; } int[] gunNums = new int[10]; for (int i = 1; i < model.NumSubmodels; i++) { gunNums[i] = robot.NumGuns; } gunNums[0] = -1; for (int g = 0; g < robot.NumGuns; g++) { int m = robot.GunSubmodels[g]; while (m != 0) { gunNums[m] = g; m = model.Submodels[m].Parent; } } for (int g = 0; g < robot.NumGuns + 1; g++) { for (int state = 0; state < 5; state++) { robot.AnimStates[g, state].NumJoints = 0; robot.AnimStates[g, state].Offset = (short)(Joints.Count + VHAMFile.NumDescent2Joints); for (int m = 0; m < model.NumSubmodels; m++) { if (gunNums[m] == g) { JointPos joint = new JointPos(); joint.JointNum = (short)m; joint.Angles = model.AnimationMatrix[m, state]; Joints.Add(joint); robot.AnimStates[g, state].NumJoints++; } } } } }
public void AddJoint(JointType joint, double radius, Brush brush) { Joints.Add(joint, new Ellipse { Width = radius, Height = radius, Fill = brush }); }
/// <summary> /// given the end joint and the IK link length, setup the IK link /// </summary> public void SetBones(Transform endJoint, int len) { Dbg.Assert(len > 0, "BaseIKSolver.SetBones: the link length must be larger than 0"); ClearBones(); // the endJoint is the joint user moves, the link's last joint is its parent Transform joint = endJoint; float totalLen = 0; // add the endJoint JointInfo endInfo = new JointInfo(); endInfo.joint = endJoint; endInfo.boneLen = 0; endInfo.remainLen = 0; m_Joints.Add(endInfo); // add joint from the end to the head for (int idx = 0; idx < len; ++idx) { Transform parentJoint = joint.parent; Dbg.Assert(parentJoint != null, "BaseIKSolver.SetBones: the link length is too big, there is already no parent joint for: {0}", joint); JointInfo info = new JointInfo(); info.joint = parentJoint; info.boneLen = (parentJoint.position - joint.position).magnitude; info.remainLen = totalLen; totalLen += info.boneLen; m_Joints.Add(info); joint = parentJoint; } m_Joints.Reverse(); //reverse the array to make the most significant joint at first entry m_TransArr = new Transform[m_Joints.Count]; for (int i = 0; i < m_TransArr.Length; ++i) { m_TransArr[i] = m_Joints[i].joint; } }
/** Adds a joint to the physics world.*/ public virtual void AddJoint(CCPhysicsJoint joint) { if (joint.World != null && joint.World != this) { joint.RemoveFormWorld(); } AddJointOrDelay(joint); Joints.Add(joint); joint._world = this; }
/// <summary> /// Lisää olion rakenteeseen. /// </summary> /// <param name="obj">Lisättävä olio</param> public void Add(IGameObject obj) { if (!(obj is PhysicsObject)) { throw new NotImplementedException("Currently only PhysicsObjects can be added to a structure."); } if (!IsAddedToGame) { // Add to game and use relative coordinates obj.Position += this.Position; if (!obj.IsAddedToGame) { Game.Instance.Add(obj); } } PhysicsObject physObj = (PhysicsObject)obj; physObj.ParentStructure = this; physObj.IsVisible = _isVisible; physObj.IgnoresGravity = _ignoresGravity; physObj.IgnoresCollisionResponse = _ignoresCollisionResponse; physObj.IgnoresExplosions = _ignoresExplosions; physObj.IgnoresPhysicsLogics = _ignoresPhysicsLogics; physObj.CollisionIgnoreGroup = _collisionIgnoreGroup; physObj.CollisionIgnorer = _collisionIgnorer; physObj.Restitution = _restitution; physObj.StaticFriction = _sfriction; physObj.KineticFriction = _kfriction; physObj.LinearDamping = _linearDamping; physObj.AngularDamping = _angularDamping; physObj.Collided += this.OnCollided; var game = PhysicsGameBase.Instance; foreach (var existing in objects) { IAxleJoint joint = game.Engine.CreateJoint(physObj, existing, existing.AbsolutePosition); joint.Softness = _softness; Joints.Add(joint); game.Add(joint); } objects.Add(physObj); CalculateMomentOfInertia(); }
private FeJoint AddNewOrGet_JointByCoordinate(Point3d inPoint) { // Rounds the point coordinates inPoint = RoundedPoint3d(inPoint); // Already exists in the list? if (Joints.Any(a => a.Value.Point == inPoint)) { return(Joints.First(a => a.Value.Point == inPoint).Value); } FeJoint newJoint = new FeJoint(_pointCount.ToString(), inPoint); Joints.Add(newJoint.Id, newJoint); _pointCount++; return(newJoint); }
//--------------------------------------------------------------------- // READING //--------------------------------------------------------------------- /// <summary> /// Converts all the base file's data classes into the editor class for that type. /// </summary> public void CreateLocalLists() { //TODO: This is just passthrough for now, need "editor" classes foreach (ushort texture in BaseFile.Textures) { Textures.Add(texture); } foreach (TMAPInfo tmapInfo in BaseFile.TMapInfo) { TMapInfo.Add(tmapInfo); } Array.Copy(BaseFile.Sounds, Sounds, 254); Array.Copy(BaseFile.AltSounds, AltSounds, 254); foreach (VClip clip in BaseFile.VClips) { VClips.Add(clip); } foreach (EClip clip in BaseFile.EClips) { EClips.Add(clip); } foreach (WClip clip in BaseFile.WClips) { WClips.Add(clip); } foreach (Robot robot in BaseFile.Robots) { Robots.Add(robot); } foreach (JointPos joint in BaseFile.Joints) { Joints.Add(joint); } foreach (Weapon weapon in BaseFile.Weapons) { Weapons.Add(weapon); } foreach (Polymodel model in BaseFile.Models) { Models.Add(model); } foreach (ushort gauge in BaseFile.Gauges) { Gauges.Add(gauge); } foreach (ushort gauge in BaseFile.GaugesHires) { GaugesHires.Add(gauge); } PlayerShip = BaseFile.PlayerShip; foreach (ushort cockpit in BaseFile.Cockpits) { Cockpits.Add(cockpit); } foreach (Reactor reactor in BaseFile.Reactors) { Reactors.Add(reactor); } foreach (Powerup powerup in BaseFile.Powerups) { Powerups.Add(powerup); } FirstMultiBitmapNum = BaseFile.FirstMultiBitmapNum; for (int i = 0; i < 2620; i++) { BitmapXLATData[i] = BaseFile.BitmapXLATData[i]; } foreach (ushort bm in BaseFile.ObjBitmaps) { ObjBitmaps.Add(bm); } foreach (ushort bm in BaseFile.ObjBitmapPointers) { ObjBitmapPointers.Add(bm); } }
public void Read(Stream stream) { BinaryReader br; br = new BinaryReader(stream); HAMDataReader bm = new HAMDataReader(); int sig = br.ReadInt32(); if (sig != 0x214D4148) { br.Dispose(); throw new InvalidDataException("HAMFile::Read: HAM file has bad header."); } Version = br.ReadInt32(); if (Version < 2 || Version > 3) { br.Dispose(); throw new InvalidDataException(string.Format("HAMFile::Read: HAM file has bad version. Got {0}, but expected \"2\" or \"3\"", Version)); } int sndptr = 0; if (Version == 2) { sndptr = br.ReadInt32(); } int NumBitmaps = br.ReadInt32(); for (int x = 0; x < NumBitmaps; x++) { Textures.Add(br.ReadUInt16()); } for (int x = 0; x < NumBitmaps; x++) { TMapInfo.Add(bm.ReadTMAPInfo(br)); TMapInfo[x].ID = x; } int NumSounds = br.ReadInt32(); if (NumSounds > 254) { throw new InvalidDataException("HAM file specifies more than 254 sounds."); } for (int x = 0; x < NumSounds; x++) { Sounds[x] = br.ReadByte(); } for (int x = 0; x < NumSounds; x++) { AltSounds[x] = br.ReadByte(); } int NumVClips = br.ReadInt32(); for (int x = 0; x < NumVClips; x++) { VClips.Add(bm.ReadVClip(br)); VClips[x].ID = x; } int NumEClips = br.ReadInt32(); for (int x = 0; x < NumEClips; x++) { EClips.Add(bm.ReadEClip(br)); EClips[x].ID = x; } int NumWallAnims = br.ReadInt32(); for (int x = 0; x < NumWallAnims; x++) { WClips.Add(bm.ReadWClip(br)); } int NumRobots = br.ReadInt32(); for (int x = 0; x < NumRobots; x++) { Robots.Add(bm.ReadRobot(br)); Robots[x].ID = x; } int NumLoadJoints = br.ReadInt32(); for (int x = 0; x < NumLoadJoints; x++) { JointPos joint = new JointPos(); joint.JointNum = br.ReadInt16(); joint.Angles.P = br.ReadInt16(); joint.Angles.B = br.ReadInt16(); joint.Angles.H = br.ReadInt16(); Joints.Add(joint); } int NumWeaponTypes = br.ReadInt32(); for (int x = 0; x < NumWeaponTypes; x++) { if (Version >= 3) { Weapons.Add(bm.ReadWeapon(br)); } else { Weapons.Add(bm.ReadWeaponInfoVersion2(br)); } Weapons[x].ID = x; } int NumPowerups = br.ReadInt32(); for (int x = 0; x < NumPowerups; x++) { Powerup powerup = new Powerup(); powerup.VClipNum = br.ReadInt32(); powerup.HitSound = br.ReadInt32(); powerup.Size = new Fix(br.ReadInt32()); powerup.Light = new Fix(br.ReadInt32()); powerup.ID = x; Powerups.Add(powerup); } int NumPolygonModels = br.ReadInt32(); for (int x = 0; x < NumPolygonModels; x++) { Models.Add(bm.ReadPolymodelInfo(br)); Models[x].ID = x; } for (int x = 0; x < NumPolygonModels; x++) { Models[x].InterpreterData = br.ReadBytes(Models[x].ModelIDTASize); //PolymodelData.Add(modeldata); } for (int x = 0; x < NumPolygonModels; x++) { Models[x].DyingModelnum = br.ReadInt32(); } for (int x = 0; x < NumPolygonModels; x++) { Models[x].DeadModelnum = br.ReadInt32(); } int gagueCount = br.ReadInt32(); for (int x = 0; x < gagueCount; x++) { Gauges.Add(br.ReadUInt16()); } for (int x = 0; x < gagueCount; x++) { GaugesHires.Add(br.ReadUInt16()); } int bitmapCount = br.ReadInt32(); for (int x = 0; x < bitmapCount; x++) { ObjBitmaps.Add(br.ReadUInt16()); } ushort value; for (int x = 0; x < bitmapCount; x++) { value = br.ReadUInt16(); if ((value + 1) > NumObjBitmaps) { NumObjBitmaps = (value + 1); } ObjBitmapPointers.Add(value); } PlayerShip = new Ship(); PlayerShip.ModelNum = br.ReadInt32(); PlayerShip.DeathVClipNum = br.ReadInt32(); PlayerShip.Mass = new Fix(br.ReadInt32()); PlayerShip.Drag = new Fix(br.ReadInt32()); PlayerShip.MaxThrust = new Fix(br.ReadInt32()); PlayerShip.ReverseThrust = new Fix(br.ReadInt32()); PlayerShip.Brakes = new Fix(br.ReadInt32()); PlayerShip.Wiggle = new Fix(br.ReadInt32()); PlayerShip.MaxRotationThrust = new Fix(br.ReadInt32()); for (int x = 0; x < 8; x++) { PlayerShip.GunPoints[x] = FixVector.FromRawValues(br.ReadInt32(), br.ReadInt32(), br.ReadInt32()); } int NumCockpits = br.ReadInt32(); for (int x = 0; x < NumCockpits; x++) { Cockpits.Add(br.ReadUInt16()); } //Build a table of all multiplayer bitmaps, to inject into the object bitmap table FirstMultiBitmapNum = br.ReadInt32(); int NumReactors = br.ReadInt32(); for (int x = 0; x < NumReactors; x++) { Reactor reactor = new Reactor(); reactor.ModelNum = br.ReadInt32(); reactor.NumGuns = br.ReadInt32(); for (int y = 0; y < 8; y++) { reactor.GunPoints[y] = FixVector.FromRawValues(br.ReadInt32(), br.ReadInt32(), br.ReadInt32()); } for (int y = 0; y < 8; y++) { reactor.GunDirs[y] = FixVector.FromRawValues(br.ReadInt32(), br.ReadInt32(), br.ReadInt32()); } Reactors.Add(reactor); } PlayerShip.MarkerModel = br.ReadInt32(); //2620 if (Version < 3) { ExitModelnum = br.ReadInt32(); DestroyedExitModelnum = br.ReadInt32(); } for (int x = 0; x < 2620; x++) { try { BitmapXLATData[x] = br.ReadUInt16(); } catch (EndOfStreamException) //Descent 2's official HAM files have only 2600 XLAT entries, but later versions of the game attempt to read 2620. { break; } } if (Version < 3) { br.BaseStream.Seek(sndptr, SeekOrigin.Begin); int dataToRead = (int)(br.BaseStream.Length - br.BaseStream.Position); sounddata = br.ReadBytes(dataToRead); } hasRead = true; //br.Dispose(); }
//Chiranjit [2011 07 09] //Create Bridge Input Data by user's given values. //Long Girder Spacing, Cross Girder Spacing, Cantilever Width public void CreateData() { //double x_incr = (Length / (Total_Columns - 1)); //double z_incr = (WidthBridge / (Total_Rows - 1)); double x_incr = Spacing_Cross_Girder; double z_incr = Spacing_Long_Girder; JointNode nd; //Joints_Array = new JointNode[Total_Rows, Total_Columns]; //Long_Girder_Members_Array = new Member[Total_Rows, Total_Columns - 1]; //Cross_Girder_Members_Array = new Member[Total_Rows - 1, Total_Columns]; int iCols = 0; int iRows = 0; Joints.Clear(); double skew_length = Math.Tan((Skew_Angle * (Math.PI / 180.0))); double val1 = 12.1; double val2 = val1 * skew_length; double last_x = 0.0; double last_z = 0.0; List <double> list_x = new List <double>(); List <double> list_z = new List <double>(); Hashtable z_table = new Hashtable(); //Store Joint Coordinates double L_2, L_4, eff_d; double x_max, x_min; //int _Columns, _Rows; //_Columns = Total_Columns; //_Rows = Total_Rows; last_x = 0.0; //Creating X Coordinates at every Z level list_x.Clear(); list_x.Add(0.0); list_x.Add(Effective_Depth); list_x.Add(Length - Effective_Depth); list_x.Add(Length / 4.0); list_x.Add(Length / 2.0); list_x.Add(Length); last_x = x_incr; do { if (!list_x.Contains(last_x) && last_x > Effective_Depth && last_x < (Length - Effective_Depth)) { list_x.Add(last_x); } last_x += x_incr; }while (last_x <= Length); list_x.Sort(); list_z.Clear(); list_z.Add(0); list_z.Add(WidthCantilever); list_z.Add(WidthCantilever / 2); list_z.Add(WidthBridge - WidthCantilever); list_z.Add(WidthBridge - WidthCantilever / 2); list_z.Add(WidthBridge); last_z = WidthCantilever + z_incr; do { if (!list_z.Contains(last_z) && last_z > WidthCantilever && last_z < (WidthBridge - WidthCantilever - 0.2)) { list_z.Add(last_z); } last_z += z_incr; } while (last_z <= WidthBridge); list_z.Sort(); _Columns = list_x.Count; _Rows = list_z.Count; int i = 0; List <double> list = new List <double>(); for (iRows = 0; iRows < _Rows; iRows++) { list = new List <double>(); for (iCols = 0; iCols < _Columns; iCols++) { list.Add(list_x[iCols] + list_z[iRows] * skew_length); } z_table.Add(list_z[iRows], list); } //Chiranjit [2011 07 11] //Calculate L/2, L/4, Deff for Skew Angle //for(i = 0; i < list_z.Count; i++) //{ // list_x = z_table[list_z[i]] as List<double>; // if (list_x != null) // { // list_x.Sort(); // //x_max = list_x[list_x.Count - 1] + (skew_length * list_z[i]); // //x_min = list_x[0] + (skew_length * list_z[i]); // x_max = list_x[list_x.Count - 1]; // x_min = list_x[0]; // if (i == 0) // { // span_length = (x_max - x_min); // //Length = span_length; // } // L_2 = (x_max + x_min) / 2.0; // L_4 = (L_2 + x_min) / 2.0; // eff_d = (Effective_Depth + x_min); // if (list_x.Contains(eff_d) == false) // list_x.Add(eff_d); // if (list_x.Contains(L_2) == false) // list_x.Add(L_2); // if (list_x.Contains(L_4) == false) // list_x.Add(L_4); // L_2 = (x_max + x_min) / 2.0; // L_4 = x_max - L_4; // eff_d = x_max - eff_d; // if (list_x.Contains(eff_d) == false) // list_x.Add(eff_d); // if (list_x.Contains(L_2) == false) // list_x.Add(L_2); // if (list_x.Contains(L_4) == false) // list_x.Add(L_4); // list_x.Sort(); // //_Columns = list_x.Count; // //_Rows = list_z.Count; // z_table[list_z[i]] = list_x; // } //} Joints_Array = new JointNode[_Rows, _Columns]; Long_Girder_Members_Array = new Member[_Rows, _Columns - 1]; Cross_Girder_Members_Array = new Member[_Rows - 1, _Columns]; for (iRows = 0; iRows < _Rows; iRows++) { list_x = z_table[list_z[iRows]] as List <double>; for (iCols = 0; iCols < _Columns; iCols++) { nd = new JointNode(); nd.Y = 0; nd.Z = list_z[iRows]; //nd.X = list_x[iCols] + (skew_length * list_z[iRows]); nd.X = list_x[iCols]; nd.NodeNo = Joints.JointNodes.Count + 1; Joints.Add(nd); Joints_Array[iRows, iCols] = nd; last_x = nd.X; } } int nodeNo = 0; Joints.Clear(); for (iCols = 0; iCols < _Columns; iCols++) { for (iRows = 0; iRows < _Rows; iRows++) { nodeNo++; Joints_Array[iRows, iCols].NodeNo = nodeNo; Joints.Add(Joints_Array[iRows, iCols]); } } Member mem = new Member(); MemColls.Clear(); for (iCols = 0; iCols < _Columns; iCols++) { for (iRows = 1; iRows < _Rows; iRows++) { mem = new Member(); mem.StartNode = Joints_Array[iRows - 1, iCols]; mem.EndNode = Joints_Array[iRows, iCols]; mem.MemberNo = MemColls.Count + 1; MemColls.Add(mem); Cross_Girder_Members_Array[iRows - 1, iCols] = mem; } } for (iRows = 0; iRows < _Rows; iRows++) { for (iCols = 1; iCols < _Columns; iCols++) { mem = new Member(); mem.StartNode = Joints_Array[iRows, iCols - 1]; mem.EndNode = Joints_Array[iRows, iCols]; mem.MemberNo = MemColls.Count + 1; MemColls.Add(mem); Long_Girder_Members_Array[iRows, iCols - 1] = mem; } } }
public void Read(Stream stream) { BinaryReader br; br = new BinaryReader(stream); HAMDataReader bm = new HAMDataReader(); uint sig = br.ReadUInt32(); if (sig != Util.MakeSig('M', 'A', 'H', 'X')) { br.Dispose(); throw new InvalidDataException("VHAMFile::Read: V-HAM file has bad header."); } int version = br.ReadInt32(); if (version != 1) { br.Dispose(); throw new InvalidDataException(string.Format("VHAMFile::Read: V-HAM file has bad version. Got {0}, but expected 1.", version)); } int numWeapons = br.ReadInt32(); for (int i = 0; i < numWeapons; i++) { Weapons.Add(bm.ReadWeapon(br)); Weapons[i].ID = i + NumDescent2WeaponTypes; } int numRobots = br.ReadInt32(); for (int i = 0; i < numRobots; i++) { Robots.Add(bm.ReadRobot(br)); Robots[i].ID = i + NumDescent2RobotTypes; } int numJoints = br.ReadInt32(); for (int i = 0; i < numJoints; i++) { JointPos joint = new JointPos(); joint.JointNum = br.ReadInt16(); joint.Angles.P = br.ReadInt16(); joint.Angles.B = br.ReadInt16(); joint.Angles.H = br.ReadInt16(); Joints.Add(joint); } int numModels = br.ReadInt32(); for (int i = 0; i < numModels; i++) { Models.Add(bm.ReadPolymodelInfo(br)); Models[i].ID = i + NumDescent2Polymodels; } for (int x = 0; x < numModels; x++) { Models[x].InterpreterData = br.ReadBytes(Models[x].ModelIDTASize); } for (int i = 0; i < numModels; i++) { Models[i].DyingModelnum = br.ReadInt32(); } for (int i = 0; i < numModels; i++) { Models[i].DeadModelnum = br.ReadInt32(); } int numObjBitmaps = br.ReadInt32(); for (int i = 0; i < numObjBitmaps; i++) { ObjBitmaps.Add(br.ReadUInt16()); } int numObjBitmapPointers = br.ReadInt32(); for (int i = 0; i < numObjBitmapPointers; i++) { ObjBitmapPointers.Add(br.ReadUInt16()); } br.Dispose(); }
internal override bool ParseNodeBodyElement(string id, VRMLParser parser) { int line = parser.Line; if (id == "center") { Center = parser.ParseSFVec3fValue(); } else if (id == "info") { Info.AddRange(parser.ParseSFStringOrMFStringValue()); } else if (id == "joints") { List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue(); foreach (X3DNode node in nodes) { IX3DHAnimJointNode joint = node as IX3DHAnimJointNode; if (joint == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } else { Joints.Add(joint); } } } else if (id == "name") { Name = parser.ParseStringValue(); } else if (id == "rotation") { Rotation = parser.ParseSFRotationValue(); } else if (id == "scale") { Scale = parser.ParseSFVec3fValue(); } else if (id == "scaleOrientation") { ScaleOrientation = parser.ParseSFRotationValue(); } else if (id == "segments") { List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue(); foreach (X3DNode node in nodes) { IX3DHAnimeSegmentNode segment = node as IX3DHAnimeSegmentNode; if (segment == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } else { Segments.Add(segment); } } } else if (id == "sites") { List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue(); foreach (X3DNode node in nodes) { IX3DHAnimSiteNode site = node as IX3DHAnimSiteNode; if (site == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } else { Sites.Add(site); } } } else if (id == "skeleton") { List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue(); foreach (X3DNode node in nodes) { IX3DHAnimHumanoidSkeleton skeleton = node as IX3DHAnimHumanoidSkeleton; if (skeleton == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } else { Skeleton.Add(skeleton); } } } else if (id == "skin") { List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue(); foreach (X3DNode node in nodes) { X3DChildNode skin = node as X3DChildNode; if (skin == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } else { Skin.Add(skin); } } } else if (id == "skinCoord") { X3DNode node = parser.ParseSFNodeValue(); if (node != null) { SkinCoord = node as X3DCoordinateNode; if (SkinCoord == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } } } else if (id == "skinNormal") { X3DNode node = parser.ParseSFNodeValue(); if (node != null) { SkinNormal = node as X3DNormalNode; if (SkinNormal == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } } } else if (id == "translation") { Translation = parser.ParseSFVec3fValue(); } else if (id == "version") { Version = parser.ParseStringValue(); } else if (id == "viewpoints") { List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue(); foreach (X3DNode node in nodes) { X3DViewpointNode vp = node as X3DViewpointNode; // x3d-Spec specs. x3dHAnimSite change to interface if neccessary if (vp == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } else { Viewpoints.Add(vp); } } } else if (id == "bboxCenter") { BBoxCenter = parser.ParseSFVec3fValue(); } else if (id == "bboxSize") { BBoxSize = parser.ParseSFVec3fValue(); } else { return(false); } return(true); }
internal override bool ParseNodeBodyElement(string id, VRMLParser parser) { int line = parser.Line; if (id == "autoDisable") { AutoDisable = parser.ParseBoolValue(); } else if (id == "bodies") { List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue(); foreach (X3DNode node in nodes) { IX3DRigidBodyNode rb = node as IX3DRigidBodyNode; if (rb == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } else { Bodies.Add(rb); } } } else if (id == "constantForceMix") { ConstantForceMix = parser.ParseDoubleValue(); } else if (id == "contactSurfaceThickness") { ContactSurfaceThickness = parser.ParseDoubleValue(); } else if (id == "disableAngularSpeed") { DisableAngularSpeed = parser.ParseDoubleValue(); } else if (id == "disableLinearSpeed") { DisableLinearSpeed = parser.ParseDoubleValue(); } else if (id == "disableTime") { DisableTime = parser.ParseDoubleValue(); } else if (id == "enabled") { Enabled = parser.ParseBoolValue(); } else if (id == "errorCorrection") { ErrorCorrection = parser.ParseDoubleValue(); } else if (id == "gravity") { Gravity = parser.ParseSFVec3fValue(); } else if (id == "iterations") { Iterations = parser.ParseIntValue(); } else if (id == "joints") { List <X3DNode> nodes = parser.ParseSFNodeOrMFNodeValue(); foreach (X3DNode node in nodes) { X3DRigidJointNode rj = node as X3DRigidJointNode; if (rj == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } else { Joints.Add(rj); } } } else if (id == "maxCorrectionSpeed") { MaxCorrectionSpeed = parser.ParseDoubleValue(); } else if (id == "preferAccuracy") { PreferAccuracy = parser.ParseBoolValue(); } else if (id == "collider") { X3DNode node = parser.ParseSFNodeValue(); if (node != null) { Collider = node as IX3DCollisionCollectionNode; if (Collider == null) { parser.ErrorParsingNode(VRMLReaderError.UnexpectedNodeType, this, id, node, line); } } } else { return(false); } return(true); }