private void CreateObject() { { // Create a sphere GeometryNode shape = new GeometryNode(); shape.Model = new Sphere(2, 30, 30); shape.Model.Shader = generalShader; // Create a material which we want to apply to a sphere model Material modelMaterial = new Material(); modelMaterial.Diffuse = new Vector4(1, 1, 1, 1); modelMaterial.Specular = Color.White.ToVector4(); modelMaterial.SpecularPower = 128f; //modelMaterial.Emissive = Color.Yellow.ToVector4(); shape.Material = modelMaterial; sphereTrans = new TransformNode(); sphereTrans.Translation = new Vector3(0, 2, 0); sphereTrans.AddChild(shape); scene.RootNode.AddChild(sphereTrans); } { // Create a ground GeometryNode shape = new GeometryNode(); shape.Model = new Box(200, 0.01f, 200); shape.Model.Shader = generalShader; // Create a material which we want to apply to a ground model Material modelMaterial = new Material(); modelMaterial.Diffuse = new Vector4(1, 1, 1, 1); modelMaterial.SpecularPower = 64f; shape.Material = modelMaterial; TransformNode trans = new TransformNode(); trans.Translation = new Vector3(0, 0, 0); trans.AddChild(shape); scene.RootNode.AddChild(trans); } { // Create a box GeometryNode shape = new GeometryNode(); shape.Model = new Box(2); shape.Model.Shader = generalShader; // Create a material which we want to apply to a box model Material modelMaterial = new Material(); modelMaterial.Diffuse = new Vector4(1, 1, 1, 1); shape.Material = modelMaterial; floorTrans = new TransformNode(); floorTrans.Translation = new Vector3(10, 1, 0); floorTrans.AddChild(shape); scene.RootNode.AddChild(floorTrans); } }
/// <summary> /// Replace an exiting bone with the passed one /// </summary> /// <param name="grps">List of all Imported Groups (needed to fix the UseBone Indices)</param> /// <param name="bns">List of all Bones</param> /// <param name="b"></param> /// <param name="index">The Number of the Bone that should be added</param> /// <returns>the real Bone Index</returns> protected virtual int ReplaceBone(ImportedGroups grps, ImportedBones bns, ImportedBone b, int index) { int nindex = b.TargetIndex; gmdc.Joints[nindex] = b.Bone; VectorTransformation t = new VectorTransformation(VectorTransformation.TransformOrder.RotateTranslate); gmdc.Model.Transformations[nindex] = t; //Change the TransformNode for the New Bone if (Options.UpdateCres) { if (gmdc.ParentResourceNode != null) { TransformNode tn = gmdc.Joints[nindex].AssignedTransformNode; tn.ObjectGraphNode.FileName = b.ImportedName; if (tn != null) { tn.Transformation = b.Transformation.Clone(); } } } return(nindex); }
private static void PraseNote(string str, string bindingOnPrefabUiScript, ref List <ObjNode> objList, ref List <TransformNode> transList, ref List <ScriptNode> scriptNodeList) { string[] strs = str.Split('\n'); if (strs.Length > 2) { string type = strs[1]; if (type.Equals("GameObject:")) { ObjNode node = PraseStrToObjNode(strs); if (null != node) { objList.Add(node); } } else if (type.Equals("Transform:") || type.Equals("RectTransform:")) { TransformNode node = PraseStrToTransformNode(strs); if (null != node) { transList.Add(node); } } else if (type.Equals("MonoBehaviour:")) { ScriptNode node = PraseStrToScriptNode(strs, bindingOnPrefabUiScript); if (null != node) { scriptNodeList.Add(node); } } } }
private void createObj(int type, Vector3 dim) { geomNode = new GeometryNode("powerup" + type); geomNode.Model = new Box(dim.X, dim.Y, dim.Z); // Create a material to apply to the wall Material powerMaterial = new Material(); Vector4 color; if (powerUpType == type) { color = Color.Black.ToVector4(); } else { color = Color.DarkRed.ToVector4(); } powerMaterial.Diffuse = color; powerMaterial.Specular = color; powerMaterial.SpecularPower = 5; geomNode.Material = powerMaterial; transNode = new TransformNode(); transNode.AddChild(geomNode); }
public static GeometryNode AddModel(MarkerNode Marker, String Folder, String Model, bool IntMaterial, float Scala) { GeometryNode ObstNode; if (Model == "null") { return(ObstNode = new GeometryNode()); } ObstNode = Graphics3D.LoadModel("Models/" + Folder, Model, IntMaterial); //define the Physic Material name ObstNode.Physics.MaterialName = "Obstacle"; TransformNode parentTransNode = new TransformNode(); parentTransNode.Name = Model; parentTransNode.Scale = new Vector3(Scala, Scala + 2, Scala); parentTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(90)); //Add Rotation because Blender Axis parentTransNode.AddChild(ObstNode); // Add this box model node to the ground marker node if (Marker != null) { Marker.AddChild(parentTransNode); } return(ObstNode); }
public Block(MarkerNode markerNode, string[] names, float scale, ref GlobalVariables g) { global = g; buildingsInBlocks = new List <Building>(); blockNode = markerNode; blockTransNode = new TransformNode(); blockTransNode.Scale = Vector3.One * scale; //////////////////////////////////////////////////////////////////////blockTransNode.Translation = new Vector3(0.0f, -64.25f, 0.0f); //blockTransNode.Translation = new Vector3(0.0f, -64.25f, 0.0f); ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //blockTransNode.Translation = new Vector3(-33.5f, -54.25f, 0); blockTransNode.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, MathHelper.PiOver2); blockNode.AddChild(blockTransNode); foreach (string s in names) { //Note, this needs to be changed so we are able to add different buildings to a marker Building tempBuilding = new Building(s, ref global); tempBuilding.loadBuildingModel(true, 1.0f); //change scale factor if necessary buildingsInBlocks.Add(tempBuilding); //blockTransNode.AddChild(tempBuilding.getBuildingNode()); ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // blockTransNode.Scale = new Vector3(blockTransNode.Scale.X * 1.0f, blockTransNode.Scale.Y * 1.0f, blockTransNode.Scale.Z * 1.0f); // blockNode.AddChild(blockTransNode); } }
public void CreateShootBullet(Vector3 InitPos, Vector3 DirBullet, Color BulletColor) { if (BulletID == 20) { return; } GeometryNode ShootBullet = new GeometryNode("ShootBullet" + BulletID++); ShootBullet.Model = BulletModel; BulletrMat.Diffuse = BulletColor.ToVector4(); ShootBullet.Material = BulletrMat; 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); TransformNode BulletTrans = new TransformNode(); BulletTrans.Translation = InitPos; groundMarkerNode.AddChild(BulletTrans); BulletTrans.AddChild(ShootBullet); }
public void CreateGroundLevel(string Folder, String Model, Vector3 ObjPos, Vector3 Scala) { GeometryNode groundNode; groundNode = LoadModel("Models/" + Folder, Model, true); //Setup Physics Aspecte groundNode.Physics.Collidable = true; // Make the ground model to receive shadow casted by other objects //groundNode.Model.ShadowAttribute = ShadowAttribute.ReceiveOnly; // Assign a shadow shader //groundNode.Model.Shader = new SimpleShadowShader(scene.ShadowMap); TransformNode parentTransNode = new TransformNode("ground"); parentTransNode.Scale = Scala; parentTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(1, 0, 0), MathHelper.ToRadians(90)); //Add Rotation because Blender Axis parentTransNode.Translation = ObjPos; parentTransNode.AddChild(groundNode); //Add Model in the Scene parentTNodeGrd.AddChild(parentTransNode); }
private void ConfigureTransformNodes(NodeGraphConfiguration configuration, List <INode> nodes) { Func <string[], string> joinScript = s => { if (s == null || s.Length == 0) { return(null); } return(string.Join(Environment.NewLine, s)); }; if (configuration.TransformNodes != null) { foreach (var transformNodeConfiguration in configuration.TransformNodes) { var node = new TransformNode(_hostingEnvironment, _factory) { Name = transformNodeConfiguration.Name, Disabled = transformNodeConfiguration.Disabled, OutputNode = transformNodeConfiguration.OutputNode, Description = joinScript(transformNodeConfiguration.Description), ScriptLanguage = transformNodeConfiguration.ScriptLanguage, RequestScript = joinScript(transformNodeConfiguration.RequestScript), ResponseScript = joinScript(transformNodeConfiguration.ResponseScript), RequestScriptFile = transformNodeConfiguration.RequestScriptFile, ResponseScriptFile = transformNodeConfiguration.ResponseScriptFile, }; transformNodeConfiguration.Node = node; nodes.Add(node); } } }
private void Initialize() { // Initialize physics. InitializePhysics(); // Add lights. AddLights(); // Add ball. AddBall(); // Add tunnel. AddTunnel(); // Add players. // Team 1. _transTeam1Node = new TransformNode(); _levelRootNode.AddChild(_transTeam1Node); _transTeam1Node.Translation = new Vector3(0.0f, -Tunnel.Length / 2.0f, 0.0f); AddPlayers(_info.Team1PlayerTypes, _team1, Role.Team1, Team1NamePrefix); // Team 2. _transTeam2Node = new TransformNode(); _levelRootNode.AddChild(_transTeam2Node); _transTeam2Node.Translation = new Vector3(0.0f, Tunnel.Length / 2.0f, 0.0f); AddPlayers(_info.Team2PlayerTypes, _team2, Role.Team2, Team2NamePrefix); }
public CSSFace(TransformNode transformNode, int p1, int p2) { // TODO: Complete member initialization this.transformNode = transformNode; this.p1 = p1; this.p2 = p2; }
private void createCorderBackground() { cornerPanelTransformNode = new TransformNode("Corner Panel Trans"); scene.RootNode.AddChild(cornerPanelTransformNode); cornerPanelNode = new GeometryNode("Corner Panel"); cornerPanelNode.Model = new TexturedLayer(new Vector2(250, 250));//new Box(300, 250, 1); cornerPanelTransformNode.AddChild(cornerPanelNode); cornerPanelTransformNode.Translation = new Vector3(2.3f, -1.58f, -5); cornerPanelTransformNode.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitX, MathHelper.ToRadians(90)); //cornerPanelTransformNode.Translation = new Vector3(0, .06f, -1); cornerPanelTransformNode.Scale = new Vector3(0.005f, 0.005f, 0.005f); Material pointerLabelMaterial = new Material(); pointerLabelMaterial.Diffuse = Color.White.ToVector4();; // new Vector4(0, 0.5f, 0, 1); // pointerLabelMaterial.Specular = Color.White.ToVector4(); // pointerLabelMaterial.SpecularPower = 50; pointerLabelMaterial.Texture = Content.Load <Texture2D>("hud/cornerPanel"); cornerPanelNode.Material = pointerLabelMaterial; //cornerPanelTransformNode.SetAlpha(0.55f); Vector4 tempColor = cornerPanelNode.Material.Diffuse; Vector3 tempVec = new Vector3(tempColor.X, tempColor.Y, tempColor.Z); cornerPanelNode.Material.Diffuse = new Vector4(tempVec, 0.7f); }
public NodeFactory() { builtin["Anchor"] = new AnchorNode(); builtin["Appearance"] = new AppearanceNode(); builtin["Background"] = new BackgroundNode(); builtin["Box"] = new BoxNode(); builtin["Color"] = new ColorNode(); builtin["Cone"] = new ConeNode(); builtin["Coordinate"] = new CoordinateNode(); builtin["CoordinateInterpolator"] = new CoordinateInterpolatorNode(); builtin["Cylinder"] = new CylinderNode(); builtin["DirectionalLight"] = new DirectionalLightNode(); builtin["Extrusion"] = new ExtrusionNode(); builtin["Group"] = new GroupNode(); builtin["Collision"] = new CollisionNode(); builtin["Switch"] = new SwitchNode(); builtin["IndexedFaceSet"] = new IndexedFaceSetNode(); builtin["IndexedLineSet"] = new IndexedLineSetNode(); builtin["Material"] = new MaterialNode(); builtin["NavigationInfo"] = new NavigationInfoNode(); builtin["OrientationInterpolator"] = new OrientationInterpolatorNode(); builtin["Normal"] = new NormalNode(); builtin["PixelTexture"] = new PixelTextureNode(); builtin["PointLight"] = new PointLightNode(); builtin["PositionInterpolator"] = new PositionInterpolatorNode(); builtin["ScalarInterpolator"] = new ScalarInterpolationNode(); builtin["Shape"] = new ShapeNode(); builtin["Sphere"] = new SphereNode(); builtin["TextureCoordinate"] = new TextureCoordinateNode(); builtin["TimeSensor"] = new TimeSensorNode(); builtin["Transform"] = new TransformNode(); builtin["Viewpoint"] = new ViewpointNode(); builtin["WorldInfo"] = new WorldInfoNode(); }
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; }
/// <summary> /// Shoot a box from the clicked mouse location /// </summary> /// <param name="near"></param> /// <param name="far"></param> private void ShootBox(Vector3 near, Vector3 far) { GeometryNode shootBox = new GeometryNode("ShooterBox" + shooterID++); shootBox.Model = boxModel; shootBox.Material = shooterMat; shootBox.Physics.Interactable = true; shootBox.Physics.Collidable = true; shootBox.Physics.Shape = GoblinXNA.Physics.ShapeType.Box; shootBox.Physics.Mass = 60f; shootBox.AddToPhysicsEngine = true; // Calculate the direction to shoot the box based on the near and far point Vector3 linVel = far - near; linVel.Normalize(); // Multiply the direction with the velocity of 20 linVel *= 30f; // Assign the initial velocity to this shooting box shootBox.Physics.InitialLinearVelocity = linVel; TransformNode shooterTrans = new TransformNode(); shooterTrans.Translation = near; scene.RootNode.AddChild(shooterTrans); shooterTrans.AddChild(shootBox); }
/// <summary> /// Shoot a box from the clicked mouse location /// </summary> /// <param name="near"></param> /// <param name="far"></param> private void ShootBox(Vector3 near, Vector3 far) { GeometryNode shootBox = new GeometryNode("ShooterBox" + shooterID++); shootBox.Model = boxModel; shootBox.Material = shooterMat; #if !WINDOWS shootBox.Physics = new MataliObject(shootBox); ((MataliObject)shootBox.Physics).CollisionStartCallback = BoxCollideWithGround; #endif // Define the material name of this shooting box model shootBox.Physics.MaterialName = "ShootingBox"; shootBox.Physics.Interactable = true; shootBox.Physics.Collidable = true; shootBox.Physics.Shape = GoblinXNA.Physics.ShapeType.Box; shootBox.Physics.Mass = 60f; shootBox.AddToPhysicsEngine = true; // Calculate the direction to shoot the box based on the near and far point Vector3 linVel = far - near; linVel.Normalize(); // Multiply the direction with the velocity of 20 linVel *= 20f; // Assign the initial velocity to this shooting box shootBox.Physics.InitialLinearVelocity = linVel; TransformNode shooterTrans = new TransformNode(); shooterTrans.Translation = near; scene.RootNode.AddChild(shooterTrans); shooterTrans.AddChild(shootBox); }
/// <summary> /// Add the passed Bone to the Gmdc and Fix the UseBone Indices to apropriate Values /// </summary> /// <param name="grps">List of all Imported Groups (needed to fix the UseBone Indices)</param> /// <param name="bns">List of all Bones</param> /// <param name="b"></param> /// <param name="index">The Number of the Bone that should be added</param> /// <returns>the real Bone Index</returns> protected virtual int AddBone(ImportedGroups grps, ImportedBones bns, ImportedBone b, int index) { int nindex = gmdc.Joints.Length; gmdc.Joints.Add(b.Bone); VectorTransformation t = new VectorTransformation(VectorTransformation.TransformOrder.RotateTranslate); gmdc.Model.Transformations.Add(t); //Create a TransformNode for the New Bone if (Options.UpdateCres) { if ((gmdc.ParentResourceNode != null) && (IsLocalCres())) { TransformNode tn = new TransformNode(gmdc.ParentResourceNode.Parent); tn.ObjectGraphNode.FileName = b.ImportedName; tn.Transformation = b.Transformation.Clone(); tn.JointReference = nindex; gmdc.ParentResourceNode.Parent.Blocks = (SimPe.Interfaces.Scenegraph.IRcolBlock[])Helper.Add( gmdc.ParentResourceNode.Parent.Blocks, tn, typeof(SimPe.Interfaces.Scenegraph.IRcolBlock) ); } } return(nindex); }
private TransformNode RecordTransformsRecursively(Transform parent) { var directChildren = GetDirectChildrenOfTransform(parent); var nodeData = new TransformNode { NodeTransformData = new TransformData { Position = parent.localPosition, Rotation = parent.localRotation, Scale = parent.localScale } }; if (directChildren.Count > 0) { nodeData.ChildrenTransformsData = new List <TransformNode>(); foreach (var child in directChildren) { nodeData.ChildrenTransformsData.Add(RecordTransformsRecursively(child)); } } else { nodeData.ChildrenTransformsData = null; } return(nodeData); }
internal override void AddCustomNodeProperties(VisualElement parentElement, AbstractMaterialNode nodeBase, Action setNodesAsDirtyCallback, Action updateNodeViewsCallback) { node = nodeBase as TransformNode; var normalizeControl = new Toggle(); normalizeControl.value = node.normalize; normalizePropRow = new PropertyRow(new Label("Normalize Output")); normalizePropRow.Add(normalizeControl, (field) => { field.RegisterValueChangedCallback(evt => { if (evt.newValue.Equals(node.normalize)) { return; } setNodesAsDirtyCallback?.Invoke(); node.owner.owner.RegisterCompleteObjectUndo("Change normalize"); node.normalize = evt.newValue; updateNodeViewsCallback?.Invoke(); node.Dirty(ModificationScope.Graph); }); }); parentElement.Add(normalizePropRow); UpdateVisibility(); node.RegisterCallback(OnNodeModified); }
private void CreateObjects() { float size = 4.0f; // Create a marker node to track a feature-based image. // NOTE: If you get an exception here, that means you haven't generated the .dat file yet // Please see this MarkerNode groundMarkerNode = new MarkerNode(scene.MarkerTracker, "markerless.png.dat"); // Now add the above nodes to the scene graph in the appropriate order. // Note that only the nodes added below the marker node are affected by // the marker transformation. scene.RootNode.AddChild(groundMarkerNode); // Create a geometry node with a model of a box that will be overlaid on top of the image GeometryNode boxNode = new GeometryNode("Box") { Model = new Box(size), Material = new Material() { Diffuse = Color.Red.ToVector4(), Specular = Color.White.ToVector4(), SpecularPower = 10 } }; TransformNode boxTrans = new TransformNode() { Translation = new Vector3(0, 0, -size / 2) }; groundMarkerNode.AddChild(boxTrans); boxTrans.AddChild(boxNode); }
List <Attribute> attributes = new List <Attribute>(); //size 8 //Constructors public Building(ref GlobalVariables g) { global = g; buildingGeomNode = new GeometryNode(); buildingMaterial = new Material(); buildingTransNode = new TransformNode(); }
public void IsDrawnActuallyWithNoDrawnNode() { var tc = new TestCore(); tc.Init(); var texture = Texture2D.Load(@"TestData/IO/AltseedPink.png"); Assert.NotNull(texture); var node = new SpriteNode(); node.Texture = texture; node.CenterPosition = texture.Size / 2; node.Position = new Vector2F(100, 100); Engine.AddNode(node); var node2 = new TransformNode(); node2.CenterPosition = texture.Size / 2; node2.Position = new Vector2F(200, 200); var node3 = new RectangleNode(); node3.RectangleSize = texture.Size; node3.Texture = texture; node3.CenterPosition = texture.Size / 2; node3.Position = new Vector2F(300, 300); tc.LoopBody(c => { if (c == 2) { node.AddChildNode(node2); } else if (c == 4) { node.IsDrawn = false; Assert.IsFalse(node.IsDrawnActually); } else if (c == 6) { node2.AddChildNode(node3); } else if (c == 8) { node.IsDrawn = true; Assert.IsTrue(node.IsDrawnActually); Assert.IsTrue(node3.IsDrawnActually); } }, null); tc.End(); }
/// <summary> /// 解析Transform yaml /// </summary> /// <param name="str"></param> private static TransformNode PraseStrToTransformNode(string[] prefabStrs) { if (null == prefabStrs || prefabStrs.Length < 2) { return(null); } TransformNode node = new TransformNode(); List <string> childrenList = new List <string>(); string parentGuid = string.Empty; bool isBeginParaseChildern = false; for (int i = 2; i < prefabStrs.Length; i++) { string pstr = prefabStrs[i]; if (isBeginParaseChildern) { if (pstr.IndexOf("- {fileID: ") > 0) { string[] fileStrs = pstr.Split(':'); if (fileStrs.Length >= 2) { var fileStr = fileStrs[1].Replace("}", "").Trim(); childrenList.Add(fileStr); } } else { isBeginParaseChildern = false; } } if (!isBeginParaseChildern) { if (pstr.IndexOf("m_Children") >= 0 && !pstr.Equals("m_Children: []")) { isBeginParaseChildern = true; } else if (pstr.IndexOf("m_Father") >= 0) { string[] nameStrs = pstr.Split(':'); if (nameStrs.Length >= 3) { parentGuid = nameStrs[2].Replace("}", "").Trim(); } } } } node.Guid = ParaseGuid(prefabStrs[0]); node.ChildrenGuid = childrenList; node.ParentGuid = parentGuid; return(node); }
public Building(System.String name, ref GlobalVariables g) { global = g; buildingName = name; buildingGeomNode = new GeometryNode(); buildingMaterial = new Material(); buildingTransNode = new TransformNode(); }
/// <summary> /// Performs encoding transformation for each <c>XmlElement</c> of <c>App.config</c> where <c>Encode</c> transform is applied for. /// </summary> protected override void Apply() { //If target node has no attributes - skip the transform: if (TargetNode.Attributes == null) { return; } //Getting list of passed XPath arguments to this Encode instance: var encodeXPathArguments = new List <string>(); if (Arguments != null) { encodeXPathArguments.AddRange(Arguments); } //Adding DefaultAttributeName to XPath arguments if it's not present: if (!encodeXPathArguments.Contains(DefaultAttributeName)) { encodeXPathArguments.Add(DefaultAttributeName); } //Looping thru TargetNodes foreach (var targetNode in TargetNodes.OfType <XmlElement>()) { //For each TargetNode looping thru encodeXPathArguments foreach (var arg in encodeXPathArguments) { //Getting TargetNode.XmlNode by XPath arg: var destinationNode = targetNode.SelectSingleNode(arg); if (destinationNode == null) { continue; } //TransformNode.XmlNode by XPath arg: var applyTransformNode = TransformNode.SelectSingleNode(arg); //Determine which XmlNode.InnerText to encode: string valueToEncode = applyTransformNode == null || string.IsNullOrEmpty(applyTransformNode.InnerText) ? destinationNode.InnerText //Getting default destination XmlNode.InnerText : applyTransformNode.InnerText; //Getting XmlNode.InnerText specified in App.config transformer if (string.IsNullOrEmpty(valueToEncode)) { continue; } //If valueToEncode is OK - then encrypt it and assign to destination XmlNode.InnerText: destinationNode.InnerText = _encryptorDecryptor.Encrypt(valueToEncode); } } }
private void CreateObjects() { // Loads a textured model of a ship ModelLoader loader = new ModelLoader(); Model shipModel = (Model)loader.Load("", "p1_wedge"); // Create a geometry node of a loaded ship model GeometryNode shipNode = new GeometryNode("Ship"); shipNode.Model = shipModel; // This ship model has material definitions in the model file, so instead // of creating a material node for this ship model, we simply use its internal materials ((Model)shipNode.Model).UseInternalMaterials = true; ((Model)shipNode.Model).ContainsTransparency = true; // Create a transform node to define the transformation for the ship TransformNode shipTransNode = new TransformNode(); // shipTransNode.Translation = new Vector3(0, 5, -12); shipTransNode.Scale = new Vector3(0.002f, 0.002f, 0.002f); // It's huge! shipTransNode.Rotation = Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), MathHelper.ToRadians(-90)); shipTransParentNode = new TransformNode(); //Set our rotation animation to ease in initially animationRotation = new AnimationHelper(Easing.EaseIn); startPosition = new Vector3(-10, 0, -10); endPosition = new Vector3(5, 2, -5); startRotationVector = new Vector3(0, 0, 0); endRotationVector = new Vector3(MathHelper.ToRadians(0), MathHelper.ToRadians(180), MathHelper.ToRadians(180)); //Set our translation animation to ease in initially animationTranslation = new AnimationHelper(Easing.EaseIn); //Define what kind of interpolation to use. animationTranslation.Animate(arrayOfTransitions[currentInterpolation], startPosition, endPosition, 2); // animationTranslation.SetLooping(true, 5); // Use if you want to loop through an animation. // Set an action to take place once the animation concludes. animationTranslation.SetEndAction(delegate() { animationRotation.Animate(arrayOfTransitions[currentInterpolation], startRotationVector, endRotationVector, 2.0); }); // Note: if you loop and set this animation, it'll occur after the end of the first loop, not after the end of all loops! textToPrint = "Linear interpolation"; // Now add the above nodes to the scene graph in appropriate order scene.RootNode.AddChild(shipTransParentNode); shipTransParentNode.AddChild(shipTransNode); shipTransNode.AddChild(shipNode); }
/// <summary> /// Creates a rope-like object by connecting several ball and socket joints. /// </summary> /// <param name="scene"></param> /// <param name="parentTrans"></param> public static void AddRope(Scene scene, TransformNode parentTrans) { Vector3 size = new Vector3(1.5f, 0.25f, 0.25f); Vector3 location = new Vector3(0, 9, 0); IPhysicsObject link0 = null; Color[] colors = { Color.Red, Color.Orange, Color.Yellow, Color.Green, Color.Blue, Color.Indigo, Color.Violet }; PrimitiveModel capsule = new Capsule(size.Y, size.X, 12); for (int i = 0; i < 7; i++) { TransformNode pileTrans = new TransformNode(); pileTrans.Translation = location; Material linkMat = new Material(); linkMat.Diffuse = colors[i].ToVector4(); linkMat.Specular = Color.White.ToVector4(); linkMat.SpecularPower = 10; GeometryNode link1 = new GeometryNode("Link " + i); link1.Model = capsule; link1.Model.ShadowAttribute = ShadowAttribute.ReceiveCast; link1.Material = linkMat; link1.AddToPhysicsEngine = true; link1.Physics.Interactable = true; link1.Physics.Collidable = true; link1.Physics.Shape = ShapeType.Capsule; link1.Physics.Mass = 2.0f; link1.Physics.LinearDamping = 1f; link1.Physics.AngularDamping = new Vector3(1f, 1f, 1f); parentTrans.AddChild(pileTrans); pileTrans.AddChild(link1); Vector3 pivot = location + parentTrans.Translation; pivot.Y += (size.X - size.Y) * 0.5f; BallAndSocketJoint joint = new BallAndSocketJoint(pivot); joint.Pin = -Vector3.UnitY; joint.MaxConeAngle = 0.0f; joint.MaxTwistAngle = 10.0f * MathHelper.Pi / 180; ((NewtonPhysics)scene.PhysicsEngine).CreateJoint(link1.Physics, link0, joint); link0 = link1.Physics; location = new Vector3(location.X, location.Y - (size.X - size.Y), location.Z); } }
public Catalog(Scene s) { this.my_scene = s; this.marker = new MarkerNode(my_scene.MarkerTracker, "palette_marker.xml"); this.changeMarker = new MarkerNode(my_scene.MarkerTracker, "palette_turn_marker.xml"); my_scene.RootNode.AddChild(marker); my_scene.RootNode.AddChild(changeMarker); library = new ItemLibrary("models.txt"); names2itemsInCatalog = new Dictionary <string, Item>(); names2itemsInRoom = new Dictionary <string, Item>(); item_list = library.getAllItems(); // this.objects = l; int grid_x = 0; int grid_y = 0; foreach (Item i in item_list) { names2itemsInCatalog.Add(i.Label, i); i.setGroupID(catalogGroupID); i.Scale = new Vector3(9.0f, 9.0f, 9.0f) / i.Radius; } for (int i = cur_start; i < cur_end && i < item_list.Count; i++) { if (grid_x > 15) { grid_x = 0; grid_y -= 15; } item_list[i].BindTo(marker); item_list[i].MoveTo(new Vector3(grid_x, grid_y, 0)); grid_x += 15; } // Create a geometry node with a model of box GeometryNode boxNode = new GeometryNode("Box"); boxNode.Model = new Box(30, 30, 0.1f); TransformNode boxTransNode = new TransformNode(); boxTransNode.AddChild(boxNode); boxTransNode.Translation += new Vector3(6, -6, -0.5f); Material boxMat = new Material(); boxMat.Diffuse = Color.DimGray.ToVector4(); boxNode.Material = boxMat; marker.AddChild(boxTransNode); }
static void Transform(int id, Vec3S32 offset, int[,] rot, Dictionary <int, Node> nodes) { Node node = nodes[id]; switch (node.Type) { // traverse the multiple children nodes case NodeType.Group: for (int i = 0; i < node.Children.Length; i++) { Transform(node.Children[i], offset, rot, nodes); } break; // transform might or might not change parent transformation case NodeType.Transform: TransformNode trans = (TransformNode)node; string raw; if (trans.FrameAttribs.TryGetValue("_t", out raw)) { string[] bits = raw.SplitSpaces(3); offset.X += int.Parse(bits[0]); offset.Y += int.Parse(bits[1]); offset.Z += int.Parse(bits[2]); } if (trans.FrameAttribs.TryGetValue("_r", out raw)) { byte flags = byte.Parse(raw); rot = new int[3, 3]; rot[0, (flags >> 0) & 3] = (flags & 0x10) != 0 ? -1 : 1; rot[1, (flags >> 2) & 3] = (flags & 0x20) != 0 ? -1 : 1; rot[2, 2] = (flags & 0x40) != 0 ? -1 : 1; } Transform(node.Children[0], offset, rot, nodes); break; // apply transformation to model case NodeType.Shape: ShapeNode shape = (ShapeNode)node; shape.Model.X = offset.X; shape.Model.Y = offset.Y; shape.Model.Z = offset.Z; if (rot != null) { shape.Model.Rot = rot; } break; } }
public void createPointer() { global.toolbar1Node = new GeometryNode("Toolbar1"); global.toolbar1Node.Model = new Box(18, 28, 0.1f); //I think toolbar itself is 20x8 // Set this toolbar model to act as an occluder so that it appears transparent global.toolbar1Node.IsOccluder = true; // Make the toolbar model to receive shadow casted by other objects with // CastShadows set to true global.toolbar1Node.Model.ReceiveShadows = true; Material toolbar1Material = new Material(); toolbar1Material.Diffuse = Color.Gray.ToVector4(); toolbar1Material.Specular = Color.White.ToVector4(); toolbar1Material.SpecularPower = 20; global.toolbar1Node.Material = toolbar1Material; global.toolBar1OccluderTransNode = new TransformNode(); global.toolBar1OccluderTransNode.Translation = new Vector3(3, 10, 0); global.toolbar1MarkerNode.AddChild(global.toolBar1OccluderTransNode); global.toolBar1OccluderTransNode.AddChild(global.toolbar1Node); //Now we create the 3D arrow pointer on top of toolbar 1 TransformNode pointerTipTransNode = new TransformNode(); float pointerConeHeight = 3.0f; Matrix pointerTipRotation = (Matrix.CreateRotationX((float)Math.PI)); pointerTipTransNode.Rotation = Quaternion.CreateFromRotationMatrix(pointerTipRotation); pointerTipTransNode.Translation = new Vector3(4.0f, -3.0f, 1.3f); global.pointerTip = new GeometryNode("Pointer Tip"); global.pointerTip.Model = new Cylinder(1.8f, 0.05f, pointerConeHeight, 12); global.pointerMaterial = new Material(); global.pointerMaterial.Emissive = Color.Red.ToVector4(); global.pointerTip.Material = global.pointerMaterial; global.pointerSegment = new GeometryNode("Pointer Segment"); global.pointerSegment.Model = new Cylinder(1.0f, 1.0f, 2.4f * pointerConeHeight, 12); TransformNode pointerSegmentTransNode = new TransformNode(); pointerSegmentTransNode.Translation = new Vector3(0.0f, -3.6f, 0.0f); global.pointerSegment.Material = global.pointerMaterial; global.toolbar1MarkerNode.AddChild(pointerTipTransNode); pointerTipTransNode.AddChild(global.pointerTip); pointerSegmentTransNode.AddChild(global.pointerSegment); pointerTipTransNode.AddChild(pointerSegmentTransNode); // Create a marker node to track a toolbar marker array. Since we expect that the // toolbar marker array will move a lot, we use a large smoothing alpha. global.toolbar1MarkerNode = new MarkerNode(global.scene.MarkerTracker, "toolbar1"); global.toolbar1MarkerNode.Smoother = new DESSmoother(0.8f, 0.8f); global.scene.RootNode.AddChild(global.toolbar1MarkerNode); }
private void InitRenderingScene() { if (!d3DImage.IsFrontBufferAvailable) return; factory = new SceneGraphFactory(); wpfRenderer = factory.CreateRenderTargetA8R8G8B8Asset(); ///////////////////////////////////////////////////////////// cameraAsset = factory.CreateCamera(); cameraAsset.Perspective(34.0 , (double)RESOLUTION_X / (double)RESOLUTION_Y, Z_NEAR, 0.0); targetRenderer = factory.CreateRenderTargetAsset(); clearTargetBuffer = factory.CreateClearBuffer(); targetRenderer.SetRoot(clearTargetBuffer); clearLayerBuffer = factory.CreateClearBuffer(); wpfRenderer.SetRoot(clearLayerBuffer); TextureLayerNode targetTextureLayer = factory.CreateTextureLayer(targetRenderer); targetTextureLayer.MakeParent(clearLayerBuffer); effectAssetMesh = factory.CreateEffect("Position.DirectX9.obj.fx"); effectAssetMesh.SetValue("Time", 1); ObjMeshAsset objMeshAsset = factory.CreateObjMesh("bigguy_g.obj"); drawMockNode = factory.CreateDrawMock(); drawMockNode.SetMesh(objMeshAsset); drawmockTransformNodeFirst = factory.CreateTransform(); drawmockTransformNodeSecond = factory.CreateTransform(); drawmockTransformNodeFirst.MakeParent(clearTargetBuffer); drawmockTransformNodeSecond.MakeParent(drawmockTransformNodeFirst); drawMockNode.MakeParent(drawmockTransformNodeSecond); /////////////////////////////////////////////// cudaRenderer = factory.CreateCudaRaytraceRenderAsset(); TextureLayerNode cudaTextureLayer = factory.CreateTextureLayer(cudaRenderer); cudaRenderer.SetRoot(drawMockNode); cudaTextureLayer.MakeParent(clearLayerBuffer); cudaRenderer.SetTextureTarget(4, factory.CreateTextureAsset(targetRenderer)); //////////////////////////////////// effectAssetLayer = factory.CreateEffect("TextureLayerWpf.DirectX9.fx"); // set the back buffer using the new scene pointer sceneIntPtr = (IntPtr)wpfRenderer.GetDirect3D9Surface(0); d3DImage.Lock(); d3DImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, sceneIntPtr); d3DImage.Unlock(); // leverage the Rendering event of WPF's composition target to // update the custom D3D scene CompositionTarget.Rendering += OnRendering; }
/// <summary> /// [This documentation is preliminary and is subject to change.] /// </summary> /// <param name="toEffectInputIndex"><para>The effect input to which the transform node will be bound.</para></param> /// <param name="node"><para>The node to which the connection will be made.</para></param> /// <param name="toNodeInputIndex"><para>The node input that will be connected.</para></param> /// <returns>The method returns an <see cref="SharpDX.Result"/>. Possible values include, but are not limited to, those in the following table.HRESULTDescription S_OKNo error occurred D2DERR_NOT_FOUND = (HRESULT_FROM_WIN32(<see cref="SharpDX.Win32.ErrorCode.NotFound"/>))Direct2D could not locate the specified node.?</returns> /// <include file='.\..\Documentation\CodeComments.xml' path="/comments/comment[@id='ID2D1TransformGraph::ConnectToEffectInput']/*"/> /// <unmanaged>HRESULT ID2D1TransformGraph::ConnectToEffectInput([In] unsigned int toEffectInputIndex,[In] ID2D1TransformNode* node,[In] unsigned int toNodeInputIndex)</unmanaged> public void ConnectToEffectInput(int toEffectInputIndex, TransformNode node, int toNodeInputIndex) { ConnectToEffectInput_(toEffectInputIndex, TransformNodeShadow.ToIntPtr(node), toNodeInputIndex); }
/// <summary> /// Connects two nodes inside the transform graph. /// </summary> /// <param name="fromNode">The node from which the connection will be made.</param> /// <param name="toNode">The node to which the connection will be made.</param> /// <param name="toNodeInputIndex">The node input that will be connected.</param> /// <unmanaged>HRESULT ID2D1TransformGraph::ConnectNode([In] ID2D1TransformNode* fromNode,[In] ID2D1TransformNode* toNode,[In] unsigned int toNodeInputIndex)</unmanaged> public void ConnectNode(TransformNode fromNode, TransformNode toNode, int toNodeInputIndex) { ConnectNode__(TransformNodeShadow.ToIntPtr(fromNode), TransformNodeShadow.ToIntPtr(toNode), toNodeInputIndex); }
/// <summary> /// Sets the output node for the transform graph. /// </summary> /// <param name="node"><para>The node that will be set as the output of the the transform graph.</para></param> /// <unmanaged>HRESULT ID2D1TransformGraph::SetOutputNode([In] ID2D1TransformNode* node)</unmanaged> public void SetOutputNode(TransformNode node) { SetOutputNode_(TransformNodeShadow.ToIntPtr(node)); }
/// <summary> /// Removes the provided node from the transform graph. /// </summary> /// <param name="node"><para>The node that will be removed from the transform graph.</para></param> /// <remarks> /// The node must already exist in the graph; otherwise, the call fails with D2DERR_NOT_FOUND.Any connections to this node will be removed when the node is removed.After the node is removed, it cannot be used by the interface until it has been added to the graph by AddNode. /// </remarks> /// <unmanaged>HRESULT ID2D1TransformGraph::RemoveNode([In] ID2D1TransformNode* node)</unmanaged> public void RemoveNode(TransformNode node) { RemoveNode_(TransformNodeShadow.ToIntPtr(node)); }
/// <summary> /// Adds the provided node to the transform graph. /// </summary> /// <param name="node"><para>The node that will be added to the transform graph.</para></param> /// <remarks> /// This adds a transform node to the transform graph. A node must be added to the transform graph before it can be interconnected in any way.A transform graph cannot be directly added to another transform graph. /// Any other kind of interface derived from <see cref="SharpDX.Direct2D1.TransformNode"/> can be added to the transform graph. /// </remarks> /// <unmanaged>HRESULT ID2D1TransformGraph::AddNode([In] ID2D1TransformNode* node)</unmanaged> public void AddNode(TransformNode node) { AddNode_(TransformNodeShadow.ToIntPtr(node)); }
/// <summary> /// Sets a single transform node as being equivalent to the whole graph. /// </summary> /// <param name="node"><para>The node to be set.</para></param> /// <remarks> /// This equivalent to calling <see cref="SharpDX.Direct2D1.TransformGraph.Clear"/>, adding a single node, and connecting all of the node inputs to the effect inputs in order. /// </remarks> /// <unmanaged>HRESULT ID2D1TransformGraph::SetSingleTransformNode([In] ID2D1TransformNode* node)</unmanaged> public void SetSingleTransformNode(TransformNode node) { SetSingleTransformNode_(TransformNodeShadow.ToIntPtr(node)); }
public void InitializeContent(IDefault page) { var control = new UserControl1(); this.frontcontrol = new FrontPanel(); this.frontcontrol.RelativeToAbsolute = href => { if (href.StartsWith("/")) return Native.Document.location.href.TakeUntilLastIfAny("/") + href; return Native.Document.location.href + href; }; Native.Document.body.ondragover += evt => { evt.stopPropagation(); evt.preventDefault(); evt.dataTransfer.dropEffect = "copy"; // Explicitly show this is a copy. }; Native.Document.body.ondrop += evt => { #region dataTransfer evt.dataTransfer.types.WithEach( x => { Console.WriteLine(x); //SystemSounds.Beep.Play(); //Console.Beep(); #region text/uri-list if (x == "text/uri-list") { var src = evt.dataTransfer.getData(x); if (src != "about:blank") { if (src.StartsWith("http://www.youtube.com/watch?v=")) src = "http://www.youtube.com/embed/" + src.SkipUntilIfAny("http://www.youtube.com/watch?v=").TakeUntilIfAny("&"); Console.WriteLine(new { src }); frontcontrol.CreateWindowAndNavigate(src); } } #endregion } ); #endregion }; Console.Write("frontcontrol set"); // http://www.addyosmani.com/resources/googlebox/test.js var TILT_BASE = 2.0f; var qtext = page.search_text; var tilt_cur = TILT_BASE; var tilt = TILT_BASE; var rot_cur = 1f; var rot = 1f; var lidAngle = 0f; var lidAngleV = 0f; var close_ok = false; var playing = false; var iframe = page.bottom_iframe; iframe.Hide(); var rootTransMatrix = new M44(); var rootTransNode = new TransformNode(rootTransMatrix); rootTransMatrix.rotX(tilt); M44 lidTrans1 = (new M44()).translate(0f, 100f, 0f); M44 lidTrans2 = new M44(); var box = new CSSCube(200, 200, 80, rootTransNode); var gbox = page.gift_box; var gbox_childnodes = gbox.childNodes.ExceptTextNodes(); for (var i = 0; i < 4; i++) { CSSFace f = box.getSide(i); f.element = gbox_childnodes[7 + i]; f.backElement = gbox_childnodes[1 + i]; } ((CSSFace)box.getTop()).element = gbox_childnodes[11]; var frontElement = (IHTMLElement)gbox_childnodes[7]; //var frontElement_firstChild = (IHTMLElement)frontElement.childNodes.ExceptTextNodes()[0]; CSSFace bt = box.getBottom(); bt.element = gbox_childnodes[5]; bt.preTrans.rotX(Math.PI); box.getTop().backElement = gbox_childnodes[6]; var floorFace = new CSSFace(bt.tNode, 256, 256); floorFace.element = gbox_childnodes[0]; floorFace.N.z = 1f; #region updateTransform Action updateTransform = delegate { box.localTrans.rotY(rot_cur); box.localTrans._42 = (80f - box.height) / 2f; rootTransMatrix.rotX(tilt_cur); rootTransMatrix._42 = (80f - box.height) / 2f; floorFace.postTrans.translate(-28, -88 - box.localTrans._42, 0); box.applyTransform(); floorFace.applyTransform(); }; updateTransform(); #endregion #region resizing var resizing = default(Action); var resize_handle = page.resize_handle; resize_handle.style.cursor = IStyle.CursorEnum.move; var prevHandleY = 0f; var prevBoxH = 0f; resize_handle.onmousedown += e => { e.PreventDefault(); e.StopPropagation(); resizing = resize_handle.CaptureMouse(); //prevHandleY = e.screenY; prevHandleY = e.OffsetY; prevBoxH = box.height; }; resize_handle.onmousemove += e => { if (resizing != null) { e.PreventDefault(); e.StopPropagation(); var yy = rootTransMatrix._22; if (yy < -0.01 || yy > 0.01) { //var dy = e.screenY - prevHandleY; var dy = e.OffsetY - prevHandleY; var h = prevBoxH - dy / yy; if (h < 20) h = 20; if (h > 200) h = 200; box.changeHeight(h); frontcontrol.Size = new System.Drawing.Size( frontElement.Bounds.Width, frontElement.Bounds.Height ); //frontElement_firstChild.style.height = frontElement.style.height; //frontElement_firstChild.style.width = frontElement.style.width; updateTransform(); } else { resizing(); resizing = null; } } }; resize_handle.onmouseup += e => { if (resizing != null) { resizing(); resizing = null; } }; #endregion #region intpMotion Func<bool> intpMotion = delegate { var dR = rot_cur - rot; var dT = tilt_cur - tilt; if (dR < 0) dR = -dR; if (dT < 0) dT = -dT; var not_finished = false; if (dR < 0.002) rot_cur = rot; else { not_finished = true; rot_cur = rot_cur * 0.8f + rot * 0.2f; } if (dT < 0.002) tilt_cur = tilt; else { not_finished = true; tilt_cur = tilt_cur * 0.8f + tilt * 0.2f; } return not_finished; }; #endregion #region setLidRotate Action<float> setLidRotate = a => { lidTrans2.rotX(-a); lidTrans2._42 = -100; box.getTop().preTrans.mul(lidTrans1, lidTrans2); }; #endregion #region doAnimation Action doAnimation = null; doAnimation = delegate { playing = false; if (lidAngle > 0) { playing = true; if (close_ok || lidAngleV > 0) lidAngleV -= 0.01f; lidAngle += lidAngleV; if (lidAngle < 0) { lidAngle = 0; iframe.src = "about:blank"; iframe.Hide(); } else if (lidAngle >= 1.3f) { lidAngle = 1.3f; playing = false; } } else { lidAngle = 0f; lidAngleV = 0f; } setLidRotate(lidAngle); if ((resizing == null) && intpMotion()) playing = true; updateTransform(); if (playing) { var _this = this; Native.window.requestAnimationFrame += delegate { doAnimation(); }; } }; #endregion #region onmousemove Native.Document.body.onmousemove += e => { if (control.checkBox1.Checked) return; if (Native.Document.pointerLockElement == Native.Document.body) { rot += e.movementX * 0.01f; tilt += e.movementY * 0.01f; } else { rot = e.CursorX * 0.006f - 0.9f; tilt = (TILT_BASE - e.CursorY * 0.004f); } if (tilt < 0.5f) tilt = 0.5f; //Console.WriteLine(new { rot, tilt }.ToString()); if (!playing) doAnimation(); }; #endregion #region close_button page.close_button.onclick += e => { e.StopPropagation(); close_ok = true; if (lidAngle > 1.2) { lidAngle -= 0.1f; lidAngleV = 0.01f; } if (!playing) doAnimation(); }; #endregion #region onSearchClick Action onSearchClick = delegate { lidAngle += 0.01f; lidAngleV = 0.17f; close_ok = false; iframe.Show(); iframe.allowFullScreen = true; // Refused to display document because display forbidden by X-Frame-Options. iframe.src = frontcontrol.comboBox1.Text; if (!playing) doAnimation(); }; page.search_text.onkeydown += e => { if (e.KeyCode == 13) { onSearchClick(); } }; page.search_button.onclick += e => { onSearchClick(); }; #endregion page.search_fullscreen.onmousedown += e => { e.preventDefault(); if (e.MouseButton != IEvent.MouseButtonEnum.Left) Native.Document.body.requestPointerLock(); }; Native.Document.body.onmouseup += delegate { Native.Document.exitPointerLock(); }; page.search_fullscreen.onclick += delegate { page.box_label.requestFullscreen(); }; { var ContainerShadow = new IHTMLDiv().AttachTo(page.box_label_container); ContainerShadow.style.position = IStyle.PositionEnum.absolute; ContainerShadow.style.left = "0px"; ContainerShadow.style.top = "0px"; ContainerShadow.style.right = "0px"; ContainerShadow.style.bottom = "0px"; var Container = new IHTMLDiv().AttachTo(page.box_label_container); Container.style.position = IStyle.PositionEnum.absolute; Container.style.left = "0px"; Container.style.top = "0px"; Container.style.right = "0px"; Container.style.bottom = "0px"; control.AttachControlTo(Container); //control.AutoSizeControlTo(ContainerShadow); } { var ContainerShadow = new IHTMLDiv().AttachTo(page.front_panel); ContainerShadow.style.position = IStyle.PositionEnum.absolute; ContainerShadow.style.left = "0px"; ContainerShadow.style.top = "0px"; ContainerShadow.style.right = "0px"; ContainerShadow.style.bottom = "0px"; var Container = new IHTMLDiv().AttachTo(page.front_panel); Container.style.position = IStyle.PositionEnum.absolute; Container.style.left = "0px"; Container.style.top = "0px"; Container.style.right = "0px"; Container.style.bottom = "0px"; frontcontrol.AttachControlTo(Container); //frontcontrol.AutoSizeControlTo(ContainerShadow); frontcontrol.Width = 200; frontcontrol.Height = 80; frontcontrol.button1.Click += delegate { onSearchClick(); }; resize_handle.Orphanize().AttachTo(page.front_panel); var once = false; frontcontrol.NewForm += f => { if (once) { #if DOESITWORK Abstractatech.JavaScript.FormAsPopup.FormAsPopupExtensions.PopupInsteadOfClosing(f); #endif return; } once = true; //f.DisableFormClosingHandler = true; global::CSSMinimizeFormToSidebar.ApplicationExtension.InitializeSidebarBehaviour( f ); }; } }
public CSSCube(int p1, int p2, int p3, TransformNode rootTransNode) { }
void InitializeContent(IDefaultPage page) { // http://www.addyosmani.com/resources/googlebox/test.js var TILT_BASE = 2.0f; var qtext = page.search_text; var tilt_cur = TILT_BASE; var tilt = TILT_BASE; var rot_cur = 1f; var rot = 1f; var lidAngle = 0f; var lidAngleV = 0f; var close_ok = false; var playing = false; var iframe = page.bottom_iframe; iframe.Hide(); var rootTransMatrix = new M44(); var rootTransNode = new TransformNode(rootTransMatrix); rootTransMatrix.rotX(tilt); M44 lidTrans1 = (new M44()).translate(0f, 100f, 0f); M44 lidTrans2 = new M44(); var box = new CSSCube(200, 200, 80, rootTransNode); var gbox = page.gift_box; var gbox_childnodes = gbox.childNodes.ExceptTextNodes(); for (var i = 0; i < 4; i++) { CSSFace f = box.getSide(i); f.element = gbox_childnodes[7 + i]; f.backElement = gbox_childnodes[1 + i]; } ((CSSFace)box.getTop()).element = gbox_childnodes[11]; var frontElement = (IHTMLElement)gbox_childnodes[7]; var frontElement_firstChild = (IHTMLElement)frontElement.childNodes.ExceptTextNodes()[0]; CSSFace bt = box.getBottom(); bt.element = gbox_childnodes[5]; bt.preTrans.rotX(Math.PI); box.getTop().backElement = gbox_childnodes[6]; var floorFace = new CSSFace(bt.tNode, 256, 256); floorFace.element = gbox_childnodes[0]; floorFace.N.z = 1f; #region updateTransform Action updateTransform = delegate { box.localTrans.rotY(rot_cur); box.localTrans._42 = (80f - box.height) / 2f; rootTransMatrix.rotX(tilt_cur); rootTransMatrix._42 = (80f - box.height) / 2f; floorFace.postTrans.translate(-28, -88 - box.localTrans._42, 0); box.applyTransform(); floorFace.applyTransform(); }; updateTransform(); #endregion #region resizing var resizing = default(Action); var resize_handle = page.resize_handle; resize_handle.style.cursor = IStyle.CursorEnum.move; var prevHandleY = 0f; var prevBoxH = 0f; resize_handle.onmousedown += e => { e.PreventDefault(); e.StopPropagation(); resizing = resize_handle.CaptureMouse(); //prevHandleY = e.screenY; prevHandleY = e.OffsetY; prevBoxH = box.height; }; resize_handle.onmousemove += e => { if (resizing != null) { e.PreventDefault(); e.StopPropagation(); var yy = rootTransMatrix._22; if (yy < -0.01 || yy > 0.01) { //var dy = e.screenY - prevHandleY; var dy = e.OffsetY - prevHandleY; var h = prevBoxH - dy / yy; if (h < 20) h = 20; if (h > 200) h = 200; box.changeHeight(h); frontElement_firstChild.style.height = frontElement.style.height; frontElement_firstChild.style.width = frontElement.style.width; updateTransform(); } else { resizing(); resizing = null; } } }; resize_handle.onmouseup += e => { if (resizing != null) { resizing(); resizing = null; } }; #endregion #region intpMotion Func<bool> intpMotion = delegate { var dR = rot_cur - rot; var dT = tilt_cur - tilt; if (dR < 0) dR = -dR; if (dT < 0) dT = -dT; var not_finished = false; if (dR < 0.002) rot_cur = rot; else { not_finished = true; rot_cur = rot_cur * 0.8f + rot * 0.2f; } if (dT < 0.002) tilt_cur = tilt; else { not_finished = true; tilt_cur = tilt_cur * 0.8f + tilt * 0.2f; } return not_finished; }; #endregion #region setLidRotate Action<float> setLidRotate = a => { lidTrans2.rotX(-a); lidTrans2._42 = -100; box.getTop().preTrans.mul(lidTrans1, lidTrans2); }; #endregion #region doAnimation Action doAnimation = null; doAnimation = delegate { playing = false; if (lidAngle > 0) { playing = true; if (close_ok || lidAngleV > 0) lidAngleV -= 0.01f; lidAngle += lidAngleV; if (lidAngle < 0) { lidAngle = 0; iframe.src = "about:blank"; iframe.Hide(); } else if (lidAngle >= 1.3f) { lidAngle = 1.3f; playing = false; } } else { lidAngle = 0f; lidAngleV = 0f; } setLidRotate(lidAngle); if ((resizing == null) && intpMotion()) playing = true; updateTransform(); if (playing) { var _this = this; Native.Window.requestAnimationFrame += delegate { doAnimation(); }; } }; #endregion #region onmousemove Native.Document.body.onmousemove += e => { if (Native.Document.pointerLockElement == Native.Document.body) { rot += e.movementX * 0.01f; tilt += e.movementY * 0.01f; } else { rot = e.CursorX * 0.006f - 0.9f; tilt = (TILT_BASE - e.CursorY * 0.004f); } if (tilt < 0.5f) tilt = 0.5f; //Console.WriteLine(new { rot, tilt }.ToString()); if (!playing) doAnimation(); }; #endregion #region close_button page.close_button.onclick += e => { e.StopPropagation(); close_ok = true; if (lidAngle > 1.2) { lidAngle -= 0.1f; lidAngleV = 0.01f; } if (!playing) doAnimation(); }; #endregion #region onSearchClick Action onSearchClick = delegate { lidAngle += 0.01f; lidAngleV = 0.17f; close_ok = false; iframe.Show(); // Refused to display document because display forbidden by X-Frame-Options. iframe.src = "http://example.com"; if (!playing) doAnimation(); }; page.search_text.onkeydown += e => { if (e.KeyCode == 13) { onSearchClick(); } }; page.search_button.onclick += e => { onSearchClick(); }; #endregion page.search_fullscreen.onmousedown += e => { e.PreventDefault(); if (e.MouseButton != IEvent.MouseButtonEnum.Left) Native.Document.body.requestPointerLock(); }; Native.Document.body.onmouseup += delegate { Native.Document.exitPointerLock(); }; page.search_fullscreen.onclick += delegate { page.box_label.requestFullscreen(); }; }
private List<Object3D> WrapTransform(TransformNode node, float[,] transformation) { float[,] matrix = node.GenerateTransformMatrix(); Shape3DComposite shapes = new Shape3DComposite(); List<Object3D> objects = new List<Object3D>(); objects.Add(shapes); foreach (BaseNode child in node) { List<Object3D> t = TestConvNode(child); foreach (Object3D obj in t) { if (obj != null) { if (obj is Shape3D) { shapes.Add((Shape3D)obj); } else { objects.Add(obj); } } } } return objects; }
/// <summary> /// Return a pointer to the unamanged version of this callback. /// </summary> /// <param name="callback">The callback.</param> /// <returns>A pointer to a shadow c++ callback</returns> public static IntPtr ToIntPtr(TransformNode callback) { return ToIntPtr<TransformNode>(callback); }
public void Freeze(TransformNode node) { for (int index = 0; index < _vertices.Count; index++) { Vector3 normal = _vertices[index].Normal; Vector2 uv = _vertices[index].TextureCoordinate; VertexPositionNormalTexture tmp = new VertexPositionNormalTexture { Position = Vector3.Transform( Vertices[index].Position,node.World), Normal = normal, TextureCoordinate = uv }; _vertices[index] = tmp; //RenderVertices[index] = tmp; } node.World = Matrix.Identity; node.Rotate = Vector3.Zero; node.Translate = Vector3.Zero; node.Scale = Vector3.One; node.RotQuaternion = Quaternion.Identity; }