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

Pages: [1]
1
Support / Relationship between Object3D & texture
« on: October 13, 2004, 03:10:58 pm »
Hi Egon,

I'm writing a rapport about my simulator and I'm writing the chapter about jPCT structure... in your notes you draw, using a solid line, that an Object3D has to have a texture.... but, I've used objs in my applet in which I've applied just simple material without textures, so I'm not pretty sure to understand this necessary relation.....

Bye and thanks

2
Support / Loading textures problem in a web server context
« on: September 08, 2004, 12:35:27 pm »
Hi Egon,

I've to move my jPCT applet in a web server (EasyPHP) context; in my current version I load my textures giving to it a path in my local drive:

Code: [Select]

File dir_texture=new File("C:/Programmi/Java_SDK/bin/textures");        String[] files_texture=dir_texture.list();
       for (int i=0; i<files_texture.length; i++) {
           
            String name_texture=files_texture[i];          
            if (name_texture.endsWith(".jpg")) {          
                texMan.addTexture(name_texture, new Texture(getDocumentBase(),"textures/"+name_texture));             }
         
       }


Running the applet with the web server the Java Console obviously says:

Code: [Select]

java.security.AccessControlException: access denied (java.io.FilePermission textures read)

at java.security.AccessControlContext.checkPermission(AccessControlContext.java:270)

at java.security.AccessController.checkPermission(AccessController.java:401)

at java.lang.SecurityManager.checkPermission(SecurityManager.java:542)

at java.lang.SecurityManager.checkRead(SecurityManager.java:887)

at java.io.File.list(File.java:912)

at ThreeDSimApplet.init(ThreeDSimApplet.java:336)

at sun.applet.AppletPanel.run(AppletPanel.java:348)

at java.lang.Thread.run(Thread.java:536)



exist a way to load the textures in this new context considering that I've to load them automatically, I mean, loading them using a loop as in the current version?

Bye and thanks

3
Support / 3D Objects & IDs
« on: June 28, 2004, 11:17:50 am »
Hi Egon,

I'm here again... I'd ask you in which way, if it's possible, I can express a 3D Object using is ID instead of is name; i.e.:

something like Object3D(ID).animate instead of animateMe.animate

It's possible to force a 3D Object to get a specific id (I've just find out a method to set the id of the next obj)?

Bye and thanks

4
Support / Animation
« on: June 16, 2004, 06:03:19 pm »
Another task: Animation. I have to start an object animation when something happens. First consideration, even if I problably I already know the answer: is it possible to import a keyframed animation created in Maya/3D Studio into jPCT? If, as I suppose, the answer is no let try to see if I have understood that way to create animations in jPCT: I load a 3ds file in which Iíve created variuos poses of my obj to animate (every pose corresponds to a keyframe); I load this file as usual, i.e.:
Code: [Select]

Object3D[] animArray=Loader.load3DS(getDocumentBase(),"3ds/ferito_anim.3ds", 20f);

every element of the array animArray is one of my poses (I guess), so after defining and instanciating an animation:
Code: [Select]

Animation anim;  
anim=new Animation(n);

where  n is the number of keyframes (poses) that I want to use. What is pretty cloudy to me is the way to use mesh (that Iíve to pass to the method addKeyFrame), in your documentation you say:
ďMesh can't be instantiated directlyĒ, so in which way can I use them? After adding all my keyframes to the animation, it simply starts when I start the applet? In which you use the interpolation attributes?

Thanks a thousand of times

5
Support / Displaying Objs Problem
« on: June 16, 2004, 01:46:08 pm »
Hi Egon,

as you know Iím using a config file where an operator can decide how many objs to load and where to place them;  for instance:
Code: [Select]

ferito1=(-591,-74,-90)
ferito2=(-766,-82,246)

my init() is:
Code: [Select]

