本文整理汇总了C#中GraphicFactory.CreateTexture2DColor方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicFactory.CreateTexture2DColor方法的具体用法?C# GraphicFactory.CreateTexture2DColor怎么用?C# GraphicFactory.CreateTexture2DColor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicFactory
的用法示例。
在下文中一共展示了GraphicFactory.CreateTexture2DColor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
SerializatorWrapper SerializatorWrapper = new SerializatorWrapper();
SerializatorWrapper.Serialize(new Vector3(10, 20, 30), "vetor.xml");
Vector3 vec = (Vector3) SerializatorWrapper.Desserialize<Vector3>("vetor.xml", null);
Debug.Assert(vec.X == 10);
Debug.Assert(vec.Y == 20);
Debug.Assert(vec.Z == 30);
ObjectMock ObjectMock = new ObjectMock(GraphicFactory, "Model/cenario", Vector3.Zero, Matrix.Identity, Vector3.One);
SerializatorWrapper.Serialize(ObjectMock, "cena.xml");
ObjectMock mloaded = (ObjectMock)SerializatorWrapper.Desserialize<ObjectMock>("cena.xml", GraphicFactory);
this.World.AddObject(mloaded);
IObject obj;
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//ball");
simpleModel.SetTexture(factory.CreateTexture2DColor(1,1,Color.Green),TextureType.DIFFUSE);
SphereObject tmesh = new SphereObject(new Vector3(100, 200, 10), 1 ,10, 5, MaterialDescription.DefaultBepuMaterial());
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
this.BindInput(new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Keys.Space,
(a) =>
{
this.World.RemoveObject(obj);
DynamicObjectSaver DynamicObjectSaver = new Serialization.DynamicObjectSaver(obj.Modelo.Name, obj.PhysicObject.Position, obj.PhysicObject.Rotation, obj.PhysicObject.Scale, obj.PhysicObject.Velocity, obj.PhysicObject.AngularVelocity);
SerializatorWrapper.Serialize(DynamicObjectSaver, "dyn.xml");
DynamicObjectSaver dloaded = (DynamicObjectSaver)SerializatorWrapper.Desserialize<DynamicObjectSaver>("dyn.xml");
SimpleModel simpleModel = new SimpleModel(factory, dloaded.modelName);
simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green), TextureType.DIFFUSE);
SphereObject tmesh = new SphereObject(dloaded.position, 1, 10, dloaded.scale.X, MaterialDescription.DefaultBepuMaterial());
tmesh.Rotation = dloaded.orientation;
tmesh.Velocity = dloaded.LinearVelocity;
tmesh.AngularVelocity = dloaded.AngularVelocity;
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
saved++;
}
));
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
}
示例2: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
{
SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10, 0.5f);
BaseObject marine = new BaseObject(fmaterial, character.Characterobj,sm);
this.World.AddObject(marine);
///ever !!!
marine.Behavior = new Repeater<BaseObject>(
new Watch<BaseObject>(
(a,b)=>
{
///condition
if(a.PhysicObject.Position.Length() < 100)
{
return TaskResult.Failure;
}
return TaskResult.Success;
}
,
///chnage its color =P
new BehaviorTrees.Action<BaseObject>(
(a,b)=>
{
a.Modelo.SetTexture(factory.CreateTexture2DColor(1,1,StaticRandom.RandomColor()),TextureType.DIFFUSE);
return TaskResult.Success;
}
)
)
);
}
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
}
示例3: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
///Create the Terrain Object
///Controls how the heigh map is loaded
TerrainObject to = new TerrainObject(factory, "..\\Content\\Textures\\Untitled", Vector3.Zero, Matrix.Identity, MaterialDescription.DefaultBepuMaterial(), 1, 1,10);
///Create the Model using the Terrain Object. Here we pass the textures used, in our case we are using MultiTextured Terrain so we pass lots of textures
TerrainModel stm = new TerrainModel(factory, to, "TerrainName", "..\\Content\\Textures\\Terraingrass");
stm.SetTexture(factory.CreateTexture2DColor(1,1,Color.Green), TextureType.DIFFUSE);
///Create the shader
///In this sample we passed lots of textures, each one describe a level in the terrain, the ground is the sand and grass. the hills are rocks and the "mountains" are snow
///They are interpolated in the shader, you can control how using the shader parameters exposed in the DeferredTerrainShader
ForwardXNABasicShader shader = new ForwardXNABasicShader();
///Deferred material
ForwardMaterial fmaterial = new ForwardMaterial(shader);
///The object itself
IObject obj = new IObject(fmaterial, stm, to);
///Add to the world
this.World.AddObject(obj);
shader.BasicEffect.EnableDefaultLighting();
CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo.Viewport);
this.World.CameraManager.AddCamera(cam);
}
示例4: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
simpleModel.SetTexture(factory.CreateTexture2DColor(1,1,Color.Gray), TextureType.MULTITEX1);
TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
//ForwardDualTextureShader shader = new ForwardDualTextureShader();
ForwardEnvironmentShader shader = new ForwardEnvironmentShader(factory.GetTextureCube("Textures//grassCUBE"));
ForwardMaterial fmaterial = new ForwardMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//uzi");
TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, new Vector3(100,10,10), Matrix.Identity, Vector3.One * 10, MaterialDescription.DefaultBepuMaterial());
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
this.RenderTechnic.AddPostEffect(new BlackWhitePostEffect());
}
示例5: LoadContent
/// <summary>
/// Load content for the screen.
/// </summary>
/// <param name="GraphicInfo"></param>
/// <param name="factory"></param>
/// <param name="contentManager"></param>
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
{
///Create a simple object
///Geomtric Info and textures (this model automaticaly loads the texture)
SimpleModel simpleModel = new SimpleModel(factory, "model/dude");
for (int i = 0; i < simpleModel.GetTextureInformation(0).Count(); i++)
{
simpleModel.GetTextureInformation(0)[i].SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
}
///Physic info (position, rotation and scale are set here)
GhostObject pi = new GhostObject(new Vector3(200, 10, 0), Matrix.Identity, new Vector3(4));
///Shader info (must be a deferred type)
ForwardGradativeAlphaShader shader = new ForwardGradativeAlphaShader();
///Material info (must be a deferred type also)
ForwardMaterial fmaterial = new ForwardMaterial(shader);
///The object itself
IObject obj = new IObject(fmaterial, simpleModel, pi);
///Add to the world
this.World.AddObject(obj);
}
{
///Create a simple object
///Geomtric Info and textures (this model automaticaly loads the texture)
SimpleModel simpleModel = new SimpleModel(factory, "model/dude");
//simpleModel.SetTexture(factory.CreateTexture2DColor(1,1,Color.Red), TextureType.DIFFUSE);
///Physic info (position, rotation and scale are set here)
GhostObject pi = new GhostObject(new Vector3(200, 10, 0), Matrix.Identity, new Vector3(4));
///Shader info (must be a deferred type)
ForwardEMTransparentShader shader = new ForwardEMTransparentShader("Textures/Cubemap");
///Material info (must be a deferred type also)
ForwardMaterial fmaterial = new ForwardMaterial(shader);
///The object itself
IObject obj = new IObject(fmaterial, simpleModel, pi);
///Add to the world
this.World.AddObject(obj);
}
{
SimpleModel simpleModel = new SimpleModel(factory, "model/cenario");
///Physic info (position, rotation and scale are set here)
TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
///Forward Shader (look at this shader construction for more info)
ForwardXNABasicShader shader = new ForwardXNABasicShader();
///Deferred material
ForwardMaterial fmaterial = new ForwardMaterial(shader);
///The object itself
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
///Add to the world
//this.World.AddObject(obj);
}
///add a camera
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
}
示例6: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;
base.LoadContent(GraphicInfo, factory, contentManager);
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
StillDesign.PhysX.Material material1 = PhysxPhysicWorld.CreatePhysicMaterial(
new StillDesign.PhysX.MaterialDescription()
{
Restitution = 0.3f,
DynamicFriction = 0.5f,
StaticFriction = 1,
}
);
PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
Matrix.Identity, Vector3.One, 1, material1);
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);
this.AttachCleanUpAble(BallThrowBullet);
for (int i = 0; i < 10; i++)
{
StillDesign.PhysX.Material material2 = PhysxPhysicWorld.CreatePhysicMaterial(
new StillDesign.PhysX.MaterialDescription()
{
Restitution = PloobsEngine.Utils.StaticRandom.RandomBetween(0,1),
DynamicFriction = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
StaticFriction = PloobsEngine.Utils.StaticRandom.RandomBetween(0, 1),
RestitutionCombineMode = CombineMode.Max,
}
);
///Load a Model with a custom texture
SimpleModel sm2 = new SimpleModel(factory, "Model\\ball");
sm2.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green, false), TextureType.DIFFUSE);
ForwardXNABasicShader nd = new ForwardXNABasicShader();
IMaterial m = new ForwardMaterial(nd);
SphereShapeDescription SphereGeometry = new SphereShapeDescription(5f);
SphereGeometry.Material = material2;
PhysxPhysicObject PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
0.5f, Matrix.CreateTranslation(new Vector3(100,100,50 * i)), Vector3.One * 5f);
IObject o = new IObject(m, sm2, PhysxPhysicObject);
this.World.AddObject(o);
}
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
}
示例7: LoadContent
/// <summary>
/// Load content for the screen.
/// </summary>
/// <param name="GraphicInfo"></param>
/// <param name="factory"></param>
/// <param name="contentManager"></param>
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);
CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);
dlines = new DebugLines();
ddrawer.AddShape(dlines);
Picking pick = new Picking(this,2000);
pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton);
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
///Physic info (position, rotation and scale are set here)
BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
tmesh.isMotionLess = true;
///Forward Shader (look at this shader construction for more info)
ForwardXNABasicShader shader = new ForwardXNABasicShader();
///Deferred material
ForwardMaterial fmaterial = new ForwardMaterial(shader);
///The object itself
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
///Add to the world
this.World.AddObject(obj);
}
wh = new WaypointHandler();
wh.LoadConnectedWaypoints("waypoints.xml");
start = wh.CurrentWaypointsCollection.GetWaypointsList()[0];
{
///Procedural yellow diffuse texture
SimpleModel sm = new SimpleModel(factory, "Model\\block");
sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
///physic Ghost object(no collision)
GhostObject pi = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5));
ForwardXNABasicShader s = new ForwardXNABasicShader();
ForwardMaterial mat = new ForwardMaterial(s);
IObject obj4 = new IObject(mat, sm, pi);
this.World.AddObject(obj4);
}
///add a camera
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
{
SimpleModel sm = new SimpleModel(factory, "Model\\block");
sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
GhostObject pi = new GhostObject(start.WorldPos, Matrix.Identity, new Vector3(5));
ForwardXNABasicShader s = new ForwardXNABasicShader();
ForwardMaterial mat = new ForwardMaterial(s);
IObject obj4 = new IObject(mat, sm, pi);
obj4.OnUpdate += new OnUpdate(obj4_OnUpdate);
this.World.AddObject(obj4);
}
}
示例8: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
{
SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
DeferredNormalShader shader = new DeferredNormalShader();
IMaterial mat = new DeferredMaterial(shader);
CharacterControllerInput character = new CharacterControllerInput(this, new Vector3(100, 150, 1), 1, 1, 50, Vector3.One * 10,0.5f);
marine = new IObject(mat, sm, character.Characterobj);
this.World.AddObject(marine);
LightThrowBepu lt = new LightThrowBepu(this.World, factory);
}
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
DeferredNormalShader shader = new DeferredNormalShader();
DeferredMaterial fmaterial = new DeferredMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
#region NormalLight
DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
float li = 0.5f;
ld1.LightIntensity = li;
ld2.LightIntensity = li;
ld3.LightIntensity = li;
ld4.LightIntensity = li;
ld5.LightIntensity = li;
this.World.AddLight(ld1);
this.World.AddLight(ld2);
this.World.AddLight(ld3);
this.World.AddLight(ld4);
this.World.AddLight(ld5);
#endregion
CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
cam.MoveSpeed *= 5;
this.World.CameraManager.AddCamera(cam);
SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grasscube");
CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
}
示例9: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
base.LoadContent(GraphicInfo,factory, contentManager);
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
DeferredNormalShader shader = new DeferredNormalShader();
DeferredMaterial fmaterial = new DeferredMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
{
SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
BoxObject pi = new BoxObject(new Vector3(100, 40, 0), 1, 1, 1, 25, new Vector3(100, 10, 100), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
DeferredNormalShader shader = new DeferredNormalShader();
IMaterial mat = new DeferredMaterial(shader);
IObject obj3 = new IObject(mat, sm, pi);
this.World.AddObject(obj3);
}
#region NormalLight
DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
float li = 0.5f;
ld1.LightIntensity = li;
ld2.LightIntensity = li;
ld3.LightIntensity = li;
ld4.LightIntensity = li;
ld5.LightIntensity = li;
this.World.AddLight(ld1);
this.World.AddLight(ld2);
this.World.AddLight(ld3);
this.World.AddLight(ld4);
this.World.AddLight(ld5);
#endregion
//SBlurPost hsv = new SBlurPost(1, SurfaceFormat.HdrBlendable);
//hsv.ImageSamplerState = SamplerState.PointClamp;
//this.RenderTechnic.AddPostEffect(hsv);
DownSamplePostEffect DownSamplePostEffect = new Post.DownSamplePostEffect();
this.RenderTechnic.AddPostEffect(DownSamplePostEffect);
CameraFirstPerson cam = new CameraFirstPerson(GraphicInfo);
cam.MoveSpeed *= 5;
this.World.CameraManager.AddCamera(cam);
LightThrowBepu lt = new LightThrowBepu(this.World, factory);
}
示例10: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Red), TextureType.DIFFUSE);
BoxObject tmesh = new BoxObject(new Vector3(0), 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
tmesh.isMotionLess = true;
ForwardTransparenteShader shader = new ForwardTransparenteShader();
shader.TransparencyLevel = 0.2f;
ForwardMaterial fmaterial = new ForwardMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
Simulator.setTimeStep(0.10f);
Simulator.setAgentDefaults(15.0f, 25, 5.0f, 5.0f, 2.0f,new Vector3());
for (int i = 0; i < 20; i++)
{
for (int j = 0; j < 20; j++)
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
GhostObject tmesh = new GhostObject(new Vector3(100 + j * 15, 5, i * 15), Matrix.Identity, new Vector3(1, 1, 1));
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
int id = Simulator.addAgent(tmesh.Position);
RVOObject obj = new RVOObject(id, fmaterial, simpleModel, tmesh);
obj.OnUpdate += new OnUpdate(obj_OnUpdate); /// dummy position update way =p
this.World.AddObject(obj);
}
}
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
Picking p = new Picking(this, 1000);
p.OnPickedLeftButton += new OnPicked(p_OnPickedLeftButton);
}
示例11: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;
base.LoadContent(GraphicInfo, factory, contentManager);
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
BoxShapeDescription SphereGeometry = new BoxShapeDescription(1000, 5, 1000);
PhysxPhysicObject PhysxPhysicObject = new PhysxPhysicObject(SphereGeometry,
Matrix.Identity, new Vector3(1000, 5, 1000));
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, PhysxPhysicObject);
this.World.AddObject(obj);
shader.BasicEffect.EnableDefaultLighting();
}
{
///very basic vehicle !!!
///no wheels also =P
Vehicle Vehicle = new Vehicle(PhysxPhysicWorld.Scene);
SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Green));
PhysxPhysicObject tmesh = new PhysxPhysicObject(Vehicle.VehicleBodyActor, new Vector3(5, 3, 7));
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
UserObject<Vehicle> obj = new UserObject<Vehicle>(fmaterial, simpleModel, tmesh,Vehicle);
obj.OnUserUpdate += new Action<UserObject<StillDesign.PhysX.Samples.Vehicle>>(obj_OnUserUpdate);
this.World.AddObject(obj);
}
BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);
this.AttachCleanUpAble(BallThrowBullet);
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
}
示例12: LoadContent
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory ,IContentManager contentManager)
{
PhysxPhysicWorld PhysxPhysicWorld = World.PhysicWorld as PhysxPhysicWorld;
base.LoadContent(GraphicInfo, factory, contentManager);
{
SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
PhysxTriangleMesh tmesh = new PhysxTriangleMesh(PhysxPhysicWorld, simpleModel,
Matrix.Identity, Vector3.One);
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial fmaterial = new ForwardMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
}
{
///Controller description
///YOu have BoxControllerDescription and SphereControllerDescription
BoxControllerDescription desc = new BoxControllerDescription(1, 1, 1);
desc.UpDirection = Axis.Y;
desc.SlopeLimit = 0;
desc.SkinWidth = 0.2f;
desc.StepOffset = 0.5f;
desc.InteractionFlag = CCTInteractionFlag.Include | CCTInteractionFlag.UseFilter;
SimpleModel sm = new SimpleModel(factory, "..\\Content\\Model\\block");
sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Blue), TextureType.DIFFUSE);
ForwardXNABasicShader shader = new ForwardXNABasicShader(ForwardXNABasicShaderDescription.Default());
ForwardMaterial mat = new ForwardMaterial(shader);
///Character Object
PhysxBoxCharacterObject PhysxCapsuleCharacterObject = new PhysxBoxCharacterObject(desc, new Vector3(50) ,Matrix.Identity, Vector3.One * 5);
IObject marine = new IObject(mat, sm, PhysxCapsuleCharacterObject);
this.World.AddObject(marine);
marine.OnUpdate += new OnUpdate(marine_OnUpdate);
}
BallThrowPhysx28 BallThrowBullet = new BallThrowPhysx28(this.World, GraphicFactory);
this.AttachCleanUpAble(BallThrowBullet);
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
}
示例13: LoadContent
/// <summary>
/// Load content for the screen.
/// </summary>
/// <param name="GraphicInfo"></param>
/// <param name="factory"></param>
/// <param name="contentManager"></param>
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
RegisterDebugDrawCommand rc = new RegisterDebugDrawCommand(ddrawer);
CommandProcessor.getCommandProcessor().SendCommandAssyncronous(rc);
dlines = new DebugLines();
ddrawer.AddShape(dlines);
Picking pick = new Picking(this,2000);
pick.OnPickedLeftButton += new OnPicked(pick_OnPickedLeftButton);
wh = new WaypointHandler();
SimpleModel simpleModel = new SimpleModel(factory, "Model//block");
simpleModel.SetTexture(factory.CreateTexture2DColor(1, 1, Color.White), TextureType.DIFFUSE);
///Physic info (position, rotation and scale are set here)
BoxObject tmesh = new BoxObject(Vector3.Zero, 1, 1, 1, 10, new Vector3(1000, 1, 1000), Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
tmesh.isMotionLess = true;
///Forward Shader (look at this shader construction for more info)
ForwardXNABasicShader shader = new ForwardXNABasicShader();
///Deferred material
ForwardMaterial fmaterial = new ForwardMaterial(shader);
///The object itself
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
///Add to the world
this.World.AddObject(obj);
{
InputPlayableKeyBoard ipk = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS,Microsoft.Xna.Framework.Input.Keys.Space);
ipk.KeyStateChange += new KeyStateChange(ipk_KeyStateChange);
this.BindInput(ipk);
}
{
InputPlayableKeyBoard ipk = new SimpleConcreteKeyboardInputPlayable(StateKey.PRESS, Microsoft.Xna.Framework.Input.Keys.Enter);
ipk.KeyStateChange += new KeyStateChange(ipk_KeyStateChange2);
this.BindInput(ipk);
}
///add a camera
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
}
示例14: LoadContent
/// <summary>
/// Load content for the screen.
/// </summary>
/// <param name="GraphicInfo"></param>
/// <param name="factory"></param>
/// <param name="contentManager"></param>
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
///Forward Shader (look at this shader construction for more info)
TerrainMaterial material = new TerrainMaterial(factory, "Terrain//HeightMap");
///The object itself
TerrainObject to = new TerrainObject(factory, Vector3.Zero, Matrix.Identity, material.Model.GetHeights(), MaterialDescription.DefaultBepuMaterial());
IObject obj = new IObject(material, null, to);
///Add to the world
this.World.AddObject(obj);
///add a camera
this.World.CameraManager.AddCamera(new CameraFirstPerson(GraphicInfo));
Texture2D t = factory.CreateTexture2DColor(1,1,Color.Red);
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 5; j++)
{
SimpleModel simpleModel = new SimpleModel(factory, "Model/block");
simpleModel.SetTexture(t);
///Physic info (position, rotation and scale are set here)
BoxObject tmesh = new BoxObject(new Vector3(j * 10 + 200,100,i * 10 + 200), 1, 1, 1, 10, Vector3.One * 2, Matrix.Identity, MaterialDescription.DefaultBepuMaterial());
///Forward Shader (look at this shader construction for more info)
ForwardXNABasicShader shader = new ForwardXNABasicShader();
///Forward material
ForwardMaterial fmaterial = new ForwardMaterial(shader);
///The object itself
obj = new IObject(fmaterial, simpleModel, tmesh);
///Add to the world
this.World.AddObject(obj);
}
}
}
示例15: LoadContent
/// <summary>
/// Load content for the screen.
/// </summary>
/// <param name="GraphicInfo"></param>
/// <param name="factory"></param>
/// <param name="contentManager"></param>
protected override void LoadContent(GraphicInfo GraphicInfo, GraphicFactory factory, IContentManager contentManager)
{
base.LoadContent(GraphicInfo, factory, contentManager);
///Classic Island
SimpleModel simpleModel = new SimpleModel(factory, "Model//cenario");
TriangleMeshObject tmesh = new TriangleMeshObject(simpleModel, Vector3.Zero, Matrix.Identity, Vector3.One, MaterialDescription.DefaultBepuMaterial());
DeferredNormalShader shader = new DeferredNormalShader();
DeferredMaterial fmaterial = new DeferredMaterial(shader);
IObject obj = new IObject(fmaterial, simpleModel, tmesh);
this.World.AddObject(obj);
{
///Procedural yellow diffuse texture
SimpleModel sm = new SimpleModel(factory, "Model\\block");
sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.BlueViolet), TextureType.DIFFUSE);
///physic Ghost object(no collision)
GhostObject pi = new GhostObject(new Vector3(0, 0, 0), Matrix.Identity, new Vector3(500, 500, 500));
pi.isMotionLess = true;
///Transparency shader
///Transparent objects are NOT affected by lights
///It is a forward shader in the deferred engine (applied after all deferreed processing)
ForwardTransparenteShader s = new ForwardTransparenteShader();
///If the texture does not have Alpha, you can create an alpha for all the model
s.TransparencyLevel = 0.3f;
///THIS MODEL is DRAW AFTER all the Deferred ones (remember:light wont afect it)
///You can use all the forward material the same way we are using this
ForwardMaterial mat = new ForwardMaterial(s);
IObject obj4 = new IObject(mat, sm, pi);
this.World.AddObject(obj4);
}
///Transparent blocks
for (int k = 0; k < 5; k++)
{
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 5; j++)
{
///Procedural yellow diffuse texture
SimpleModel sm = new SimpleModel(factory, "Model\\block");
sm.SetTexture(factory.CreateTexture2DColor(1, 1, Color.Yellow), TextureType.DIFFUSE);
///physic Ghost object(no collision)
GhostObject pi = new GhostObject(new Vector3(i * 10, 50 + k * 10, j * 10), Matrix.Identity, new Vector3(5));
pi.isMotionLess = true;
///Transparency shader
///Transparent objects are NOT affected by lights
///It is a forward shader in the deferred engine (applied after all deferreed processing)
ForwardTransparenteShader s = new ForwardTransparenteShader();
///If the texture does not have Alpha, you can create an alpha for all the model
s.TransparencyLevel = 0.3f;
///THIS MODEL is DRAW AFTER all the Deferred ones (remember:light wont afect it)
///You can use all the forward material the same way we are using this
ForwardMaterial mat = new ForwardMaterial(s);
IObject obj4 = new IObject(mat, sm, pi);
this.World.AddObject(obj4);
}
}
}
#region NormalLight
DirectionalLightPE ld1 = new DirectionalLightPE(Vector3.Left, Color.White);
DirectionalLightPE ld2 = new DirectionalLightPE(Vector3.Right, Color.White);
DirectionalLightPE ld3 = new DirectionalLightPE(Vector3.Backward, Color.White);
DirectionalLightPE ld4 = new DirectionalLightPE(Vector3.Forward, Color.White);
DirectionalLightPE ld5 = new DirectionalLightPE(Vector3.Down, Color.White);
float li = 0.5f;
ld1.LightIntensity = li;
ld2.LightIntensity = li;
ld3.LightIntensity = li;
ld4.LightIntensity = li;
ld5.LightIntensity = li;
this.World.AddLight(ld1);
this.World.AddLight(ld2);
this.World.AddLight(ld3);
this.World.AddLight(ld4);
this.World.AddLight(ld5);
#endregion
CameraFirstPerson cam = new CameraFirstPerson(MathHelper.ToRadians(30), MathHelper.ToRadians(-10), new Vector3(200, 150, 250), GraphicInfo);
this.World.CameraManager.AddCamera(cam);
SkyBoxSetTextureCube stc = new SkyBoxSetTextureCube("Textures//grassCUBE");
CommandProcessor.getCommandProcessor().SendCommandAssyncronous(stc);
}