private PrimitiveMapping ImportPrimitiveMapping(PrimitiveModel model, string dataType) { PrimitiveMapping mapping = new PrimitiveMapping(); mapping.IsSoap = true; if (dataType.Length > 0) { mapping.TypeDesc = _typeScope.GetTypeDesc(dataType, XmlSchema.Namespace); if (mapping.TypeDesc == null) { // try it as a non-Xsd type mapping.TypeDesc = _typeScope.GetTypeDesc(dataType, UrtTypes.Namespace); if (mapping.TypeDesc == null) { throw new InvalidOperationException(SR.Format(SR.XmlUdeclaredXsdType, dataType)); } } } else { mapping.TypeDesc = model.TypeDesc; } mapping.TypeName = mapping.TypeDesc.DataType.Name; mapping.Namespace = mapping.TypeDesc.IsXsdType ? XmlSchema.Namespace : UrtTypes.Namespace; return(mapping); }
private GeometryNode ObstModel; //Geometry Node und Model #endregion #region Constructor public Game_Weapon(PrimitiveModel BulletModel, Material BulletMaterial, MarkerNode GrdMarkerNode) { FOV = NORMAL_FOV; DeltaGiro = DELTA_THETA; Active = true; ActAngle = 0; InitAngle = 0; MaxAng = 360; RadActAngle = 0; GirDir = RotDirection.RECHS; RotaMode = RotMode.CONTINUE; this.BulletModel = BulletModel; BulletMat = BulletMaterial; GMarkerNode = GrdMarkerNode; WBullets = new List <Bullet>(); //Config type of Shoot WaitBullet = WAIT_SHOOT; CountToShoot = WaitBullet; ReloadTime = WAIT_RELOAD; CountToReload = 0; CountOfBullets = 0; NumBullets = Game_Logic.MAX_BULLET; RadOffset = Math.PI * (95) / 180.0; BulletOffset = new Vector3(0, 10, 30); }
private TransformNode BulletTrans; //Transfor Node for Bullet #endregion #region Constructors public Bullet(Vector3 InitPos, PrimitiveModel BulletModel, Material Material, Vector3 DirBullet, MarkerNode grdMarkerNode) { //Create Bullet ShootBullet = new GeometryNode(); ShootBullet.Name = "ShootBullet" + ShootBullet.ID; ShootBullet.Model = BulletModel; ShootBullet.Material = Material; ShootBullet.Physics.Interactable = true; ShootBullet.Physics.Collidable = true; ShootBullet.Physics.Shape = GoblinXNA.Physics.ShapeType.Box; ShootBullet.Physics.Mass = 60f; ShootBullet.Physics.MaterialName = "Bullet"; ShootBullet.AddToPhysicsEngine = true; // Assign the initial velocity to this shooting box ShootBullet.Physics.InitialLinearVelocity = new Vector3(DirBullet.X * 80, DirBullet.Y * 80, DirBullet.Z * 50); BulletTrans = new TransformNode(); BulletTrans.Translation = InitPos; grdMarkerNode.AddChild(BulletTrans); BulletTrans.AddChild(ShootBullet); //Normal asignament isvisible = true; //Agrego Segundo desde que se creo livetime = Convert.ToInt32(DateTime.Now.TimeOfDay.TotalSeconds) + BULLET_TIMELIVE; }
protected override JToken SerializeWithoutMetadata(ValueModel model) { PrimitiveModel prim = model as PrimitiveModel; if (prim.Value == null || prim.StoreAs == null) { return(JValue.CreateNull()); } return(new JValue(Convert.ChangeType(prim.Value, prim.StoreAs))); }
internal TypeModel GetTypeModel(Type type, bool directReference) { TypeModel model; if (_models.TryGetValue(type, out model)) { return(model); } TypeDesc typeDesc = _typeScope.GetTypeDesc(type, null, directReference); switch (typeDesc.Kind) { case TypeKind.Enum: model = new EnumModel(type, typeDesc, this); break; case TypeKind.Primitive: model = new PrimitiveModel(type, typeDesc, this); break; case TypeKind.Array: case TypeKind.Collection: case TypeKind.Enumerable: model = new ArrayModel(type, typeDesc, this); break; case TypeKind.Root: case TypeKind.Class: case TypeKind.Struct: model = new StructModel(type, typeDesc, this); break; default: if (!typeDesc.IsSpecial) { throw new NotSupportedException(SR.Format(SR.XmlUnsupportedTypeKind, type.FullName)); } model = new SpecialModel(type, typeDesc, this); break; } _models.Add(type, model); return(model); }
public DatatypeModel HandleAsObject(string s) { string temp = s; temp.Remove(s.IndexOf('{')); temp.Remove(s.LastIndexOf('}') - 1); ClassModel result = new ClassModel(); List <Tuple <string, string> > tempSeperated = Seperate(temp); foreach (Tuple <string, string> t in tempSeperated) { if (t.Item2.Contains('{') || t.Item2.Contains('}')) { HandleAsObject(s); } else { if (t.Item2.Contains('[') || t.Item2.Contains(']')) { result.properties.Add(new PropertyModel() { property = HandleAsArray(t.Item2) }); result.properties.Last().property.name = t.Item1; } else { PrimitiveModel prim = new PrimitiveModel(); prim.name = t.Item1; prim.type = parser(t.Item2).ToString(); result.properties.Add(new PropertyModel() { property = prim }); } } } return(result); }
public DatatypeModel HandleAsArray(string s) { string sTemp = s.Remove(s.IndexOf('[')).Remove(s.LastIndexOf(']')); CompositeModel result = new CompositeModel(); if (sTemp.Contains('{') || sTemp.Contains('}')) { result.datatypeModel = new ClassModel(); } else { if (sTemp.Contains('[') || sTemp.Contains(']')) { List <Tuple <string, string> > tempSeperated = Seperate(sTemp); foreach (Tuple <string, string> t in tempSeperated) { if (t.Item2.Contains('{') || t.Item2.Contains('}')) { HandleAsObject(s); } else { if (t.Item2.Contains('[') || t.Item2.Contains(']')) { result.datatypeModel = HandleAsArray(t.Item2); result.name = t.Item1; } else { PrimitiveModel prim = new PrimitiveModel(); prim.name = t.Item1; prim.type = parser(t.Item2).ToString(); result.datatypeModel = prim; } } } } } return(result); }
public Graphics3D(MarkerNode MarkerNode, IShadowMap ShadowMap) { //Asignation Ground Node this.groundMarkerNode = MarkerNode; //Asignation Shadow Map this.GShadowMap = ShadowMap; //Add Big Parent for All Scenary Elements parentTNodeGrd = new TransformNode(); parentTNodeGrd.Name = "Level"; groundMarkerNode.AddChild(parentTNodeGrd); // Create a material for the model BulletrMat = new Material(); BulletrMat.Diffuse = Color.Blue.ToVector4(); BulletrMat.Specular = Color.White.ToVector4(); BulletrMat.SpecularPower = 10; //create Bullet Model BulletModel = new TexturedBox(2.0f); LoadLevel = false; LoadCars = false; }
private void CreateObjects() { // Create a model of box and sphere boxModel = new Box(Vector3.One); PrimitiveModel sphereModel = new Sphere(1f, 20, 20); // Create our ground plane GeometryNode groundNode = new GeometryNode("Ground"); groundNode.Model = boxModel; // Define the material name of this ground model groundNode.Physics.MaterialName = "Ground"; // Make this ground plane collidable, so other collidable objects can collide // with this ground groundNode.Physics.Collidable = true; groundNode.Physics.Shape = GoblinXNA.Physics.ShapeType.Box; groundNode.AddToPhysicsEngine = true; // Create a material for the ground Material groundMaterial = new Material(); groundMaterial.Diffuse = Color.LightGreen.ToVector4(); groundMaterial.Specular = Color.White.ToVector4(); groundMaterial.SpecularPower = 20; groundNode.Material = groundMaterial; // Create a parent transformation for both the ground and the sphere models TransformNode parentTransNode = new TransformNode(); parentTransNode.Translation = new Vector3(0, -10, -20); // Create a scale transformation for the ground to make it bigger TransformNode groundScaleNode = new TransformNode(); groundScaleNode.Scale = new Vector3(100, 1, 100); // Add this ground model to the scene scene.RootNode.AddChild(parentTransNode); parentTransNode.AddChild(groundScaleNode); groundScaleNode.AddChild(groundNode); // Create a material that will be applied to all of the sphere models Material sphereMaterial = new Material(); sphereMaterial.Diffuse = Color.Cyan.ToVector4(); sphereMaterial.Specular = Color.White.ToVector4(); sphereMaterial.SpecularPower = 10; Random rand = new Random(); // Create bunch of sphere models and pile them up for (int i = 0; i <= 0; i++) { for (int j = -1; j <= 1; j++) { TransformNode pileTrans = new TransformNode(); pileTrans.Translation = new Vector3(2 * j + (float)rand.NextDouble() / 5, 2 * i + 5f + (i + 1) * 0.05f, 0 + 0.01f * i + (float)rand.NextDouble() / 5); GeometryNode gNode = new GeometryNode("Sphere" + (10 * i + j)); gNode.Model = sphereModel; gNode.Material = sphereMaterial; // Make the sphere models interactable, which means that they // participate in the physical simulation gNode.Physics.Interactable = true; gNode.Physics.Collidable = true; gNode.Physics.Shape = GoblinXNA.Physics.ShapeType.Sphere; gNode.Physics.Mass = 30f; gNode.AddToPhysicsEngine = true; parentTransNode.AddChild(pileTrans); pileTrans.AddChild(gNode); } } // Create a material for shooting box models shooterMat = new Material(); shooterMat.Diffuse = Color.Pink.ToVector4(); shooterMat.Specular = Color.Yellow.ToVector4(); shooterMat.SpecularPower = 10; }
private void CreateObject() { // Create a primitive mesh for creating our custom pyramid shape CustomMesh pyramid = new CustomMesh(); // Even though we really need 5 vertices to create a pyramid shape, since // we want to assign different normals for points with same position to have // more accurate lighting effect, we will use 16 vertices. // Also, we want to have position, normal, and texture information in our // vertices, we'll use VertexPositionNormalTexture format. There are other // types of Vertex format as well depending on your needs. VertexPositionNormalTexture[] verts = new VertexPositionNormalTexture[16]; // Create a pyramid with 8x8 base and height of 6 Vector3 vBase0 = new Vector3(-4, 0, 4); Vector3 vBase1 = new Vector3(4, 0, 4); Vector3 vBase2 = new Vector3(4, 0, -4); Vector3 vBase3 = new Vector3(-4, 0, -4); Vector3 vTop = new Vector3(0, 6, 0); verts[0].Position = vTop; verts[1].Position = vBase1; verts[2].Position = vBase0; verts[3].Position = vTop; verts[4].Position = vBase2; verts[5].Position = vBase1; verts[6].Position = vTop; verts[7].Position = vBase3; verts[8].Position = vBase2; verts[9].Position = vTop; verts[10].Position = vBase0; verts[11].Position = vBase3; verts[12].Position = vBase0; verts[13].Position = vBase1; verts[14].Position = vBase2; verts[15].Position = vBase3; verts[0].Normal = verts[1].Normal = verts[2].Normal = CalcNormal(vTop, vBase1, vBase0); verts[3].Normal = verts[4].Normal = verts[5].Normal = CalcNormal(vTop, vBase2, vBase1); verts[6].Normal = verts[7].Normal = verts[8].Normal = CalcNormal(vTop, vBase3, vBase2); verts[9].Normal = verts[10].Normal = verts[11].Normal = CalcNormal(vTop, vBase0, vBase3); verts[12].Normal = verts[13].Normal = verts[14].Normal = verts[15].Normal = CalcNormal(vBase0, vBase1, vBase3); Vector2 texCoordTop = new Vector2(0.5f, 0); Vector2 texCoordLeftBase = new Vector2(0, 1); Vector2 texCoordRightBase = new Vector2(1, 1); verts[0].TextureCoordinate = texCoordTop; verts[1].TextureCoordinate = texCoordLeftBase; verts[2].TextureCoordinate = texCoordRightBase; verts[3].TextureCoordinate = texCoordTop; verts[4].TextureCoordinate = texCoordLeftBase; verts[5].TextureCoordinate = texCoordRightBase; verts[6].TextureCoordinate = texCoordTop; verts[7].TextureCoordinate = texCoordLeftBase; verts[8].TextureCoordinate = texCoordRightBase; verts[9].TextureCoordinate = texCoordTop; verts[10].TextureCoordinate = texCoordLeftBase; verts[11].TextureCoordinate = texCoordRightBase; verts[12].TextureCoordinate = new Vector2(1, 1); verts[13].TextureCoordinate = new Vector2(1, 0); verts[14].TextureCoordinate = new Vector2(0, 0); verts[15].TextureCoordinate = new Vector2(0, 1); pyramid.VertexBuffer = new VertexBuffer(graphics.GraphicsDevice, typeof(VertexPositionNormalTexture), 16, BufferUsage.None); pyramid.VertexDeclaration = VertexPositionNormalTexture.VertexDeclaration; pyramid.VertexBuffer.SetData(verts); pyramid.NumberOfVertices = 16; short[] indices = new short[18]; indices[0] = 0; indices[1] = 1; indices[2] = 2; indices[3] = 3; indices[4] = 4; indices[5] = 5; indices[6] = 6; indices[7] = 7; indices[8] = 8; indices[9] = 9; indices[10] = 10; indices[11] = 11; indices[12] = 12; indices[13] = 13; indices[14] = 15; indices[15] = 13; indices[16] = 14; indices[17] = 15; pyramid.IndexBuffer = new IndexBuffer(graphics.GraphicsDevice, typeof(short), 18, BufferUsage.WriteOnly); pyramid.IndexBuffer.SetData(indices); pyramid.PrimitiveType = PrimitiveType.TriangleList; pyramid.NumberOfPrimitives = 6; PrimitiveModel pyramidModel = new PrimitiveModel(pyramid); GeometryNode pyramidNode = new GeometryNode(); pyramidNode.Model = pyramidModel; Material pyramidMaterial = new Material(); pyramidMaterial.Diffuse = Color.White.ToVector4(); pyramidMaterial.Specular = Color.White.ToVector4(); pyramidMaterial.SpecularPower = 10; pyramidMaterial.Texture = Content.Load <Texture2D>("brick_wall_14"); pyramidNode.Material = pyramidMaterial; scene.RootNode.AddChild(pyramidNode); }
protected override ValueModel DeserializeWithoutMetadata(JToken token) { return(PrimitiveModel.FromToken(token as JValue)); }