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

Pages: [1] 2 3
1
Support / the swept
« on: January 06, 2007, 02:59:42 pm »
everything works great
i think that rescaling everything by 10 or 100 will do the job, cause I won't have to use so small values (I use such a small speed because even 1 is slightly too fast)

thanks for your effort

2
Support / Cel Shading...
« on: January 05, 2007, 10:07:49 pm »
cool then :D

3
Support / the swept
« on: January 05, 2007, 10:06:29 pm »
YAY! (or not...)
I found it! I took this example, copy-pasted it, compiled... it works, so OK. Let's start adding things one by one so that it get's like my code until it stops working...
it stopped working after I set the speed (i mean the value which multiplies the vector which is checked and then added to the resultant) to 0.2

here is the code, the SPEED is set to 1 and it works, but if you change it to 0.2 (should be bigger than moveDamp) it stops working (oh, and BTW, I changed the renderer to OpenGL and made a camera on the back of the cube)

Code: [Select]
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import com.threed.jpct.*;
import com.threed.jpct.util.*;

public class CollisionDemo {

    private static float moveDamp = 0.1f;
    private static float SPEED = 1f;
    private static float MAXSPEED = 1f;

    private Graphics g = null;
    private KeyMapper keyMapper = null;
    private FrameBuffer fb = null;
    private World world = null;
    private Object3D plane = null;
    private Object3D ramp = null;
    private Object3D cube = null;
    private Object3D cube2 = null;
    private Object3D sphere = null;

    private SimpleVector moveRes = new SimpleVector(0, 0, 0);

    private boolean up = false;
    private boolean down = false;
    private boolean left = false;
    private boolean right = false;

    private boolean doloop = true;

    private SimpleVector ellipsoid = new SimpleVector(2, 2, 2);

    public CollisionDemo() {
        Config.glFullscreen=false;
    }

    private void initStuff() {
        //keyMapper = new KeyMapper(this);
        fb = new FrameBuffer(1024, 768, FrameBuffer.SAMPLINGMODE_NORMAL);
        world = new World();
        fb.enableRenderer(IRenderer.RENDERER_SOFTWARE);
        fb.enableRenderer(IRenderer.RENDERER_OPENGL, IRenderer.MODE_OPENGL);
        fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);
        keyMapper = new KeyMapper();

        plane = Primitives.getPlane(20, 10);
        ramp = Primitives.getCube(20);
        ramp.setAdditionalColor(Color.BLUE);
        plane.setAdditionalColor(Color.GREEN);
        sphere=Primitives.getSphere(30);
        sphere.setAdditionalColor(Color.CYAN);
        sphere.translate(-50,10,50);
        cube2=Primitives.getCube(20);
        cube2.setAdditionalColor(Color.ORANGE);
        cube2.translate(60,-20,60);

        plane.rotateX((float) Math.PI / 2f);
        ramp.rotateX((float) Math.PI / 2f);

        cube = Primitives.getCube(2);

        plane.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
        ramp.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
        sphere.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
        cube2.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
        cube.setCollisionMode(Object3D.COLLISION_CHECK_SELF);

        world.addObject(plane);
        world.addObject(ramp);
        world.addObject(cube);
        world.addObject(sphere);
        world.addObject(cube2);

        cube.translate( -50, -10, -50);

        Light light = new Light(world);
        light.setPosition(new SimpleVector(0, -80, 0));
        light.setIntensity(40, 25, 22);

