Main Menu
Menu

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.

Show posts Menu

Topics - stormp

#1
Support / How to Rotate Object relative to camera?
November 04, 2007, 10:25:43 PM
Hi again,

I'm trying to figure out how to rotate an object relative to the X Y axis of the screen space.

This *seemed* at first to almost work, but when I move the camera behind or under the object, I get inverse and / or reverse rotations - so I guess I'm way off here. :-(

Any suggestions?

Thank you,

S.


public SimpleVector rotateRespect2Cam(float rotX, float rotY)
{
   SimpleVector dir = theCamera.getDirection();

   dir.rotateX(rotX);
   dir.rotateY(rotY);

   return dir.calcSub(theCamera.getDirection());
}



SimpleVector rotate = rotateRespect2Cam(delta.x * -camRotSpeed, delta.y * -camRotSpeed);

object.rotateX(rotate.x);  // rx rz ry to avoid gimbal lock.
object.rotateZ(rotate.z);
object.rotateY(rotate.y);
#2
Support / Scene Rotation
October 28, 2007, 07:02:12 AM
Hi :-)

I'm looking for some pointers on how to mimic scene rotation similar to how GoogleEarth does.  IE: grabbing a point on a (imaginary) sphere and dragging that point around.

I found this article: http://www.mactech.com/articles/mactech/Vol.15/15.03/NaturalObjectRotation/index.html

Is there any similar examples in jPCT?

Appreciate any help!

Thanks.

S.
#3
Hi,

Still working on my grid lines.  ;D 

project3D2D wont render if "the center is behind the viewplane".   How can I adjust my vectors to clip at the approriate end?

Much thanks.

S.

   
    private void drawLine(FrameBuffer fb, Graphics2D g, SimpleVector v1, SimpleVector v2)
    {
        SimpleVector point1 = Interact2D.project3D2D(theWorld.getCamera(), fb, v1);
        SimpleVector point2 = Interact2D.project3D2D(theWorld.getCamera(), fb, v2);


        if(point1 != null && point2 != null)
        {
            g.drawLine((int)point1.x, (int)point1.y, (int)point2.x, (int)point2.y);
        }  // if
    }
#4
Support / Using project3D2D & reproject2D3D
July 18, 2007, 12:32:13 AM
Hi,

I'm trying to draw a line that is 25 pixels away based on a position in my 3D scene but reporject2D3D seems to be not working for me.


vertex1 = new SimpleVector(centerX, topY, minZ);

// Get the point in 3D space and convert to 2D screen space.
point1  = Interact2D.project3D2D(theWorld.getCamera(), fb, vertex1);

if(point1 != null)                   
{
   // Add 25 to the screen X and convert back to 3D world space.
   vertex2 = Interact2D.reproject2D3D(theWorld.getCamera(), fb, (int)point1.x+25,  (int)point1.y, minZ);


vertex2 gives me back odd results.

Am I using this right?

Thanks for all the help thus far.

S.
#5
Support / poly clipping outside box.
July 02, 2007, 06:25:03 AM
Hi, is there a way that I can clip the world outside a defined box?  That is, I want to define a box around my scene and only see the poly's that are contained inside the box no matter where I place the camera.

Thanks for any suggestions.

S.
#6
Hi,

When in software render mode is there a ceiling limit to the number of visible polygons?  I've noticed in some examples maxPolysVisible is set to 10000 even 64000.

I get this error message intermittently:
WARNING: You've exceeded the configured triangle limit for the visibility list. Consider adjusting Config.maxPolysVisible!

I've set mine to         
Config.maxPolysVisible = 20000;

I'm never seeing any more than 3800 polygons in a scene
theWorld.getVisibilityList().getSize();

I really only have about 350 five faced cylinders randomly plotted in the world and a couple of planes. So there isn't really that many polygons to display in a scene.  Why would I be getting this error?

Also, what is a reasonable visible polygone count in a scene in software mode?  (I know this is a vague question, but just looking for some sort of guidelines or references).

Thanks for any help :-)

S.

#7
Hi, 

I wanted to help visualize my camera movements / rotations as I was getting some strange results.

I have made a simple applet (source link included at the bottom) which has a small cube orbiting a larger cube.  the cube movements are manually controlled by pressing the arrow keys and you can toggle the camera by pressing 1 for follow mode 2 for free float and R to reset the cam to it's original position.

The little cube rotates around the cube if you press UP and DOWN.  If you press 1 to set the camera to follow behind the little cube, the rendering seems to mess up (inversed).

I've been searching on the forums for reference to this problem but I can't seem to figure out how to fix it.   :(

This seemed my best bet: http://www.jpct.net/forum2/index.php/topic,641.0.html
but when i tried to use the invert3x3() it didn't seem to work.

I also tried the "follower" code with the same result: http://www.jpct.net/forum2/index.php/topic,616.msg3214.html#msg3214

If anyone can help out I'd appreciate it greatly.

Thanks:

cube rotation:

if(mvSpinLeft)                            // Cube2 orbit left
{
     objCube2.rotateAxis(objCube2.getYAxis(), rotSpeed);
} // if

if(mvSpinRight)                           // Cube2 obrit right
{
      objCube2.rotateAxis(objCube2.getYAxis(), -rotSpeed);
}  // if


camera follow small cube:

if(modeFollow)
{
      theCamera.setPositionToCenter(objCube2);                    // place camera inside cube2
      theCamera.align(objCube2);                                  // Copy the cube2 positive Z-axis.
      theCamera.lookAt(objCube1.getTransformedCenter());          // look at cube 1 center.
      theCamera.moveCamera(Camera.CAMERA_MOVEOUT, 50.0f);         // put camera behind cube2 a little

      // Problem is here?
}  // if



TEMPORARY HOSTED APPLET:
http://154.5.173.123:8001/test/index.html


FULL SOURCE:  (in case it might be useful to someone in the future) :)
http://154.5.173.123:8001/test/tester3d.java

#8
Hi,

I was experimenting with building a custom plane.  Is there any order which the addTriangle() or the vectors must be added?

This works:

objSurface.addTriangle(new SimpleVector(-8.0f,  8.0f, 0.0f),
                       new SimpleVector( 8.0f,  8.0f, 0.0f),
                       new SimpleVector( 8.0f, -8.0f, 0.0f));

objSurface.addTriangle(new SimpleVector( 8.0f, -8.0f, 0.0f),
                       new SimpleVector(-8.0f, -8.0f, 0.0f),
                       new SimpleVector(-8.0f,  8.0f, 0.0f));


Where as this doesn't work:

       
objSurface.addTriangle(new SimpleVector(-8.0f, 8.0f, 0.0f),
                       new SimpleVector( 8.0f,  8.0f, 0.0f),
                       new SimpleVector( 8.0f, -8.0f, 0.0f));

objSurface.addTriangle(new SimpleVector(-8.0f,  8.0f, 0.0f),
                       new SimpleVector(-8.0f, -8.0f, 0.0f),
                       new SimpleVector( 8.0f, -8.0f, 0.0f));



Can someone explain? :)

Thanks.
#9
Support / newbie: how to make a 3d grid
June 11, 2007, 11:46:59 AM
Hi, I'm a newbie to jPCT.

I would like to place objects inside a variable lined 3D grid.  As i zoom into the object, i would like the grid lines to become more detailed.

Can someone point me into the right direction on how to accomplish this using jPCT?

Thanks so much  :)

    __|
        \
         
eg: