public string StaticShapeDataCreate(coSimDataBlock data)
     {
     Torque_Class_Helper tch = new Torque_Class_Helper("StaticShape");
     tch.Props.Add("dataBlock", data);
     coSimObject obj = tch.Create();
     return obj;
     }
 public string StaticShapeDataCreate(string data)
     {
     Torque_Class_Helper tch = new Torque_Class_Helper("StaticShape");
     tch.Props.Add("dataBlock", data);
     string obj = tch.Create(m_ts).AsString();
     return obj;
     }
        public void Initialize_AdvanceLight_LightViz4()
            {
            Torque_Class_Helper tch = new Torque_Class_Helper("ShaderData", "AL_ShadowVisualizeShader");
            tch.PropsAddString("DXVertexShaderFile", "shaders/common/guiMaterialV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/lighting/advanced/dbgShadowVisualizeP.hlsl");

            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/gl/guiMaterialV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/lighting/advanced/gl/dbgShadowVisualizeP.glsl");

            tch.Props.Add("pixVersion", "2.0");
            tch.Create();

            tch = new Torque_Class_Helper("CustomMaterial", "AL_ShadowVisualizeMaterial");
            tch.Props.Add("shader", "AL_ShadowVisualizeShader");
            tch.Props.Add("stateBlock", "AL_DepthVisualizeState");

            tch.PropsAddString(@"sampler[""shadowMap""]", "#AL_ShadowVizTexture");
            tch.PropsAddString(@"sampler[""depthViz""]", "depthviz");

            tch.Props.Add("pixVersion", "2.0");
            tch.Create();

            TorqueSingleton ts = new TorqueSingleton("GuiControlProfile", "AL_ShadowLabelTextProfile");
            ts.PropsAddString("fontColor", "0 0 0");
            ts.Props.Add("autoSizeWidth", "true");
            ts.Props.Add("autoSizeHeight", "true");
            ts.PropsAddString("justify", "left");
            ts.Props.Add("fontSize", "14");
            ts.Create();
            }
        public void initialize_scattersky()
            {
            Torque_Class_Helper tch = new Torque_Class_Helper("GFXStateBlockData", "ScatterSkySBData");
            tch.Props.Add("cullDefined", "true");
            tch.PropsAddString("cullMode", "GFXCullNone");
            tch.Props.Add("zDefined", "true");
            tch.Props.Add("zEnable", "true");
            tch.Props.Add("zWriteEnable", "false");
            tch.Props.Add("zFunc", "GFXCmpLessEqual");

            tch.Props.Add("samplersDefined", "true");
            tch.Props.Add("samplerStates[0]", "SamplerClampLinear");
            tch.Props.Add("samplerStates[1]", "SamplerClampLinear");
            tch.Props.Add("vertexColorEnable", "true");
            tch.Create();

            TorqueSingleton ts = new TorqueSingleton("ShaderData", "ScatterSkyShaderData");
            ts.PropsAddString("DXVertexShaderFile", "shaders/common/scatterSkyV.hlsl");
            ts.PropsAddString("DXPixelShaderFile", "shaders/common/scatterSkyP.hlsl");

            ts.PropsAddString("OGLVertexShaderFile", "shaders/common/gl/scatterSkyV.glsl");
            ts.PropsAddString("OGLPixelShaderFile", "shaders/common/gl/scatterSkyP.glsl");

            ts.Props.Add("pixVersion", "2.0");

            ts.Create();
            }
        public void initializeShadowMaps()
            {
            Torque_Class_Helper tch = new Torque_Class_Helper("ShaderData", "BlurDepthShader");
            tch.PropsAddString("DXVertexShaderFile", "shaders/common/lighting/shadowMap/boxFilterV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/lighting/shadowMap/boxFilterP.hlsl");

            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/lighting/shadowMap/gl/boxFilterV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/lighting/shadowMap/gl/boxFilterP.glsl");
            tch.Props.Add("pixVersion", "2.0");
            tch.Create();
            }
 public void DoManualDetonation(coSceneObject obj)
     {
     Torque_Class_Helper tch = new Torque_Class_Helper("Item", "");
     tch.Props.Add("dataBlock", "Detonade");
     coSceneObject nade = tch.Create();
     ((coSimSet)"MissionCleanUp").pushToBack(nade);
     nade.setTransform(obj.getTransform());
     nade["sourceObject"] = obj["SourceObject"];
     nade.schedule("50", "setDamageState", "Destroyed");
     obj.delete();
     }
 public void DoManualDetonation(string obj)
     {
     Torque_Class_Helper tch = new Torque_Class_Helper("Item", "");
     tch.Props.Add("dataBlock", "Detonade");
     string nade = tch.Create(m_ts).ToString(CultureInfo.InvariantCulture);
     SimSet.pushToBack("MissionCleanUp", nade);
     SceneObject.setTransform(nade, SceneObject.getTransform(obj));
     console.SetVar("sourceObject", console.GetVarString(string.Format("{0}.sourceObject", obj)));
     SimObject.schedule(nade, "50", "setDamageState", "Destroyed");
     console.deleteVariables(obj);
     }
        public string ProximityMineDataOnThrow(string datablock, string player, string amount)
            {
            ShapeBaseShapeBaseDecInventory(player, datablock, "1");

            Torque_Class_Helper tch = new Torque_Class_Helper("ProximityMine", "");
            tch.Props.Add("datablock", datablock);
            tch.Props.Add("sourceObject", player);
            tch.Props.Add("rotation", string.Format("\"0 0 1 {0} \"", new Random().NextDouble()*360));
            tch.Props.Add("static", "false");
            tch.Props.Add("client", console.GetVarString(string.Format("{0}.client", player)));
            uint obj = tch.Create(m_ts);
            SimSet.pushToBack("MissionCleanup", obj.AsString());
            return obj.AsString();
            }
        public void commonMaterialData_Init()
            {
            console.SetVar("$scroll", 1);
            console.SetVar("$rotate", 2);
            console.SetVar("$wave", 4);
            console.SetVar("$scale", 8);
            console.SetVar("$sequence", 16);
            // Common stateblock definitions

            Torque_Class_Helper tch = new Torque_Class_Helper("GFXSamplerStateData", "SamplerClampLinear");
            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXAddressClamp");
            tch.Props.Add("addressModeV", "GFXAddressClamp");
            tch.Props.Add("addressModeW", "GFXAddressClamp");
            tch.Props.Add("magFilter", "GFXTextureFilterLinear");
            tch.Props.Add("minFilter", "GFXTextureFilterLinear");
            tch.Props.Add("mipFilter", "GFXTextureFilterLinear");
            tch.Create(m_ts);

            tch = new Torque_Class_Helper("GFXSamplerStateData", "SamplerClampPoint");
            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXAddressClamp");
            tch.Props.Add("addressModeV", "GFXAddressClamp");
            tch.Props.Add("addressModeW", "GFXAddressClamp");
            tch.Props.Add("magFilter", "GFXTextureFilterPoint");
            tch.Props.Add("minFilter", "GFXTextureFilterPoint");
            tch.Props.Add("mipFilter", "GFXTextureFilterPoint");
            tch.Create(m_ts);

            tch = new Torque_Class_Helper("GFXSamplerStateData", "SamplerWrapLinear");
            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXTextureAddressWrap");
            tch.Props.Add("addressModeV", "GFXTextureAddressWrap");
            tch.Props.Add("addressModeW", "GFXTextureAddressWrap");
            tch.Props.Add("magFilter", "GFXTextureFilterLinear");
            tch.Props.Add("minFilter", "GFXTextureFilterLinear");
            tch.Props.Add("mipFilter", "GFXTextureFilterLinear");
            tch.Create(m_ts);

            tch = new Torque_Class_Helper("GFXSamplerStateData", "SamplerWrapPoint");
            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXTextureAddressWrap");
            tch.Props.Add("addressModeV", "GFXTextureAddressWrap");
            tch.Props.Add("addressModeW", "GFXTextureAddressWrap");
            tch.Props.Add("magFilter", "GFXTextureFilterPoint");
            tch.Props.Add("minFilter", "GFXTextureFilterPoint");
            tch.Props.Add("mipFilter", "GFXTextureFilterPoint");
            tch.Create(m_ts);
            }
        public void commonMaterialData_Init()
            {
            iGlobal["$scroll"] = 1;
            iGlobal["$rotate"] = 2;
            iGlobal["$wave"] = 4;
            iGlobal["$scale"] = 8;
            iGlobal["$sequence"] = 16;
            // Common stateblock definitions

            Torque_Class_Helper tch = new Torque_Class_Helper("GFXSamplerStateData", "SamplerClampLinear");
            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXAddressClamp");
            tch.Props.Add("addressModeV", "GFXAddressClamp");
            tch.Props.Add("addressModeW", "GFXAddressClamp");
            tch.Props.Add("magFilter", "GFXTextureFilterLinear");
            tch.Props.Add("minFilter", "GFXTextureFilterLinear");
            tch.Props.Add("mipFilter", "GFXTextureFilterLinear");
            tch.Create();

            tch = new Torque_Class_Helper("GFXSamplerStateData", "SamplerClampPoint");
            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXAddressClamp");
            tch.Props.Add("addressModeV", "GFXAddressClamp");
            tch.Props.Add("addressModeW", "GFXAddressClamp");
            tch.Props.Add("magFilter", "GFXTextureFilterPoint");
            tch.Props.Add("minFilter", "GFXTextureFilterPoint");
            tch.Props.Add("mipFilter", "GFXTextureFilterPoint");
            tch.Create();

            tch = new Torque_Class_Helper("GFXSamplerStateData", "SamplerWrapLinear");
            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXTextureAddressWrap");
            tch.Props.Add("addressModeV", "GFXTextureAddressWrap");
            tch.Props.Add("addressModeW", "GFXTextureAddressWrap");
            tch.Props.Add("magFilter", "GFXTextureFilterLinear");
            tch.Props.Add("minFilter", "GFXTextureFilterLinear");
            tch.Props.Add("mipFilter", "GFXTextureFilterLinear");
            tch.Create();

            tch = new Torque_Class_Helper("GFXSamplerStateData", "SamplerWrapPoint");
            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXTextureAddressWrap");
            tch.Props.Add("addressModeV", "GFXTextureAddressWrap");
            tch.Props.Add("addressModeW", "GFXTextureAddressWrap");
            tch.Props.Add("magFilter", "GFXTextureFilterPoint");
            tch.Props.Add("minFilter", "GFXTextureFilterPoint");
            tch.Props.Add("mipFilter", "GFXTextureFilterPoint");
            tch.Create();
            }
        public void Initialize_AdvanceLight_LightViz()
            {
            Torque_Class_Helper tch = new Torque_Class_Helper("GFXStateBlockData", "AL_DepthVisualizeState");
            tch.Props.Add("zDefined", "true");
            tch.Props.Add("zEnable", "false");
            tch.Props.Add("zWriteEnable", "false");

            tch.Props.Add("samplersDefined", "true");
            tch.Props.Add("samplerStates[0]", "SamplerClampPoint"); // depth    
            tch.Props.Add("samplerStates[1]", "SamplerClampLinear"); // viz color lookup
            tch.Create(m_ts);

            tch = new Torque_Class_Helper("GFXStateBlockData", "AL_DefaultVisualizeState");
            tch.Props.Add("blendDefined", "true");
            tch.Props.Add("blendEnable", "true");
            tch.Props.Add("blendSrc", "GFXBlendSrcAlpha");
            tch.Props.Add("blendDest", "GFXBlendInvSrcAlpha");

            tch.Props.Add("zDefined", "true");
            tch.Props.Add("zEnable", "false");
            tch.Props.Add("zWriteEnable", "false");

            tch.Props.Add("samplersDefined", "true");
            tch.Props.Add("samplerStates[0]", "SamplerClampPoint"); // #prepass
            tch.Props.Add("samplerStates[1]", "SamplerClampLinear"); // depthviz
            tch.Create(m_ts);

            tch = new Torque_Class_Helper("ShaderData", "AL_DepthVisualizeShader");
            tch.PropsAddString("DXVertexShaderFile ", "shaders/common/postFx/postFxV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/lighting/advanced/dbgDepthVisualizeP.hlsl");

            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/postFx/postFxV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/lighting/advanced/gl/dbgDepthVisualizeP.glsl");

            tch.PropsAddString("samplerNames[0]", "prepassBuffer");
            tch.PropsAddString("samplerNames[1]", "depthViz");

            tch.Props.Add("pixVersion", "2.0");
            tch.Create(m_ts);

            TorqueSingleton ts = new TorqueSingleton("PostEffect", "AL_DepthVisualize");
            ts.Props.Add("shader", "AL_DepthVisualizeShader");
            ts.Props.Add("stateBlock", "AL_DefaultVisualizeState");
            ts.PropsAddString("texture[0]", "#prepass");
            ts.PropsAddString("texture[1]", "depthviz");
            ts.PropsAddString("target", "$backBuffer");
            ts.Props.Add("renderPriority", "9999");
            ts.Create(m_ts);
            }
        public string ProximityMineDataOnThrow(coItemData datablock, coPlayer player, int amount)
            {
            ShapeBaseShapeBaseDecInventory(player, datablock, 1);

            Torque_Class_Helper tch = new Torque_Class_Helper("ProximityMine", "");
            tch.Props.Add("datablock", datablock);
            tch.Props.Add("sourceObject", player);
            tch.Props.Add("rotation", string.Format("\"0 0 1 {0} \"", new Random().NextDouble()*360));
            tch.Props.Add("static", "false");
            tch.Props.Add("client", player["client"]);
            coProximityMine pm = (tch.Create());

            ((coSimSet) "MissionCleanup").pushToBack(pm);

            return pm;
            }
        public bool CreateAndConnectToLocalServer(string serverType, string level)
            {
            if (!CreateServer(serverType, level))

                return false;

            Torque_Class_Helper tch = new Torque_Class_Helper("GameConnection", "ServerConnection");
            string conn = tch.Create(m_ts).AsString();

            GameConnection.setConnectArgs(conn, console.GetVarString("$pref::Player::Name"));

            GameConnection.setJoinPassword(conn, console.GetVarString("$Client::Password"));

            string result = NetConnection.connectLocal(conn);

            if (result != "")
                {
                console.Call(conn, "delete");
                DestroyServer();
                return false;
                }
            return true;
            }
        public void WeaponImageonWetFire(string thisobj, string obj, string slot)
            {
            if (!console.isObject(thisobj + ".projectile"))
                {
                console.error("WeaponImage::onFire() - Invalid projectile datablock");
                return;
                }
            // Decrement inventory ammo. The image's ammo state is updated
            // automatically by the ammo inventory hooks.
            if (!console.GetVarBool(string.Format("{0}.infiniteAmmo", thisobj)))
                ShapeBaseShapeBaseDecInventory(obj, console.GetVarString(string.Format("{0}.ammo", thisobj)), "1");

            // Get the player's velocity, we'll then add it to that of the projectile
            int numProjectiles = console.GetVarInt(string.Format("{0}.projectileNum", thisobj));
            if (numProjectiles == 0)
                numProjectiles = 1;
            TransformF muzzleVector = new TransformF();

            for (int i = 0; i < numProjectiles; i++)
                {
                if (console.GetVarBool(string.Format("{0}.wetProjectileSpread", thisobj)))
                    {
                    // We'll need to "skew" this projectile a little bit.  We start by
                    // getting the straight ahead aiming point of the gun
                    Point3F vec = ShapeBase.getMuzzleVector(obj, slot.AsInt());
                    // Then we'll create a spread matrix by randomly generating x, y, and z
                    // points in a circle
                    Random r = new Random();
                    TransformF matrix = new TransformF();
                    matrix.MPosition.x = (float) ((r.NextDouble() - .5)*2*Math.PI*console.GetVarFloat(string.Format("{0}.wetProjectileSpread ", thisobj)));
                    matrix.MPosition.y = (float) ((r.NextDouble() - .5)*2*Math.PI*console.GetVarFloat(string.Format("{0}.wetProjectileSpread ", thisobj)));
                    matrix.MPosition.z = (float) ((r.NextDouble() - .5)*2*Math.PI*console.GetVarFloat(string.Format("{0}.wetProjectileSpread ", thisobj)));
                    TransformF mat = math.MatrixCreateFromEuler(matrix);

                    muzzleVector = math.MatrixMulVector(mat, vec);
                    }
                else
                    {
                    muzzleVector = new TransformF(ShapeBase.getMuzzleVector(obj, slot.AsInt()));
                    }
                Point3F objectVelocity = ShapeBase.getVelocity(obj);

                muzzleVector = muzzleVector.vectorScale(console.GetVarFloat(string.Format("{0}.wetProjectile.muzzleVelocity", thisobj)));
                objectVelocity = objectVelocity.vectorScale(console.GetVarFloat(string.Format("{0}.wetProjectile.velInheritFactor", thisobj)));
                Point3F muzzleVelocity = muzzleVector.MPosition + objectVelocity;

                Torque_Class_Helper tch = new Torque_Class_Helper(console.GetVarString(string.Format("{0}.projectileType", thisobj)), "");
                tch.Props.Add("dataBlock", console.GetVarString(string.Format("{0}.wetProjectile", thisobj)));
                tch.Props.Add("initialVelocity", '"' + muzzleVelocity.ToString() + '"');
                tch.Props.Add("initialPosition", '"' + ShapeBase.getMuzzlePoint(obj, slot.AsInt()).ToString() + '"');
                tch.Props.Add("sourceObject", obj);
                tch.Props.Add("sourceSlot", slot);
                tch.Props.Add("client", console.GetVarString(string.Format("{0}.client", obj)));
                tch.Props.Add("sourceClass", console.GetClassName(obj));

                string project = tch.Create(m_ts).ToString(CultureInfo.InvariantCulture);
                SimSet.pushToBack("MissionCleanup", project);
                }
            }
