public static void Main(string[] args) { try { // throw new Exception(); renderer = new DirectXLib.DirectEngine(); flip = true; }catch(Exception) { renderer = new GLRenderer(); flip = false; } renderer.cameraPosition.Z = -5; Shader myder = renderer.createBasicShader(); //Uncomment for AABB collisions //physicsworld.testtype = CollisionTestType.AABB; myder.Draw(); Bitmap mmap = new Bitmap("pic.jpg"); Texture2D mtex = renderer.createTextureFromBitmap(mmap); Bitmap newmap = new Bitmap("pic.jpg"); Graphics tfix = Graphics.FromImage(newmap); tfix.DrawString("Hello world!", new Font(FontFamily.GenericMonospace, 16), Brushes.Red, new PointF(0, 0)); tfix.Dispose(); mtex.UploadBitmap(newmap); mtex.Draw(); rtex = renderer.createTexture(512, 512); rtex.Draw(); Mesh[] meshes = Primitives.LoadMesh("playercube.obj",flip); collisiontester = new PhysicalObject(meshes[0].meshverts, 5, CollisionType.Dynamic,physicsworld); collisiontester.Position = new Vector3D(-5, 0, 0); mainmesh = meshes[0]; foreach (Mesh mesh in meshes) { VertexBuffer tbuff = renderer.CreateVertexBuffer(mesh.meshverts, mesh.meshtexas, mesh.meshnorms); rotatingbuffer = tbuff; if (mesh.bitmap != null) { Console.WriteLine("BITMAP RENDER"); Texture2D tt = renderer.createTextureFromBitmap(mesh.bitmap); tt.Draw(); } tbuff.Draw(); } mtex.Draw(); Mesh cube = Primitives.LoadMesh("playercube.obj",flip)[0]; theobject = new PhysicalObject(cube.meshverts, 9, CollisionType.Dynamic,physicsworld); collisiontester.ownedVBO = rotatingbuffer; theobject.ownedVBO = renderer.CreateVertexBuffer(cube.meshverts, cube.meshtexas, cube.meshnorms); theobject.ownedVBO.Draw(); physicsworld.physicalobjects.Add(theobject); physicsworld.physicalobjects.Add(collisiontester); Mesh anothercube = Primitives.LoadMesh("playercube.obj",flip)[0]; PhysicalObject mobject = new PhysicalObject(anothercube.meshverts.Clone() as Vector3D[], 1, CollisionType.Dynamic,physicsworld); mobject.ownedVBO = renderer.CreateVertexBuffer(anothercube.meshverts, anothercube.meshtexas, anothercube.meshnorms); physicsworld.physicalobjects.Add(mobject); mobject.ownedVBO.Draw(); mobject.Position = new Vector3D(30, 0, 0); //Set physics properties theobject.Weight = 1; collisiontester.Weight = 1; //collisiontester.Velocity = new Vector3D(.05f, 0, 0); theobject.Position = new Vector3D(15, 0, 0); theobject.IsCube = true; theobject.Weight = 9999999; mobject.IsCube = true; //End physics properties physicsworld.Start(); physicsworld.physicsUpdateFrame += new System.Threading.ThreadStart(physicsworld_physicsUpdateFrame); System.Threading.Thread mthread = new System.Threading.Thread(thetar); mthread.Start(); foreach (Keyboard et in renderer.GetExtensionKeyboards()) { et.onKeyDown += new keyboardeventargs(defaultKeyboard_onKeyDown); et.onKeyUp += new keyboardeventargs(defaultKeyboard_onKeyUp); } renderer.defaultMouse.onMouseMove += new mouseEvent(defaultMouse_onMouseMove); renderer.defaultMouse.onMouseDown += new mouseEvent(defaultMouse_onMouseDown); //Draw a quad List<Vector3D> overts = new List<Vector3D>(); List<Vector3D> onorms = new List<Vector3D>(); List<Vector2D> ocords = new List<Vector2D>(); //Triangle 0 overts.Add(new Vector3D(-1,-1,0)); overts.Add(new Vector3D(-1,1,0)); overts.Add(new Vector3D(1,1,0)); ocords.Add(new Vector2D(0,0)); ocords.Add(new Vector2D(0,1)); ocords.Add(new Vector2D(1,1)); //Triangle 1 overts.Add(new Vector3D(1,1,0)); overts.Add(new Vector3D(1,-1,0)); overts.Add(new Vector3D(-1,-1,0)); ocords.Add(new Vector2D(1,1)); ocords.Add(new Vector2D(1,0)); ocords.Add(new Vector2D(0,0)); float zfactor = 900; for(int i = 0;i<overts.Count;i++) { //Translate by -1 overts[i] = new Vector3D((overts[i].X)*zfactor,(overts[i].Y)*zfactor,overts[i].Z); } for(int i = 0;i<overts.Count;i++) { onorms.Add(new Vector3D(1,1,1)); } mbuff = renderer.CreateVertexBuffer(overts.ToArray(),ocords.ToArray(),onorms.ToArray()); mbuff.IsStatic = true; mbuff.Position.Z = zfactor; //rtex.Draw(); mbuff.Draw(); mtex.Draw(); }
public RealProg(Renderer _renderer) { renderer = _renderer; renderer.cameraPosition.Z = -15; Shader myder = renderer.createBasicShader(); //Uncomment for AABB collisions // physicsworld.testtype = CollisionTestType.AABB; myder.Draw(); Bitmap mmap = new Bitmap("pic.jpg"); Texture2D mtex = renderer.createTextureFromBitmap(mmap); mtex.Draw(); rtex = renderer.createTexture(512, 512); rtex.Draw(); Mesh[] meshes = Primitives.LoadMesh("playercube.obj", flip); collisiontester = new PhysicalObject(meshes[0].meshverts, 5, CollisionType.Dynamic, physicsworld); collisiontester.Position = new Vector3D(-5, 0, 0); mainmesh = meshes[0]; foreach (Mesh mesh in meshes) { VertexBuffer tbuff = renderer.CreateVertexBuffer(mesh.meshverts, mesh.meshtexas, mesh.meshnorms); rotatingbuffer = tbuff; if (mesh.bitmap != null) { Console.WriteLine("BITMAP RENDER"); Texture2D tt = renderer.createTextureFromBitmap(mesh.bitmap); tt.Draw(); } tbuff.Draw(); } mtex.Draw(); Mesh cube = Primitives.LoadMesh("playercube.obj", flip)[0]; theobject = new PhysicalObject(cube.meshverts, 9, CollisionType.Dynamic, physicsworld); collisiontester.ownedVBO = rotatingbuffer; theobject.ownedVBO = renderer.CreateVertexBuffer(cube.meshverts, cube.meshtexas, cube.meshnorms); theobject.ownedVBO.Draw(); physicsworld.physicalobjects.Add(theobject); physicsworld.physicalobjects.Add(collisiontester); Mesh anothercube = Primitives.LoadMesh("playercube.obj", flip)[0]; PhysicalObject mobject = new PhysicalObject(anothercube.meshverts.Clone() as Vector3D[], 1, CollisionType.Dynamic, physicsworld); mobject.ownedVBO = renderer.CreateVertexBuffer(anothercube.meshverts, anothercube.meshtexas, anothercube.meshnorms); physicsworld.physicalobjects.Add(mobject); mobject.ownedVBO.Draw(); mobject.Position = new Vector3D(30, 0, 0); //Set physics properties theobject.Weight = 1; collisiontester.Weight = 1; //collisiontester.Velocity = new Vector3D(.05f, 0, 0); theobject.Position = new Vector3D(15, 0, 0); theobject.IsCube = true; theobject.Weight = 9999999; mobject.IsCube = true; //End physics properties physicsworld.Start(); physicsworld.physicsUpdateFrame += new System.Threading.ThreadStart(physicsworld_physicsUpdateFrame); System.Threading.Thread mthread = new System.Threading.Thread(thetar); mthread.Start(); #if PHONE renderer.defaultTouchpad.onTouchMoved += new TouchEvent(defaultTouchpad_onTouchMoved); renderer.defaultTouchpad.onTouchFound += new TouchEvent(defaultTouchpad_onTouchFound); renderer.defaultTouchpad.onTouchLost += new TouchEvent(defaultTouchpad_onTouchLost); #endif #if !PHONE renderer.defaultKeyboard.onKeyDown += new keyboardeventargs(defaultKeyboard_onKeyDown); renderer.defaultKeyboard.onKeyUp += new keyboardeventargs(defaultKeyboard_onKeyUp); renderer.defaultMouse.onMouseMove += new mouseEvent(defaultMouse_onMouseMove); renderer.defaultMouse.onMouseDown += new mouseEvent(defaultMouse_onMouseDown); #endif }
public UploadBitmapOperation(Bitmap mmap, Texture2D tptr) { bitmap = mmap; texptr = tptr; }
public TextureOperation(Texture2D _underlyingtexture, TextureOperationType optype) { underlyingtexture = _underlyingtexture; _optype = optype; }
public abstract void SetRenderTarget(Texture2D texture, Vector3D campos, Vector3D camrot);
public override void SetRenderTarget(Texture2D texture, Vector3D cpos, Vector3D crot) { spos = cpos; srot = crot; rendertexture = texture as GLTexture; //TODO: Use a RenderTargetOperation instead of this method //SetRenderTargetOperation mop = new SetRenderTargetOperation(this,texture as GLTexture,cpos,crot); }
public override void SetRenderTarget(Texture2D texture, Vector3D campos, Vector3D camrot) { RenderTargetChange mchange = new RenderTargetChange(texture as DXTexture, this,campos,camrot); }