Jump to content

  • Log In with Google      Sign In   
  • Create Account

Oblivion165

Member Since 03 Feb 2011
Offline Last Active Jan 31 2013 11:58 PM

Topics I've Started

OpenGL (lwjgl) wont disable texturing

31 January 2013 - 04:00 PM

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:

 

But when a texture is drawn, it looks like this:


 

 

Any ideas?


XNA - Trying to get a point in space, based on viewscreen (not traditional picking)

16 October 2012 - 03:47 AM

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.

http://imageshack.us...51/65739345.png

My plan is to use the intersect point:

http://imageshack.us...76/55634161.png

and then create the ray from that point to the intersect point. Ive tried this:
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;
}

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?

XNA Deferred Renderer without loading models

03 April 2012 - 11:54 AM

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.

3DS Max animated model to XNA

02 April 2011 - 07:16 PM

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.

Odd ray intersect behavior

10 February 2011 - 04:07 PM

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.

public Ray CalculateRay(Vector3 src, Vector3 tar)
    	{
        	Vector3 direction = (tar - src);
        	return new Ray(src,direction);
    	}
Attached File  RayFixed.png   137.01KB   36 downloads

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.

Attached File  RayOdd.png   203.12KB   30 downloads

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)

Attached File  RayOdd2.png   203.16KB   37 downloads

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.

PARTNERS