Exemple #15
0
 public string ItemDataCreateItem(string datablock)
     {
     Torque_Class_Helper tch = new Torque_Class_Helper("Item");
     tch.Props.Add("dataBlock", datablock);
     tch.Props.Add("static", "true");
     tch.Props.Add("rotate", "true");
     string obj = tch.Create(m_ts).AsString();
     return obj;
     }
        public void water_init()
            {
            TorqueSingleton ts = new TorqueSingleton("ShaderData", "WaterShader");
            ts.PropsAddString("DXVertexShaderFile", "shaders/common/water/waterV.hlsl");
            ts.PropsAddString("DXPixelShaderFile", "shaders/common/water/waterP.hlsl");
            ts.PropsAddString("OGLVertexShaderFile", "shaders/common/water/gl/waterV.glsl");
            ts.PropsAddString("OGLPixelShaderFile", "shaders/common/water/gl/waterP.glsl");
            ts.Props.Add("pixVersion", "3.0");
            ts.Create();

            Torque_Class_Helper tch = new Torque_Class_Helper("GFXSamplerStateData", "WaterSampler");

            tch.Props.Add("textureColorOp", "GFXTOPModulate");
            tch.Props.Add("addressModeU", "GFXAddressWrap");
            tch.Props.Add("addressModeV", "GFXAddressWrap");
            tch.Props.Add("addressModeW", "GFXAddressWrap");
            tch.Props.Add("magFilter", "GFXTextureFilterLinear");
            tch.Props.Add("minFilter", "GFXTextureFilterAnisotropic");
            tch.Props.Add("mipFilter", "GFXTextureFilterLinear");
            tch.Props.Add("maxAnisotropy", "4");
            tch.Create();


            ts = new TorqueSingleton("GFXStateBlockData", "WaterStateBlock");
            ts.Props.Add("samplersDefined", "true");
            ts.Props.Add("samplerStates[0]", "WaterSampler"); // noise
            ts.Props.Add("samplerStates[1]", "SamplerClampPoint"); // #prepass
            ts.Props.Add("samplerStates[2]", "SamplerClampLinear"); // $reflectbuff
            ts.Props.Add("samplerStates[3]", "SamplerClampPoint"); // $backbuff
            ts.Props.Add("samplerStates[4]", "SamplerWrapLinear"); // $cubemap   
            ts.Props.Add("samplerStates[5]", "SamplerWrapLinear"); // foam     
            ts.Props.Add("samplerStates[6]", "SamplerClampLinear"); // depthMap ( color gradient ) 
            ts.Props.Add("cullDefined", "true");
            ts.PropsAddString("cullMode", "GFXCullCCW");
            ts.Create();

            ts = new TorqueSingleton("GFXStateBlockData", "UnderWaterStateBlock : WaterStateBlock");
            ts.PropsAddString("cullMode", "GFXCullCW");
            ts.Create();

            ts = new TorqueSingleton("CustomMaterial", "WaterMat");
            ts.PropsAddString(@"sampler[""prepassTex""]", "#prepass");
            ts.PropsAddString(@"sampler[""reflectMap""]", "$reflectbuff");
            ts.PropsAddString(@"sampler[""refractBuff""]", "$backbuff");

            ts.Props.Add("shader", "WaterShader");
            ts.Props.Add("stateBlock", "WaterStateBlock");
            ts.Props.Add("version", "3.0");

            ts.Props.Add("useAnisotropic[0]", "true");
            ts.Create();


            //-----------------------------------------------------------------------------
            // Underwater
            //-----------------------------------------------------------------------------

            ts = new TorqueSingleton("ShaderData", "UnderWaterShader");
            ts.PropsAddString(@"DXVertexShaderFile", "shaders/common/water/waterV.hlsl");
            ts.PropsAddString(@"DXPixelShaderFile", "shaders/common/water/waterP.hlsl");

            ts.PropsAddString(@"OGLVertexShaderFile", "shaders/common/water/gl/waterV.glsl");
            ts.PropsAddString(@"OGLPixelShaderFile", "shaders/common/water/gl/waterP.glsl");

            ts.PropsAddString(@"defines", "UNDERWATER");
            ts.Props.Add("pixVersion", "3.0");
            ts.Create();

            ts = new TorqueSingleton("CustomMaterial", "UnderwaterMat");
            // These samplers are set in code not here.
            // This is to allow different WaterObject instances
            // to use this same material but override these textures
            // per instance.   
            //sampler["bumpMap"] = "core/art/water/noise02";
            //sampler["foamMap"] = "core/art/water/foam";
            ts.PropsAddString(@"sampler[""prepassTex""]", "#prepass");
            ts.PropsAddString(@"sampler[""refractBuff""]", "$backbuff");

            ts.PropsAddString(@"shader", "UnderWaterShader");
            ts.PropsAddString(@"stateBlock", "UnderWaterStateBlock");
            ts.PropsAddString(@"specular", "0.75 0.75 0.75 1.0");
            ts.Props.Add(@"specularPower", "48.0");
            ts.Props.Add(@"version", "3.0");
            ts.Create();


            //-----------------------------------------------------------------------------
            // Basic Water
            //-----------------------------------------------------------------------------

            ts = new TorqueSingleton("ShaderData", "WaterBasicShader");

            ts.PropsAddString("DXVertexShaderFile", "shaders/common/water/waterBasicV.hlsl");
            ts.PropsAddString("DXPixelShaderFile", "shaders/common/water/waterBasicP.hlsl");

            ts.PropsAddString("OGLVertexShaderFile", "shaders/common/water/gl/waterBasicV.glsl");
            ts.PropsAddString("OGLPixelShaderFile", "shaders/common/water/gl/waterBasicP.glsl");
            ts.Props.Add("pixVersion", "2.0");
            ts.Create();

            ts = new TorqueSingleton("GFXStateBlockData", "WaterBasicStateBlock");
            ts.Props.Add("samplersDefined", "true");
            ts.Props.Add("samplerStates[0]", "WaterSampler"); // noise
            ts.Props.Add("samplerStates[2]", "SamplerClampLinear"); // $reflectbuff
            ts.Props.Add("samplerStates[3]", "SamplerClampPoint"); // $backbuff
            ts.Props.Add("samplerStates[4]", "SamplerWrapLinear"); // $cubemap
            ts.Props.Add("cullDefined", "true");
            ts.PropsAddString("cullMode", "GFXCullCCW");
            ts.Create();

            ts = new TorqueSingleton("GFXStateBlockData", "UnderWaterBasicStateBlock : WaterBasicStateBlock");
            ts.PropsAddString("cullMode", "GFXCullCW");
            ts.Create();

            ts = new TorqueSingleton("CustomMaterial", "WaterBasicMat");
            // These samplers are set in code not here.
            // This is to allow different WaterObject instances
            // to use this same material but override these textures
            // per instance.     
            //sampler["bumpMap"] = "core/art/water/noise02";
            //sampler["skyMap"] = "$cubemap";   

            //sampler["prepassTex"] = "#prepass";
            ts.PropsAddString(@"sampler[""reflectMap""]", "$reflectbuff");
            ts.PropsAddString(@"sampler[""refractBuff""]", "$backbuff");

            ts.Props.Add("cubemap", "NewLevelSkyCubemap");
            ts.Props.Add("shader", "WaterBasicShader");
            ts.Props.Add("stateBlockZ", "WaterBasicStateBlock");
            ts.Props.Add("version", "2.0");
            ts.Create();

            //-----------------------------------------------------------------------------
            // Basic UnderWater
            //-----------------------------------------------------------------------------

            ts = new TorqueSingleton("ShaderData", "UnderWaterBasicShader");
            ts.PropsAddString(@"DXVertexShaderFile", "shaders/common/water/waterBasicV.hlsl");
            ts.PropsAddString(@"DXPixelShaderFile", "shaders/common/water/waterBasicP.hlsl");

            ts.PropsAddString(@"OGLVertexShaderFile", "shaders/common/water/gl/waterBasicV.glsl");
            ts.PropsAddString(@"OGLPixelShaderFile", "shaders/common/water/gl/waterBasicP.glsl");

            ts.PropsAddString(@"defines", "UNDERWATER");
            ts.Props.Add("pixVersion", "2.0");
            ts.Create();

            ts = new TorqueSingleton("CustomMaterial", "UnderwaterBasicMat");
            // These samplers are set in code not here.
            // This is to allow different WaterObject instances
            // to use this same material but override these textures
            // per instance.  
            //sampler["bumpMap"] = "core/art/water/noise02";
            //samplers["skyMap"] = "$cubemap";  

            //sampler["prepassTex"] = "#prepass";
            ts.PropsAddString(@"sampler[""refractBuff""]", "$backbuff");

            ts.Props.Add("shader", "UnderWaterBasicShader");
            ts.Props.Add("stateBlock", "UnderWaterBasicStateBlock");
            ts.Props.Add("version", "2.0");
            ts.Create();
            }
        public void CheetahCarOnAdd(string thisobj, string obj, string nameSpaceDepth)
            {
            int nsd = (nameSpaceDepth.AsInt() + 1);
            console.ParentExecute(thisobj, "onAdd", nsd, new[] {thisobj, obj});
            WheeledVehicle.setWheelTire(obj, 0, "CheetahCarTire");
            WheeledVehicle.setWheelTire(obj, 1, "CheetahCarTire");
            WheeledVehicle.setWheelTire(obj, 2, "CheetahCarTireRear");
            WheeledVehicle.setWheelTire(obj, 3, "CheetahCarTireRear");
            // Setup the car with some tires & springs
            for (int i = WheeledVehicle.getWheelCount(obj) - 1; i >= 0; i--)
                {
                WheeledVehicle.setWheelPowered(obj, i, true);
                WheeledVehicle.setWheelSpring(obj, i, "CheetahCarSpring");
                }
            // Steer with the front tires
            WheeledVehicle.setWheelSteering(obj, 0, 1);
            WheeledVehicle.setWheelSteering(obj, 1, 1);
            // Add tail lights
            Torque_Class_Helper tc = new Torque_Class_Helper("PointLight", "");
            tc.Props.Add("radius", "1");
            tc.Props.Add("isEnabled", "0");
            tc.Props.Add("color", @"""1 0 0.141176 1""");
            tc.Props.Add("brightness", "2");
            tc.Props.Add("castShadows", "1");
            tc.Props.Add("priority", "1");
            tc.Props.Add("animate", "0");
            tc.Props.Add("animationPeriod", "1");
            tc.Props.Add("animationPhase", "1");
            tc.Props.Add("flareScale", "1");
            tc.Props.Add("attenuationRatio", @"""0 1 1""");
            tc.Props.Add("shadowType", @"""DualParaboloidSinglePass""");
            tc.Props.Add("texSize", "512");
            tc.Props.Add("overDarkFactor", @"""2000 1000 500 100""");
            tc.Props.Add("shadowDistance", "400");
            tc.Props.Add("shadowSoftness", "0.15");
            tc.Props.Add("numSplits", "1");
            tc.Props.Add("logWeight", "0.91");
            tc.Props.Add("fadeStartDistance", "0");
            tc.Props.Add("lastSplitTerrainOnly", "0");
            tc.Props.Add("representedInLightmap", "0");
            tc.Props.Add("shadowDarkenColor", @"""0 0 0 -1""");
            tc.Props.Add("includeLightmappedGeometryInShadow", "0");
            tc.Props.Add("rotation", @"""1 0 0 0 """);
            tc.Props.Add("canSave", "1");
            tc.Props.Add("canSaveDynamicFields", "1");
            tc.Props.Add("splitFadeDistances", @"""10 20 30 40""");

            string rightbrakelight = tc.Create(m_ts).ToString(CultureInfo.InvariantCulture);
            console.SetVar(string.Format("{0}.rightBrakeLight", obj), rightbrakelight);

            string leftbrakelight = tc.Create(m_ts).ToString(CultureInfo.InvariantCulture);
            console.SetVar(string.Format("{0}.leftBrakeLight", obj), leftbrakelight);

            console.SetVar(string.Format("{0}.inv[BulletAmmo]", obj), 1000);


            // Mount a ShapeBaseImageData
            //Current T3d Turrets are broken in dedicated mode.
            ShapeBase.mountImage(obj, "TurretImage", console.GetVarInt(thisobj + ".turretSlot"), true, "");
            // Mount the brake lights

            SceneObject.mountObject(obj, rightbrakelight, console.GetVarInt(string.Format("{0}.rightBrakeSlot", thisobj)), new TransformF(true));
            SceneObject.mountObject(obj, leftbrakelight, console.GetVarInt(string.Format("{0}.leftBrakeSlot", thisobj)), new TransformF(true));
            }
        public string RocketLauncherImageOnAltFire(coItem thisobj, coPlayer obj, string slot)
            {
            int currentAmmo = ShapeBaseShapeBaseGetInventory(obj, (thisobj["ammo"]));
            if (currentAmmo < thisobj["loadCount"].AsInt())
                thisobj["loadCount"] = currentAmmo.AsString();
            coProjectile projectile = null;
            for (int shotCount = 0; shotCount < thisobj["loadCount"].AsInt(); shotCount++)
                {
                // Decrement inventory ammo. The image's ammo state is updated
                // automatically by the ammo inventory hooks.
                ShapeBaseShapeBaseDecInventory(obj, (thisobj["ammo"]), 1);
                // We fire our weapon using the straight ahead aiming point of the gun
                // We'll need to "skew" the projectile a little bit.  We start by getting
                // the straight ahead aiming point of the gun
                Point3F vec = obj.getMuzzleVector(slot.AsInt());
                Random r = new Random();
                TransformF matrix = new TransformF();
                matrix.MPosition.x = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                matrix.MPosition.y = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                matrix.MPosition.z = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                TransformF mat = math.MatrixCreateFromEuler(matrix);

                // Which we'll use to alter the projectile's initial vector with
                TransformF muzzleVector = math.MatrixMulVector(mat, vec);

                // Get the player's velocity, we'll then add it to that of the projectile
                TransformF objectVelocity = new TransformF(obj.getVelocity());

                muzzleVector = muzzleVector.vectorScale(thisobj["projectile.muzzleVelocity"].AsFloat());
                objectVelocity = objectVelocity.vectorScale(thisobj["projectile.velInheritFactor"].AsFloat());
                TransformF muzzleVelocity = muzzleVector + objectVelocity;

                Torque_Class_Helper tch = new Torque_Class_Helper(thisobj["projectileType"], "");
                tch.Props.Add("dataBlock", thisobj["projectile"]);
                tch.Props.Add("initialVelocity", '"' + muzzleVelocity.ToString() + '"');
                tch.Props.Add("initialPosition", '"' + obj.getMuzzlePoint(slot.AsInt()).AsString() + '"');
                tch.Props.Add("sourceObject", obj);
                tch.Props.Add("sourceSlot", slot);
                tch.Props.Add("client", obj["client"]);


                projectile = tch.Create();
                ((coSimSet) "MissionCleanup").pushToBack(projectile);
                }
            return projectile;
            }
        public void ResetMission()
            {
            console.print("*** MISSION RESET");
            // Remove any temporary mission objects
            console.Call("MissionCleanup", "delete");
            console.SetVar("$instantGroup", console.GetVarString("ServerGroup"));
            Torque_Class_Helper tcg = new Torque_Class_Helper("SimGroup", "MissionCleanup");
            string sMissionCleanup = tcg.Create(m_ts).AsString();
            console.SetVar("$instantGroup", sMissionCleanup);

            console.clearServerPaths();
            console.error("-------------> Client Group Count = " + ClientGroup.Count);
            }
        public void LoadMissionStage2()
            {
            console.print("*** Stage 2 load CSHARP");
            // Create the mission group off the ServerGroup
            console.SetVar("$instantGroup", "ServerGroup");

            // Make sure the mission exists
            string file = console.GetVarString("$Server::MissionFile");
            if (!Util.isFile(file))
                Server__LoadFailMsg = "Could not find mission " + file;
            else
                {
                // Calculate the mission CRC.  The CRC is used by the clients
                // to caching mission lighting.
                int missioncrc = Util.getFileCRC(file);
                console.SetVar("$missionCRC", missioncrc.AsString());
                //Looked at making this one a dll direct call, doesn't appear
                //it can be easily converted.
                // Exec the mission.  The MissionGroup (loaded components) is added to the ServerGroup
                Util.exec(console.GetVarString("$Server::MissionFile"), false, false);

                if (!console.isObject("MissionGroup"))
                    Server__LoadFailMsg = "No 'MissionGroup' found in mission " + file;
                }
            if (Server__LoadFailMsg != "")
                {
                // Inform clients that are already connected
                foreach (UInt32 client in ClientGroup)
                    MessageClient(client.AsString(), "MsgLoadFailed", Server__LoadFailMsg);
                return;
                }
            // Set mission name.
            if (console.isObject("theLevelInfo"))
                console.SetVar("$Server::MissionName", "theLevelInfo.levelName");

            // Mission cleanup group.  This is where run time components will reside.  The MissionCleanup
            // group will be added to the ServerGroup.

            Torque_Class_Helper tc = new Torque_Class_Helper("SimGroup", "MissionCleanup");
            tc.Create(m_ts);
            // Make the MissionCleanup group the place where all new objects will automatically be added.
            console.SetVar("$instantGroup", "MissionCleanup");
            console.pathOnMissionLoadDone();

            // Mission loading done...
            console.warn("*** Mission loaded");

            missionRunning = true;
            //Even though we track this in the CSharp, the tools use it as a flag.
            console.SetVar("$missionRunning", true);
            // Start all the clients in the mission
            foreach (UInt32 client in ClientGroup)
                {
                GameConnectionLoadMission(client.AsString());
                }

            onMissionLoaded();
            }
        public void CheetahCarOnAdd(coWheeledVehicleData datablock, coWheeledVehicle vehicle, string nameSpaceDepth)
            {
            int nsd = (nameSpaceDepth.AsInt() + 1);
            console.ParentExecute(datablock, "onAdd", nsd, new string[] { datablock, vehicle.ID });
            vehicle.setWheelTire(0, "CheetahCarTire");
            vehicle.setWheelTire(1, "CheetahCarTire");
            vehicle.setWheelTire(2, "CheetahCarTireRear");
            vehicle.setWheelTire(3, "CheetahCarTireRear");


            // Setup the car with some tires & springs
            for (int i = vehicle.getWheelCount() - 1; i >= 0; i--)
                {
                vehicle.setWheelPowered(i, true);
                vehicle.setWheelSpring(i, "CheetahCarSpring");
                }
            // Steer with the front tires
            vehicle.setWheelSteering(0, 1);
            vehicle.setWheelSteering(1, 1);


            // Add tail lights
            Torque_Class_Helper tc = new Torque_Class_Helper("PointLight", "");
            tc.Props.Add("radius", "1");
            tc.Props.Add("isEnabled", "0");
            tc.Props.Add("color", @"""1 0 0.141176 1""");
            tc.Props.Add("brightness", "2");
            tc.Props.Add("castShadows", "1");
            tc.Props.Add("priority", "1");
            tc.Props.Add("animate", "0");
            tc.Props.Add("animationPeriod", "1");
            tc.Props.Add("animationPhase", "1");
            tc.Props.Add("flareScale", "1");
            tc.Props.Add("attenuationRatio", @"""0 1 1""");
            tc.Props.Add("shadowType", @"""DualParaboloidSinglePass""");
            tc.Props.Add("texSize", "512");
            tc.Props.Add("overDarkFactor", @"""2000 1000 500 100""");
            tc.Props.Add("shadowDistance", "400");
            tc.Props.Add("shadowSoftness", "0.15");
            tc.Props.Add("numSplits", "1");
            tc.Props.Add("logWeight", "0.91");
            tc.Props.Add("fadeStartDistance", "0");
            tc.Props.Add("lastSplitTerrainOnly", "0");
            tc.Props.Add("representedInLightmap", "0");
            tc.Props.Add("shadowDarkenColor", @"""0 0 0 -1""");
            tc.Props.Add("includeLightmappedGeometryInShadow", "0");
            tc.Props.Add("rotation", @"""1 0 0 0 """);
            tc.Props.Add("canSave", "1");
            tc.Props.Add("canSaveDynamicFields", "1");
            tc.Props.Add("splitFadeDistances", @"""10 20 30 40""");


            vehicle["rightBrakeLight"] = ((coPointLight)tc.Create());
            vehicle["leftBrakeLight"] = ((coPointLight)tc.Create());
            vehicle["inv[BulletAmmo]"] = "1000";

            // Mount a ShapeBaseImageData
            vehicle.mountImage("TurretImage", datablock["turretSlot"].AsInt(), true, "");

            // Mount the brake lights
            vehicle.mountObject(vehicle["rightBrakeLight"], datablock["rightBrakeSlot"].AsInt(), new TransformF(true));
            vehicle.mountObject(vehicle["leftbrakelight"], datablock["leftBrakeSlot"].AsInt(), new TransformF(true));
            }
