www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: athanazio on December 02, 2006, 03:45:08 am

Title: rearview mirror
Post by: athanazio on December 02, 2006, 03:45:08 am
Iīm implementing a basic car control to understand more about jpct features, butīm facing a challenge now: how to implement a rearview mirror ?
something like this for example ...
(http://www.riogdug.org/files/7812_316.jpg)

should I use more than one camera ?

thanks for the help
Title: rearview mirror
Post by: Melssj5 on December 02, 2006, 05:10:18 am
:shock:  Well, I guess that it cant be done with jpct, maybe if Egon implements a way to render a camera into a defined rectagle, you could render one camera and then the another anoe on the rectangle desired, Only Egon can resolve this.
Title: rearview mirror
Post by: athanazio on December 02, 2006, 12:18:55 pm
ouch !  :shock:

I tried last night to do like this:

1. created a new world
2. cloned all the objects to the new world (is itreally necessary, as Im looking for the same objects ? ...
3. created another FrameBuffer
4. rendered the new FrameBuffer in a small rectangle

result = black rectangle ...

is this a good aproach Egon ? IMO a good to do it is have the possibility of use the way I'm doing with some other details:
- dont need to copy the objects from one world to other
- define a view port or something like this to the rendering process

all the source code is here (http://www.riogdug.org/files/rearwindow_20061202_283.zip)

and this is the game class, with what I tried

Code: [Select]
package com.foo.game;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.util.Enumeration;

import com.foo.game.test.Pathbuilder;
import com.foo.game.util.CameraUtil;
import com.foo.game.util.LightUtil;
import com.foo.game.util.PlaneUtil;
import com.foo.game.util.SimpleGame;
import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.IRenderer;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.World;

public class RearViewGame extends SimpleGame {

public RearViewGame(Component owner, Pathbuilder builder) throws Exception {
super(owner, builder);
init();
}

private static final long serialVersionUID = 1L;

private static final float ROTATE_ANGLE = (float) Math.toRadians(20.0);

private static final float SPEED = 25.0f;

private Object3D current = null;

public void init() throws Exception {
addTexture("rocks", "textures/rocks.jpg");
addTexture("floor", "textures/floor.jpg");

Object3D[] list = new Object3D[3];

list[0] = Primitives.getCube(20);
setCurrent(list[0]);

// remove from the floor, decrease
list[0].translate(0, -20, 0);
list[2] = Primitives.getCylinder(50);
list[2].translate(0, -50, -100);

list[1] = PlaneUtil.getPlane("floor", 20, 300);
addObjects(list);

CameraUtil.setCameraLookingFromTop(getCamera(), list[0]);
LightUtil.addDefaultLight(getWorld());
createRearViewWorld();
}

World rearView = new World();

FrameBuffer rearViewBuffer;

private void createRearViewWorld() {
World rearView = new World();
Enumeration objects = getWorld().getObjects();
while (objects.hasMoreElements()) {
Object3D element = (Object3D) objects.nextElement();
rearView.addObject(element.cloneObject());
}
rearView.buildAllObjects();

LightUtil.addDefaultLight(rearView);
Camera c = rearView.getCamera();
c.setPosition(50, -100, 50);
c.lookAt(SimpleVector.ORIGIN);

rearViewBuffer = new FrameBuffer(300, 100,
FrameBuffer.SAMPLINGMODE_NORMAL);
rearViewBuffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);

Enumeration o= rearView.getObjects();
while (o.hasMoreElements()) {
Object3D element = (Object3D) o.nextElement();
System.out.println(element.getVisibility());
System.out.println(element.getCenter());
}

}

private void renderRearView() {
rearViewBuffer.clear();
rearView.renderScene(rearViewBuffer);
rearView.draw(rearViewBuffer);
rearViewBuffer.update();
}

public void afterPaintComponent(Graphics g) {
rearViewBuffer.display(g, 30, 30);
g.setColor(Color.WHITE);
g.drawRect(30, 30, 300, 100);
}

// TODO move the camera with the object
public void loop() {
renderRearView();

if (getCurrent() != null) {

if (isUp()) {
SimpleVector a = getCurrent().getZAxis();
a.scalarMul(SPEED);
getCurrent().translate(a);
CameraUtil.moveCamera(getWorld().getCamera(), current);
}

if (isDown()) {
SimpleVector a = getCurrent().getZAxis();
a.scalarMul(-SPEED);
getCurrent().translate(a);
CameraUtil.moveCamera(getWorld().getCamera(), current);
}

if (isLeft()) {
getCurrent().rotateY(ROTATE_ANGLE);
}

if (isRight()) {
getCurrent().rotateY(-ROTATE_ANGLE);
}
} else {
System.out.println("current is null");
}
}

public Object3D getCurrent() {
return current;
}

public void setCurrent(Object3D current) {
this.current = current;
}

}


this is the visual result :
(http://www.riogdug.org/files/rearview_creation_black_rectangle_211.jpg)
Title: rearview mirror
Post by: athanazio on December 02, 2006, 01:28:35 pm
I found in a presentation of ogre, the way that is done over there ...
It can be done with the creation of ViewPort, or RenderTexture, that is something like render a camera to an texture ... this would be very cool :)
imagine to render mirrors and reflexive images over water ... uhuuuu !

I can see the player gatting close to the water and seeing its on image on it ... this is a good coding challenge hehehe
Title: rearview mirror
Post by: athanazio on December 02, 2006, 01:36:49 pm
well, I'm trying to solve this ... with no success ...
I tried to save the image fro mthe second renderer but still black screen ...
no good ... help me Egon !! :)

look what I tried ...

Code: [Select]
public void afterPaintComponent(Graphics g) {
BufferedImage buffer = new BufferedImage(getWidth(), getHeight(),
BufferedImage.TYPE_INT_RGB);

Graphics2D g2 = buffer.createGraphics();

rearViewBuffer.display(g2);

try {
generateJPG(buffer, "d:/foo.jpg");
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

g.setColor(Color.WHITE);
g.drawRect(30, 30, 300, 100);
}

private static void generateJPG(BufferedImage buffer, String fileName)
throws FileNotFoundException, IOException {

FileOutputStream file = new FileOutputStream(fileName);

JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(file);
JPEGEncodeParam param = encoder.getDefaultJPEGEncodeParam(buffer);
param.setQuality(1.0F, true);
encoder.setJPEGEncodeParam(param);

encoder.encode(buffer);
file.close();
}
Title: rearview mirror
Post by: athanazio on December 02, 2006, 01:59:19 pm
getting better !! :)
after some small changes in the code, some stupid mistakes... shhh... =) like the second world instance wanst used in the code that copies the objects.