public void init() {

      theWorld=new World();
 
       String param = getParameter("FileToRead");
       
       if ( param != null){
      FileToRead = new String(param);
       }
       
       // Now read the file.
       readConfigFile();
.
.
.

theWorld.addObject(mondo);
theWorld.addObject(ferito);


where readConfigFile() is method that scans the config file; when it find out a line having the word ďferitoĒ, it passes to a method loadFerito that name (completed with 1 or 2) and his coordinate:
Code: [Select]


public void loadFerito(String name, float x, float y, float z){
     
      texMan=TextureManager.getInstance();
      texMan.addTexture(name+".jpg",new      Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
      Object3D[] feritoArray=Loader.load3DS(getDocumentBase(),"3ds/"+name+".3ds", 20f);
      ferito=new Object3D(0);
      ferito=feritoArray[0];
      ferito.setCenter(SimpleVector.ORIGIN);
      ferito.translate (x, y+50, z);
      ferito.rotateX((float)-Math.PI/2);
      ferito.rotateMesh();
      ferito.setRotationMatrix(new Matrix());
     
      ferito.createTriangleStrips(2);
      ferito.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
      ferito.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
     
      ferito.enableLazyTransformations();      
     

  }



Even if the two 3ds object are correctly loaded:

Code: [Select]

Loading Texture...textures/feriti/ferito1.jpg
Loading file 3ds/ferito1.3ds
File 3ds/ferito1.3ds loaded...55321 bytes
Processing new material 1.Mat0Tex1!
Processing object from 3DS-file: polySur
Object 'polySur_jPCT0' created using 694 polygons and 354 vertices.
Created 183 triangle-strips for polySur_jPCT0 in 1 pass(es)
Loading Texture...textures/feriti/ferito2.jpg
Loading file 3ds/ferito2.3ds
File 3ds/ferito2.3ds loaded...54631 bytes
Processing new material 1.Mat0Tex1!
Processing object from 3DS-file: polySur
Object 'polySur_jPCT4' created using 706 polygons and 360 vertices.
Created 178 triangle-strips for polySur_jPCT4 in 1 pass(es)


Itís displayed just the one in the last line of the config file. I guess this behavior is dued by the fact that
Code: [Select]
theWorld.addObject(ferito) is outside loadFerito() and so it passes just the last value of ferito to init(). So Iíve tried to move
Code: [Select]
theWorld.addObject(ferito) in the last line of the loadFerito method (and even
Code: [Select]
theWorld=new World() to avoid a null exception) to try to add an obj to the world for every feritoís occurance, but nothing changes... Any suggestion.....Bye and thanks  :)

6
Support / Camera position object3D position mismatching
« on: June 14, 2004, 05:51:01 pm »
Hi Egon,

Iíve to implement the following capability: I need to place some objects in the world using custom coordinate. So, for decide where place objects Iíve to move myself in the world (by the camera) and, where I decide to place an object, pressing the right click, my applet has to pass the cameraís coordinate to a html page. Iíve created this feature in this way:

Code: [Select]

if (event.getButton()==MouseEvent.BUTTON3) {
    cameraPosition=camera.getPosition();
    cameraX=(int)cameraPosition.x;
    cameraY=(int)cameraPosition.y;
    cameraZ=(int)cameraPosition.z;
                 clicked=true;
                 rightClick=true;
}


then Iíve created a function that creates and places the object using the cameraís coordinates:

Code: [Select]

public void loadFerito(String name, float x, float y, float z){
     
      texMan=TextureManager.getInstance();
      texMan.addTexture(name+".jpg",new  Texture(getDocumentBase(),"textures/feriti/"+name+".jpg"));
      Object3D[] ferito1Array=Loader.load3DS(getDocumentBase(),"3ds/"+name+".3ds", 20f);
      ferito1=new Object3D(0);
      ferito1=ferito1Array[0];
      ferito1.setCenter(SimpleVector.ORIGIN);
      ferito1.translate (x, y+109, z);
      ferito1.rotateX((float)-Math.PI/2);
      ferito1.rotateMesh();
      ferito1.setRotationMatrix(new Matrix());
     
      ferito1.createTriangleStrips(2);
      ferito1.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
      ferito1.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
     
      ferito1.enableLazyTransformations();
     

  }


My problem is that the object in placed in a different position compared to the camera position where Iíve taken the cameraís coordinates. I guess the resulting cameraís coordinates donít match the object coordinates method. Exist a way to make a matching?

Bye and thanks

7
Support / A texture errorÖ
« on: June 11, 2004, 04:40:48 pm »
Hi Egon,

another question/problemÖ.. Iím loading textures in a generic way as follow:

Code: [Select]

File dir=new File("C:/Programmi/Java_SDK/bin/textures");    
       String[] files=dir.list();

        for (int i=0; i<files.length; i++) {
         String name=files[i];
         if (name.endsWith(".jpg")) {
            texMan.addTexture(name, new Texture(getDocumentBase(),"textures/"+name));
         }
       }


in init() method. In my previous version Iíve loaded some objs separately from my world in init() method too, as follow:
Code: [Select]

      Object3D[] ferito1Array=Loader.load3DS(getDocumentBase(),"3ds/ferito1.3ds", 20f);
      ferito1=new Object3D(0);
      ferito1=ferito1Array[0];
      ferito1.setCenter(SimpleVector.ORIGIN);
      ferito1.rotateX((float)-Math.PI/2);
      ferito1.rotateMesh();
      ferito1.setRotationMatrix(new Matrix());
     
      ferito1.createTriangleStrips(2);
      ferito1.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);
      ferito1.setCollisionOptimization(Object3D.COLLISION_DETECTION_OPTIMIZED);
     
      ferito1.enableLazyTransformations();