Exemple #22
0
        public string ItemDataOnThrow(coItemData datablock, coPlayer player, int amount)
            {
            if (amount == 0)
                amount = 1;

            if (amount > datablock["maxInventory"].AsInt())
                amount = datablock["maxInventory"].AsInt();

            if (!amount.AsBool())
                return "0";


            ShapeBaseShapeBaseDecInventory(player, datablock, amount);

            // Construct the actual object in the world, and add it to
            // the mission group so it's cleaned up when the mission is
            // done.  The object is given a random z rotation.
            Torque_Class_Helper tch = new Torque_Class_Helper("Item", "");
            tch.Props.Add("datablock", datablock);
            tch.Props.Add("rotation", @"""0 0 1 " + (new Random().Next(0, 360)) + @"""");
            tch.Props.Add("count", amount.AsString());

            coItem item = tch.Create();

            ((coSimSet)"MissionGroup").pushToBack(item);

            ItemschedulePop(item);
            return item;
            }
        public string PickPlayerSpawnPoint(string spawnGroups)
            {
            coSimObject spawnpoint = null;
            String[] lspawngroups = spawnGroups.Split(' ');


            foreach (coSimSet group in lspawngroups)
                {
                if (!group.isObject())
                    continue;
                spawnpoint = group.getRandom();
                if (spawnpoint.isObject())
                    return spawnpoint;
                }


            coSpawnSphere DefaultPlayerSpawnSphere = null;

            DefaultPlayerSpawnSphere = "DefaultPlayerSpawnSphere";

            if (DefaultPlayerSpawnSphere.isObject())
                {
                Torque_Class_Helper spawn = new Torque_Class_Helper("SpawnSphere", "DefaultPlayerSpawnSphere");
                spawn.Props.Add("dataBlock", "SpawnSphereMarker");
                spawn.PropsAddString("spawnClass", Game__DefaultPlayerClass);
                spawn.PropsAddString("spawnDatablock", Game__DefaultPlayerDataBlock);
                coSpawnSphere spawnid = spawn.Create();
                ((coSimSet)"MissionCleanup").pushToBack(spawnid);
                }

            return DefaultPlayerSpawnSphere;
            }
        public void Initialize_AdvanceLight_Shaders()
            {
            #region new GFXStateBlockData( AL_VectorLightState )

            Torque_Class_Helper tch = new Torque_Class_Helper("GFXStateBlockData", "AL_VectorLightState");
            tch.Props.Add("blendDefined", "true");
            tch.Props.Add("blendEnable", "true");
            tch.Props.Add("blendSrc", "GFXBlendOne");
            tch.Props.Add("blendDest", "GFXBlendOne");
            tch.Props.Add("blendOp", "GFXBlendOpAdd");

            tch.Props.Add("zDefined", "true");
            tch.Props.Add("zEnable", "false");
            tch.Props.Add("zWriteEnable", "false");

            tch.Props.Add("samplersDefined", "true");
            tch.Props.Add("samplerStates[0]", "SamplerClampPoint"); // G-buffer
            tch.Props.Add("samplerStates[1]", "SamplerClampPoint"); // Shadow Map (Do not change this to linear, as all cards can not filter equally.)
            tch.Props.Add("samplerStates[2]", "SamplerClampLinear"); // SSAO Mask
            tch.Props.Add("samplerStates[3]", "SamplerWrapPoint"); // Random Direction Map

            tch.Props.Add("cullDefined", "true");
            tch.Props.Add("cullMode", "GFXCullNone");

            tch.Props.Add("stencilDefined", "true");
            tch.Props.Add("stencilEnable", "true");
            tch.Props.Add("stencilFailOp", "GFXStencilOpKeep");
            tch.Props.Add("stencilZFailOp", "GFXStencilOpKeep");
            tch.Props.Add("stencilPassOp", "GFXStencilOpKeep");
            tch.Props.Add("stencilFunc", "GFXCmpLess");
            tch.Props.Add("stencilRef", "0");
            tch.Create(m_ts);

            #endregion

            #region new ShaderData( AL_VectorLightShader )

            tch = new Torque_Class_Helper("ShaderData", "AL_VectorLightShader");
            tch.PropsAddString("DXVertexShaderFile", "shaders/common/lighting/advanced/farFrustumQuadV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/lighting/advanced/vectorLightP.hlsl");

            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/lighting/advanced/gl/farFrustumQuadV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/lighting/advanced/gl/vectorLightP.glsl");
            tch.Props.Add("pixVersion", "3.0");
            tch.Create(m_ts);

            #endregion

            #region new CustomMaterial( AL_VectorLightMaterial )

            tch = new Torque_Class_Helper("CustomMaterial", "AL_VectorLightMaterial");
            tch.Props.Add("shader", "AL_VectorLightShader");
            tch.Props.Add("stateBlock", "AL_VectorLightState");
            tch.PropsAddString(@"sampler[""prePassBuffer""]", "#prepass");
            tch.PropsAddString(@"sampler[""ShadowMap""]", "$dynamiclight");
            tch.PropsAddString(@"sampler[""ssaoMask""]", "#ssaoMask");

            tch.PropsAddString("target", "lightinfo");

            tch.Props.Add("pixVersion", "3.0");
            tch.Create(m_ts);

            #endregion

            #region new GFXStateBlockData( AL_ConvexLightState )

            tch = new Torque_Class_Helper("GFXStateBlockData", "AL_ConvexLightState");

            tch.Props.Add("blendDefined", "true");
            tch.Props.Add("blendEnable", "true");
            tch.Props.Add("blendSrc", "GFXBlendOne");
            tch.Props.Add("blendDest", "GFXBlendOne");
            tch.Props.Add("blendOp", "GFXBlendOpAdd");

            tch.Props.Add("zDefined", "true");
            tch.Props.Add("zEnable", "true");
            tch.Props.Add("zWriteEnable", "false");
            tch.Props.Add("zFunc", "GFXCmpGreaterEqual");

            tch.Props.Add("samplersDefined", "true");
            tch.Props.Add("samplerStates[0]", "SamplerClampPoint"); // G-buffer
            tch.Props.Add("samplerStates[1]", "SamplerClampPoint"); // Shadow Map (Do not use linear, these are perspective projections)
            tch.Props.Add("samplerStates[2]", "SamplerClampLinear"); // Cookie Map   
            tch.Props.Add("samplerStates[3]", "SamplerWrapPoint"); // Random Direction Map

            tch.Props.Add("cullDefined", "true");
            tch.Props.Add("cullMode", "GFXCullCW");

            tch.Props.Add("stencilDefined", "true");
            tch.Props.Add("stencilEnable", "true");
            tch.Props.Add("stencilFailOp", "GFXStencilOpKeep");
            tch.Props.Add("stencilZFailOp", "GFXStencilOpKeep");
            tch.Props.Add("stencilPassOp", "GFXStencilOpKeep");
            tch.Props.Add("stencilFunc", "GFXCmpLess");
            tch.Props.Add("stencilRef", "0");
            tch.Create(m_ts);

            #endregion

            #region new ShaderData( AL_PointLightShader )

            tch = new Torque_Class_Helper("ShaderData", "AL_PointLightShader");
            tch.PropsAddString("DXVertexShaderFile", "shaders/common/lighting/advanced/convexGeometryV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/lighting/advanced/pointLightP.hlsl");
            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/lighting/advanced/gl/convexGeometryV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/lighting/advanced/gl/pointLightP.glsl");
            tch.Props.Add("pixVersion", "3.0");
            tch.Create(m_ts);

            #endregion

            #region new CustomMaterial( AL_PointLightMaterial )

            tch = new Torque_Class_Helper("CustomMaterial", "AL_PointLightMaterial");
            tch.Props.Add("shader", "AL_PointLightShader");
            tch.Props.Add("stateBlock", "AL_ConvexLightState");
            tch.PropsAddString(@"sampler[""prePassBuffer""]", "#prepass");
            tch.PropsAddString(@"sampler[""shadowMap""]", "$dynamiclight");
            tch.PropsAddString(@"sampler[""cookieTex""]", "$dynamiclightmask");
            tch.PropsAddString(@"target", "lightinfo");
            tch.Props.Add("pixVersion", "3.0");
            tch.Create(m_ts);

            #endregion

            #region new ShaderData( AL_SpotLightShader )

            tch = new Torque_Class_Helper("ShaderData", "AL_SpotLightShader");
            tch.PropsAddString("DXVertexShaderFile", "shaders/common/lighting/advanced/convexGeometryV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/lighting/advanced/spotLightP.hlsl");
            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/lighting/advanced/gl/convexGeometryV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/lighting/advanced/gl/spotLightP.glsl");
            tch.Props.Add("pixVersion", "3.0");
            tch.Create(m_ts);

            #endregion

            #region new CustomMaterial( AL_SpotLightMaterial )

            tch = new Torque_Class_Helper("CustomMaterial", "AL_SpotLightMaterial");
            tch.Props.Add("shader", "AL_SpotLightShader");
            tch.Props.Add("stateBlock", "AL_ConvexLightState");

            tch.PropsAddString(@"sampler[""prePassBuffer""]", "#prepass");
            tch.PropsAddString(@"sampler[""shadowMap""]", "$dynamiclight");
            tch.PropsAddString(@"sampler[""cookieTex""]", "$dynamiclightmask");

            tch.PropsAddString("target", "lightinfo");
            tch.Props.Add("pixVersion", "3.0");
            tch.Create(m_ts);

            #endregion

            #region new Material( AL_DefaultPrePassMaterial )

            tch = new Torque_Class_Helper("Material", "AL_DefaultPrePassMaterial");
            // We need something in the first pass else it 
            // won't create a proper material instance.  
            //
            // We use color here because some objects may not
            // have texture coords in their vertex format... 
            // for example like terrain.
            //

            tch.PropsAddString("diffuseColor[0]", "1 1 1 1");
            tch.Create(m_ts);

            #endregion

            // This material is used for generating shadow 
            // materials for objects that do not have materials.

            #region new Material( AL_DefaultShadowMaterial )

            tch = new Torque_Class_Helper("Material", "AL_DefaultShadowMaterial");
            // We need something in the first pass else it 
            // won't create a proper material instance.  
            //
            // We use color here because some objects may not
            // have texture coords in their vertex format... 
            // for example like terrain.
            //

            tch.PropsAddString("diffuseColor[0]", "1 1 1 1");
            // This is here mostly for terrain which uses
            // this material to create its shadow material.
            //
            // At sunset/sunrise the sun is looking thru 
            // backsides of the terrain which often are not
            // closed.  By changing the material to be double
            // sided we avoid holes in the shadowed geometry.
            //
            tch.Props.Add("doubleSided", "true");
            tch.Create(m_ts);

            #endregion

            #region new ShaderData( AL_ParticlePointLightShader )

            tch = new Torque_Class_Helper("ShaderData", "AL_ParticlePointLightShader");
            tch.PropsAddString("DXVertexShaderFile", "shaders/common/lighting/advanced/particlePointLightV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/lighting/advanced/particlePointLightP.hlsl");
            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/lighting/advanced/gl/convexGeometryV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/lighting/advanced/gl/pointLightP.glsl");
            tch.Props.Add("pixVersion", "3.0");
            tch.Create(m_ts);

            #endregion

            #region new CustomMaterial( AL_ParticlePointLightMaterial )

            tch = new Torque_Class_Helper("CustomMaterial", "AL_ParticlePointLightMaterial");
            tch.Props.Add("shader", "AL_ParticlePointLightShader");
            tch.Props.Add("stateBlock", "AL_ConvexLightState");

            tch.PropsAddString(@"sampler[""prePassBuffer""]", "#prepass");
            tch.PropsAddString(@"target", "lightinfo");

            tch.Props.Add("pixVersion", "3.0");
            tch.Create(m_ts);

            #endregion
            }
        public void shaders_Init()
            {
            TorqueSingleton ts = new TorqueSingleton("ShaderData", "_DebugInterior_");

            ts.PropsAddString("DXVertexShaderFile", "shaders/common/debugInteriorsV.hlsl");
            ts.PropsAddString("DXPixelShaderFile", "shaders/common/debugInteriorsP.hlsl");
            ts.PropsAddString("OGLVertexShaderFile", "shaders/common/gl/debugInteriorsV.glsl");
            ts.PropsAddString("OGLPixelShaderFile", "shaders/common/gl/debugInteriorsP.glsl");
            ts.Props.Add("pixVersion", "1.1");
            ts.Create();

            ts = new TorqueSingleton("ShaderData", "ParticlesShaderData");
            ts.PropsAddString("DXVertexShaderFile", "shaders/common/particlesV.hlsl");
            ts.PropsAddString("DXPixelShaderFile", "shaders/common/particlesP.hlsl");

            ts.PropsAddString("OGLVertexShaderFile", "shaders/common/gl/particlesV.glsl");
            ts.PropsAddString("OGLPixelShaderFile", "shaders/common/gl/particlesP.glsl");
            ts.Props.Add("pixVersion", "2.0");
            ts.Create();

            ts = new TorqueSingleton("ShaderData", "OffscreenParticleCompositeShaderData");
            ts.PropsAddString("DXVertexShaderFile", "shaders/common/particleCompositeV.hlsl");
            ts.PropsAddString("DXPixelShaderFile", "shaders/common/particleCompositeP.hlsl");

            ts.PropsAddString("OGLVertexShaderFile", "shaders/common/gl/particleCompositeV.glsl");
            ts.PropsAddString("OGLPixelShaderFile", "shaders/common/gl/particleCompositeP.glsl");
            ts.Props.Add("pixVersion", "2.0");
            ts.Create();

            //-----------------------------------------------------------------------------
            // Planar Reflection
            //-----------------------------------------------------------------------------

            Torque_Class_Helper tch = new Torque_Class_Helper("ShaderData", "ReflectBump");

            tch.PropsAddString("DXVertexShaderFile", "shaders/common/planarReflectBumpV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/planarReflectBumpP.hlsl");

            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/gl/planarReflectBumpV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/gl/planarReflectBumpP.glsl");

            tch.PropsAddString("samplerNames[0]", "$diffuseMap");
            tch.PropsAddString("samplerNames[1]", "$refractMap");
            tch.PropsAddString("samplerNames[2]", "$bumpMap");
            tch.Props.Add("pixVersion", "2.0");
            tch.Create();

            tch = new Torque_Class_Helper("ShaderData", "Reflect");
            tch.PropsAddString("DXVertexShaderFile", "shaders/common/planarReflectV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/planarReflectP.hlsl");

            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/gl/planarReflectV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/gl/planarReflectP.glsl");

            tch.PropsAddString("samplerNames[0]", "$diffuseMap");
            tch.PropsAddString("samplerNames[1]", "$refractMap");
            tch.Props.Add("pixVersion", "1.4");
            tch.Create();

            tch = new Torque_Class_Helper("ShaderData", "fxFoliageReplicatorShader");
            tch.PropsAddString("DXVertexShaderFile", "shaders/common/fxFoliageReplicatorV.hlsl");
            tch.PropsAddString("DXPixelShaderFile", "shaders/common/fxFoliageReplicatorP.hlsl");

            tch.PropsAddString("OGLVertexShaderFile", "shaders/common/gl/fxFoliageReplicatorV.glsl");
            tch.PropsAddString("OGLPixelShaderFile", "shaders/common/gl/fxFoliageReplicatorP.glsl");

            tch.PropsAddString("samplerNames[0]", "$diffuseMap");
            tch.PropsAddString("samplerNames[1]", "$alphaMap");
            tch.Props.Add("pixVersion", "1.4");
            tch.Create();
            }
        public string RocketLauncherImageOnAltFire(string thisobj, string obj, string slot)
            {
            string currentAmmo = ShapeBaseShapeBaseGetInventory(obj, console.GetVarString(string.Format("{0}.ammo", thisobj))).AsString();
            if (currentAmmo.AsInt() < console.GetVarInt(string.Format("{0}.loadCount", thisobj)))
                console.SetVar(string.Format("{0}.loadCount", thisobj), currentAmmo);
            string project = "";
            for (int shotCount = 0; shotCount < console.GetVarInt(string.Format("{0}.loadCount", thisobj)); shotCount++)
                {
                // Decrement inventory ammo. The image's ammo state is updated
                // automatically by the ammo inventory hooks.
                ShapeBaseShapeBaseDecInventory(obj, console.GetVarString(string.Format("{0}.ammo", thisobj)), "1");
                // We fire our weapon using the straight ahead aiming point of the gun
                // We'll need to "skew" the projectile a little bit.  We start by getting
                // the straight ahead aiming point of the gun
                Point3F vec = ShapeBase.getMuzzleVector(obj, slot.AsInt());
                Random r = new Random();
                TransformF matrix = new TransformF();
                matrix.MPosition.x = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                matrix.MPosition.y = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                matrix.MPosition.z = (float) ((r.NextDouble() - .5)*2*Math.PI*0.008);
                TransformF mat = math.MatrixCreateFromEuler(matrix);

                // Which we'll use to alter the projectile's initial vector with
                TransformF muzzleVector = math.MatrixMulVector(mat, vec);

                // Get the player's velocity, we'll then add it to that of the projectile
                TransformF objectVelocity = new TransformF(ShapeBase.getVelocity(obj));

                muzzleVector = muzzleVector.vectorScale(console.GetVarFloat(string.Format("{0}.projectile.muzzleVelocity", thisobj)));
                objectVelocity = objectVelocity.vectorScale(console.GetVarFloat(string.Format("{0}.projectile.velInheritFactor", thisobj)));
                TransformF muzzleVelocity = muzzleVector + objectVelocity;

                Torque_Class_Helper tch = new Torque_Class_Helper(console.GetVarString(string.Format("{0}.projectileType", thisobj)), "");
                tch.Props.Add("dataBlock", console.GetVarString(string.Format("{0}.projectile", thisobj)));
                tch.Props.Add("initialVelocity", '"' + muzzleVelocity.ToString() + '"');
                tch.Props.Add("initialPosition", '"' + ShapeBase.getMuzzlePoint(obj, slot.AsInt()).ToString() + '"');
                tch.Props.Add("sourceObject", obj);
                tch.Props.Add("sourceSlot", slot);
                tch.Props.Add("client", console.GetVarString(string.Format("{0}.client", obj)));

                project = tch.Create(m_ts).ToString(CultureInfo.InvariantCulture);
                SimSet.pushToBack("MissionCleanup", project);
                }
            return project;
            }
        public void initRenderManager()
            {
            //con.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!RENDOR_MANAGER_INITIALIZED!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");

            console.Eval(@"assert(!isObject(""DiffuseRenderPassManager""), ""initRenderManager() - DiffuseRenderPassManager already initialized!"")");
            new Torque_Class_Helper("RenderPassManager", "DiffuseRenderPassManager").Create(m_ts);
            // This token, and the associated render managers, ensure that driver MSAA 
            // does not get used for Advanced Lighting renders.  The 'AL_FormatResolve' 
            // PostEffect copies the result to the backbuffer.	

            #region new RenderFormatToken(AL_FormatToken)

            Torque_Class_Helper tch = new Torque_Class_Helper("RenderFormatToken", "AL_FormatToken");
            tch.PropsAddString("enabled", "false");
            tch.PropsAddString("format", "GFXFormatR8G8B8A8");
            tch.PropsAddString("depthFormat", "GFXFormatD24S8");
            tch.Props.Add("aaLevel", "0"); // -1 = match backbuffer
            // The contents of the back buffer before this format token is executed
            // is provided in $inTex
            tch.PropsAddString("copyEffect", "AL_FormatCopy");
            // The contents of the render target created by this format token is
            // provided in $inTex
            tch.PropsAddString("resolveEffect", "AL_FormatCopy");
            tch.Create(m_ts);

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderPassStateBin() { renderOrder = 0.001; stateToken = AL_FormatToken; } );

            Torque_Class_Helper tchb = new Torque_Class_Helper("RenderPassStateBin");
            tchb.Props.Add("renderOrder", "0.001");
            tchb.Props.Add("stateToken", "AL_FormatToken");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            // We really need to fix the sky to render after all the 
            // meshes... but that causes issues in reflections.

            #region DiffuseRenderPassManager.addManager( new RenderObjectMgr() { bintype = "Sky"; renderOrder = 0.1; processAddOrder = 0.1; } );

            tchb = new Torque_Class_Helper("RenderObjectMgr");
            tchb.PropsAddString("bintype", "Sky");
            tchb.Props.Add("renderOrder", "0.1");
            tchb.Props.Add("processAddOrder", "0.1");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderObjectMgr()              { bintype = "Begin"; renderOrder = 0.2; processAddOrder = 0.2; } );

            tchb = new Torque_Class_Helper("RenderObjectMgr");
            tchb.PropsAddString("bintype", "Begin");
            tchb.Props.Add("renderOrder", "0.2");
            tchb.Props.Add("processAddOrder", "0.2");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            // Normal mesh rendering.

            #region DiffuseRenderPassManager.addManager( new RenderMeshMgr()                { bintype = "Interior"; renderOrder = 0.3; processAddOrder = 0.3; } );

            tchb = new Torque_Class_Helper("RenderMeshMgr");
            tchb.PropsAddString("bintype", "Interior");
            tchb.Props.Add("renderOrder", "0.3");
            tchb.Props.Add("processAddOrder", "0.3");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderTerrainMgr()             { renderOrder = 0.4; processAddOrder = 0.4; } );

            tchb = new Torque_Class_Helper("RenderTerrainMgr");
            tchb.Props.Add("renderOrder", "0.4");
            tchb.Props.Add("processAddOrder", "0.4");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region   DiffuseRenderPassManager.addManager( new RenderMeshMgr()                { bintype = "Mesh"; renderOrder = 0.5; processAddOrder = 0.5; } );

            tchb = new Torque_Class_Helper("RenderMeshMgr");
            tchb.PropsAddString("bintype", "Mesh");
            tchb.Props.Add("renderOrder", "0.5");
            tchb.Props.Add("processAddOrder", "0.5");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderImposterMgr()            { renderOrder = 0.56; processAddOrder = 0.56; } );

            tchb = new Torque_Class_Helper("RenderImposterMgr");
            tchb.Props.Add("renderOrder", "0.56");
            tchb.Props.Add("processAddOrder", "0.56");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderObjectMgr()              { bintype = "Object"; renderOrder = 0.6; processAddOrder = 0.6; } );

            tchb = new Torque_Class_Helper("RenderObjectMgr");
            tchb.PropsAddString("bintype", "Object");
            tchb.Props.Add("renderOrder", "0.6");
            tchb.Props.Add("processAddOrder", "0.6");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderObjectMgr()              { bintype = "Shadow"; renderOrder = 0.7; processAddOrder = 0.7; } );

            tchb = new Torque_Class_Helper("RenderObjectMgr");
            tchb.PropsAddString("bintype", "Shadow");
            tchb.Props.Add("renderOrder", "0.7");
            tchb.Props.Add("processAddOrder", "0.7");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderMeshMgr()                { bintype = "Decal"; renderOrder = 0.8; processAddOrder = 0.8; } );

            tchb = new Torque_Class_Helper("RenderMeshMgr");
            tchb.PropsAddString("bintype", "Decal");
            tchb.Props.Add("renderOrder", "0.8");
            tchb.Props.Add("processAddOrder", "0.8");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderOcclusionMgr()           { bintype = "Occluder"; renderOrder = 0.9; processAddOrder = 0.9; } );

            tchb = new Torque_Class_Helper("RenderOcclusionMgr");
            tchb.PropsAddString("bintype", "Occluder");
            tchb.Props.Add("renderOrder", "0.9");
            tchb.Props.Add("processAddOrder", "0.9");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            // We now render translucent objects that should handle
            // their own fogging and lighting.

            // Note that the fog effect is triggered before this bin.

            #region DiffuseRenderPassManager.addManager( new RenderObjectMgr(ObjTranslucentBin) { bintype = "ObjectTranslucent"; renderOrder = 1.0; processAddOrder = 1.0; } );

            tchb = new Torque_Class_Helper("RenderObjectMgr", "ObjTranslucentBin");
            tchb.PropsAddString("bintype", "ObjectTranslucent");
            tchb.Props.Add("renderOrder", "1");
            tchb.Props.Add("processAddOrder", "1");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderObjectMgr()              { bintype = "Water"; renderOrder = 1.2; processAddOrder = 1.2; } );

            tchb = new Torque_Class_Helper("RenderObjectMgr");
            tchb.PropsAddString("bintype", "Water");
            tchb.Props.Add("renderOrder", "1.2");
            tchb.Props.Add("processAddOrder", "1.2");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderObjectMgr()              { bintype = "Foliage"; renderOrder = 1.3; processAddOrder = 1.3; } );

            tchb = new Torque_Class_Helper("RenderObjectMgr");
            tchb.PropsAddString("bintype", "Foliage");
            tchb.Props.Add("renderOrder", "1.3");
            tchb.Props.Add("processAddOrder", "1.3");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderParticleMgr()            { renderOrder = 1.35; processAddOrder = 1.35; } );

            tchb = new Torque_Class_Helper("RenderParticleMgr");
            tchb.Props.Add("renderOrder", "1.35");
            tchb.Props.Add("processAddOrder", "1.35");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            #region DiffuseRenderPassManager.addManager( new RenderTranslucentMgr()         { renderOrder = 1.4; processAddOrder = 1.4; } );

            tchb = new Torque_Class_Helper("RenderTranslucentMgr");
            tchb.Props.Add("renderOrder", "1.4");
            tchb.Props.Add("processAddOrder", "1.4");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            // Note that the GlowPostFx is triggered after this bin.

            #region DiffuseRenderPassManager.addManager( new RenderGlowMgr(GlowBin) { renderOrder = 1.5; processAddOrder = 1.5; } );

            tchb = new Torque_Class_Helper("RenderGlowMgr", "GlowBin");
            tchb.Props.Add("renderOrder", "1.5");
            tchb.Props.Add("processAddOrder", "1.5");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            // We render any editor stuff from this bin.  Note that the HDR is
            // completed before this bin to keep editor elements from tone mapping. 

            #region DiffuseRenderPassManager.addManager( new RenderObjectMgr(EditorBin) { bintype = "Editor"; renderOrder = 1.6; processAddOrder = 1.6; } );

            tchb = new Torque_Class_Helper("RenderObjectMgr", "EditorBin");
            tchb.PropsAddString("bintype", "Editor");
            tchb.Props.Add("renderOrder", "1.6");
            tchb.Props.Add("processAddOrder", "1.6");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion

            // Resolve format change token last.

            #region DiffuseRenderPassManager.addManager( new RenderPassStateBin() { renderOrder = 1.7; stateToken = AL_FormatToken; } );

            tchb = new Torque_Class_Helper("RenderPassStateBin");
            tchb.Props.Add("renderOrder", "1.7");
            tchb.Props.Add("stateToken", "AL_FormatToken");
            RenderPassManager.addManager("DiffuseRenderPassManager", tchb.Create(m_ts).AsString());

            #endregion
            }
