本文整理匯總了C#中System.IO.BinaryReader.ReadQuaternion方法的典型用法代碼示例。如果您正苦於以下問題:C# BinaryReader.ReadQuaternion方法的具體用法?C# BinaryReader.ReadQuaternion怎麽用?C# BinaryReader.ReadQuaternion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.IO.BinaryReader
的用法示例。
在下文中一共展示了BinaryReader.ReadQuaternion方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: reaParser
public reaParser(Stream stream)
{
try
{
using (BinaryReader reader = new BinaryReader(stream))
{
byte[] type = reader.ReadBytes(4);
Trace.Assert(remParser.TypeCheck(reaANICsection.ClassType, type));
int anicLength = reader.ReadInt32();
int unk1 = reader.ReadInt32();
float unk2 = reader.ReadSingle();
int count = reader.ReadInt32();
ANIC = new reaANICsection(count);
ANIC.unk1 = unk1;
ANIC.unk2 = unk2;
for (int i = 0; i < count; i++)
{
reaAnimationTrack track = new reaAnimationTrack();
type = reader.ReadBytes(4);
Trace.Assert(remParser.TypeCheck(reaAnimationTrack.ClassType, type));
int anioLength = reader.ReadInt32();
byte[] name = reader.ReadBytes(256);
track.boneFrame = remParser.GetIdentifier(name, 0, 256);
int numScalings = reader.ReadInt32();
track.scalings = new reaIndexVector[numScalings];
int numRotations = reader.ReadInt32();
track.rotations = new reaIndexQuaternion[numRotations];
int numTranslations = reader.ReadInt32();
track.translations = new reaIndexVector[numTranslations];
for (int j = 0; j < numScalings; j++)
{
reaIndexVector ivec = new reaIndexVector();
ivec.index = reader.ReadInt32();
ivec.value = reader.ReadVector3();
track.scalings[j] = ivec;
}
for (int j = 0; j < numRotations; j++)
{
reaIndexQuaternion iq = new reaIndexQuaternion();
iq.index = reader.ReadInt32();
iq.value = reader.ReadQuaternion();
track.rotations[j] = iq;
}
for (int j = 0; j < numTranslations; j++)
{
reaIndexVector ivec = new reaIndexVector();
ivec.index = reader.ReadInt32();
ivec.value = reader.ReadVector3();
track.translations[j] = ivec;
}
ANIC.AddChild(track);
}
}
}
catch (FileNotFoundException)
{
Report.ReportLog("file not found");
}
}
示例2: Load
/// <summary>
/// Loads the file from the specified stream.
/// </summary>
/// <param name="stream">The stream to read from.</param>
public override void Load(Stream stream)
{
BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));
Name = reader.ReadIntString();
SoundEnabled = reader.ReadInt32() != 0;
SoundFilePath = reader.ReadIntString();
LoopCount = reader.ReadInt32();
int particleCount = reader.ReadInt32();
for (int i = 0; i < particleCount; i++) {
EffectParticle particle = new EffectParticle();
particle.Name = reader.ReadIntString();
particle.UniqueIdentifier = reader.ReadIntString();
particle.ParticleIndex = reader.ReadInt32();
particle.FilePath = reader.ReadIntString();
particle.AnimationEnabled = reader.ReadInt32() != 0;
particle.AnimationName = reader.ReadIntString();
particle.AnimationLoopCount = reader.ReadInt32();
particle.AnimationIndex = reader.ReadInt32();
particle.Position = reader.ReadVector3();
particle.Rotation = reader.ReadQuaternion();
particle.Delay = reader.ReadInt32();
particle.LinkedToRoot = reader.ReadInt32() != 0;
Particles.Add(particle);
}
int animationCount = reader.ReadInt32();
for (int i = 0; i < animationCount; i++) {
EffectAnimation animation = new EffectAnimation();
animation.EffectName = reader.ReadIntString();
animation.MeshName = reader.ReadIntString();
animation.MeshIndex = reader.ReadInt32();
animation.MeshFilePath = reader.ReadIntString();
animation.AnimationFilePath = reader.ReadIntString();
animation.TextureFilePath = reader.ReadIntString();
animation.AlphaEnabled = reader.ReadInt32() != 0;
animation.TwoSidedEnabled = reader.ReadInt32() != 0;
animation.AlphaTestEnabled = reader.ReadInt32() != 0;
animation.DepthTestEnabled = reader.ReadInt32() != 0;
animation.DepthWriteEnabled = reader.ReadInt32() != 0;
animation.SourceBlend = reader.ReadInt32();
animation.DestinationBlend = reader.ReadInt32();
animation.BlendOperation = reader.ReadInt32();
animation.AnimationEnabled = reader.ReadInt32() != 0;
animation.AnimationName = reader.ReadIntString();
animation.AnimationLoopCount = reader.ReadInt32();
animation.AnimationIndex = reader.ReadInt32();
animation.Position = reader.ReadVector3();
animation.Rotation = reader.ReadQuaternion();
animation.Delay = reader.ReadInt32();
animation.LoopCount = reader.ReadInt32();
animation.LinkedToRoot = reader.ReadInt32() != 0;
Animations.Add(animation);
}
}
示例3: ReadMODD
static void ReadMODD(BinaryReader br, WMORoot wmo, uint size)
{
// Why oh why is wmo.Header.DoodadCount wrong sometimes
// 40 is the size of DoodadDefinition
wmo.DoodadDefinitions = new DoodadDefinition[size / 40];
for (var i = 0; i < wmo.DoodadDefinitions.Length; i++)
{
var dd = new DoodadDefinition
{
NameIndex = br.ReadInt32(),
Position = br.ReadVector3(),
Rotation = br.ReadQuaternion(),
Scale = br.ReadSingle(),
Color = br.ReadColor4()
};
if (dd.NameIndex != -1)
{
if(!wmo.DoodadFiles.TryGetValue(dd.NameIndex, out dd.FilePath))
{
dd.FilePath = "";
log.Error(String.Format("Doodad File Path for index: {0} missing from the Dictionary!", dd.NameIndex));
}
}
wmo.DoodadDefinitions[i] = dd;
}
}
示例4: ReadMODD
static void ReadMODD(BinaryReader br, WMORoot wmo, uint size)
{
// Why oh why is wmo.Header.DoodadCount wrong sometimes
// 40 is the size of DoodadDefinition
wmo.DoodadDefinitions = new DoodadDefinition[size / 40];
for (var i = 0; i < wmo.DoodadDefinitions.Length; i++)
{
var dd = new DoodadDefinition
{
NameIndex = br.ReadInt32(),
Position = br.ReadWMOVector3(),
Rotation = br.ReadQuaternion(),
Scale = br.ReadSingle(),
Color = br.ReadColor4()
};
if (dd.NameIndex != -1)
{
dd.FilePath = wmo.DoodadFiles[dd.NameIndex];
}
wmo.DoodadDefinitions[i] = dd;
}
}
示例5: Read
/// <summary>
/// Reads the block data from the underlying stream.
/// </summary>
/// <param name="reader">The reader.</param>
public virtual void Read(BinaryReader reader)
{
Name = reader.ReadByteString();
WarpID = reader.ReadInt16();
EventID = reader.ReadInt16();
ObjectType = reader.ReadInt32();
ObjectID = reader.ReadInt32();
MapPosition = new IntVector2(reader.ReadInt32(), reader.ReadInt32());
Rotation = reader.ReadQuaternion();
Position = reader.ReadVector3();
Scale = reader.ReadVector3();
}
示例6: Load
public void Load(Stream fs, bool leaveOpen)
{
// Reset whole world
foreach (var block in blocks.ToArray())
{
this[block.X, block.Y, block.Z] = null;
}
Action<bool> assert = (b) => { if (!b) throw new InvalidDataException(); };
using (var br = new BinaryReader(fs, Encoding.UTF8, leaveOpen))
{
assert(br.ReadString() == "BLOCKWORLD");
int major = br.ReadByte();
int minor = br.ReadByte();
assert(major == 1);
int typeCount = br.ReadInt32();
Type[] types = new Type[typeCount];
for (int i = 0; i < typeCount; i++)
{
string typeName = br.ReadString();
types[i] = Type.GetType(typeName);
if (types[i] == null)
throw new TypeLoadException("Could not find type " + typeName);
}
long blockCount = br.ReadInt64();
for (long i = 0; i < blockCount; i++)
{
int x = br.ReadInt32();
int y = br.ReadInt32();
int z = br.ReadInt32();
Type type = types[br.ReadInt32()];
var block = Activator.CreateInstance(type) as Block;
block.Deserialize(br);
this[x, y, z] = block;
}
// Details are stored here as well
if(minor == 1)
{
int detailCount = br.ReadInt32();
for (int i = 0; i < detailCount; i++)
{
int id = br.ReadInt32();
string model = br.ReadString();
int parentID = br.ReadInt32();
var position = br.ReadVector3();
var rotation = br.ReadQuaternion();
Shape shape = null;
bool hasShape = br.ReadBoolean();
if (hasShape)
{
var size = br.ReadVector3();
shape = new BoxShape(size.Jitter());
}
DetailObject detail = new DetailObject(this.GetDetail(parentID), id, shape);
if (string.IsNullOrWhiteSpace(model) == false)
detail.Model = model;
detail.Position = position;
detail.Rotation = rotation;
this.RegisterDetail(detail);
int behaviourCount = br.ReadInt32();
for (int j = 0; j < behaviourCount; j++)
{
var typeName = br.ReadString();
var type = Type.GetType(typeName, true);
int behaviourID = br.ReadInt32();
bool isEnabled = br.ReadBoolean();
var behaviour = (Behaviour)Activator.CreateInstance(type);
detail.CreateBehaviour(behaviour, behaviourID, isEnabled);
}
}
int signalCount = br.ReadInt32();
for (int j = 0; j < signalCount; j++)
{
var signalDetailID = br.ReadInt32();
var signalBehaviourID = br.ReadInt32();
var signalName = br.ReadString();
var signal = this.GetDetail(signalDetailID).Behaviours[signalBehaviourID].Signals[signalName];
var slotCount = br.ReadInt32();
for (int k = 0; k < slotCount; k++)
{
//.........這裏部分代碼省略.........
示例7: StructureBspMarkerBlock
public StructureBspMarkerBlock(BinaryReader binaryReader)
{
this.name = binaryReader.ReadString32();
this.rotation = binaryReader.ReadQuaternion();
this.position = binaryReader.ReadVector3();
}
示例8: ReadFrame
/// <summary>
/// Reads a channel frame from the underlying stream.
/// </summary>
/// <param name="reader">The reader.</param>
/// <param name="frame">The frame to read.</param>
public override void ReadFrame(BinaryReader reader, int frame)
{
frames[frame] = reader.ReadQuaternion();
}
示例9: RenderModelNodeBlock
public RenderModelNodeBlock(BinaryReader binaryReader)
{
this.name = binaryReader.ReadStringID();
this.parentNode = binaryReader.ReadShortBlockIndex1();
this.firstChildNode = binaryReader.ReadShortBlockIndex1();
this.nextSiblingNode = binaryReader.ReadShortBlockIndex1();
this.importNodeIndex = binaryReader.ReadInt16();
this.defaultTranslation = binaryReader.ReadVector3();
this.defaultRotation = binaryReader.ReadQuaternion();
this.inverseForward = binaryReader.ReadVector3();
this.inverseLeft = binaryReader.ReadVector3();
this.inverseUp = binaryReader.ReadVector3();
this.inversePosition = binaryReader.ReadVector3();
this.inverseScale = binaryReader.ReadSingle();
this.distanceFromParent = binaryReader.ReadSingle();
}
示例10: CreateDetail
private void CreateDetail(BinaryReader reader)
{
int id = reader.ReadInt32();
int parentID = reader.ReadInt32();
string model = reader.ReadString();
var pos = reader.ReadVector3();
var rot = reader.ReadQuaternion();
Shape shape = null;
bool hasShape = reader.ReadBoolean();
if (hasShape == true)
{
var shapeSize = reader.ReadVector3();
shape = DetailHelper.CreateShape(shapeSize);
}
var parent = this.world.GetDetail(parentID);
DetailObject obj = new DetailObject(parent, id, shape);
obj.Position = pos;
obj.Rotation = rot;
obj.Model = model.Length > 0 ? model : null;
this.world.RegisterDetail(obj);
}
示例11: UpdateDetail
private void UpdateDetail(BinaryReader reader)
{
int id = reader.ReadInt32();
var pos = reader.ReadVector3();
var rot = reader.ReadQuaternion();
DetailObject obj = this.world.GetDetail(id);
if (obj == null)
return;
obj.Position = pos;
obj.Rotation = rot;
}
示例12: HeiDeserialize
GameObject HeiDeserialize(Transform parent, ref BinaryReader reader)
{
var id = reader.ReadInt32();
var name = reader.ReadString();
var gobj = new GameObject(name);
var trans = gobj.transform;
ReferenceMap[id] = trans;
trans.parent = parent;
trans.localPosition = reader.ReadVector3();
trans.localRotation = reader.ReadQuaternion();
trans.localScale = reader.ReadVector3();
var childCount = reader.ReadInt32();
//recurse to children
for (int i = 0; i < childCount; i++)
{
HeiDeserialize(trans, ref reader);
}
return gobj;
}
示例13: ReadMODD
static void ReadMODD(BinaryReader br, WMORoot wmo, uint size)
{
// Why oh why is wmo.Header.DoodadCount wrong sometimes
uint count = size / 40; // 40 is the size of DoodadDefinition
wmo.DoodadDefinitions = new DoodadDefinition[count];
for (int i = 0; i < wmo.DoodadDefinitions.Length; i++)
{
var dd = new DoodadDefinition
{
NameIndex = br.ReadInt32(),
Position = br.ReadVector3(),
Rotation = br.ReadQuaternion(),
Scale = br.ReadSingle(),
Color = br.ReadUInt32()
};
if (dd.NameIndex != -1)
{
if (!wmo.DoodadFiles.TryGetValue(dd.NameIndex, out dd.FilePath))
{
Console.WriteLine("Erroneous dd.NameIndex in WmoRoot: {0}", wmo.FilePath);
}
}
wmo.DoodadDefinitions[i] = dd;
}
}
示例14: StructureBspEnvironmentObjectBlock
public StructureBspEnvironmentObjectBlock(BinaryReader binaryReader)
{
this.name = binaryReader.ReadString32();
this.rotation = binaryReader.ReadQuaternion();
this.translation = binaryReader.ReadVector3();
this.paletteIndex = binaryReader.ReadShortBlockIndex1();
this.padding = binaryReader.ReadBytes(2);
this.uniqueID = binaryReader.ReadInt32();
this.exportedObjectType = binaryReader.ReadTagClass();
this.scenarioObjectName = binaryReader.ReadString32();
}
示例15: ReadLights
public static MapLights ReadLights(string path)
{
/*string assetPath = path.Replace(".ded", ".asset");*/
GameObject subGO = Scene.BeginEditingPrefab(path, "Lights");
try
{
MapLights lights = subGO.AddComponent<MapLights>();
BinaryReader reader = new BinaryReader(new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read));
reader.SkipInt16(); //Usually the area's code
reader.SkipInt16(); //Usually 1, saw a 20
short globalLightsCount = reader.ReadInt16();
reader.SkipInt16(0);
short globalLightsOffset = reader.ReadInt16();
reader.SkipInt16(0);
reader.SkipBytes(8, 0);
short weirdLightsCount = reader.ReadInt16();
reader.SkipInt16(0);
short weirdLightsOffset = reader.ReadInt16();
reader.SkipInt16(0);
reader.SkipBytes(8, 0);
short lightsCount = reader.ReadInt16();
reader.SkipInt16(0);
short lightsOffset = reader.ReadInt16();
reader.SkipInt16(0);
reader.SkipBytes(40, 0);
short ambientOffset = reader.ReadInt16();
reader.SkipBytes(24, 0);
Matrix4x4 transMat = lights.GetComponentInParent<Scene>().GetSH3ToUnityMatrix();
reader.BaseStream.Position = globalLightsOffset;
for (int i = 0; i != globalLightsCount; i++)
{
GlobalLight gl = new GlobalLight();
gl.rotation = reader.ReadQuaternion();
gl.Unknown1 = reader.ReadVector3();
reader.SkipInt16(0);
gl.Unknown2 = reader.ReadInt16();
lights.globalLights.Add(gl);
}
reader.BaseStream.Position = weirdLightsOffset;
for (int i = 0; i != weirdLightsCount; i++)
{
LocalLight ll = new LocalLight();
ll.color = reader.ReadColor();
ll.Unknown1 = reader.ReadSingle();
ll.Range = reader.ReadSingle();
reader.SkipBytes(8, 0);
ll.position = reader.ReadVector3YInverted();
reader.SkipInt16(0x0);
ll.Unknown2 = reader.ReadInt16();
lights.weirdLights.Add(ll);
}
reader.BaseStream.Position = lightsOffset;
for (int i = 0; i != lightsCount; i++)
{
LocalLight ll = new LocalLight();
ll.color = reader.ReadColor();
ll.Unknown1 = reader.ReadSingle();
ll.Range = reader.ReadSingle();
reader.SkipBytes(8, 0);
ll.position = reader.ReadVector3YInverted();
reader.SkipInt16(0x0);
ll.Unknown2 = reader.ReadInt16();
lights.localLights.Add(ll);
GameObject lightGO = new GameObject("Light " + i);
lightGO.transform.SetParent(subGO.transform);
lightGO.transform.localPosition = transMat.MultiplyPoint(ll.position);
Light light = lightGO.AddComponent<Light>();
light.type = LightType.Point;
light.range = ll.Range * Scene.GLOBAL_SCALE;
light.color = ll.color;
light.intensity = 8.0f;
light.bounceIntensity = 1.0f;
}
reader.BaseStream.Position = ambientOffset;
lights.Unknown1 = reader.ReadVector4();
lights.Unknown2 = reader.ReadVector4();
lights.ambientColor = reader.ReadColor();
lights.Unknown3 = reader.ReadVector4();
reader.Close();
Scene.FinishEditingPrefab(path, subGO);
return lights;
}
catch (Exception e)
//.........這裏部分代碼省略.........