public bool initDirect3D() { try { PresentParameters presentParameter = new PresentParameters(); presentParameter.Windowed = true; presentParameter.SwapEffect = SwapEffect.Discard; presentParameter.AutoDepthStencilFormat = DepthFormat.D16; presentParameter.PresentationInterval = PresentInterval.Immediate; presentParameter.EnableAutoDepthStencil = true; m_device = new Device(0, DeviceType.Hardware, this, CreateFlags.SoftwareVertexProcessing, presentParameter); m_camera = new CCamera(m_device); m_camera.Width = this.Width; m_camera.Height = this.Height; m_render = new CRender(m_camera); m_plane = new CPlane(); m_plane.setPlane(new Vector3(0, 0, 0), 200, 200); m_camera.CameraTarget = new Vector3(0, 0, 0); m_camera.CameraPostion = new Vector3(100, 100, 100); m_roleMgr = new CRoleMgr(); } catch (Exception) { return(false); } return(true); }
public void update(CCamera a_camera, float a_delayTime, float a_serverTimer) { foreach (DictionaryEntry keyValuePair in m_hashtable) { IRole item = (IRole)keyValuePair.Value; item.update(a_camera, a_delayTime, a_serverTimer); } }
public void update(CCamera a_camera, float a_delayTime, float a_serverTimer) { Vector3 dirCamera = a_camera.Direction; Vector3 dirFront = new Vector3(dirCamera.X, 0, dirCamera.Z); Vector3 dirLeft = new Vector3(dirCamera.Z * -1, 0, dirCamera.X); Vector3 dirSpeedFront; Vector3 dirSpeedLeft; if (m_isMoveFrontValid) { dirSpeedFront = dirFront; } else if (m_isMoveBackValid) { dirSpeedFront = -1 * dirFront; } else { dirSpeedFront = new Vector3(0, 0, 0); } if (m_isMoveLeftValid) { dirSpeedLeft = dirLeft; } else if (m_isMoveRightValid) { dirSpeedLeft = -1 * dirLeft; } else { dirSpeedLeft = new Vector3(0, 0, 0); } m_direction = dirSpeedFront + dirSpeedLeft; m_direction.Normalize(); Vector3 offset = m_direction * m_speed * a_delayTime; m_position.Add(offset); m_box.setBox(m_position); }
public CRender(CCamera a_camera) { m_device = a_camera.getDevice(); m_camera = a_camera; }