Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - ToddMcF2002

Pages: 1 ... 5 6 [7]
Support / Re: Mouse Movement
« on: April 05, 2007, 07:26:56 pm »
If you are going to add it - please add a wrapper for CustomCursor that implements both Rendering paths.

I had a pretty harrowing time getting the lg renderer to accept the transparency and orientation of my GIFs - which also affects the offset to 2D x and y if you decide to give up and invert the GIFs like I did.

Egon?  Anyone?  I'm planning on doing a good chunk of coding this weekend so any input would really help!

This is design question really - impacting code efficiency and its performance impact.

Currently I'm composing variable length/width lines out of Vectors of Object3D Primitive Plane.   

I can't work with a model because of the variability ie. the rectangle resizes its length and rotation on the x/z plane based on the mouse coords.  Think Lightning Bolt for example.  It can be strait or have variable directional adjustments between SimpleVector source and target.

The question is this:

Its it "worth" investigating building a Rectangle primitive for performance?  Its really a question of whether there is an advantage to having a single Object3D I'll have to create and destroy or a vector of them (which is my current approach).  In the end, the total number of underlying Triangle faces is the same isnt it? 

Is there any performance advantage or disadvantage?

This is an important issue for me since I'm using this approach to build other "pathing" objects as part of a larger Particle effect factory.


Support / Re: My MD2 runs sideways!
« on: April 04, 2007, 07:35:48 am »
Once again thinking it would take 2 seconds to implement -  lwjgl setNativeCursor was like having a root canal.

At least it works.  I had to place my textures inverted for some reason!

Support / Re: Blitting a UI onto the FrameBuffer
« on: April 04, 2007, 01:50:25 am »
Nice. :)  Exactly what I wanted.  Thanks a million!

Support / Re: Blitting a UI onto the FrameBuffer
« on: April 03, 2007, 06:03:59 am »
So I got this working myself with the alpha channel - very slick!  But honestly... what are you folks using to create your PNGs?  I'm using GIMP right now and I'm pulling my hair out trying to figure out how to do basic drawing.

Is there anything easier?

Support / Re: My MD2 runs sideways!
« on: April 01, 2007, 06:13:10 am »
Alright this one could definately help somebody out there.  I figured out how to convert the matrix to a PI based rotation.  So now I can support key turns and mouse follow since they both now can track the PI based rotation on Y.  The only caveat is that this will work only when the rotations are on the Y axis (a typical isometric RPG).

          // this measures (PI/2 radians) -1.5707 to 1.5707 aka -180 to 180 degrees on x... 
          float[] md =_rotY.getDump();
          float rad =(float) Math.asin(-md[2]);

         // this will give us x and z rotations around y...
         SimpleVector vz = _rotY.getZAxis();   
         float fPi = 0f;   
         // once we know which 90 degree quadrant we are in
         // we can adjust the raidians and add to magnitudes of PI to get 0 - 6.28... PI
         if(vz.x > 0 && vz.z > 0)
        fPi = (float)rad;
         else if(vz.x > 0 && vz.z < 0)
        fPi = (float)Math.PI - (float)rad;
         else if(vz.x < 0 && vz.z < 0)
        fPi = (float)Math.PI - (float)rad;
          else if(vz.x < 0 && vz.z > 0)
        fPi = (float)Math.PI*2  + (float)rad;

Support / Re: My MD2 runs sideways!
« on: March 31, 2007, 06:01:48 am »
Well now my MD2 runs to where I click.  Works and looks fantastic! 

The only thing bugging me about the implementation is now I'm holding the rotationMatrix on the stack instead of float yRot like in the Car example.  I'm wondering if I should convert back to an absolute angle (via Math.atan etc).  Without yRot I can't easily support turning via keys and clicking via mouse like Neverwinter Nights.  Can you think of a better way to maintain yRot or is math after every rotationMatrix adjustment the way to go?

Also, I might actually have a real small contribution here LOL.  I noticed my X pitch kept getting mangled on the rotation adjustments since the Y axis wasnt normalized between the objects - so target.add(new SimpleVector(0, (xd.y + target.y)*-1, 0)) keeps the height constant while allowing x-z adjustment.  Anyway here is the revised routine.  Of course its always possible I broke your working code and this is all a bad hack ha ha!

