Jump to content

  • Log In with Google      Sign In   
  • Create Account

Lunatix

Member Since 17 Dec 2010
Offline Last Active Dec 17 2012 10:11 AM

Topics I've Started

Matrices, Lights, Objects - Transformation Question

04 September 2012 - 12:41 PM

Hi!

Currently, i'm writing a little raytracing library, everything worked very well - but now, i'm implementing matrices for the transformation.. so i would like to make some things right, because i think they could be wrong:

- LoadMatrix: Simply resets all Push and Pop stages and loads the given values into CurrentMatrix.
- PushMatrix: Creates a new matrix, copyies the current stage and pushes the current matrix on stack
- MultMatrix: Multiplies CurrentMatrix * ObjectMatrix
- PopMatrix: Restores the last pushed stage

- Normal Matrix: Upper 3x3 of CurrentMatrix, Inversed, Transposed (Compute it every time Load or MultMatrix is called)

- Set a Vertex: Vector(x, y, z) is multiplied by CurrentMatrix
- Set a Normal: Normal(nx, ny, nz) is Multiplied by CurrentMatrix -- or, when computed by intersection algorythm, this normal is used (and not transformed by NormalMatrix?)

- The Lights: Position and Direction is recomputed each "LoadMatrix" is called, not multiplied by CurrentMatrix
- Rays of Projection: Computed once per "SetViewport" - because our world is transformed, it isn't necessary to transform them

Would be nice if someone knows, if my thoughts are right or not..

Happy coding,
Lunatix

How draws OpenGL to a Window Handle?

29 August 2012 - 02:55 AM

Hello!

I would like to know, how a graphics api like opengl finally draws to a window's handle.. i know what a pixelformatdescriptor or a HDC is, but my question is - how draws opengl the final "pixels" to the control / handle, whatever? I downloaded the Mesa GL source code and i'm trying to find something.. but maybe, someone knows a sample or something or another solution for my problem?

Idea for a Fog "Layer"

21 June 2012 - 10:22 AM

I need an idea for rendering fog, for example, like in greed corp:

Posted Image

What did you think what greed corp is doing for this? Simple sprites with cloudy textures, floating at a definied level over the map? Or is there a shader solution?


Regards,
Lunatix

[GL, C#] Texture flags and setup like in Minecraft

14 June 2012 - 06:56 AM

Hi!


I'm building a Voxel Shooter Game and i stuck at the textures. I have a chunk and map system and now trying to texturize the voxels via tile-textureing. All tiles of the texture are 32x32 and the texture itself is 512x512.

[Picture 1]
Posted Image

[Picture 2]
Posted Image

[Picure 3]
Posted Image

So, as you see, the tiles look like they are blurred [Pic. 2] and there are seems [Pic. 1] between them. I thought the mipmapping was causing it, also i've ad one extra pixel to prevent bleeding [Pic. 3] - but nothing seems to work. For example, the minecraft tiles are 16x16 - and they are sharp as hell.

So, i would like to ask, if somebody knows a good texture setup for this... maybe i have to write my own "BuildMipMaps" function? With a "Pixel Resize" Downsampling Mode like in Paint Shop Pro?

Monitor (Threading) Locking Problem

13 May 2012 - 01:11 PM

Hey Everyone!

I have a little problem with my game... i have a worker thread for updating and calculating objects (matrices for opengl) in the background.
This static class called "Driver" holds a thread handle and two lists - one for camera's, one for other objects. The "Driver" checks continously for changes of the objects, iteration through the two lists. If an object has changes, its "Calculate()" method is called by the "Driver".

Each time of iteration through one of the Lists, the list is locked:

   Monitor.Enter(CameraList);
   try{
	foreach (BaseCamera Cam in CameraList){
	 if (!(Cam.isLocked) && (Cam.isCalcRequired())){
	  Cam.onUpdate();
	 }
	}
   }finally{
	Monitor.Exit(CameraList);
   }
   Monitor.Enter(ObjectList);
   try{
	foreach (BaseObject obj in ObjectList){
	 if (!(obj.isLocked) && (obj.isCalcRequired())){
	  obj.onUpdate();
	 }
	}
   }finally{
	Monitor.Exit(ObjectList);
   }

All fine. But sometimes I get a deadlock when adding an object - i call a static "AddObject" method which looks like this:
		public static bool AddObject(BaseObject Object){
   if (Object.Ident == ObjectIdent.Camera){
	Monitor.Enter(CameraList);
	try{
	 CameraList.Add((BaseCamera)Object);
	 return true;
	}finally{
	 Monitor.Exit(CameraList);
	}
   }else{
	Monitor.Enter(ObjectList);
	try{
	 ObjectList.Add(Object);
	 return true;
	}finally{
	 Monitor.Exit(ObjectList);
	}
   }
  
   return false;
  }

I think, the deadlock appears, because the WorkerThread iterates to fast and the AddObject function is unable to lock one of the lists. But to solve the problem, i had to add "Thread.Sleep(100)" after updating both lists... is there a simple way to avoid such problems? Sleeping for 100Ms makes everything very laggy ;)

P.s.: I tried other variants with Semaphores and Mutex but none of them solved the deadlock problem =/

PARTNERS