now I got and fixed image ... in the "mirror" now I will create something like a movement listener to update the clone with the position information ...

Hey would be great if we dont need to clone() the objets, just share the same objets, one sugestion is create a subclass of world called Viewport that can share the same objects, and have for example different light sources, differnt camera...

look how it looks
(http://www.riogdug.org/files/rearview_creation_getting_better_273.jpg)
Title: rearview mirror
Post by: cyberkilla on December 02, 2006, 02:58:52 pm
Well done man:) I knew that would be possible.


I didnt read everything, so i dont know exactly what you did, but this is what id do...


2 Cameras. One for front, one for rear.

render view from REAR to bufferedimage.


render front view, and blit buffered image into place.
Title: rearview mirror
Post by: athanazio on December 02, 2006, 03:27:08 pm
aha !!!
now is working !!

http://www.athanazio.pro.br/wp-content/uploads/2006/11/testAppletRearView.html

What I made :
1. create a new World with a new FrameBuffer
2. add to my AbstractEntity (copied from the Car sample) some methods to deal with Object3D synchronization, if you change the master one the others are changed

3. and as cyberkilla said, another camera in other direction, hehehe worked fine !!

now I will try to do using an Texture, to offer object reflection :) lets see what happens ...
Title: rearview mirror
Post by: athanazio on December 02, 2006, 03:37:17 pm
source code for the implementation of an rearview mirror =) (this is to help google ...)
http://www.athanazio.pro.br/wp-content/uploads/2006/11/rearwindow_src_20061202.zip

some interesting pieces ... :)

the game class

Code: [Select]
package com.foo.game.rearview;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.util.Enumeration;

import com.foo.game.test.Pathbuilder;
import com.foo.game.util.AbstractEntity;
import com.foo.game.util.CameraUtil;
import com.foo.game.util.FPSListener;
import com.foo.game.util.LightUtil;
import com.foo.game.util.PlaneUtil;
import com.foo.game.util.SimpleGame;
import com.threed.jpct.Camera;
import com.threed.jpct.FrameBuffer;
import com.threed.jpct.IRenderer;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.World;

public class RearViewGame extends SimpleGame implements FPSListener{

public RearViewGame(Component owner, Pathbuilder builder) throws Exception {
super(owner, builder);
init();
}

private static final long serialVersionUID = 1L;

private static final float ROTATE_ANGLE = (float) Math.toRadians(20.0);

private static final float SPEED = 25.0f;

private Object3D current = null;
private int lastFPS = 0;

public void init() throws Exception {
addTexture("rocks", "textures/rocks.jpg");
addTexture("floor", "textures/floor.jpg");

AbstractEntity[] list = new AbstractEntity[3];

list[0] = new AbstractEntity(Primitives.getCube(20));
setCurrent(list[0]);

// remove from the floor, decrease
list[0].translate(0, -20, 0);
list[2] = new AbstractEntity(Primitives.getCylinder(50));
list[2].translate(0, -50, -100);

list[1] = new AbstractEntity(PlaneUtil.getPlane("floor", 20, 300));
addObjects(list);

CameraUtil.setCameraLookingFromTop(getCamera(), list[0]);
LightUtil.addDefaultLight(getWorld());
createRearViewWorld();
addFPSListener(this);
}

World rearViewWorld = new World();

FrameBuffer rearViewBuffer;

private void createRearViewWorld() {
rearViewWorld = new World();
Enumeration objects = getWorld().getObjects();
while (objects.hasMoreElements()) {
AbstractEntity element = (AbstractEntity) objects.nextElement();
AbstractEntity clone = new AbstractEntity( element.cloneObject());
[b] element.addSyncObject(clone);
[/b] rearViewWorld.addObject(clone);
}
rearViewWorld.buildAllObjects();

LightUtil.addDefaultLight(rearViewWorld);
Camera c = rearViewWorld.getCamera();
c.setPosition(50, -100, 50);
c.lookAt(SimpleVector.ORIGIN);

[b]rearViewBuffer = new FrameBuffer(300, 100,
FrameBuffer.SAMPLINGMODE_NORMAL);[/b]
rearViewBuffer.enableRenderer(IRenderer.RENDERER_SOFTWARE);

Enumeration o = rearViewWorld.getObjects();
while (o.hasMoreElements()) {
Object3D element = (Object3D) o.nextElement();
System.out.println(element.getCenter());
}

}

private void renderRearView() {
rearViewBuffer.clear();
rearViewWorld.renderScene(rearViewBuffer);
rearViewWorld.draw(rearViewBuffer);
rearViewBuffer.update();
}

[b] public void afterPaintComponent(Graphics g) {
[/b]
rearViewBuffer.display(g, 30, 30);

g.setColor(Color.WHITE);
g.drawRect(30, 30, 300, 100);

g.drawString(Integer.toString(lastFPS) + "FPS", 15, 15);
}

// TODO move the camera with the object
public void loop() {
renderRearView();

if (getCurrent() != null) {

if (isUp()) {
SimpleVector a = getCurrent().getZAxis();
a.scalarMul(SPEED);
getCurrent().translate(a);
CameraUtil.moveCamera(getWorld().getCamera(), current);
}

if (isDown()) {
SimpleVector a = getCurrent().getZAxis();
a.scalarMul(-SPEED);
getCurrent().translate(a);
CameraUtil.moveCamera(getWorld().getCamera(), current);
}

if (isLeft()) {
getCurrent().rotateY(ROTATE_ANGLE);
}

if (isRight()) {
getCurrent().rotateY(-ROTATE_ANGLE);
}
} else {
System.out.println("current is null");
}
}

public Object3D getCurrent() {
return current;
}

public void setCurrent(Object3D current) {
this.current = current;
}

public void notifyFPS(int fps) {
lastFPS = fps;
}


}
Title: rearview mirror
Post by: raft on December 02, 2006, 05:38:47 pm
nice work athanazio ;)

isnt it possible two use two cameras instead of cloning objects and using two worlds ?

Code: [Select]
r a f t
Title: more mirrors ... :)
Post by: athanazio on December 02, 2006, 05:41:14 pm
Oh well, I really like this challenge ! :)
soh I implemented the class ViewPort to be like a second view of an world, and add the possbility to create an texture with the current framebuffer of it

the result was pretty nice (I think ...)