Now, Iím using a config file where I can decide to load or not the above obj, so Iíve decide to move the above code in another method, defined  by myself named loadFerito(). The problem is that when I perform this, the Sun Java Console says:

Code: [Select]
ERROR: A texture with the name 'ferito1.jpg' has been declared twice!

where ferito1.jpg is the texture associated with ferito1.3ds and the obj in the applet is obviously white.
If I move back the loading/defition obj code into the init() method everything works fine. Any explanation ? Bye and thanks

8
Support / Loading generic texture in an Applet
« on: June 08, 2004, 11:32:42 am »
Hi Egon,

as you know Iím loading texture in this way:

Code: [Select]
texMan.addTexture("car1.jpg",new Texture(getDocumentBase(),"textures/car1.jpg"));

in my applet context. Considering that Iím using now a certificate, so I can access to the local filesystem, Iíd like to load texture in a generic way using a for cycle (as you do in fps) :

Code: [Select]

File dir=new File("textures");
       String[] files=dir.list();
        for (int i=0; i<files.length; i++) {
         String name=files[i];
         if (name.endsWith(".jpg")) {
            texMan.addTexture(name, new Texture("textures"+File.separator+name));
         }
       }


but, when I run the applet the Java console says:

Code: [Select]

java.lang.NullPointerException
at ThreeDSimApplet.init(ThreeDSimApplet.java:238)
at sun.applet.AppletPanel.run(AppletPanel.java:348)
at java.lang.Thread.run(Thread.java:536)


thereís another way to load texture in a generic way in my context? Bye and thanks

9
Support / Loading texture problem while using certificate
« on: June 04, 2004, 05:20:48 pm »
Hi Egon,

Iíve to improve my applet defining a config file where someone can decide what world or another object to load without handling javaís codeÖ Iíve created a config file and Iíve added this code to my applet:
Code: [Select]

    String line;
    String worldValue;
    String tempFile;
    char checkStart;
    File f = null;
    BufferedReader br = null;
   
   
    public void init() {

   
       tempFile="ThreeDSim.cfg";
       f = new File(tempFile);
       
       try{
       
           br = new BufferedReader(new FileReader(f));
           
       }catch(FileNotFoundException fnfe){
        System.out.println("File not found...");        
        fnfe.printStackTrace();
       
        }
       
       try {
           while ((line = br.readLine()) != null) {

         if (line.length()>0) {
           checkStart = line.charAt(0);
   
                  if (checkStart != '*') {
                 
             if (line.startsWith("world")) {
               worldValue=line.substring(6);
                   }
                   
               }
     
           }

    }
   
       } catch (IOException e) {
    e.printStackTrace();
         }

.
.
.


Obviously, when I open my html page the applet doesnít load because Iím trying to access a file in an applet context. So, Iíve defined a certificate to let the applet to access the fileÖ. using the certificate I can now access the file and reading informations without problemsÖ. But, the problem now is that no texture is visible in my applet (as you know, Iím loading texture one by one in this way:
Code: [Select]
texMan.addTexture("car1.jpg",new Texture(getDocumentBase(),"textures/car1.jpg"));). If is remove the certificate, textures become visible.... but I canít access the fileÖ. Thereís an explanation for this behaviour?

Bye and thanks

10
Support / A javascript listening problem
« on: May 20, 2004, 12:08:11 pm »
Hi, I hope this is my last problemÖ.. After Iíve got the obj ID, I need to pass this value to a javascript that displays this value in the other side of my web page. So Iíve written the following code:
Code: [Select]


<html>
<head>
<title>ThreeDSim</title>
</head>
<body bgcolor="#000000" text="#FFFFFF" topmargin=0 rightmargin=0 leftmargin=0 marginheight=0 marginwidth=0>
<table>
<tr>
<td>&</td></tr>
<tr>
<td valign="middle" align="left">
<font size="5" face="arial">Road Accident Area</font><br>
<applet name="ThreeDSim"  code="ThreeDSimApplet" width="640" height="480"></applet>
<br>
</td></tr>
<tr>
<td>
 <script type="text/javascript">
    <!--
    var temp = document.applets[0].feritoID;
    document.writeln(temp);
   // -->
  </script>
</td>
</tr>
</table>
</body>
</html>


and it worksÖ. The problem is that the javascript obviously reads the feritoID value just when itís loaded instead I need that the javascript reads this value whenever I make a click on the applet and so, this value changes. Exist a way to perform this task?

Bye and thanks

11
Support / Interact2D behaviour
« on: May 19, 2004, 02:54:11 pm »
Hi, Iím here again to waste your timeÖ but Iíve another question. Iíve implemented the selection objects function, as Iíve wrote in some previous thread, and Iíve place, as you said,  the following code:

Code: [Select]

SimpleVector ray=Interact2D.reproject2D3D(camera, buffer, mouseX, mouseY);
                     int[] res=Interact2D.pickPolygon(theWorld.getVisibilityList(), ray);

                     if (res!=null) {
                         Object3D pickedObjs=theWorld.getObject(Interact2D.getObjectID(res));
                     }
                     
                     feritoID = Interact2D.getObjectID(res);
                     
                     System.out.println("ID: "+feritoID);


after:

Code: [Select]

 theWorld.renderScene(buffer);


When I run my applet and look in Java Console, I see that it repeats many times the string ID: 120 when I click in the applet on a non-selectable objs (I guess this code is a default code for non-selectable objs) or the string ID: with the selectable obj code. Why it repeats many times this string instead that just one time?
Second question: I need that this string appears on the java console just when I make a click on a obj; Iíve experimented that if I place the mouseís arrow on the applet window and I use the keyboard keys to move in my scene, when the arrow passes on a selectable obj (without pressing a mouseís button) appears the string ID: in the java console. Is it possible to prevent this behaviour making string appears just when I press a mouse button?

Bye and thanks a lot
 :)

