XNA Game Development Forums
2012/05/18 06:07:20 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Help Search Calendar Login Register  
Pages: [1]
  Print  
Author Topic: Screen Flickering problem...  (Read 1699 times)
simpson.jon
Newbie
*
Offline Offline

Posts: 6


View Profile
« on: 2007/02/21 13:46:48 »

I was wondering if anyone might know of a reason the screen would flicker when using globalRevolve? While rotating it appears to blink and if you let go of the controls at the right moment the objects all dissappear. I've tried commenting out lines to see if I can get it to stop and I found that it would if I commented out the lines

Code:
myPosition = Vector3.Transform( myRevolveTarget - myPosition, Matrix.CreateFromQuaternion(rotate)) + myRevolveTarget;

My computer doesn't support the pixel shaders used in the HMEngine so I've rewritten parts to use the basic effect, is that the problem? I don't understand what that line could possibly do to make the screen flicker, but it does work without flickering without that line. Although the camera rotation is off.

Thanks for any help!
Logged
simpson.jon
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #1 on: 2007/02/23 11:49:09 »

I've realized what I think is the problem but I don't know how to fix it. My camera appears to be rotating 180 degrees every frame so the screen 'flickers' but it's really looking the wrong way. My myRevolveTarget points to an object in front of the camera, and the myPosition is the current position so I'm lost. It always seems to be weird little problems that back me up.

Looking at the console using writeline I noticed that the vectors switch signs in the (myRevolveTarget - myPosition). My outputs looks like this when trying to do a revolve of any type.

Revolve target{X:0 Y:0 Z:0}, My postion {X:1.979998 Y:0 Z:4000},
Revolve target{X:0 Y:0 Z:0}, My postion {X:-1.991998 Y:0 Z:-4000},
Revolve target{X:0 Y:0 Z:0}, My postion {X:2.003998 Y:0 Z:4000}

Is that suppose to be a dot product or something to find the up vector between the two? Any help would be much appreciated.
« Last Edit: 2007/02/23 12:18:40 by simpson.jon » Logged
simpson.jon
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #2 on: 2007/02/25 15:29:56 »

I've been messing with the code and have come to understand what I believe every part to mean, but it still performs incorrectly with my program. My problem is the flickering like before but I can't seem to understand what about my program causes the value of myPosition to oscilate.

Code:
public void Revolve(Vector3 target, Vector3 axis, float angle) {
Rotate(axis, angle);
axis = Vector3.Transform(axis, Matrix.CreateFromQuaternion(myRotation));
Quaternion rotate = Quaternion.CreateFromAxisAngle(axis, angle);
myPosition = Vector3.Transform(target - myPosition, Matrix.CreateFromQuaternion(rotate));

Update();
}

For this function in my code the target is passed, say Vector3.zero, the X axis is passed (1,0,0), and .03f is passed as my rotation angle. When it comes down to the myPosition = Vector3.... line myPosition switches signs on all the values that are not Zero. So if my myPosition =(0, 50, 4000) and it subtracts itself from zero it gets (0, -50, -4000).

Only it does recieve some modification from the quaternion and the values change. I'm guessing something about the vector3.transform function should stop the values of myPosition from changing in this manner but I can't figure out what. Any advice would be most helpful. Thanks.
Logged
mikeschuld
Administrator
Sr. Member
*****
Offline Offline

Posts: 389


View Profile WWW
« Reply #3 on: 2007/02/25 16:58:13 »

that code is wrong. it is from before a fix that was mentioned elsewhere. Try this instead:

      public void Revolve(Vector3 axis, float angle) {
         Vector3 revolveAxis = Vector3.Transform(axis, Matrix.CreateFromQuaternion(myRotation));
         Quaternion rotate = Quaternion.CreateFromAxisAngle(revolveAxis, angle);

         myPosition = Vector3.Transform(
            myPosition - target, Matrix.CreateFromQuaternion(rotate)
         ) + target;

         Rotate(axis, angle);
      }


Update: I swapped the target - position to position - target.. This is what was causing the flickering.
« Last Edit: 2008/05/23 19:10:33 by mikeschuld » Logged
simpson.jon
Newbie
*
Offline Offline

Posts: 6


View Profile
« Reply #4 on: 2007/02/25 17:09:05 »

I tried using the new code and I still get the flicker. How does the transform function prevent the numbers from flipping?

The exact function I'm using to call the Revolve is
Code:
CameraManager.ActiveCamera.Revolve(new Vector3(1, 0, 0), -0.05f);

At the time I call revolve the target location is 0,0,0. It functions exactly like I would expect and revolves around the target but every other frame is drawn from the opposite side looking at the same angle so you can't see the object. Could it be something outside of the camera class that makes the function not work?
Logged
Pages: [1]
  Print  
 
Jump to:  

Related Topics
Subject Started by Replies Views Last post
Tutorial 6 :: Getting a Model on Screen Tutorial Discussion mikeschuld 11 5582 Last post 2007/02/18 10:35:28
by Iarus
Got a problem with an .x file Hazy Mind XNA Engine bobbie_dache 8 2784 Last post 2007/01/16 12:26:30
by bobbie_dache
Question about Getting 2D screen coordinates General Discussion DaphydTheBard 6 2461 Last post 2007/02/27 03:23:36
by DaphydTheBard
Animations! But one problem... Hazy Mind XNA Engine EclipsE 2 1412 Last post 2007/04/12 02:42:27
by EclipsE
tutorial 4 problem Hazy Mind 3D Engine precious roy 3 2495 Last post 2007/08/03 12:24:26
by mikeschuld
Interface problem. Help!! General Discussion XNASorcerer 5 2111 Last post 2007/05/09 09:46:36
by CarlosFreitas
ObjectManagers problem Hazy Mind XNA Engine Jonotron 1 1339 Last post 2007/08/03 12:29:19
by mikeschuld
Adding in a Screen Manager Hazy Mind XNA Engine mimminito 1 1683 Last post 2010/02/20 23:59:09
by Jeff Lamoureux
Powered by MySQL Powered by PHP Powered by SMF 1.1.12 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 1.198 seconds with 19 queries.