        world.buildAllObjects();
    }

    private void move() {
        KeyState ks = null;
        while ((ks = keyMapper.poll()) != KeyState.NONE) {
            if (ks.getKeyCode() == KeyEvent.VK_UP) {
                up = ks.getState();
            }
            if (ks.getKeyCode() == KeyEvent.VK_DOWN) {
                down = ks.getState();
            }
            if (ks.getKeyCode() == KeyEvent.VK_LEFT) {
                left = ks.getState();
            }
            if (ks.getKeyCode() == KeyEvent.VK_RIGHT) {
                right = ks.getState();
            }
            if(ks.getKeyCode() == KeyEvent.VK_ESCAPE) {
                doloop = false;
            }
        }

        // move the cube
        if (up) {
            SimpleVector t = cube.getZAxis();
            t.scalarMul(SPEED);
            //t = cube.checkForCollisionEllipsoid(t, ellipsoid, 5);
            //cube.translate(t);
            moveRes.add(t);
        }

        if (down) {
            SimpleVector t = cube.getZAxis();
            t.scalarMul(-SPEED);
            //t = cube.checkForCollisionEllipsoid(t, ellipsoid, 5);
            //cube.translate(t);
            moveRes.add(t);
        }

        if (left) {
            cube.rotateY((float)Math.toRadians(-1));
        }

        if (right) {
            cube.rotateY((float)Math.toRadians(1));
        }

        // finally apply the gravity:
        SimpleVector t=new SimpleVector(0,1,0);
        t=cube.checkForCollisionEllipsoid(t,ellipsoid,1);
        cube.translate(t);

        //avoid too high speed
        if(moveRes.length()>MAXSPEED) {
            moveRes.makeEqualLength(new SimpleVector(0,0,MAXSPEED));
        }

        moveRes = cube.checkForCollisionEllipsoid(moveRes, ellipsoid, 5);
        cube.translate(moveRes);

        //damping
        if(moveRes.length()>moveDamp) {
            moveRes.makeEqualLength(new SimpleVector(0,0,moveDamp));
        } else {
            moveRes = new SimpleVector(0,0,0);
        }
    }

    private void doIt() throws Exception {
        Camera cam = world.getCamera();
        cam.moveCamera(Camera.CAMERA_MOVEOUT, 100);
        cam.moveCamera(Camera.CAMERA_MOVEUP, 100);
        cam.lookAt(ramp.getTransformedCenter());

        while(doloop) {
            move();
            cam.setPositionToCenter(cube);
            cam.align(cube);
            cam.rotateCameraX((float)Math.toRadians(30));
            cam.moveCamera(Camera.CAMERA_MOVEOUT, 50);
            fb.clear(Color.RED);
            world.renderScene(fb);
            world.draw(fb);
            fb.update();
            fb.displayGLOnly();
        }
        fb.disableRenderer(IRenderer.RENDERER_OPENGL);
        System.exit(0);
    }

    public static void main(String[] args) throws Exception {
        CollisionDemo cd = new CollisionDemo();
        cd.initStuff();
        cd.doIt();
    }
}

4
Support / Cel Shading...
« on: January 05, 2007, 09:38:08 pm »
will there be a "power" (how intense the bloom will be) setting?

5
Support / Cel Shading...
« on: January 05, 2007, 06:25:58 pm »
if(bloom.getMeaning()=="darkness also gets bloom") {
  Voter.setVote("bloom", "NO");
}
// if this "bloom" will be like this: take the render, apply gaussian blurr (or some other blurr), apply it to the main render with alpha blend ("half-transparen") then please don't do it, it will cause shadows and other darkness to cause bloom while it shouldn't... or just tell me that it won't cause such nasty effect

6
News / Forum update to 2.0.22
« on: January 04, 2007, 07:17:36 pm »
any changelog?

7
Support / the swept
« on: January 01, 2007, 06:07:40 pm »
depth - i tried 1, 4, 6, 25
size - generated dynamically with the getMesh().getBoundingBox
threshold - i tried 0.01 and it started working but only for the smallest ramp (it's almost unnoticably rised)

8
Support / the swept
« on: January 01, 2007, 05:24:17 pm »
The cube doesn't go up the ramp, it gets blocked by everything that's not flat or lower, and doesn't go along the wall when I collide with it under an angle... according to the manual the Ellipsoid collision should not only stop the movement but also try to avoid the obstacle by modifying the vector

or maybe I got it all wrong and there's nothing like thet in jpct?

9
Support / the swept
« on: January 01, 2007, 12:21:41 pm »
the FPS example uses cameraCheckCollisionEllipsoid(), maybe it differs

maybe it's because I use cube.checkForCollisionEllipsoid, not theWorld.check..., maybe... I don't know, maybe I have to make my own SWEPT, but I don't know how... :?

10
Support / the swept
« on: December 31, 2006, 07:12:57 pm »
Could you provide any small (only the essentials - the less, the better) example of a working swept? A simple "cube moves up the ramp", please?

11
Support / strange movement
« on: December 29, 2006, 09:45:43 pm »
damn, after commenting it out everything is cool :/

in my old DirectX game i used such thing to round to the second number after the comma so that I don't have someting like 0.0000000000001...
that's why I added it as soos as I added the "resultant vector movement" technique

thanks

12
Support / strange movement
« on: December 29, 2006, 11:27:07 am »
no, it's a test with 2 objects only... a cube as moving object and a plane as a map (small, whole visible all the time)

I'm wondering if the cube.getZAxis() doesn't do it

13
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?

14
Support / Cel Shading...
« on: December 28, 2006, 02:55:57 pm »
and are there any plans to add anything? :D (could use some new stuff)

15
Support / just render
« on: December 22, 2006, 08:44:01 pm »
openGL mode

Pages: [1] 2 3