// // GetActorInformation - Chapter 20, page 760 // public EditorActorParams GetActorInformation(uint actorId) { EditorActorParams actorParams; try { // We're getting a position array from the unmanaged dll, so // allocate space in memory that can hold 3 floats. IntPtr tempArray = Marshal.AllocCoTaskMem(3 * sizeof(float)); NativeMethods.GetActorPos(tempArray, actorId); // Copy the memory into a float array and dispose of our memory. float[] actorPos = new float[3]; Marshal.Copy(tempArray, actorPos, 0, 3); Marshal.FreeCoTaskMem(tempArray); int actorType = NativeMethods.GetActorType(actorId); UInt32 actorColor = NativeMethods.GetActorColor(actorId); actorParams = new EditorActorParams(actorId, (ActorType)actorType, actorPos, Color.FromArgb((int)actorColor), 0.0f, 0.0f); return(actorParams); } catch { return(actorParams = new EditorActorParams(EditorActorParams.INVALID_ID)); } }
private void PopulateActorInformation(EditorActorParams actorParams) { m_actorIdTextbox.Text = actorParams.m_actorId.ToString(); m_actorTypeTextbox.Text = (String)m_types[(int)actorParams.m_actorType]; m_actorXTextbox.Text = actorParams.m_pos[0].ToString(); m_actorYTextbox.Text = actorParams.m_pos[1].ToString(); m_actorZTextbox.Text = actorParams.m_pos[2].ToString(); m_colorPreviewPanel.BackColor = actorParams.m_color; }
// // RestoreActorPosBtn_Click - Chapter 20, page 786 // private void RestoreActorPosBtn_Click(object sender, EventArgs e) { // The position has been changed in the EditorForm, but the user wants to get the // old position information on this actor before updating the position. // The EngineDisplayForm should retrieve information on this actor, which the EditorForm // will use to repopulate actor information. EditorActorParams actorParams = m_parent.GetActorInformation(UInt32.Parse(this.m_actorIdTextbox.Text)); PopulateActorInformation(actorParams); }
private void TreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { TreeNode node = e.Node; if (node != m_mainNode) { // If we click on an actor node, have the EngineDisplayForm retrieve information // on that actor from the unmanaged dll. EditorActorParams actorParams = m_parent.GetActorInformation(UInt32.Parse(node.Name)); PopulateActorInformation(actorParams); } }
public void SelectTreeNode(int actorId) { // There are two methods of populating actor information. We can // select a node in the treeview, or we can click on the actor // in the world view. If we click on the actor in the world view, // we use this function to update the actor information. TreeNode[] node = m_mainNode.Nodes.Find(actorId.ToString(), true); if (node.GetLength(0) > 0) { m_treeView.SelectedNode = node[0]; EditorActorParams actorParams = m_parent.GetActorInformation((uint)actorId); PopulateActorInformation(actorParams); } }
// // GetActorInformation - Chapter 20, page 760 // public EditorActorParams GetActorInformation(uint actorId) { EditorActorParams actorParams; try { // We're getting a position array from the unmanaged dll, so // allocate space in memory that can hold 3 floats. IntPtr tempArray = Marshal.AllocCoTaskMem(3 * sizeof(float)); NativeMethods.GetActorPos(tempArray, actorId); // Copy the memory into a float array and dispose of our memory. float[] actorPos = new float[3]; Marshal.Copy(tempArray, actorPos, 0, 3); Marshal.FreeCoTaskMem(tempArray); int actorType = NativeMethods.GetActorType(actorId); UInt32 actorColor = NativeMethods.GetActorColor(actorId); actorParams = new EditorActorParams(actorId, (ActorType)actorType, actorPos, Color.FromArgb((int)actorColor), 0.0f, 0.0f); return actorParams; } catch { return actorParams = new EditorActorParams(EditorActorParams.INVALID_ID); } }