public PointLight(ICore core, TV_3DVECTOR position) : base(core) { Position = new VECTOR3D(position.x, position.y, position.z); this.Color = new MyColor(); mesh = core.Scene.CreateMeshBuilder(); mesh = Core.Scene.CreateBillboard(Helpers.GetTextureFromResource(core, Resources.pointLight), position.x, position.y, position.z, 1.0f, 1.0f); mesh.SetAlphaTest(true); UniqueId = mesh.GetMeshName(); Radius = 30f; LightId = core.LightEngine.CreatePointLight(position, 1f, 1f, 1f, Radius); Core.LightEngine.SetLightProperties(LightId, true, true, true); Name = core.GetName <PointLight>(); }
public Trigger(ICore core) : base(core) { this.core = core; Name = core.GetName <Trigger>(); Color = new MyColor(0, 255, 0); mesh = core.Scene.CreateMeshBuilder(); mesh.CreateBox(1f, 1f, 1f, false); mesh.SetColor(core.Globals.RGBA(Color.R / 255f, Color.G / 255f, Color.B / 255f, 1)); mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); mesh.SetAlphaTest(true); mesh.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ADD); UniqueId = mesh.GetMeshName(); }
public Trigger(ICore core) : base(core) { this.core = core; Name = core.GetName<Trigger>(); Color = new MyColor(0, 255, 0); mesh = core.Scene.CreateMeshBuilder(); mesh.CreateBox(1f, 1f, 1f, false); mesh.SetColor(core.Globals.RGBA(Color.R / 255f, Color.G / 255f, Color.B / 255f, 1)); mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); mesh.SetAlphaTest(true); mesh.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ADD); UniqueId = mesh.GetMeshName(); }
public override void Initialize() { mesh = Scene.CreateMeshBuilder(); switch (Helpers.GetFileFormat(FileName)) { case Helpers.FileFormat.TVM: mesh.LoadTVM(FileName, true, false); break; case Helpers.FileFormat.X: mesh.LoadXFile(FileName, true, false); break; } if (Visible) { mesh.EnableFrustumCulling(true, true); mesh.ComputeNormals(); mesh.ComputeBoundings(); mesh.ComputeOctree(); mesh.SetAlphaTest(true); mesh.SetCullMode(CONST_TV_CULLING.TV_BACK_CULL); mesh.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA); mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); mesh.SetShadowCast(true, true); mesh.SetPosition(Position.x, Position.y, Position.z); mesh.SetRotation(Rotation.x, Rotation.y, Rotation.z); mesh.SetScale(Scale.x, Scale.y, Scale.z); // Physics SetPhysics(); } else { // Hide mesh. for (var i = 0; i < mesh.GetGroupCount(); i++) { mesh.SetGroupEnable(i, false); } } // Register object in Lua. ScriptManager.SetGlobal(Name, this); }
public Sound(ICore core, string fileName) : base(core) { FileName = fileName; Name = core.GetName<Sound>(); TV_3DVECTOR position = Core.Camera.GetFrontPosition(10.0f); Position = new VECTOR3D(position.x, position.y, position.z); Is3D = false; mySound = core.SoundFactory.Load(fileName, Is3D); core.SoundFactory.StopAllSounds(); mesh = core.Scene.CreateBillboard(Helpers.GetTextureFromResource(core, Resources.sound), position.x, position.y, position.z, 1.0f, 1.0f); mesh.SetAlphaTest(true); Stopped = true; Loop = false; volume = 100; UniqueId = mesh.GetMeshName(); }
public DirectionalLight(ICore core, TV_3DVECTOR position) : base(core) { LightId = -1; Position = new VECTOR3D(position.x, position.y, position.z); Direction = GetDirection(); this.Color = new MyColor(); mesh = core.Scene.CreateMeshBuilder(); mesh = Core.Scene.CreateBillboard(Helpers.GetTextureFromResource(core, Resources.directionalLight), position.x, position.y, position.z, 1.0f, 1.0f); mesh.SetAlphaTest(true); UniqueId = mesh.GetMeshName(); LightId = core.LightEngine.CreateDirectionalLight(new TV_3DVECTOR(Direction.X, Direction.Y, Direction.Z), Color.R / 255f, this.Color.G / 255f, this.Color.B / 255f, Helpers.SUN); //core.LightEngine.SetLightAttenuation(LightId, 1f, 0f, 0f); //core.LightEngine.SetSpecularLighting(true); //core.LightEngine.EnableLight(LightId, true); Core.LightEngine.SetLightProperties(LightId, true, true, true); Name = "DirectionalLight"; }
//[Browsable(false)] //public override VECTOR3D Rotation { get; set; } public Particle(ICore core, string fileName) : base(core) { this.core = core; FileName = fileName; Visible = true; Name = core.GetName<Particle>(); TV_3DVECTOR position = Core.Camera.GetFrontPosition(10.0f); Position = new VECTOR3D(position.x, position.y, position.z); mesh = core.Scene.CreateBillboard(Helpers.GetTextureFromResource(core, Resources.particleBig), position.x, position.y, position.z, 1.0f, 1.0f); mesh.SetAlphaTest(true); particle = core.Scene.CreateParticleSystem(); particle.Load(fileName); particle.SetGlobalPosition(Position.X, Position.Y, Position.Z); particle.SetGlobalRotation(Rotation.X, Rotation.Y, Rotation.Z); particle.SetGlobalScale(Scale.X, Scale.Y, Scale.Z); UniqueId = mesh.GetMeshName(); }
//[Browsable(false)] //public override VECTOR3D Rotation { get; set; } public Particle(ICore core, string fileName) : base(core) { this.core = core; FileName = fileName; Visible = true; Name = core.GetName <Particle>(); TV_3DVECTOR position = Core.Camera.GetFrontPosition(10.0f); Position = new VECTOR3D(position.x, position.y, position.z); mesh = core.Scene.CreateBillboard(Helpers.GetTextureFromResource(core, Resources.particleBig), position.x, position.y, position.z, 1.0f, 1.0f); mesh.SetAlphaTest(true); particle = core.Scene.CreateParticleSystem(); particle.Load(fileName); particle.SetGlobalPosition(Position.X, Position.Y, Position.Z); particle.SetGlobalRotation(Rotation.X, Rotation.Y, Rotation.Z); particle.SetGlobalScale(Scale.X, Scale.Y, Scale.Z); UniqueId = mesh.GetMeshName(); }
private void InitObjects() { #region Car //Building PK9 pk_9 = scene.CreateMeshBuilder("pk"); // load the object from an x file pk_9.LoadTVM(@"Models\pk8.tvm", false, false); // set its position pk_9.SetPosition(5.0f, 0.0f, 50.0f); // make the table 3x larger pk_9.SetScale(3, 3, 3); // rotate it 25 degrees around the Y 3D Axis pk_9.RotateY(25, true); // set the tables texture pk_9.SetShadowCast(true, true); pk_9.SetTexture(globals.GetTex("pk9tex"), 0); //Chassis m_chassis = scene.CreateMeshBuilder("mChassis"); m_chassis.LoadTVM(@"Models\chassis.tvm", false, false); m_chassis.SetShadowCast(true, true); m_chassis.SetTexture(globals.GetTex("ChassisSTI"), 0); //m_chassis.SetTextureEx(0, globals.GetTex("ChassisSTI"), 1); //m_chassis.SetTextureEx(1, globals.GetTex("ChassisSTI"), 1); m_chassis.SetTexture(globals.GetTex("UnderCarriage"), 2); m_chassis.SetMaterial(matWindow, 1); m_chassis.SetAlphaTest(true, 0, true, 1); m_chassis.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ADD, 1); m_chassis.SetCullMode(CONST_TV_CULLING.TV_DOUBLESIDED); m_chassis.SetShadowCast(true, true); //Front Left Wheel float scale = 1f; m_fl = scene.CreateMeshBuilder("mfl"); m_fl.LoadTVM(@"Models\wheel_l.tvm", true, true); m_fl.SetScale(scale, scale, scale); m_fl.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); m_fl.SetMaterial(matWheels); m_fl.SetTexture(globals.GetTex("Wheel")); m_fl.SetCullMode(CONST_TV_CULLING.TV_DOUBLESIDED); m_fl.SetShadowCast(true, true); //Front Right Wheel m_rl = scene.CreateMeshBuilder("mrl"); m_rl.LoadTVM(@"Models\wheel_l.tvm", true, true); m_rl.SetScale(scale, scale, scale); m_rl.SetMaterial(matWheels); m_rl.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); m_rl.SetTexture(globals.GetTex("Wheel")); m_rl.SetCullMode(CONST_TV_CULLING.TV_DOUBLESIDED); m_rl.SetShadowCast(true, false); m_rl.SetShadowCast(true, true); //Rear Left Wheel m_fr = scene.CreateMeshBuilder("mfr"); m_fr.LoadTVM(@"Models\wheel_r.tvm", true, true); m_fr.SetScale(scale, scale, scale); m_fr.SetMaterial(matWheels); m_fr.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); m_fr.SetTexture(globals.GetTex("Wheel")); m_fr.SetCullMode(CONST_TV_CULLING.TV_DOUBLESIDED); m_fr.SetShadowCast(true, false); //Rear Right Wheel m_rr = scene.CreateMeshBuilder("mrr"); m_rr.LoadTVM(@"Models\wheel_r.tvm", true, true); m_rr.SetScale(scale, scale, scale); m_rr.SetMaterial(matWheels); m_rr.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); m_rr.SetTexture(globals.GetTex("Wheel")); m_rr.SetCullMode(CONST_TV_CULLING.TV_DOUBLESIDED); m_rr.SetShadowCast(true, false); m_rr.SetShadowCast(true, true); m_chassis.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); m_chassis.SetMaterial(matVehicleBody); m_chassis.ComputeNormals(); m_chassis.ComputeBoundings(); m_chassis.SetScale(scale, scale, scale); #endregion //Add The Physics to the chassis pbi_chassis = physics.CreateMeshBody(1500, m_chassis, CONST_TV_PHYSICSBODY_BOUNDING.TV_BODY_CONVEXHULL); //1500 physics.SetAutoFreeze(pbi_chassis, false); physics.SetBodyPosition(pbi_chassis, 0f, 15, 0f); physics.SetBodyRotation(pbi_chassis, 0f, 0f, 0f); //Create The Vehicle car_ID = physics.CreateVehicle(pbi_chassis); //Do Suspention Settings float susheight = 1.5f; //distance from chassis to wheel 0.5f float susplen = 1.5f; // 10 float susshock = 40f; //Springiness of suspension 10 float susspring = 300f; //Stiffness of suspension 400 flw = physics.AddVehicleWheelEx(car_ID, 25f, 0.5f * scale, 0.372f * scale+0.1f, new TV_3DVECTOR(1, 0, 0), -0.8f * scale, -susheight * scale - 0.1f, 1.25f * scale + 0.5f, 1, 0, 0, susplen, susshock, susspring, m_fl); //fl frw = physics.AddVehicleWheelEx(car_ID, 25f, 0.5f * scale, 0.372f * scale+0.1f, new TV_3DVECTOR(1, 0, 0), 0.8f * scale, -susheight * scale - 0.1f, 1.25f * scale + 0.5f, 1, 0, 0, susplen, susshock, susspring, m_fr); //fr rlw = physics.AddVehicleWheelEx(car_ID, 25f, 0.5f * scale, 0.372f * scale+0.1f, new TV_3DVECTOR(1, 0, 0), -0.8f * scale, -susheight * scale - 0.1f, -1.425f * scale + 0.2f, 1, 0, 0, susplen, susshock, susspring, m_rl); //rl rrw = physics.AddVehicleWheelEx(car_ID, 25f, 0.5f * scale, 0.372f * scale+0.1f, new TV_3DVECTOR(1, 0, 0), 0.8f * scale, -susheight * scale - 0.1f, -1.425f * scale + 0.2f, 1, 0, 0, susplen, susshock, susspring, m_rr); //rr //Change the car's center of mass / make it drive better physics.SetBodyCenterOfMass(car_ID, new TV_3DVECTOR(0, -1.0f, 10f)); //Add wheel frictions //Note that this code will also stop sliding on slopes float sideslip = 0.1f; float sideslipcoef = 0f; float maxlongslide = 10000f; float maxlongslidecoef = 0f; physics.SetVehicleWheelParameters(car_ID, flw, sideslip, sideslipcoef, maxlongslide, maxlongslidecoef); physics.SetVehicleWheelParameters(car_ID, frw, sideslip, sideslipcoef, maxlongslide, maxlongslidecoef); physics.SetVehicleWheelParameters(car_ID, rlw, sideslip, sideslipcoef, maxlongslide, maxlongslidecoef); physics.SetVehicleWheelParameters(car_ID, rrw, sideslip, sideslipcoef, maxlongslide, maxlongslidecoef); }
public Mesh(ICore core, ProgramSettings settings, string fileName) : base(core) { this.core = core; this.settings = settings; mass = 0f; staticFriction = 0.9f; kineticFriction = 0.5f; softness = 0.1f; bounciness = 0.1f; materialIdx = -1; SetMaterialToCustom(); FileName = fileName; customTexture = string.Empty; //Name = fileName.Split(new[] { '\\' }).Last(); PhysicsId = -1; enableLightning = true; Name = core.GetName <Mesh>(); string ending = fileName.Split(new[] { '\\' }).Last().ToUpper(); mesh = core.Scene.CreateMeshBuilder(); if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.TVM))) { mesh.LoadTVM(fileName, true, false); } else if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.X))) { mesh.LoadXFile(fileName, true, false); } else if (ending.EndsWith(Helpers.GetFileExtension(Helpers.FileFormat.TVA))) { TVActor actor = core.Scene.CreateActor(); actor.Load(fileName, true, false); mesh = actor.GetDeformedMesh(); core.Scene.DestroyAllActors(); IsAnimated = true; } else { return; } mesh.EnableFrustumCulling(true, true); mesh.ComputeNormals(); mesh.ComputeBoundings(); mesh.ComputeOctree(); mesh.SetCullMode(CONST_TV_CULLING.TV_BACK_CULL); mesh.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA); mesh.SetAlphaTest(true); mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); mesh.SetShadowCast(true, true); lightmapIdx = mesh.GetTextureEx((int)CONST_TV_LAYER.TV_LAYER_LIGHTMAP); textureScale = new UV(1.0f, 1.0f); LoadTextures(); UniqueId = mesh.GetMeshName(); }
public override void Initialize() { mesh = Scene.CreateMeshBuilder(); switch (Helpers.GetFileFormat(FileName)) { case Helpers.FileFormat.TVM: mesh.LoadTVM(FileName, true, false); break; case Helpers.FileFormat.X: mesh.LoadXFile(FileName, true, false); break; } if (Visible) { mesh.EnableFrustumCulling(true, true); mesh.ComputeNormals(); mesh.ComputeBoundings(); mesh.ComputeOctree(); mesh.SetAlphaTest(true); mesh.SetCullMode(CONST_TV_CULLING.TV_BACK_CULL); mesh.SetBlendingMode(CONST_TV_BLENDINGMODE.TV_BLEND_ALPHA); mesh.SetLightingMode(CONST_TV_LIGHTINGMODE.TV_LIGHTING_MANAGED); mesh.SetShadowCast(true, true); mesh.SetPosition(Position.x, Position.y, Position.z); mesh.SetRotation(Rotation.x, Rotation.y, Rotation.z); mesh.SetScale(Scale.x, Scale.y, Scale.z); // Physics SetPhysics(); } else { // Hide mesh. for (var i = 0; i < mesh.GetGroupCount(); i++) mesh.SetGroupEnable(i, false); } // Register object in Lua. ScriptManager.SetGlobal(Name, this); }