Exemple #28
0
        public string ItemDataOnThrow(string datablock, string player, string amount)
            {
            if (amount == "")
                amount = "1";

            if (console.GetVarString(datablock + ".maxInventory") != "")
                if (amount.AsInt() > console.GetVarInt(datablock + ".maxInventory"))
                    amount = console.GetVarString(datablock + ".maxInventory");
            if (!amount.AsBool())
                return "0";


            ShapeBaseShapeBaseDecInventory(player, datablock, amount);

            // Construct the actual object in the world, and add it to
            // the mission group so it's cleaned up when the mission is
            // done.  The object is given a random z rotation.
            Torque_Class_Helper tch = new Torque_Class_Helper("Item", "");
            tch.Props.Add("datablock", datablock);
            tch.Props.Add("rotation", @"""0 0 1 " + (new Random().Next(0, 360)) + @"""");
            tch.Props.Add("count", amount);

            string item = tch.Create(m_ts).AsString();
            SimSet.pushToBack("MissionGroup", item);
            ItemschedulePop(item);
            return item;
            }
        public void WeaponImageonWetFire(coScriptObject thisobj, coPlayer obj, int slot)
            {
            if (!thisobj["projectile"].isObject())
                {
                console.error("WeaponImage::onFire() - Invalid projectile datablock");
                return;
                }
            // Decrement inventory ammo. The image's ammo state is updated
            // automatically by the ammo inventory hooks.
            if (!thisobj["infiniteAmmo"].AsBool())
                ShapeBaseShapeBaseDecInventory(obj, thisobj["ammo"], 1);

            // Get the player's velocity, we'll then add it to that of the projectile
            int numProjectiles = thisobj["projectileNum"].AsInt();
            if (numProjectiles == 0)
                numProjectiles = 1;
            TransformF muzzleVector = new TransformF();

            for (int i = 0; i < numProjectiles; i++)
                {
                if (thisobj["wetProjectileSpread"].AsBool())
                    {
                    // We'll need to "skew" this projectile a little bit.  We start by
                    // getting the straight ahead aiming point of the gun
                    Point3F vec = obj.getMuzzleVector(slot);
                    // Then we'll create a spread matrix by randomly generating x, y, and z
                    // points in a circle
                    Random r = new Random();
                    TransformF matrix = new TransformF();
                    matrix.MPosition.x = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat());
                    matrix.MPosition.y = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat());
                    matrix.MPosition.z = (float)((r.NextDouble() - .5) * 2 * Math.PI * thisobj["wetProjectileSpread"].AsFloat());
                    TransformF mat = math.MatrixCreateFromEuler(matrix);

                    muzzleVector = math.MatrixMulVector(mat, vec);
                    }
                else
                    {
                    muzzleVector = new TransformF(obj.getMuzzleVector(slot));
                    }
                Point3F objectVelocity = obj.getVelocity();

                muzzleVector = muzzleVector.vectorScale(thisobj["wetProjectile.muzzleVelocity"].AsFloat());

                objectVelocity = objectVelocity.vectorScale(thisobj["wetProjectile.velInheritFactor"].AsFloat());
                Point3F muzzleVelocity = muzzleVector.MPosition + objectVelocity;

                Torque_Class_Helper tch = new Torque_Class_Helper(thisobj["projectileType"]);


                tch.Props.Add("dataBlock", thisobj["wetProjectile"]);
                tch.Props.Add("initialVelocity", '"' + muzzleVelocity.AsString() + '"');
                tch.Props.Add("initialPosition", '"' + obj.getMuzzlePoint(slot).AsString() + '"');
                tch.Props.Add("sourceObject", obj);
                tch.Props.Add("sourceSlot", slot.AsString());
                tch.Props.Add("client", obj["client"]);
                tch.Props.Add("sourceClass", obj.getClassName());

                coItem projectile = tch.Create();
                ((coSimSet)"MissionCleanup").pushToBack(projectile);
                }
            }
Exemple #30
0
 public coItem ItemDataCreateItem(coItemData datablock)
     {
     Torque_Class_Helper tch = new Torque_Class_Helper("Item");
     tch.Props.Add("dataBlock", datablock);
     tch.Props.Add("static", "true");
     tch.Props.Add("rotate", "true");
     return tch.Create();
     }