(http://www.riogdug.org/files/rearview_with_mirror_762.jpg)

This is the ViewPort class

Code: [Select]
package com.foo.game.util;

import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.Enumeration;

import com.threed.jpct.FrameBuffer;
import com.threed.jpct.IRenderer;
import com.threed.jpct.Texture;
import com.threed.jpct.World;

public class ViewPort {

private World w;

private FrameBuffer fb;

private int width;

private int height;

public ViewPort(World master, int width, int height) {

this.width = width;
this.height = height;

w = new World();
Enumeration objects = master.getObjects();
while (objects.hasMoreElements()) {
AbstractEntity element = (AbstractEntity) objects.nextElement();
AbstractEntity clone = new AbstractEntity(element.cloneObject());
element.addSyncObject(clone);
w.addObject(clone);
}
w.buildAllObjects();

fb = new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
fb.enableRenderer(IRenderer.RENDERER_SOFTWARE);
}

public void render() {
fb.clear();
w.renderScene(fb);
w.draw(fb);
fb.update();
}

public World getWorld() {
return w;
}

/**
* draws the world using the framebuffer in the informed Graphics at the
* position (x,y)
*
* @param g
* @param x
* @param y
*/
public void display(Graphics g, int x, int y) {
fb.display(g, x, y);
}

/**
* returns the draw result of the view port in a texture
*
* @return
*/
public Texture getTexture() {
BufferedImage buffer = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);

Graphics2D g2 = buffer.createGraphics();
display(g2, 0, 0);

return new Texture(buffer);
}
}


This is the class that is using the ViewPort class

Code: [Select]
package com.foo.game.rearview;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;

import com.foo.game.test.Pathbuilder;
import com.foo.game.util.AbstractEntity;
import com.foo.game.util.CameraUtil;
import com.foo.game.util.FPSListener;
import com.foo.game.util.LightUtil;
import com.foo.game.util.PlaneUtil;
import com.foo.game.util.SimpleGame;
import com.foo.game.util.ViewPort;
import com.threed.jpct.Camera;
import com.threed.jpct.Config;
import com.threed.jpct.Object3D;
import com.threed.jpct.Primitives;
import com.threed.jpct.SimpleVector;
import com.threed.jpct.Texture;
import com.threed.jpct.TextureManager;

public class RearViewGame extends SimpleGame implements FPSListener {

public RearViewGame(Component owner, Pathbuilder builder) throws Exception {
super(owner, builder);
init();
}

private static final long serialVersionUID = 1L;

private static final float ROTATE_ANGLE = (float) Math.toRadians(20.0);

private static final float SPEED = 25.0f;

private Object3D current = null;

private int lastFPS = 0;

private ViewPort rearview;

private ViewPort mirror;

public void init() throws Exception {
System.out.println("Config.maxPolysVisible=" + Config.maxPolysVisible);
Config.maxPolysVisible = 12000;

addTexture("rocks", "textures/rocks.jpg");
addTexture("floor", "textures/floor.jpg");

AbstractEntity[] list = new AbstractEntity[4];

list[0] = new AbstractEntity(Primitives.getCube(20));
setCurrent(list[0]);

// remove from the floor, decrease
list[0].translate(0, -20, 0);
list[2] = new AbstractEntity(Primitives.getCylinder(50));
list[2].translate(0, -50, -100);

// the mirror
list[3] = new AbstractEntity(Primitives.getPlane(50, 3));
list[3].translate(100, -50, 100);
getTextureManager().addTexture("mirror",
getTextureManager().getDummyTexture());
list[3].setTexture("mirror");

list[1] = new AbstractEntity(PlaneUtil.getPlane("floor", 20, 300));
addObjects(list);

CameraUtil.setCameraLookingFromTop(getCamera(), list[0]);

mirror = new ViewPort(getWorld(), 256, 256);
Camera c = mirror.getWorld().getCamera();
c.setPosition(100, -50, 100);
c.lookAt(SimpleVector.ORIGIN);

rearview = new ViewPort(getWorld(), 300, 100);
c = rearview.getWorld().getCamera();
c.setPosition(50, -100, 50);
c.lookAt(SimpleVector.ORIGIN);

LightUtil.addDefaultLight(getWorld());
LightUtil.addDefaultLight(rearview.getWorld());
LightUtil.addDefaultLight(mirror.getWorld());
addFPSListener(this);
}

public void afterPaintComponent(Graphics g) {

rearview.display(g, 30, 30);

g.setColor(Color.WHITE);
g.drawRect(30, 30, 300, 100);

g.drawString(Integer.toString(lastFPS) + "FPS", 15, 15);
}

public void loop() {
rearview.render();
mirror.render();
getTextureManager().replaceTexture("mirror", mirror.getTexture());

if (getCurrent() != null) {

if (isUp()) {
SimpleVector a = getCurrent().getZAxis();
a.scalarMul(SPEED);
getCurrent().translate(a);
CameraUtil.moveCamera(getWorld().getCamera(), current);
}

if (isDown()) {
SimpleVector a = getCurrent().getZAxis();
a.scalarMul(-SPEED);
getCurrent().translate(a);
CameraUtil.moveCamera(getWorld().getCamera(), current);
}

if (isLeft()) {
getCurrent().rotateY(ROTATE_ANGLE);
}

if (isRight()) {
getCurrent().rotateY(-ROTATE_ANGLE);
}
} else {
System.out.println("current is null");
}
}

public Object3D getCurrent() {
return current;
}

public void setCurrent(Object3D current) {
this.current = current;
}

public void notifyFPS(int fps) {
lastFPS = fps;
}

}
Title: rearview mirror
Post by: EgonOlsen on December 02, 2006, 07:22:24 pm
Well done. I haven't tried this myself yet. It will be difficult to do this using the hardware renderer, because currently there's no support for rendering into a texture. Anyway, nice work.
Title: rearview mirror
Post by: athanazio on December 04, 2006, 12:02:13 pm
Egon,

