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

Pages: 1 2 3 [4] 5
46
Support / Re: How to add texture to textured object
« on: December 13, 2009, 01:56:42 pm »
Hello,

I would like to ask if it is possible to get the list of textures that are assigned to given polygon?

The PolygonManager have void setPolygonTexture(int polyID, TextureInfo tInf) method where TextureInfo allows to add many textures to it,
and there is a int getPolygonTexture(int polyID) method that returns id of one texture, but I cannot find any method that will return a list of textures assigned to given polygon.

Thanks,
Wojtek

47
Support / Re: Normal maps
« on: December 09, 2009, 10:58:26 pm »
Thanks. I will play with that :)

Wojtek

48
Support / Normal maps
« on: December 09, 2009, 09:41:47 pm »
Hello,

Recently, I have read in book on Blender that Normal Maps could be quite interesting and useful in making low-poly objects look better. Those maps uses RGB values to determine the shift of any given pixel in XYZ dimensions.

I wonder how useful is that in practice and if it is possible to use that in JPCT framework? If not, then are there any plans to add that functionality? I would also add, that I am mostly interested about hardware rendering mode.

The reason I asked is that I think it may be useful to make low-poly spherical shapes look more smooth.

Thanks,
Wojtek

49
Support / Re: How to add texture to textured object
« on: November 18, 2009, 12:03:18 am »
Thank you for your help once again. It works of course :)

There is a screenshot:

50
Support / Re: How to add texture to textured object
« on: November 17, 2009, 05:17:45 pm »
Thank you for response. It works :)

Now I have another question. When I added the envmap image, I have lost the shadow effect. There are example screenshots.
The first is with glare effect, and the second is without:



Can you please explain me why the shadow effect disappeard, and if it is possible to have both effects at the same time?

I can add that right now I am not using the ShadowHelper class so this is a standard shadow effect.

51
Support / How to add texture to textured object
« on: November 16, 2009, 04:43:13 pm »
Hello,

Is it possible to add additional texture to loaded 3ds object that already has some textures?

I see that there is a
Code: [Select]
public void setTexture(TextureInfo tInf) method, but it replaces all existing textures that are associated to the object and I do not see any methods that will be able to return texture list that is already assigned to object.

What I want to do is to add an additional texture that will be used as envmap (just like in viper example http://www.jpct.net/forum2/index.php/topic,988.0.html).

Thanks,
Wojtek

52
Support / Re: Why GLCanvas does not show up in Full Screen mode
« on: October 29, 2009, 09:16:42 pm »
Thanks for clarification.

Btw, I've voted. :)

53
Support / Re: Why GLCanvas does not show up in Full Screen mode
« on: October 28, 2009, 09:30:22 pm »
Great, it works with that parameter :) Thank you for help.

By the way, what that parameter means?

Thanks,
Wojtek

54
Support / Re: Why GLCanvas does not show up in Full Screen mode
« on: October 28, 2009, 12:02:44 pm »
Yes, the rest of GUI is working correctly in FullScreen mode. I am not getting any exceptions or warnings...
In fact even mouse events are working for GLCanvas, so canvas is present in place where it should be. The only thing is that there is nothing displayed in it.

The example code that I put in first post recreates the display problem.

Thanks,
Wojtek

55
Support / Re: Why GLCanvas does not show up in Full Screen mode
« on: October 27, 2009, 08:04:38 pm »
I'm not sure...i've never used a GLCanvas in a fullscreen window myself. Maybe you want to try the jogl-option instead to see, if this works better. More information about this can be found here: http://www.jpct.net/wiki/index.php/The_different_renderers#JOGL_support. It requires Jogl 1.1, not the 2.0beta stuff.

Unfortunately it does not seem to work as well :(

56
Support / Why GLCanvas does not show up in Full Screen mode
« on: October 26, 2009, 11:04:26 pm »
Hello,

Recently I tried to use full screen mode in my game but I found that GLCanvases that I use did not showed up after my change.

Here is an example code that shows my problem:
Code: [Select]
package Test;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.Timer;

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 FullScreenTest extends JFrame
{
    private GraphicsDevice device;
    private FrameBuffer buffer;
    private Canvas canvas;
    private World world;
    private Object3D object;
    private Timer timer;

    public static void main(String[] args)
    {
FullScreenTest frame = new FullScreenTest();
frame.setVisible(true);
    }

    public FullScreenTest()
    {
initResolution();
initComponents();
initCanvas();
initWorld();
startRendering();
    }

    private void startRendering()
    {
timer = new Timer(50, new ActionListener()
{

    @Override
    public void actionPerformed(ActionEvent e)
    {
renderScene();
    }
});
    }

    protected void renderScene()
    {
object.rotateX(0.1f);
object.rotateY(0.2f);

buffer.clear(java.awt.Color.BLACK);

world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.displayGLOnly();
canvas.repaint();
    }

    private void initWorld()
    {
world = new World();
world.setAmbientLight(10, 10, 10);
world.addLight(new SimpleVector(0, 0, -150), 40, 40, 40);

world.getCamera().setPosition(0, 0, -10);
world.getCamera().lookAt(new SimpleVector(0, 0, 0));

object = Primitives.getCube(2);
object.setAdditionalColor(Color.RED);
object.build();
object.setCenter(new SimpleVector(0, 0, 0));
world.addObject(object);
    }

    private void initCanvas()
    {
buffer = new FrameBuffer(400, 400, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);

canvas = buffer.enableGLCanvasRenderer();
add(canvas, BorderLayout.CENTER);
    }

    private void initComponents()
    {
setDefaultCloseOperation(EXIT_ON_CLOSE);
JPanel buttonBox = new JPanel();
buttonBox.setLayout(new BoxLayout(buttonBox, BoxLayout.LINE_AXIS));
getContentPane().add(buttonBox, BorderLayout.PAGE_END);
JButton button = new JButton("Start");
buttonBox.add(button);
button.addActionListener(new ActionListener()
{
    @Override
    public void actionPerformed(ActionEvent arg0)
    {
timer.start();
    }
});
button = new JButton("Exit");
buttonBox.add(button);
button.addActionListener(new ActionListener()
{
    @Override
    public void actionPerformed(ActionEvent arg0)
    {
timer.stop();
device.setFullScreenWindow(null);
setVisible(false);
dispose();
    }
});
    }

    private void initResolution()
    {
setUndecorated(true);
setResizable(false);

device = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices()[0];
device.setFullScreenWindow(this);
DisplayMode mode = device.getDisplayMode();
setSize(mode.getWidth(), mode.getHeight());

    }
}

If I comment out the device.setFullScreenWindow(this) line it works.
Does anyone know what I have to change to make it work in full screen mode?
I use: JPCT 1.18 and java 1.6

Thanks,
Wojtek

57
Support / Re: Camera UP vector
« on: August 12, 2009, 07:43:12 pm »
Thank you both for quick help :)

