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.


Topics - theFALCO

Pages: [1]
1
Support / strange movement
« on: December 29, 2006, 10:52:56 am »
first I do the gravity
Code: [Select]
       SimpleVector theG = cube.checkForCollisionEllipsoid(GRAVITY, CUBE_SIZE, 1);
        moveResultant.add(theG);

then I "move" (actually at this point I only set the resultant vector) the cube according to pressed keys
Code: [Select]
       boolean movinDaC = false;

        cube.rotateY(MX*0.01f);

        if(left && moveResultant.x>-3) {
            SimpleVector a = cube.getXAxis();
            a.scalarMul(-BASESPEED);
            moveResultant.add(a);
            movinDaC=true;
        }
        if(right && moveResultant.x<3) {
            SimpleVector d = cube.getXAxis();
            d.scalarMul(BASESPEED);
            moveResultant.add(d);
            movinDaC=true;
        }
        if(forward && moveResultant.z<3) {
            SimpleVector w = cube.getZAxis();
            w.scalarMul(BASESPEED);
            moveResultant.add(w);
            movinDaC=true;
        }
        if(back && moveResultant.z>-3) {
            SimpleVector s = cube.getZAxis();
            s.scalarMul(-BASESPEED);
            moveResultant.add(s);
            movinDaC=true;
        }
        if(MX!=0) {
            camRot+=MX*0.01f;
        }
        if(MY!=0) {
            CAMANGLE-=MY*0.01f;
        }

then comes the translaition
Code: [Select]
       moveResultant = cube.checkForCollisionEllipsoid(moveResultant, CUBE_SIZE, 1);
        cube.translate(moveResultant);

        moveResultant.x=Math.round(moveResultant.x*10)/10f;
        moveResultant.y=Math.round(moveResultant.y*10)/10f;
        moveResultant.z=Math.round(moveResultant.z*10)/10f;

and if no keys are pressed I do the velocity loss
Code: [Select]
       if(!movinDaC) {
            if(moveResultant.x>FRICTION) {
                moveResultant.x-=FRICTION;
            } else if(moveResultant.x<-FRICTION) {
                moveResultant.x+=FRICTION;
            } else {
                moveResultant.x=0f;
            }
            if(moveResultant.y>FRICTION) {
                moveResultant.y-=FRICTION;
            } else if(moveResultant.y<-FRICTION) {
                moveResultant.y+=FRICTION;
            } else {
                moveResultant.y=0f;
            }
            if(moveResultant.z>FRICTION) {
                moveResultant.z-=FRICTION;
            } else if(moveResultant.z<-FRICTION) {
                moveResultant.z+=FRICTION;
            } else {
                moveResultant.z=0f;
            }
        }


the SimpleVector CUBE_SIZE is achieved by
Code: [Select]
       float b[] = cube.getMesh().getBoundingBox();
        CUBE_SIZE.x = (Math.abs(b[0])+Math.abs(b[1]))/2f;
        CUBE_SIZE.y = (Math.abs(b[2])+Math.abs(b[3]))/2f;
        CUBE_SIZE.z = (Math.abs(b[4])+Math.abs(b[5]))/2f;


The problem is that if I move forwads it's cool but when I rotate 45 degrees (so it's positioned "diagonally" to global axis) the cube moves very slowly, like ten times slower.
Any ideas what might cause it?

2
Support / just render
« on: December 21, 2006, 08:18:34 pm »
I'm currently trying to make everything I did in jPCT before from the beginning but without any ready stuff. What I ended up with is a flickering cube... could anyone please list everything that MUST be set/configured to render successfully with all Config.* settings? Thanks

3
Support / Live mesh deformations
« on: December 20, 2006, 05:45:03 pm »
Is there a way to get all vertices as an array or list of SimpleVectors? What I want to do is... ummm... let's say move the most-top vertice down... or make a blobby mesh blending... can I do that in jPCT and how?

4
Support / the swept
« on: December 17, 2006, 09:19:00 pm »
what exactly is this swept algorithm? is it like I have an object and if it collides with a ramp it moves up the ramp instead of getting blocked? if yes, how do I set the max hight?

5
Support / model size
« on: December 17, 2006, 05:03:09 pm »
How do I get the size of a model (to set the right radious for ellipsoid collision)?

6
Feedback / Particles?
« on: December 16, 2006, 03:51:23 pm »
Could anyone implement a particle engine to jPCT?

7
Support / rotation problem (it moves)
« on: December 12, 2006, 08:24:21 pm »
I'm rotating my cube like so:
Code: [Select]
               if(right) {
                    cube.rotateY(0.01f);
                    cube.translate(cube.getYAxis());
                }


when I rotate it, it moves down (while rotating), and when I rotate it the similar way with the X axis it moves right (while rotating).

any idea why it acts like that and how to fix it?

8
Support / [noob] my first try
« on: December 10, 2006, 06:19:03 pm »
It's my first try with this (well exactly ANY) engine and I just can't get it to work
here's the code (sorry for making another thread with "correct my code, please", I just really can't find the critial thing that makes stuff not working):
Code: [Select]
import java.io.*;

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;

import com.threed.jpct.*;
import com.threed.jpct.util.*;

class Cube {

    private final static int SWITCH_RENDERER=35;
    private boolean fullscreen=false;
    private boolean openGL=true;
    private boolean wireframe=false;