is there possible to set something at the Object3D to allow the use in multiple worlds ? doing like this I would be able to set more than one camera with less objects in memory.
Title: rearview mirror
Post by: EgonOlsen on December 04, 2006, 06:36:10 pm
No. An Object3D holds a reference to its World. That's bad, i know...but it's a requirement from some methods if you don't want to make the World a parameter that you would have to pass all time.
But you can work with different cameras on one World and render that world into different framebuffers. So i'm not sure if you really need multiple Worlds for implementing the mirror effects. It should be possible with a single one.
Title: rearview mirror
Post by: athanazio on December 05, 2006, 01:33:34 pm
done !! only one world and multiple cameras, and the mirror I'm rendering in a BufferedImage and changing the Texture in the TextureManager ... hehehe dont know if this is the best aproach ... but its working, the performance its not fantastic, but I'm trying to tune it ...

(http://www.riogdug.org/files/rearview_one_world_multiple_cameras_264.jpg)
this is funny screenshot mirror seeing it self ... :)
Title: rearview mirror
Post by: EgonOlsen on December 05, 2006, 04:58:06 pm
You may consider to get the raw pixel data from the framebuffer what represents the mirror and feed that into an implementation of an ITextureEffect that is attached to the "mirror texture". That way, you can skip the BufferedImage.
Title: rearview mirror
Post by: athanazio on December 06, 2006, 04:11:29 am
I tried this way :

Code: [Select]
public class ViewPortEffect implements ITextureEffect {

private FrameBuffer fb;

public ViewPortEffect(FrameBuffer fb) {
this.fb = fb;
}

public void apply(int[] dest, int[] source) {
dest = fb.getPixels();
}

public void init(Texture arg0) {
}


}


and set the effect to the Texture object

Code: [Select]
public ViewPort(World master, int width, int height) {

this.camera = new Camera();
this.width = width;
this.height = height;
this.w = master;

fb = new FrameBuffer(width, height, FrameBuffer.SAMPLINGMODE_NORMAL);
fb.enableRenderer(IRenderer.RENDERER_SOFTWARE);

texture = TextureManager.getInstance().getDummyTexture();
texture.setEffect(new ViewPortEffect(fb));

// buffer = new BufferedImage(width, height,
// BufferedImage.TYPE_INT_RGB);
// g2 = buffer.createGraphics();

}


at my loop the render method of the viewport is called

Code: [Select]
public void render() {
Camera foo = w.getCamera();
w.setCameraTo(camera);

fb.clear();
w.renderScene(fb);
w.draw(fb);
fb.update();
texture.applyEffect();

w.setCameraTo(foo);
}


and at the creation of the objects I set the texture to the new one ...

Code: [Select]
mirror = new ViewPort(getWorld(), 256, 256);
Camera c = mirror.getCamera();
getTextureManager().replaceTexture("mirror", mirror.getTexture());

c.setPosition(80, -70, 80);
c.lookAt(SimpleVector.ORIGIN);


but I got nothing at the mirror ... any idea ? I'm missing something ?
Title: rearview mirror
Post by: EgonOlsen on December 06, 2006, 08:53:25 am
Quote from: "athanazio"

   public void apply(int[] dest, int[] source) {
      dest = fb.getPixels();
   }
This can't work, because you are just setting the reference locally. Copy the pixels from fb.getPixels() into dest[] with System.arraycopy instead.
Title: rearview mirror
Post by: athanazio on December 06, 2006, 02:24:34 pm
thanks worked fine !!!