12
Support / Using mouse in jPCT applet version
« on: May 14, 2004, 12:02:03 pm »
Hi,

Iím experimenting on using mouse in my jPCT applet following, as trace, your way to map keys in your Bounce applet example; so Iíve initialized a variable:

private boolean click=false;

Iíve definited the following method:

public boolean mouseClick(Event e, int key) {
        ProcessKey(key,true);
        return (true);
 }

in ProcessKey Iíve added the following ďcaseĒ:

case (MouseEvent.MOUSE_CLICKED):     {wire=event; break;}


where Ďwireí is the the wireframe mode, here just as example. At last, Iíve added the following Ďifí in the timer():

if (wire) {
                         wireframe=!wireframe;
                }

but, running the applet, nothing happens (using the 1 key, for example, the wireframe mode works, so the problem is just on the mouse event).
Iíve to add a mouse listenerÖ.. or something else?

Bye and thanks
 :)

13
Support / Selectable objects
« on: May 12, 2004, 05:08:42 pm »
Hi,

Iíd want to have three selectable objs in my jpctís scene applet and I need, when I do a mouseís click on one of these, that some text appears, for example showing his id, on the applet area.
Iíve read the Selection Mode thread where youíve posted the following code:

SimpleVector ray=Interact2D.reproject2D3D(camera, buffer, mouseX, mouseY);
int[] res=Interact2D.pickPolygon(theWorld.getVisibilityList(), ray);

if (res!=null) {
   Object3D pickedObj=theWorld.getObject(Interact2D.getObjectID(res));
}


Iíve made my objs selectable using the following code:

ferito1.setSelectable(ferito1.MOUSE_SELECTABLE); (where ferito1 is an Object3D).

First question: mouseX, mouseY should contain the x,y value of the mouse on the applet area; I guess Iíve to get these values, isnít so? If itís so, using which method?

Second question: pickedObj contains the obj that Iíve selected by a mouseís click? If itís so, using the method, getID(), I get this objís id?


Bye and thanks  :)

14
Support / Switching renderer in an applet context
« on: May 10, 2004, 04:36:53 pm »
Hi,

Is possible to use the fpsís switching renderer option in a applet context? If itís so, in which way I can fit the dos command line:

java -Djava.library.path=..\..\lib\lwjgl-0.8\ -cp ..\..\lib\lwjgl-0.8\lwjgl.jar;fps.jar -Xmx100000000 JPCTDemo

into the ďhtml codeĒ that loads the applet?

Bye and thanks for any answers
 :)

15
Support / Problem importing 3ds files into applet
« on: April 29, 2004, 12:02:17 pm »
Hi all,

I'm using jPCT to create an University 3d simulation for medical porpouse; I've created a world using Maya and I've converted the Maya's file into a 3DS file using FBX Converter.
When I load the 3DS file using an stand-alone application, such as FPS, the file is loaded without any problem; Problems occur when I try to load the 3DS scene in a applet, such as Bounce; in fact the Sun Java Console shows the following message:

[ Thu Apr 29 11:20:24 CEST 2004 ] - ERROR: Couldn't read file 3ds\prova.3ds
[ Thu Apr 29 11:20:24 CEST 2004 ] - ERROR: Not a valid 3DS file!
Created 0 triangle-strips for object2 in 1 pass(es)
[ Thu Apr 29 11:20:24 CEST 2004 ] - ERROR: Couldn't build() object! Check if the object is assigned to a world and if the TextureManager has all required textures loaded.

Do you have any explaination about this behaviour? Is it possible that 3DS files don't fit in a web application? If it's so, what other file format should I try? Thanks for any help  :)

Pages: [1]