    private FrameBuffer buffer=null;
    private World theWorld=null;
    private TextureManager texMan=null;
    private Camera camera=null;

    private int width=640;
    private int height=480;

    private Frame frame=null;
    private Graphics gFrame=null;
    private BufferStrategy bufferStrategy=null;
    private GraphicsDevice device=null;
    private int titleBarHeight=0;
    private int leftBorderWidth=0;

    private int switchMode=0;

    private int fps;
    private int lastFps;
    private long totalFps;

    private int pps;
    private int lastPps;

    private boolean isIdle=false;
    private boolean exit=false;

    private boolean left=false;
    private boolean right=false;
    private boolean forward=false;
    private boolean back=false;
    private boolean fire=false;
    private int fireCount=3;

    private float speed=0;

    private KeyMapper keyMapper=null;

    private Cube(String[] args) {
        Config.glFullscreen=false;
        Config.glMipmap=true;
        Config.glColorDepth=16;
        Config.maxPolysVisible=10000;
        isIdle=false;
        switchMode=0;
        totalFps=0;
        fps=0;
        lastFps=0;
        theWorld=new World();
        texMan=TextureManager.getInstance();
        Config.fadeoutLight=false;
        theWorld.getLights().setOverbrightLighting(Lights.OVERBRIGHT_LIGHTING_DISABLED);
        theWorld.getLights().setRGBScale(Lights.RGB_SCALE_2X);
        theWorld.setAmbientLight(25, 30, 30);
        theWorld.addLight(new SimpleVector(0, -150, 0), 25, 22, 19);
        theWorld.addLight(new SimpleVector(-1000, -150, 1000), 22, 5, 4);
        theWorld.addLight(new SimpleVector(1000, -150, -1000), 4, 2, 22);
        theWorld.setFogging(World.FOGGING_ENABLED);
        theWorld.setFogParameters(1200, 0, 0, 0);
        Config.farPlane=1200;
        Object3D cube = Primitives.getBox(10, 1);
        cube.setOrigin(new SimpleVector(0, 0, 0));
        char c=File.separatorChar;
        texMan.addTexture("tekstura", new Texture("textures"+c+"ql0.jpg"));
        cube.setTexture("tekstura");
        cube.setTranslationMatrix(new Matrix());
        theWorld.addObject(cube);
        camera=theWorld.getCamera();
        camera.setPosition(0, 0, -180);
        camera.lookAt(cube.getTransformedCenter());

        theWorld.buildAllObjects();
        Config.tuneForOutdoor();
        initializeFrame();
        gameLoop();
    }

    public static void main(String[] args) {
        new Cube(args);
    }

    private void initializeFrame() {
        if (fullscreen) {
            GraphicsEnvironment env=GraphicsEnvironment.getLocalGraphicsEnvironment();
            device=env.getDefaultScreenDevice();
            GraphicsConfiguration gc=device.getDefaultConfiguration();
            frame=new Frame(gc);
            frame.setUndecorated(true);
            frame.setIgnoreRepaint(true);
            device.setFullScreenWindow(frame);
            if (device.isDisplayChangeSupported()) {
                device.setDisplayMode(new DisplayMode(width, height, 32, 0));
            }
            frame.createBufferStrategy(2);
            bufferStrategy=frame.getBufferStrategy();
            Graphics g=bufferStrategy.getDrawGraphics();
            bufferStrategy.show();
            g.dispose();
        } else {
            frame=new Frame("jPCT "+Config.getVersion());
            frame.pack();
            Insets insets = frame.getInsets();
            titleBarHeight=insets.top;
            leftBorderWidth=insets.left;
            frame.setSize(width+leftBorderWidth+insets.right, height+titleBarHeight+insets.bottom);
            frame.setResizable(false);
            frame.show();
            gFrame=frame.getGraphics();
        }
        frame.addWindowListener(new WindowEvents());
        keyMapper=new KeyMapper(frame);
    }

    private void gameLoop() {
        World.setDefaultThread(Thread.currentThread());
        buffer=new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
        buffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);
        buffer.setBoundingBoxMode(FrameBuffer.BOUNDINGBOX_NOT_USED);
        buffer.optimizeBufferAccess();

        Timer timer = new Timer(25);
        timer.start();

        while(!exit) {
            if(!isIdle) {
                buffer.clear();
                theWorld.renderScene(buffer);
                theWorld.draw(buffer);
                buffer.update();
                buffer.display(gFrame, height, width);
                Thread.yield();
            }
        }
        if (openGL) {
            buffer.disableRenderer(IRenderer.RENDERER_OPENGL);
        } else {
            if (fullscreen) {
                device.setFullScreenWindow(null);
            }
        }
        System.exit(0);
    }

    private class WindowEvents extends WindowAdapter {
        public void windowIconified(WindowEvent e) {
            isIdle=true;
        }

        public void windowDeiconified(WindowEvent e) {
            isIdle=false;
        }
    }

    private class Timer {

        private long ticks=0;
        private long granularity=0;

        public Timer(int granularity) {
            this.granularity=granularity;
        }

        public void start() {
            ticks=System.currentTimeMillis();
        }

        public void reset() {
            start();
        }

        public long getElapsedTicks() {
            long cur=System.currentTimeMillis();
            long l=cur-ticks;

            if (l>=granularity) {
                ticks=cur-(l%granularity);
                return l/granularity;
            }
            return 0;
        }
    }

}


all I see is a white window with no box

Pages: [1]