Code: [Select]
public void apply(int[] dest, int[] source) {
System.arraycopy(fb.getPixels(), 0, dest, 0, fb.getPixels().length);
}


trying to optimize the code, I'm looking for a way to remove the Graphics operations, and use the blit method, in order to draw the upper box with a blit over the main frambuffer

done this :

this the method to draw the current viewport
Code: [Select]
public void display(FrameBuffer buffer, int x, int y) {
if (buffer != null) {
buffer.blit(getTexture(), 0, 0, x, y, getTexture().getWidth(),
getTexture().getHeight(), false);
}
// fb.display(g, x, y);
}


that is called by (that its in my game class)
Code: [Select]
public void afterPaintComponent(Graphics g) {

rearview.display(getBuffer(), 30, 30);

g.setColor(Color.WHITE);
g.drawRect(30, 30, 300, 100);
g.drawString(Integer.toString(lastFPS) + "FPS", 15, 15);
}


and its called by my gamesuper class (that is a Jcomponent)
Code: [Select]
protected void paintComponent(Graphics g) {
if (buffer != null) {
buffer.display(g, leftBorderWidth, titleBarHeight);
afterPaintComponent(g);
}
}


but ... I got nothing at the white box ...
Title: rearview mirror
Post by: Mizuki Takase on December 06, 2006, 03:05:47 pm
I wonder... Since you are creating an ITextureEffect, does that mean that reflective or chromed surfaces are possible? I would love to see that~!!

Off topic: I love the Lamborghini Mucielago! Definitively can not afford one, but oh well....
Title: rearview mirror
Post by: EgonOlsen on December 06, 2006, 03:40:35 pm
Maybe the buffer that holds the mirror view hasn't been updated!? Try to call update(); on it before making the blit and see if that helps.
Title: rearview mirror
Post by: athanazio on December 06, 2006, 04:28:00 pm
I got the problem ! I was updating the framebuffer AFTER the display ... like this is harder to see something hehehehe, anyway now at least I see something ... still wrong ... probably the size of the texture or something like this ...

the FPS are increasing :) around 10 when hanging around the mirror and around 20 without the mirror

(http://www.riogdug.org/files/rearview_bliting_getting_better_606.jpg)
Title: rearview mirror
Post by: athanazio on December 06, 2006, 04:55:24 pm
the problem was the size restrictions of the Texture, I changed the size of the viewport and averybody got happy !!! thanks !!!

(http://www.riogdug.org/files/rearview_working_130.jpg)
Title: rearview mirror
Post by: athanazio on December 06, 2006, 04:58:19 pm
Mizuki,
reflexive texture... humm is there possible to put one texture one over the other like layers ? if so we can use the technique that I used and merge the original texture, with a view of something that is around, creating the reflexive effect ... :D
Title: rearview mirror
Post by: Mizuki Takase on December 06, 2006, 05:05:36 pm
I thought that the TextureInfo class has something to do with multi-texturing... Quoting from the javadoc...

Quote
TextureInfo is jPCT's key to multi texturing. Multi texturing is supported by the OpenGL renderer only. You may still use the software renderer to render such a scene, but it will simply ignore the additional texture stages. You can use addTriangle() or setTexture() in Object3D to define a polygon or the whole object as multi textured.
You can use any combination of textures and blending modes for a polygon. jPCT will try to optimize the texture state changes when rendering the image. However, don't overuse this feature on a single object, because jPCT can only do so much.
If you are adding more layers than the hardware supports, jPCT will switch to multi pass rendering automatically. Due to the way the OpenGL pipeline is specified, this may produce different results compared to one pass multi texturing. This happens most when using transparency, fog or blending modes like MODE_ADD, when the card's internal accuracy is higher than the framebuffer's.


Atleast the class seem simple to use; the one and only function is add...
Title: rearview mirror
Post by: EgonOlsen on December 06, 2006, 06:39:43 pm
Yes, but the software renderer ignores all texture layers but the first. Or in other words: It can do single texturing only. The hardware renderer can do more (which is what TextureInfo is mostly for), but it currently can't do, what athanazio is doing here, because it can't render to texture.
What you have in mind is cubic environment mapping with dynamic environment maps. jPCT can't do this. However, it can do spherical environment mapping with a static texture, which should be sufficient for simple, chrome like surfaces.
Title: rearview mirror
Post by: Mizuki Takase on December 06, 2006, 08:28:26 pm
^_^;;; Oh well... One could at least dream I guess.... Thanks for the reply on that subject matter...