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

Pages: [1]
1
Support / How to reset direction of object
« on: May 07, 2009, 11:18:09 am »
I want to reset  objects which  are rotated ,but I can't get the direction when these objects are Loaded.
these objects has been roteted (by rotateX()),i try to get original direction of these(by getOrigin() ),bescause of i didn't use setOrigin() giving these a original direction ,i can't get the direction i needed .
 how can i get the direction ?
thanks.

2
Support / how to control object rotating ?
« on: May 05, 2009, 11:58:56 am »
I want to use jpct
to achieve rotating  object like cult3D example :
http://www.cult3d.com/gallery/conceptcar/index.html

any suggestions?

 Do I need to rotate object,or camera?
 excuse me for my english!

3
Support / How can i get the texture which in an object
« on: April 27, 2009, 02:13:00 pm »
how  i  get the texture which in an object after loading 3ds file ?

I want to know which textures(pictures) in an object .please give me some advice,thanks a lot!

4
Support / How to get the texture of obj files
« on: April 08, 2009, 09:42:01 am »
My program used *.obj files.
in the document of the jpct ,I found out the method readTextureNames3DS(java.lang.String filename)  in Loader Class .
if i load *.obj files, Loader class have no suitable method likes readTextureNames3DS() ?

please give me some suggestion.Thank U.

5
Support / About rotate object
« on: March 25, 2009, 10:33:55 am »
Firstly ,excuse me for my english.

I want to rotate object in world by mouse.

use lwjgl.jar ,it has a method that can solve my problem
core code is
Code: [Select]
  int x=Mouse.getDX();
            int y=Mouse.getDY();
             if (Mouse.isButtonDown(0)) {
       
            // Rotate camera around object by holding down the left button
                SimpleVector line=new SimpleVector(x, 0, y);
                Matrix m=line.normalize().getRotationMatrix();
                m.rotateAxis(m.getXAxis(), (float) -Math.PI/2f);
                cam.moveCamera(Camera.CAMERA_MOVEIN, distance);
                cam.rotateAxis(m.invert3x3().getXAxis(), line.length() / 200f);
                cam.moveCamera(Camera.CAMERA_MOVEOUT, distance);
            }

   but i do not want to use this method ,how to solve my problem by  jpct ???

  thanks everyone .

6
Support / How to add Mouse Listener
« on: March 24, 2009, 03:02:41 am »
I wanna to add MouseListener into this example for rotate or scale 3D object in canvas
the code is
Code: [Select]
package org.bm;

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

public class CarDemo extends JFrame {

World world;
Camera camara;
FrameBuffer buffer;
Texture colores[];
KeyMapper mapaTeclas;
Canvas canvasRender;
ThreadRender render;

/** Creates new form AutoFrame */
public CarDemo() {
Config.maxPolysVisible = 20000;
Config.farPlane = 12000;
Config.glMipmap = false;
Config.glForceEnvMapToSecondStage = true;

initComponents();
setTitle("test");

world = new World();
world.setAmbientLight(120, 120, 120);
world.addLight(new SimpleVector(0, -30, 0), 20, 20, 20);
camara = world.getCamera();
camara.setPosition(10, -5, -8);
camara.lookAt(new SimpleVector(0, 0, 0));
buffer = new FrameBuffer(600, 400,
FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.enableRenderer(IRenderer.RENDERER_OPENGL);
canvasRender = buffer.enableGLCanvasRenderer(IRenderer.RENDERER_OPENGL);

mapaTeclas = new KeyMapper(canvasRender);
pnl_Canvas.add(canvasRender);

render = new ThreadRender(world, buffer, mapaTeclas, canvasRender);
render.OGL = true;
render.start();

colores = new Texture[8];
colores[0] = new Texture("Auto/Texturas/ROJO.JPG");
colores[1] = new Texture("Auto/Texturas/AZUL.JPG");
colores[2] = new Texture("Auto/Texturas/VERDE.JPG");
colores[3] = new Texture("Auto/Texturas/NEGRO.JPG");
colores[4] = new Texture("Auto/Texturas/TOMATE.JPG");
colores[5] = new Texture("Auto/Texturas/AMARILLO.JPG");
colores[6] = new Texture("Auto/Texturas/GRIS.JPG");
colores[7] = new Texture("Auto/Texturas/BLANCO.JPG");
}

private void initComponents() {
btn_blanco = new JButton();
btn_gris = new JButton();
pnl_Canvas = new JPanel();
btn_amarillo = new JButton();
btn_negro = new JButton();
btn_verde = new JButton();
btn_azul = new JButton();
btn_rojo = new JButton();
btn_tomate = new JButton();
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(1, 10, 2, 2));
getContentPane().setLayout(new BorderLayout());

addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});

btn_blanco
.setIcon(new javax.swing.ImageIcon("Auto/Texturas/BLANCO.JPG"));
btn_blanco.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
btn_blancoMouseReleased(evt);
}
});

buttonPanel.add(btn_blanco);


btn_gris.setIcon(new javax.swing.ImageIcon("Auto/Texturas/GRIS.JPG"));
btn_gris.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
btn_grisMouseReleased(evt);
}
});

buttonPanel.add(btn_gris);


pnl_Canvas.setBorder(new javax.swing.border.EtchedBorder());
this.getContentPane().add(pnl_Canvas, BorderLayout.CENTER);


btn_amarillo.setIcon(new javax.swing.ImageIcon(
"Auto/Texturas/AMARILLO.JPG"));
btn_amarillo.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
btn_amarilloMouseReleased(evt);
}
});

buttonPanel.add(btn_amarillo);

btn_negro.setIcon(new javax.swing.ImageIcon("Auto/Texturas/NEGRO.JPG"));
btn_negro.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
btn_negroMouseReleased(evt);
}
});

buttonPanel.add(btn_negro);


btn_verde.setIcon(new javax.swing.ImageIcon("Auto/Texturas/VERDE.JPG"));
btn_verde.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
btn_verdeMouseReleased(evt);
}
});

buttonPanel.add(btn_verde);


btn_azul.setIcon(new javax.swing.ImageIcon("Auto/Texturas/AZUL.JPG"));
btn_azul.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
btn_azulMouseReleased(evt);
}
});

buttonPanel.add(btn_azul);

btn_rojo.setIcon(new javax.swing.ImageIcon("Auto/Texturas/ROJO.JPG"));
btn_rojo.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
btn_rojoMouseReleased(evt);
}
});

buttonPanel.add(btn_rojo);


btn_tomate
.setIcon(new javax.swing.ImageIcon("Auto/Texturas/TOMATE.JPG"));
btn_tomate.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
btn_tomateMouseReleased(evt);
}
});

buttonPanel.add(btn_tomate);

this.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
this.setSize(600, 600);
}

private void btn_verdeMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_verdeMouseReleased
// Add your handling code here:
render.texturaActual = colores[2];
render.cambiarTextura("Base");
canvasRender.requestFocus();
}

private void btn_negroMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_negroMouseReleased
// Add your handling code here:
render.texturaActual = colores[3];
render.cambiarTextura("Base");
canvasRender.requestFocus();
}

private void btn_tomateMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_tomateMouseReleased
// Add your handling code here:
render.texturaActual = colores[4];
render.cambiarTextura("Base");
canvasRender.requestFocus();
}

private void btn_amarilloMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_amarilloMouseReleased
// Add your handling code here:
render.texturaActual = colores[5];
render.cambiarTextura("Base");
canvasRender.requestFocus();
}

private void btn_grisMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_grisMouseReleased
// Add your handling code here:
render.texturaActual = colores[6];
render.cambiarTextura("Base");
canvasRender.requestFocus();
}

private void btn_blancoMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_blancoMouseReleased
// Add your handling code here:
render.texturaActual = colores[7];
render.cambiarTextura("Base");
canvasRender.requestFocus();
}

private void btn_azulMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_azulMouseReleased

render.texturaActual = colores[1];
render.cambiarTextura("Base");
canvasRender.requestFocus();
}

private void btn_rojoMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btn_rojoMouseReleased

render.texturaActual = colores[0];
render.cambiarTextura("Base");
canvasRender.requestFocus();
}

/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
render.salir = true;
render.stop();
render = null;
System.exit(0);
}

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new CarDemo().show();
}


private javax.swing.JButton btn_blanco;
private javax.swing.JButton btn_gris;
private javax.swing.JPanel pnl_Canvas;
private javax.swing.JButton btn_amarillo;
private javax.swing.JButton btn_negro;
private javax.swing.JButton btn_verde;
private javax.swing.JButton btn_azul;
private javax.swing.JButton btn_rojo;
private javax.swing.JButton btn_tomate;


}


can you give me a example
thanks a lot 

Pages: [1]