13 Replies - 5812 Views - Last Post: 05 February 2012 - 08:05 AM

Moving texture to point

Posted 31 January 2012 - 02:20 PM

Hi, guys I am trying to make my 2d texture to go at my 3D model points slowly,but I have some problems with that:

1.My first question is how to make the enemy initialize randomly only behind the black line ?
2.How to get pseudo 3D model coordinates ?
3.After I have the model coordinates how to move my 2d texture slowly to the model ?

Re: Moving texture to point

Posted 31 January 2012 - 03:52 PM

You need to look into controlling the drawing order (z-buffer) for your objects, if you look around your room/office you'll see exactly what I'm talking about. Pick any object in front of you that is visible and you'll notice that it's in front of something else because it's closer to you. The same thing applies to 3D games, since we're using XNA that uses the LHR (Left Hand Rule), so that means Z = 0 is the closest thing possible to the screen and anything else is either behind the screen (0-N) or further away (0+N).

So you will need to figure out a way of making an artificial draw order for your 2D objects and then use it with the Z axis of your 3D objects to work out the draw order for all your objects together.

and in the view matrix the position value x,y are always random from 0 to 700,but when I start the game windows and call the enemy class 3 times it draw me three objects at the same coordinates, but the values in position are always different.

Re: Moving texture to point

Posted 05 February 2012 - 06:56 AM

Ok I have some progress ,and some problems:

The green sphere is the player and the red one the enemy,in this picture the enemy collided successfully with the player.
The problem is that the sphere is too far from the model,here the code which draw the sphere: