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

Messages - roninjnj

#1
Support / Re: why render invisible object3d??
August 28, 2008, 07:30:48 PM
Okis!!! thanks very much again!! ;)
#2
Support / Re: why render invisible object3d??
August 28, 2008, 04:43:18 PM
I was looking the problem.

Code is larger, need more time. I have another thread to put-remove object3Ds in the world variable.

Problem only appear with a polygon attached to mouse movements ,mouse.getX() and mouse.getY() is checked in main thread.

But nerver NEVER is add this poligon to a shadowCaster with addCaster o reciveCaster, and sometimes a shadow of this poligon appear .

I´m going more test to find problem and send you results.

Is version 1.17 lastest version of JPCT??

Thanks!  (Sorry my english)


#3
Support / Re: why render invisible object3d??
August 27, 2008, 11:06:46 PM
Version returned is  1.17.

I solve the problem removing this object3D from world, updating shadowmap, inserting again this object into the world, and rendering scene with shadowHelper.

If the object3D is not in world, it can be appear in shadow map rendering.

If a new version of JPCT is relase in future, I will modify the code. Now, it is runing rigth with that method.

Thanks for all!!
#4
Support / Re: why render invisible object3d??
August 27, 2008, 10:33:32 PM
Its a sample of my problem.

I have a map dividided in squares to a turn based strategy game.

I use a gemometry with texture (with blending actived) to know in what square in 3d world is aiming mouse (using 2DInteract).

I had this error, and i didn´t know what code is doing some bad. Then I decided go directly to render bucle and do that test:   

                                             1) hide object3D mouseCursor.
                                             2) render shadows and scene.
                                             3) and finally, set object3D mouseCursor setVisible(true).

In theory, object3D mouseCursor should be not visible in window. BUT in some frames, it appears!

I don´t know why... ¿?



I have assigned a geometry with texture to aim positions with mouse. , but a got this problem.

#5
Support / why render invisible object3d??
August 27, 2008, 10:15:20 PM
Hi!! a new question!!

I have next code:


              if (!wireframe)
             {                
        cursorMouse.setVisibility(false);
       
        shadowHelper.updateShadowMap();       
        buffer.clear(java.awt.Color.GRAY);       
                         shadowHelper.drawScene();                                 
             }
             else
             {
        buffer.clear(java.awt.Color.BLACK);
                     world.drawWireframe(buffer, colorWireFrame);
             }       

             buffer.update();
             buffer.displayGLOnly();
             canvas.repaint(); 
            
             cursorMouse.setVisibility(true);
        }


NOTE: CursorMouse is a Object3D instance.

Ok, the problems...

1)  I can´t switch to wireframe mode, it only draw a black screen.

2)  cursorMouse is displayed in any frames, in another frames is displayed his shadow only (but cursorMouse is not added to shadowHelper (not set to addcaster or addreciver), and in another cases, both are displayer, geometry with texture and shadow. Why? Its is set not visible before render and set visible after render. (it is always in mode non-selectable).

Thanks!!!
#6
Support / Re: Error using ShadowHelper.
August 26, 2008, 10:31:42 PM
I have finished download and install lastes drivers for my ATI mobility redeon X700.

Its works fine, FBOs warning has gone, now said FBO is supported and used.

All samples works fine and mi application works fine :-(

I apologize for wasting your time :-(

Thanks very much yet.
#7
Support / Re: Error using ShadowHelper.
August 26, 2008, 10:08:41 PM
I got same error. Its most probably that error is in my code, not in JPCT.

I modified "SimpleShadow.java" sample to put it in a canvas and render it at 640 * 480.

I got same error:.

The modified "SimpleShadow.java" code is this:


import java.awt.*;
import javax.swing.JFrame;
import java.awt.Canvas;
import com.threed.jpct.*;
import com.threed.jpct.util.*;

public class SimpleShadows extends JFrame{


private Canvas canvas = null;
private boolean fin = false;

private FrameBuffer fb = null;
private World world = null;
private Object3D plane = null;
private Object3D cube = null;
private Object3D sphere = null;
private Projector projector=null;
private ShadowHelper sh = null;
private Light sun=null;

public SimpleShadows() {

super("TEST JNJ");
Config.glColorDepth = 24;
Config.glFullscreen = false;
Config.farPlane = 1000;
Config.glShadowZBias = 0.8f;
Config.glTrilinear=true;
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

}

private void initStuff() throws Exception {

fb = new FrameBuffer(640, 480, FrameBuffer.SAMPLINGMODE_NORMAL);    
                fb.disableRenderer(IRenderer.RENDERER_SOFTWARE);      
 
world = new World();

plane = Primitives.getPlane(20, 30);
plane.rotateX((float) Math.PI / 2f);

cube=Primitives.getCube(15);
cube.setAdditionalColor(Color.RED);
cube.translate(0, -30, -10);

sphere=Primitives.getSphere(12);
sphere.translate(0, 0, -50);
sphere.setAdditionalColor(new Color(0,0,50));

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

TextureManager tm = TextureManager.getInstance();

projector = new Projector();
sh = new ShadowHelper(world, fb, projector, 512);

sh.addCaster(cube);
sh.addReceiver(plane);
sh.addReceiver(sphere);
sh.setAmbientLight(new Color(30,30,30));
sh.setFiltering(true);

world.setAmbientLight(90,90,90);
world.buildAllObjects();

sun=new Light(world);
sun.setIntensity(50, 50, 50);

      canvas = fb.enableGLCanvasRenderer();
        System.out.println("listo canvas");

System.out.println("Poniendo canvas");
this.getContentPane().add(canvas);
}

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

projector.setFOV(0.5f);
projector.setYFOV(0.5f);


SimpleVector pos=cube.getTransformedCenter();

projector.setPosition(pos);
projector.moveCamera(Camera.CAMERA_MOVEUP, 200);
projector.lookAt(pos);
SimpleVector offset=new SimpleVector(1,0,-1).normalize();
projector.moveCamera(offset, 215);

while (!fin) {

projector.lookAt(cube.getTransformedCenter());
offset.rotateY(0.007f);
projector.setPosition(pos);
projector.moveCamera(new SimpleVector(0,-1,0), 200);
projector.moveCamera(offset, 215);
sun.setPosition(projector.getPosition());

sh.updateShadowMap();

fb.clear();
sh.drawScene();

fb.update();
fb.displayGLOnly();

canvas.repaint();     

Thread.sleep(10);
}
fb.disableRenderer(IRenderer.RENDERER_OPENGL);
fb.dispose();
System.exit(0);
}

public static void main(String[] args) throws Exception {
SimpleShadows cd = new SimpleShadows();
cd.initStuff();
cd.setVisible(true);
cd.pack();
cd.setBounds(new Rectangle(640,480));
cd.doIt();
}
}


Thanks very much.
#8
Support / Re: Error using ShadowHelper.
August 26, 2008, 07:35:21 PM
The newer version that you send me don´t solve the problem.

Buffer size   640*480     with    ShadowHelper(world, buffer, proyector, 512)   --> ERROR
Buffer size   800*600     with    ShadowHelper(world, buffer, proyector, 512)   --> FINE
Buffer size   1024*768     with    ShadowHelper(world, buffer, proyector, 512)   --> FINE

Buffer size   640*480     with    ShadowHelper(world, buffer, proyector, 1024)   --> ERROR
Buffer size   800*600     with    ShadowHelper(world, buffer, proyector, 1024)   --> ERROR
Buffer size   1024*768     with    ShadowHelper(world, buffer, proyector, 1024)   --> ERROR

I recive always a warning in ejecution window:

WARNING: this graphics hardware may have performance problems with shadow mapping /depth textures without using FBOs!

It is like my graphic hardware don´t support FBO (it is set to true, but i recive this message).

there is relation between this two messages?

I´m downloading latest drivers for my graphic card.
#9
Support / Re: Error using ShadowHelper.
August 26, 2008, 06:54:01 PM
I have a Windows XP O.S. My graphics car is a ATI Mobility Redeon X700  256 Mgs.

I´m working with JPCT since one month about. I suposse that is the lastes version.

BOPSSSSSS I find something now.

If i put a 800*600 size in frame buffer, it go fine, like "SimpleShadow.java sample."

But if i put 640*480 size in frame buffer, CRASH, same ERROR.

800*600 resolution is too big to my application (Its render into a canvas y put this canvas into a JFrame).

Some idea?

Thanks

#10
Support / Error using ShadowHelper.
August 26, 2008, 06:09:09 PM
Hi!! I have a new question ;-).

Now I´m learning how to do shadow mapping with ShadowHelper.

I was reading "SimpleShadow.java" sample in forum. I got it and I modify it to test in a Canvas. Result was nice!!

Now, I´m using ShadowHelper in my application and i got this message error:

ERROR: Can´t render into a texture larger than the current framebuffer.

I can use sh = new ShadowHelper(world, fb, projector, 500) or sh = new ShadowHelper(world, fb, projector, 1000);

But i can´t use sh = new ShadowHelper(world, fb, projector, 512); or sh = new ShadowHelper(world, fb, projector, 1024);

My question is: Why i can´t use 500 or 1000 size of the shadow map but i got a ERROR using 512 o 1024??

In SimpleShadow.java sample i was using "sh = new ShadowHelper(world, fb, projector, 512);" whitout error..... why?


Thanks very much!!!! ;-)
#11
Support / Re: Low fps
August 24, 2008, 08:43:18 PM
Very interesting!!

That´s solve me some questions about frame-counters in JPCT.

It´s a very clean explain! :D

Thanks!!!
#12
Support / Re: Low fps
August 24, 2008, 08:06:04 PM


1) Yes, i´m using Thread.sleep(25) in the loop.  (if i not do some like this, cpu work at 100%)

2) Yes, i´m measuring fps in the loop :S (FPS.JAR sample do something like that in loop() method, isn´t? )

#13
Support / Low fps
August 24, 2008, 06:37:55 PM
Hi!

I´m working in a tile-style engine 3D. Main idea is render the world in a canvas instance to put this canvas in a JFrame with all buttons, labels, ect...

My problems is that with 4200 vertexs in world, its only can do between 30 or 40 frames per second.

Time delayed between buffers updates is only 25 millisecons.

Otherside, i was reading FPS sample in JPCT download section and its can up 200 frames por seconds.

¿There is another way to make faster hardware render into a canvas instance that i´m using?

My code example:


In object creation:

buffer = new FrameBuffer(width, height, defaultFrameBufferMode);     
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
canvas = buffer.enableGLCanvasRenderer();

In loop method:

buffer.clear(java.awt.Color.BLACK);                             
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
canvas.repaint();     




A Screenshot
[img=http://img231.imageshack.us/img231/4391/image1wd3.th.jpg]

THANKS!!!! ;-)
#14
Support / Re: Merge Object3D with extends Object3D
August 12, 2008, 07:29:52 PM
Understood!! ;-)

Thanks! :D
#15
Support / Re: Merge Object3D with extends Object3D
August 12, 2008, 06:11:57 PM
Hi!! I have finish the TerrainObject3D class.

I can load 3ds models and adds all his triangles, textures ID and U,V vertexs positions to TerrainObject3D one to one.



I have reduced polygons count in 5000!! and lights go fine! :D

I leave here the code, to help more people. ;-)

One more questions:  ¿What is a Octree? ¿what can it do?

Thansk very very much! ;-)



package engine3D;

import com.threed.jpct.*;

public class TerrainObject3D{

private Object3D terrain;

public TerrainObject3D(int maxPol){

terrain = new Object3D(maxPol);
}
public void addNewTerrainCell(Object3D obj, int posX, int posY){

PolygonManager polMan = obj.getPolygonManager();
int maxPolyID = polMan.getMaxPolygonID();
System.out.println("MaxPolyID = "+ Integer.toString(maxPolyID));
for (int poly = 0; poly < maxPolyID; poly++)
{
//Cada polígono tiene 3 vértices.
SimpleVector vect1 = polMan.getTransformedVertex( poly, 0);
SimpleVector vect2 = polMan.getTransformedVertex( poly, 1);
SimpleVector vect3 = polMan.getTransformedVertex( poly, 2);
//Cada vértice de cada polígono tiene asociado un par de valores U,V para la textura.
SimpleVector uv1 = polMan.getTextureUV(poly , 0);
SimpleVector uv2 = polMan.getTextureUV(poly , 1);
SimpleVector uv3 = polMan.getTextureUV(poly , 2);
//Cada polígono tiene una textura asociada, la optenemos.
int texID = polMan.getPolygonTexture(poly);
//Vemos que no haya un error en la textura.
if (texID == -1)
{
texID = 0;
}
vect1.set(vect1.x+posX,vect1.y, vect1.z+posY);
vect2.set(vect2.x+posX,vect2.y, vect2.z+posY);
vect3.set(vect3.x+posX,vect3.y, vect3.z+posY);
//Lo unimos al objeto terrain.
terrain.addTriangle(vect1, uv1.x, uv1.y, vect2, uv2.x, uv2.y, vect3, uv3.x, uv3.y, texID);
}
}
}