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

Pages: [1] 2
1
Support / Re: How to reset direction of object
« on: May 07, 2009, 11:29:42 am »
Incidentally , my ultimate goal is Making the world back to the initial state,Namely,back to the state object loaded.
now ,i have reseted the camera in  world.

2
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.

3
Support / Re: how to control object rotating ?
« on: May 07, 2009, 02:29:10 am »
thanks paul,
I mean that don't use the lwjgl ,becaus of my jar has more than 800kb,if i use the lwjgl i have to add the lib into my jar

4
Support / Re: how to control object rotating ?
« on: May 06, 2009, 04:22:40 am »
Thanks a lot.
Egon,
I use the lwjgl  implementing object rotation.
I need use applet,if i only use jpct (don'r use lwjgl ) ,Can I implement it?
or Can i implement the same effect?

5
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!

6
Support / Re: How can i get the texture which in an object
« on: April 28, 2009, 10:29:41 am »
Thanks a lot

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

8
Support / Re: How to get the texture of obj files
« on: April 08, 2009, 10:59:10 am »
Oh! I know .
I forgot the mtl files ,Thanks!

9
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.

10
Support / Re: About rotate object
« on: March 26, 2009, 09:50:16 am »
thank you ,paulscode。
I have solved this problem .

Originally ,I wanted to  achieve the  effect of rotating whole object (there are many objects in world  ) through  rotating  camera .but i can't .So i change my train of thought ,i use setparent()(Object3D class) for adding all object in a new object ,then i try to rotate the new object when i drag my mouse.



11
Support / Re: import 3ds file setColor
« on: March 26, 2009, 03:07:17 am »
 :D ,me too, try to  change the light

12
Support / Re: About rotate object
« on: March 25, 2009, 11:11:34 am »
thanks a lot.

13
Support / Re: About rotate object
« on: March 25, 2009, 10:53:22 am »
I don't use lwjgl ,my code is
Code: [Select]
package org.test;

import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;
import java.io.File;

import com.threed.jpct.*;

import javax.swing.*;

public class MouseEventDemo {
private World world;
private FrameBuffer buffer;
private JFrame frame;
private TextureManager texMan = null;
private static float distance = 70;

Canvas canvas;

public static void main(String[] args) throws Exception {
MouseEventDemo d=new MouseEventDemo();
d.loop();
}

public MouseEventDemo() throws Exception {
Config.fadeoutLight = true;
Config.maxPolysVisible = 1000000;

frame = new JFrame("MouseTest");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new BorderLayout());


world = new World();
world.setAmbientLight(211, 211, 211);
addTexture();
load3dFile();
world.getCamera().lookAt(new SimpleVector(0, 0, 0));
}

private void loop() throws Exception {
buffer = new FrameBuffer(600, 600, FrameBuffer.SAMPLINGMODE_NORMAL);

canvas = buffer.enableGLCanvasRenderer();
canvas.addMouseMotionListener(new MyMouseMotionListener(this));

frame.getContentPane().add(canvas,BorderLayout.CENTER);
frame.setSize(600, 620);
frame.setVisible(true);


while (frame.isShowing()) {
buffer.clear(java.awt.Color.LIGHT_GRAY);
world.renderScene(buffer);
world.draw(buffer);
buffer.update();
buffer.display(canvas.getGraphics());
Thread.sleep(10);
}
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
buffer.dispose();
frame.dispose();
System.exit(0);
}

public void addTexture() {
texMan = TextureManager.getInstance();
String pathTextura = "impreza/";
File dir = new File(pathTextura);
String texturas[] = dir.list();
for (int i = 0; i < texturas.length; i++) {
if (texturas[i].endsWith(".JPG"))
texMan.addTexture(texturas[i].toUpperCase(), new Texture(
pathTextura + texturas[i]));
}
}

public void load3dFile() {
Object3D[] cars = Loader.loadOBJ("impreza/impreza.obj",
"impreza/impreza.mtl", 2f);
for (Object3D part : cars) {

part.build();
world.getCamera().setPosition(5, 15, 10);
world.addObject(part);
}
}
public void mouse_dragged(MouseEvent e) {
float x= world.getCamera().getDirection().x;
float y= world.getCamera().getDirection().y;
  SimpleVector line=new SimpleVector(x, 0, y);
          Matrix m=line.normalize().getRotationMatrix();
          m.rotateAxis(m.getXAxis(), (float) -Math.PI/2f);
          world.getCamera().moveCamera(Camera.CAMERA_MOVEIN, distance);
          world.getCamera().rotateAxis(m.invert3x3().getXAxis(), line.length() / 200f);
          world.getCamera().moveCamera(Camera.CAMERA_MOVEOUT, distance);
}
}

class MyMouseMotionListener implements MouseMotionListener {
MouseEventDemo demo;
MyMouseMotionListener(MouseEventDemo demo) {
this.demo = demo;
}
public void mouseDragged(MouseEvent e) {
demo.mouse_dragged(e);
}
public void mouseMoved(MouseEvent e) {

}

}
how to rotate object? i.e how to rotate object by rotating camera?Do I have to use lwjgl?

14
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 .

15
Support / Re: How to add Mouse Listener
« on: March 25, 2009, 03:45:35 am »
the problem has been solved .
Thank you everyone
Code: [Select]
frame = new JFrame("MouseTest");
frame.setSize(600, 600);
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.addMouseWheelListener(new MyMouseWheelListener(this));

frame.addMouseListener(new MyMouseListener(this));
frame.addMouseMotionListener(new MyMouseMotionListener(this));

Pages: [1] 2