• Content count

  • Joined

  • Last visited

Community Reputation

107 Neutral

About Oblivion165

  • Rank
  1. Hello,   I come from a background of XNA and some DX9 programming and I'm trying to learn some more about OpenGL. Im currently making a JavaXNA port to make my life easier.   The problem I'm having is that OpenGL wont disable texturing with GL11.glDisable(GL11.GL_TEXTURE_2D); I'm recreating spritebatch and this is how I draw a texture:   public void DrawTexture2D(Texture2D Texture,int x, int y, int width,int height) { GL11.glEnable(GL11.GL_TEXTURE_2D); y = Game.graphics.PreferredBackBufferHeight - height; GL11.glBindTexture(GL11.GL_TEXTURE_2D, Texture.ID); GL11.glColor3f(1.0F, 1.0F, 1.0F); GL11.glTexCoord2f(0.0F, 1.0F); GL11.glVertex2f(x, y); GL11.glTexCoord2f(0.0F, 0.0F); GL11.glVertex2f(x, y + height); GL11.glTexCoord2f(1.0F, 0.0F); GL11.glVertex2f(x + width, y + height); GL11.glTexCoord2f(1.0F, 1.0F); GL11.glVertex2f(x + width, y); GL11.glDisable(GL11.GL_TEXTURE_2D); }   And then after it, I simply want to draw a colored rectangle like so:   public void DrawRect(int x, int y,int width,int height,Color Color) { GL11.glDisable(GL11.GL_TEXTURE_2D); y = Game.graphics.PreferredBackBufferHeight - height; GL11.glColor3f(Color.r,Color.g,Color.b); GL11.glVertex2f( x, y); GL11.glColor3f(Color.r,Color.g,Color.b); GL11.glVertex2f( x, y + height); GL11.glColor3f(Color.r,Color.g,Color.b); GL11.glVertex2f(x + width, y + height); GL11.glColor3f(Color.r,Color.g,Color.b); GL11.glVertex2f(x + width, y); }   But even though I told OpenGL to disable texturing twice, the plain rectangle still has the texture that was used before. (just doesn't have texture coords)   This is what its supposed to look like: [url=http://img541.imageshack.us/img541/9581/60622173.png][/URL]   But when a texture is drawn, it looks like this: [url=http://img10.imageshack.us/img10/466/44268445.png][/URL]     Any ideas?
  2. Hi there, Im trying to get the Vector3 of the bottom right corner of a viewport in 3d space. I'm trying to create a ray for a weapon but I cant seem to find the correct information to get it. [url="http://imageshack.us/a/img203/5751/65739345.png"]http://imageshack.us...51/65739345.png[/url] My plan is to use the intersect point: [url="http://imageshack.us/a/img24/6876/55634161.png"]http://imageshack.us...76/55634161.png[/url] and then create the ray from that point to the intersect point. Ive tried this: [CODE] public static Vector3 ScreenPositionToWorldPoint(Matrix View, Matrix Projection, Matrix World,IntVector2 MousePos) { Vector3 nearSource = new Vector3((float)MousePos.x, (float)MousePos.y, 0f); Vector3 nearPoint = gGlobal.Device.Viewport.Unproject(nearSource, Projection, View, World); return nearPoint; } [/CODE] But the vector3 returned isn't the correct number. For instance, if the player is standing at 10,0,10 then that will return 9.999, 0.00123, 9.9999. Thats with the viewport being 800x600 and sending that as the mouse position. Anyone have a clue how to do this or an alternate way?
  3. Is it possible to use a deferred renderer without using a model pipeline? My engine creates all models from an editor and I dont use any imported models at all. It seems that all XNA DR for 4.0 are all using the same code just copy/paste and i cant find anyone using one on just generated triangles.
  4. I've looked all over the internet for this. I can't find a single place that gives you the required information anywhere! All the samples come with pre-compiled models that have no information on how to setup the animation correctly at all. Even microsofts "dude" model is just there and apparently it has an animation called "walk" inside of it but how do you do such a thing? I have a model that is boned, exports and loads into XNA perfectly but I cant get the animation to play for the life of me and every animation library i've found doesn't tell you how to setup the animations either. When I follow tutorials for animating models for cgi like instances, the model wont export and fails to load in XNA...its madness.
  5. EDIT: Of course after fighting it for 3 days I figure it out 5 minutes after I post. The correct way to do it was to calculate a direction based off the source and taget vectors. [code] public Ray CalculateRay(Vector3 src, Vector3 tar) { Vector3 direction = (tar - src); return new Ray(src,direction); }[/code] [attachment=1346:RayFixed.png] It looks like a mess but it works on every test I threw at it. Posted this solution incase someone has a similar problem. ............ Original Post: Hi there, I'm having some odd ray to bounding box intersection issues. I have working picking code and its pixel perfect but when I use rays in this manor, it claims collisions where it shouldn't and doesn't where it should. (Box one the end of the top row should be shadowed by the one to its left) I'm working on some basic lights and using rays to determine shadows etc. [attachment=1344:RayOdd.png] As you can see in this one, the rays start at the top of the box only and goes directly to the light source: (I am not checking for collision on the origin squares bounding box) [attachment=1345:RayOdd2.png] Now to me it looks like the ray intersect is calculating it as if the ray were pointing straight up in the air with no angle. The ones below the top layer collide with the cube above it but ones at the top don't collide with the ones next to them. I have verified that the bounding boxes are perfectly aligned to each cube and the only thing i can see is that the picking code uses matrix data to align itself. Do i need to adjust the rays for the world matrix or some such? Right now I'm making rays by simply Ray ry = new Ray(SourceVector3, TargetVector3) and that's it.
  6. Ah thank you for clearing that up looks like I had my terminology wrong. I was able to use that phone example to create exactly what I needed and I am getting fantastic performance. 60 frames rendering 10,000 quads with a 128x128 texture! Thanks for your help guys. EDIT: And that link is the one I was talking about that is too complex for me.
  7. [quote name='j0mich01' timestamp='1296748703' post='4769051'] This XNA tutorial is for windows phone, but it should run on a PC somewhat effortlessly. It basically draws a textured cube and builds the vertex information in the code. It'll at least point you in the right direction. [url="http://blogs.msdn.com/b/dawate/archive/2011/01/20/constructing-drawing-and-texturing-a-cube-with-vertices-in-xna-on-windows-phone-7.aspx"]http://blogs.msdn.co...ws-phone-7.aspx[/url] [/quote] That is a very nice example but sadly is doesn't use hardware instances to draw that cube, just uses standard primitives. Thanks though! EDIT: Wait, I could be wrong here. I thought that it requires you to use the DrawIndexedPrimitive but that one is setting a vertex buffer. I'll look more into it and get back to ya' EDIT 2: Fantastic, as long as this is actually doing it this is perfect. Has 4 of my major questions in it right off the bat. [code] public void RenderToDevice(GraphicsDevice device) { // Build the cube, setting up the _vertices array if (_isConstructed == false) ConstructCube(); // Create the shape buffer and dispose of it to prevent out of memory using (VertexBuffer buffer = new VertexBuffer( device, VertexPositionNormalTexture.VertexDeclaration, NUM_VERTICES, BufferUsage.WriteOnly)) { // Load the buffer buffer.SetData(_vertices); // Send the vertex buffer to the device device.SetVertexBuffer(buffer); } // Draw the primitives from the vertex buffer to the device as triangles device.DrawPrimitives(PrimitiveType.TriangleList, 0, NUM_TRIANGLES); } [/code] So is this a legit way of doing hardware instaces? I take it that you just build all the objects in the same vertex declare and then load them into the buffer.
  8. Hi, I am a long time programmer just starting to get into 3D from 2D games. I have made some progress in DX9 but am having trouble finding a functional XNA 4.0 Tutorial that isn't overly complicated or uses meshes instead of vertex based geometry. For instance the one from MSDN is way too complicated for someone just starting out. All I want to do is take 1 quad with a texture and render it multiple times at other locations. Like so: [img]http://img714.imageshack.us/img714/4121/quadd.png[/img] If it would work with standard lighting that would be fantastic or at lease let me manually determine the darkness like in DX9's material color. Thanks for your help if anyone has any EDIT: Oh and I'm working in C#