First I have tried the solution presented by Egon (Scene Rotation topic: http://www.jpct.net/forum2/index.php/topic,977.0.html)
and it works even better than I assumed :)

There is a code that I used to for testing:
Code: [Select]
public class CameraPosition
{
    private float distance = 5;

    public void rotate(Camera cam, double x, double y)
    {
SimpleVector line = new SimpleVector(x, 0, y);
Matrix m = line.normalize().getRotationMatrix();
m.rotateAxis(m.getXAxis(), (float) -Math.PI / 2f);

SimpleVector shift = moveCameraToZeroPosition(cam);
cam.rotateAxis(m.invert3x3().getXAxis(), line.length() / 200f);
restoreCameraPosition(cam, shift);
    }

    private void restoreCameraPosition(Camera cam, SimpleVector shift)
    {
cam.moveCamera(Camera.CAMERA_MOVEOUT, distance);
shift.add(cam.getPosition());
cam.setPosition(shift);
    }

    private SimpleVector moveCameraToZeroPosition(Camera cam)
    {
cam.moveCamera(Camera.CAMERA_MOVEIN, distance);
SimpleVector shift = cam.getPosition();
cam.setPosition(new SimpleVector(0, 0, 0));
return shift;
    }

    public void zoom(Camera cam, double delta)
    {
distance -= delta;
cam.moveCamera(Camera.CAMERA_MOVEIN, (float) delta);
    }

    public void updateCamera(Object3D object, Camera cam)
    {
if (cam.getPosition().length() == 0)
    initCamera(object, cam);
moveCameraToZeroPosition(cam);
restoreCameraPosition(cam, object.getTransformedCenter());
    }

    private void initCamera(Object3D object, Camera cam)
    {
SimpleVector vec = new SimpleVector(0, 5, 5);
vec.add(object.getTransformedCenter());
cam.setPosition(vec);
cam.lookAt(object.getTransformedCenter());
    }
}

I have added two modifications to the code:
1. initCamera() if camera position is [0,0,0] - this helps me to set correct starting point for camera
2. Apart from moving camera using distance, moveCameraToZeroPosition() and restoreCameraPosition() methods resets the camera position to [0,0,0] (and returns the shift vector) and applies shift vector when camera position is restored. Having that, camera is able to follow moving objects.


I have not checked the second solution because the first one is ok for me and it also allows ship to rotate independently from camera.

58
Support / Camera UP vector
« on: August 11, 2009, 10:47:20 pm »
Hello,

I would like to allow player to move camera around the player's ship to see it from different perspective.
The following image shows what I am planning to do: .

First I have tried to use Camera.lookAt() method, however when I run the game it does not work as I wanted.
It is difficult for me to explain why, so i attached 3 screenshots showing how it works with lookAt() method:



What I want is not to see the effect of rotating ship, but have the effect that player is 'flying' around the ship.


After that I have started playing with Camera.setOrientation() method. I am using following code to calculate direction vector:
Code: [Select]
SimpleVector direction = object.getTransformedCenter();
direction=direction.calcSub(camera.getPosition());

It seems to work for me, however I have no idea how to calcluate up vector. If I understand it correctly its purpose is to show the direction where is the 'sky' so it suppose to be a perpendicular vector to direction vector (I have showed it as a small blue line at the first picture). I am trying to make it work a second day but without result :( Can anyone help me and give a hint how to calculate it?

Thanks,
Wojtek

59
Support / Re: Tiled texture on an infinitly big plane?
« on: July 14, 2009, 09:54:13 pm »
Hello,

Recently I had a similar problem - how to create a textured world for my space game. I have read that thread, however what I needed was a little bit different than Mystara. I wanted to have a starfield that is not moving when starship is travelling, however it needs to look different if camera angle is changed.

I have created a solution that may be helpful for others too.

So what I did was to create a very big sphere (lets say with radius=1000), textured it and put camera inside it.

My game is working the way, that camera is always looking at player's ship from some specified distance (so in fact it is being moved with the spaceship during the game). Having that implemented I continueusly update the sphere center position to be the same as ship's one, so when ship is moving, the starfield looks the same from cameras perspective, however when camera angle is changed, it looks different.


I have uploaded an example with textured sphere and camera located in the sphere center. It is possible to use arrows to change camera angles and see how world texture is changing.
The example files can be downloaded from: working example with sources

Thanks,
Wojtek

60
And there are the screenshots:

and



Pages: 1 2 3 [4] 5