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 - stormp

Pages: 1 2 [3]
31
Support / plz help with Camera rotation aligned with orbiting object.
« on: June 17, 2007, 12:13:05 am »
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:
Code: [Select]
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:
Code: [Select]
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


32
Support / Re: building custom plane: is there an addTriangle() order?
« on: June 14, 2007, 12:39:29 pm »
Doh! I cant believe i didn't notice that.  thx.

33
Support / building custom plane: is there an addTriangle() order?
« on: June 14, 2007, 11:24:20 am »
Hi,

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

This works:
Code: [Select]
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:

Code: [Select]
       
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.

34
Support / Re: newbie: how to make a 3d grid
« on: June 11, 2007, 04:29:16 pm »
OK, that did the trick.

Thanks for your help, I really appreciate it.  ;D

35
Support / Re: newbie: how to make a 3d grid
« on: June 11, 2007, 03:54:03 pm »
Thanks for the reply! :)

Actually, I do want perspective projection of course.  I used a bad graphic example I suppose.

Can I line draw on the buffer before the scene is rendered?  If so how?  I only seem to be able to figure out how to draw after.  I thought maybe I could use the IPaintListener?

Thanks so much for your help.

Where would I insert the g.drawLine(x1, y1, x2, y2); function call?

simple example code:

Code: [Select]
import java.awt.*;
import java.applet.*;
import com.threed.jpct.*;

public class View3D extends Applet
{
    World theWorld;              // The world. This Object will contain the 3D objects and the lightsources
    TextureManager texMan=null;  // The texture-manager. This is required for loading and managing textures
    Camera camera;               // The camera
    FrameBuffer buffer=null;     // The framebuffer. This is were jPCT will render the final image into
    Object3D objCube=null;
    Object3D objShpere=null;

    public void init()
    {
        getAppletContext().showStatus("Initializing...");

        resize(450,300);

        buffer=new FrameBuffer(450, 300, FrameBuffer.SAMPLINGMODE_NORMAL);
        buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE, IRenderer.MODE_OPENGL);
        buffer.setPaintListener(listener);

        theWorld= new World();

        objCube = Primitives.getCube(3);

        objCube.setAdditionalColor(Color.red);
        objCube.setTransparency(128);

        objShpere = Primitives.getSphere(2);

        theWorld.addObject(objShpere);
        theWorld.addObject(objCube);

        theWorld.buildAllObjects();
        theWorld.getCamera().setPosition(new SimpleVector(0,0,-30));

        getAppletContext().showStatus("Done !");
    }  // init()

    public void paint(Graphics g)
    {
        buffer.clear(Color.white);

        theWorld.renderScene(buffer);
        theWorld.draw(buffer);

        buffer.update();
        buffer.display(this.getGraphics());
     }  // paint()
}  // class View3D

*humble newb*

36
Support / Re: newbie: how to make a 3d grid
« on: June 11, 2007, 01:41:35 pm »
Thanks.

Planes will not work?

Are there any example code at all that would demonstrate using project3D2D for line drawing?

Thanks so much!

S.

37
Support / Re: newbie: how to make a 3d grid
« on: June 11, 2007, 12:57:26 pm »
Hi, thanks for the response.

I need to use software rendering.

38
Support / newbie: how to make a 3d grid
« on: 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:

Pages: 1 2 [3]