Beispiel #1
0
        public override void Execute(ScriptState state)
        {
            state.Log.Status($"Creating object {Name}");
            var extant = state.Data.SectionsOfType <S.Object3D>()
                         .Where(i => i.Name == Name)
                         .FirstOrDefault();

            if (extant != null)
            {
                throw new Exception($"Cannot create object {Name}: Already exists.");
            }

            S.Object3D parent = null;
            if (Parent != null)
            {
                parent = state.Data.SectionsOfType <S.Object3D>()
                         .Where(i => i.Name == Parent)
                         .FirstOrDefault();
                if (parent == null)
                {
                    throw new Exception($"Cannot find Object3D named \"{Parent}\" to use as a parent for {Name}");
                }
            }

            var obj = new S.Object3D(Name, parent);
            var tf  = Matrix4x4.CreateScale(Scale) * Matrix4x4.CreateFromQuaternion(Rotation);

            tf.Translation = Position;
            obj.Transform  = tf;
            state.Data.AddSection(obj);
        }
        public override void PostLoad(uint id, Dictionary <uint, ISection> parsed_sections)
        {
            base.PostLoad(id, parsed_sections);
            SkinPositions = new List <Matrix4x4>(count);

            for (int i = 0; i < objects.Count; i++)
            {
                Object3D obj = (Object3D)parsed_sections[objects[i]];
                Objects.Add(obj);

                Matrix4x4 inter     = rotations[i].MultDiesel(obj.WorldTransform);
                Matrix4x4 skin_node = inter.MultDiesel(global_skin_transform);

                SkinPositions.Add(skin_node);
            }
            objects = null;
        }
Beispiel #3
0
 public Model(obj_data obj, PassthroughGP passGP, TopologyIP topoIP, MaterialGroup matg, Object3D parent)
     : this(obj.object_name, (uint)obj.verts.Count, (uint)obj.faces.Count, passGP, topoIP, matg, parent)
 {
 }
Beispiel #4
0
        public Model(string object_name, float v6_unknown7, System.Numerics.Vector3 bounds_min, System.Numerics.Vector3 bounds_max, Object3D parent)
            : base(object_name, parent)
        {
            this.size = 0;
            // TODO: Get rid of all referring to things by section ID outside of read/write of model files so we don't have to do this.
            SectionId = (uint)object_name.GetHashCode();

            this.version     = 6;
            this.BoundsMin   = bounds_min;
            this.BoundsMax   = bounds_max;
            this.v6_unknown7 = v6_unknown7;
            this.v6_unknown8 = 0;
        }
Beispiel #5
0
        public Model(string object_name, uint triangleCount, uint vertexCount, PassthroughGP passGP, TopologyIP topoIP, MaterialGroup matg, Object3D parent)
            : base(object_name, parent)
        {
            this.size = 0;
            // TODO: Get rid of all referring to things by section ID outside of read/write of model files so we don't have to do this.
            SectionId = (uint)object_name.GetHashCode();

            this.version       = 3;
            this.PassthroughGP = passGP;
            this.TopologyIP    = topoIP;
            this.RenderAtoms   = new List <RenderAtom>();
            RenderAtom nmi = new RenderAtom
            {
                BaseVertex          = 0,
                TriangleCount       = triangleCount,
                BaseIndex           = 0,
                GeometrySliceLength = vertexCount,
                MaterialId          = 0
            };

            this.RenderAtoms.Add(nmi);

            //this.unknown9 = 0;
            this.MaterialGroup     = matg;
            this.lightset_ID       = 0;
            this.properties_bitmap = 0;
            this.BoundingRadius    = 1;
            this.unknown13         = 6;
            this.SkinBones         = null;
        }
Beispiel #6
0
 public Camera(string name, Object3D parent) : base(name, parent)
 {
 }
Beispiel #7
0
        }                                    // BitConverter.ToSingle(byte[4] { 4, 0, 0, 0 }, 0) in all known lights

        public Light(string name, Object3D parent) : base(name, parent)
        {
        }