private void rotateToMarker(){
      // mdl is the object to turn here...
      SimpleVector xd=mdl.getTransformedCenter();

     SimpleVector target = marker.getTransformedCenter();
     // normalize the y axis between the objects to avoid x tilt...
     target.add(new SimpleVector(0, (xd.y + target.y)*-1, 0));    

      // Copy it...
      SimpleVector yd=new SimpleVector(xd);     
      // store the matrix for other placement routines


Support / Re: My MD2 runs sideways!
« on: March 30, 2007, 07:09:08 pm »
Thanks.  I'm still a bit lost on the matrix but I think get the intent?  For example after the matrix adjustment the z axis direction goes from near 0 (strait down) toward 1 (far plane).  I get that.

How could you describe what the normal vector z direction is before adjustment?  It ranges from .9 to about .94.  Is that because its only considering the "camera cone" relative to the world so it doesnt reflect much movement?

I'm just trying to find a way to conceptualize things.

Support / Re: My MD2 runs sideways!
« on: March 30, 2007, 05:45:01 pm »
LOL Yeah exactly!!!!  Thanks a ton!

Can you please explain something though - its a noob thing.

Looking at follow()...

Can you tell me (conceptually) where I'm right, wrong and/or need help?
1.  norm is a directional vector (normal vector)
2.  I don't grasp why we multiply the normalized ray by an inverted matrix from the camera.
3.  "f" gets you the scalar to turn the directional vector into a vector with length to the click point.
4.  You subtract the small directional vector otherwise its a bit too long
5.  cube goes back to identity, then relative to the camera, and finally remove the camera vector impact.

I guess part "2" is where I'm pretty confused.

Support / Re: My MD2 runs sideways!
« on: March 30, 2007, 05:04:36 am »
OK I really need help.  I can't make heads or tails of these problems.  Again I'm using a variation of the Car sample.  The Object selection code works great, and I have nice selection "disks" under my MD2 guys who are running around the screen.  Progress!  Yay!  So now I'm trying to click in front of my guys and get them to walk over to the point I clicked at (like Neverwinter Nights etc). 

I thought that would be easy but its not.  My first problem is conceptual.  I realize I'm totally disoriented on the y Axis in JPCT.  I'm confused why my MD2 gets a more negative y (getTransformedCenter) when he is taller than the car?  If I walk forward and to the right the x and z axis increase (from 0's) which makes sense.  Interact2D.reproject2D3D return negative as you go up too.  The negative y axis is driving me crazy!
I'm sure you are laughing at me now and that is OK I'm a total noob at 3D vectors.  :P

The second problem is that the function below (found on the forum) seems to return a reasonable x axis value when I click on the flat terrain but the y and z values are wildly negative.  For example, if I click on the terrain as close to my MD2 as possible without moving the MD2 from its initial position (close to 0,0,0) I get x:y:z -1.19205055E-7:-328.108:-753.85815.   Vector.x makes sense to me.  Vector.z gets deeper negative as I click toward the horizon.  I can't even speak for y.

I'm lost!  Any assistance would be great.

public static SimpleVector getAbsoluteCoordinate(Camera camera, FrameBuffer buffer, int x, int y, Object3D object) {
        SimpleVector rezult = null;
        if (camera != null && buffer != null) {
            SimpleVector rayTemp = Interact2D.reproject2D3D(camera, buffer, x, y);

            Matrix orient = camera.getFront();
            float[] dump = orient.getDump();
            SimpleVector ray = new SimpleVector();
            ray.x = dump[0] * rayTemp.x + dump[1] * rayTemp.y + dump[2] * rayTemp.z + dump[3] * 1;
            ray.y = dump[4] * rayTemp.x + dump[5] * rayTemp.y + dump[6] * rayTemp.z + dump[7] * 1;
            ray.z = dump[8] * rayTemp.x + dump[9] * rayTemp.y + dump[10] * rayTemp.z + dump[11] * 1;

            float distance = object.rayIntersectsAABB(camera.getPosition(), ray);
         System.out.println("getAbsoluteCoordinate() distance: " + distance);

            if (distance != Object3D.RAY_MISSES_BOX) {
                rezult = new SimpleVector(camera.getPosition());
        return rezult;

Support / Re: My MD2 runs sideways!
« on: March 27, 2007, 12:16:02 am »
Excellent guys.  That fixed it.  Much appreciated!

Now I need to figure out how to click ahead of the models and have them walk to the spot. 

Obviously I need to figure out the rotation amount and the distance and speed.  This is basic angle
math I think!  Given the "known" currentY I need to rotate to the new Y and move forward until I reach
the new SimpleVector.

Has anyone done this?

BTW I love this engine guys!  Hats off to Egon (I assume he wrote it?)

I started to think about implementing my own Object3D.lookAt() and apparently others have thought of this. 
I remember an old CQuake routine called "castBearingLine" that used to iterate around its axis looking for objects
in its sphere.  Part of AI routines I think.  I wish I remembered the code!  Anyway, this holds promise....,513.0.html

Support / My MD2 runs sideways!
« on: March 26, 2007, 06:13:21 pm »
Using the Car example I loaded a few MD2's to have models running next to the car.  Everything works great except my models are oriented at 45 degree angles to the car.  My models are pacing the car just fine buy they run sideways.

The only way I could fix was to initialize by turning 45 degrees during load and change the "moveForward" method to use the xaxis instead of the yaxis.

I think I need something like rotateMesh() but it doesnt seem to work.  Any ideas?

- Todd

Pages: 1 ... 5 6 [7]