JAVA3D rotation problem

I'm using JAVA3D that creates a map. The map is split into 4 parts. I forced each part to rotate only around the X-axis and this is done with the user clicking on it with the mouse. I want to limit the rotation where the user can rotate up to 90 degrees only downwards, and want to eliminate the option of rotation upwards. Is that possible.
Another question is that when the user rotates one of the parts, the part comes out towards the user. Is it possible i can stop that and make it rotate on itself?
Thanks in advance

well my dear friend sorry to disappoint you but i did understand and that's the way rotX/Y/Z work within the Transform3D.
the behavior you desire by the rotation is based on a cylindric coordinate system in which the point of view will move on the cylinder while the upVector of the lookAt method stay at the Y axis(Y axis is "up" in Java3D).
since the Transform3d is based on spherical coordinate system you can't use it.
the only way i know is to write an object as the Transform3d but much simpler, well lets see:
class Transform extends Transform3D {
   Point3d position=new Point3d();
   Point3d lookingAt=new Point3d(1,0,0); // looking at the x axis
   Vector3d upVector=new Vector3d(0,1,0); // y is up
   double totalAngleXZ=0; // its a must to add the angle and to calculate it from the top since it creates a bug later on
   double totalAngleY=0; // its a must to add the angle and to calculate it from the top since it creates a bug later on
   public void rotXZ(double angle) {
      totalAngleXZ+= angle;
      lookAt();
   public void rotY(double angle) {
      totalAngleY+= angle;
      lookAt();
   private void lookAt() {
        lookingAt.set(Math.cos(totalAngleXZ),Math.cos(totalAngleY),Math.sin(totalAngleXZ));
        lookAt(position,lookingAt,upVector);
}now if i'm not mistaken this should work...
best of luck.

Similar Messages

  • Rotation problem after editing in Photoshop

    I'm using Lightroom 1.3 and Photoshop CS3 with all the current updates. This problem was the same in LR1 and PS CS2.
    I have a mix of orientations in the JPEGs in my library - portrait and landscape. When the photos are imported into LR they appear correct. If I select a bunch of them, open them in PS (using Edit in Photoshop > Edit Originals), run a noise filter, save them, and then go back to LR, the previews for the portrait images are rotated so that all the previews show as landscape.
    The portrait images display correctly (except for the fact that they have been rotated) in the Library module - both grid and loupe view). In the Develop module, the image aspect is displayed portrait but the image is as a distorted landscape - the image is rotated and then distorted to fill the portrait oriented space. In the Print module, that same distorted image is fills the portrait oriented page. To be clear, instead of a portrait image appearing in the correct orientation on a portrait page preview, the image is rotated 90 degrees and then stretched to fill the page.
    There is a badge on the preview indicating that the metadata is out of sync with the file.
    If I rotate the image in LR, the badge goes away and the image appears portrait and undistorted in the Library module's grid and loupe views. The Develop module show the portrait image in the correct rotation, but has been stretched to a landscape aspect. The Print module shows that distorted image rotated to fit the portrait page.
    The only way to correct this is to "Read Metadata from file". This resets all the orientation information so that it displays correctly in LR, but all the tags and IPTC information gets erased.
    This is most of the reason why I was writing all the metadata into to files until now. I would write the metadata before editing in PS, do my PS edits, and then back in LR I'd "Read the Metadata" from the files to set everything correctly in LR. But of course now that I'm working with Leopard I get screwed if I do this because my files will crash the Finder.
    To top it all off, I've run into the "...cannot be saved because the file is in use" problem with some files I opened last night.
    Clearly none of these issues are being addressed in Adobe or Apple's updates. Is there a reasonable workaround that will let me:
    1. set metadata and tags and know that they won't either get lost or cause problems
    2. have image orientation respected and displayed correctly
    3. not crash any of the three critical applications on this computer - Lightroom, Photoshop, and Finder.

    I really appreciate your explaining this Jao.
    I'm going to explain how I got into this situation, in the hopes that it may prove useful to someone (I'm looking at you, Adobe) who wants to understand how the app is being used in the real world.
    So as not to break up the narrative, let me just say that I'd be happy (ecstatic, actually) if I could use Lightroom for my entire workflow, but the noise reduction filter in LR is just nowhere near as good as NoiseNinja. (A problem shared by LR, PS, and Aperture.) If I could run NN from inside LR, that would rock.
    Oh, and I shoot JPEG because I shoot live events where the lighting is usually crap and I need to be ready at any moment for something interesting to happen. Shooting RAW would be nice, but it's too slow and takes up way too much space.
    So here's what I do, (hopefully edited to make the reading non-tedious)
    1. import all photos from source (usually memory cards)
    The photos go onto a drive reserved for photos. I shoot events, so everything is organised by date-event. On import I set filenames (date - event name - time stamp.jpg) and keywords.
    2. cull
    They get marked "1" (irretrievably useless, to be deleted), "2" (keep just in case), "3" (decent shots), "4" (photos that I want to show to other people), or "5" (this is one of my best this year). Delete the "1"s.
    3. select 20-30 "picks"
    I create a folder within the event folder called "Picks" for these photos. Then I duplicate that folder as "Originals"
    In doing it this way I can protect myself if I need/want to change my cataloguing application. I'm on my fourth one at this point (Lightroom) and while I am generally finding that LR is meeting my needs more than anything else I've tried, I've been burned in the past (how many of us have regretted letting Aperture put all our photos into an incomprehensible database/folder hell?)
    The Picks/Originals structure makes sure that the originals never get touched (because it doesn't show up in LR) and I can quickly find the Picks.
    I -was- writing the metadata to the files so the ratings, keywords, and IPTC info was where it should be - attached to the photo. I've stopped doing this for the time being until this whole Finder-craching debacle is corrected.
    So why am I not using LR's built "Edit - Copy"/stacking function, which more or less duplicates my process?
    Well part of it was my own dumbness - Aperture made the edited copy/variation a Photoshop file, which ballooned my collections with staggering speed. I'm not sure if LR used to do the same thing, or I just made the assumption. My mistake.
    The other part of the problem is just the simplicity of having an Originals folder that is effectively ignored. Using LR will mix the "-edited" files in with originals, which is not as efficient or elegant a solution, but I'll give it a whirl.
    Thanks for your suggestion. If giving up my Picks/Original process solves the rotation problem then perhaps it's a fair trade.
    Still, it seems that the right hand is somehow oblivious to what the left hand is doing in the whole PS/LR thing, and that it ought not work that way.

  • IPad Rotation Problem

    After just 1 week bought the iPad.. i'm facing the rotation problem.. the Apple technicians said its hdware problem and send back to Apple Service Centre... Feel very very sad with this situation... wasting my time and probably my money...

    1. Check the little black rotation lock on the edge of iPad.
    2. Try a reset. Hold the Sleep and Home button down for about 10 seconds until you see the Apple logo.
    http://i1224.photobucket.com/albums/ee374/Diavonex/9ecbcd49.jpg

  • Iphone 6 rotating problem

    My ipone6 has rotating problems with for example the calendar app, somtimes it's working but most of time I can't rotate the screen.
    When is this going to be solved, as I many people are complaining about this?

    Try to reset the phone by holding the sleep and home button for about 10sec, until the Apple logo comes back again. You will not lose any data by resetting, but it can cure some glitches.
    If this does not help, setting it up as new device would be the next step:
    How to erase your iOS device and then set it up as a new device or restore it from backups
    Or, if you want to use your computer and iTunes instead:
    Use iTunes to restore your iOS device to factory settings - Apple Support
    If setting it up as new device does not bring back the full functionality of your brightness settings, get the phone checked by visiting an Authorized Apple Service Provider, Apple Store or contact Apple Support to have it serviced:
    iPhone - Contact Support - Apple Support

  • New log rotation problem

    I have resolved some log rotation problem...I have set del log rtation by size...and now the first time the log rotate,but then the output continue to go on the lod with the extension .log001 and not on the configured file.
    why?

    no,it the server rotates the log only the first time but then it continues to write on the .log001.On the original file it continues to write some server exception.
    the server launch line in the scritp is the follow
    nohup "$JAVA_HOME/bin/java" ${JAVA_VM} ${JAVA_OPTIONS_NODE} ${JAVA_OPTIONS} \
    Dweblogic.Name=${SERVER_NAME} \
    Dweblogic.ProductionModeEnabled=${PRODUCTION_MODE} \
    Djava.security.policy="${WL_HOME}/server/lib/weblogic.policy" \
    Dweblogic.Stdout=/u02/bea/weblogic81/mydomain/mydomain_LOG/myserver_Admin.log \
    Dweblogic.Stderr=/u02/bea/weblogic81/mydomain/mydomain_LOG/myserver_Admin.log \
    weblogic.Server > /dev/null &
    and the config.xml part for the server configuration is the follow
    <Server COMEnabled="true" CompleteMessageTimeout="0"
    ConsoleInputEnabled="false" EnabledForDomainLog="true"
    ExpectedToRun="false" JDBCLogFileName="./mydomain_LOG/jdbc.log"
    JDBCLoggingEnabled="true" JavaCompiler="javac"
    ListenAddress="10.2.1.16" ListenPort="10001"
    MaxMessageSize="100000000" Name="myserver_Admin"
    ServerVersion="8.1.3.0" SocketReaderTimeoutMaxMillis="10"
    StagingMode="nostage" StdoutDebugEnabled="true"
    StdoutEnabled="true" StdoutSeverityLevel="16" TransactionLogFilePrefix="../myserver_LOG/myserverAdminTransaction.log">
    <SSL Enabled="false" IdentityAndTrustLocations="KeyStores"
    ListenPort="10002" Name="myserver_Admin"/>
    <Log FileCount="4" FileMinSize="30"
    FileName="/u02/bea/weblogic81/mydomain/mydomain_LOG/myserver_Admin.log"
    FileTimeSpan="1" Name="myserver_Admin"
    NumberOfFilesLimited="true" RotationType="bySize"/>
    <WebServer LogFileCount="2" LogFileLimitEnabled="true"
    LogFileName="./mydomain_LOG/access.log"
    LogRotationPeriodMins="360" LogRotationType="size"
    MaxLogFileSizeKBytes="20000" Name="myserver_Admin"/>

  • Rotation Problem on FCP

    Friends,
    When I rotate a video on FCP (does not matter the degrees, 20, 45, 90...), using the motion tab, my rendered images gets sort kind of distortion... When I preview it on FCP, it rotates ok, but when I export using the Compressor, when the video rotates, it squeezes, it does not look right...
    Please, could someone help me?
    Thanks

    Yes - the button is in rotation lock mode (not mute).
    Neither switch setting (up or down) work. The state of the button is accurately reflected on the screen when changed, but the problem of not rotating problem when unlocked persists.
    Given that this started just after updating to iOS 7.0.6 I'm inclined to think there is a software issue.

  • Animation / Rotation Problem

    Hello!
    I have a vrml -file imported in java3d. This still works. I also can pick
    the different objects.
    Now I will rotate one object, called "Flagge"
    The Problem is, that this object get minimized and doesn't rotate.
    It moves from up to down. Where is my problem?
    Thanks a lot!
    private class PickObjectsListener implements MouseListener {
              public void mouseClicked(MouseEvent arg0) {
                   pickC.setShapeLocation(arg0);
                   PickResult pickResult = pickC.pickClosest();
                   if (pickResult != null) {
                        //System.out.println("Closest PickResult: " + pickResult);
                        Node actualNode;
                        actualNode = pickResult.getObject();
                        if (actualNode.getUserData() != null) {
                             String name = (String) actualNode.getUserData();
                             Hashtable namedObjects = s.getNamedObjects();
                             System.out.println("Object " + name);
                             if (name.equals("Fahnenmast")) {
                                  System.out.println("Fahnenmast");
                                  a.flagge((TransformGroup)namedObjects.get("Flagge"),getGehisst());
                                  Transform3D xAxis=new Transform3D();
                                      xAxis.rotZ(Math.PI*0.5d); //90�drehen,Animation nur in x_Achse
                                  Alpha upRamp = new Alpha( );
                                  upRamp.setIncreasingAlphaDuration( 10000 );
                                  upRamp.setLoopCount( -1 );  // loop forever
                                  PositionInterpolator position = new PositionInterpolator(upRamp, (TransformGroup)namedObjects.get("leuchtturm"), xAxis, 0.0f, 1000.0f);
                                  position.setSchedulingBounds(new BoundingSphere());
                                  BranchGroup test = new BranchGroup();
                                  test.addChild(position);
                                  s.getSceneGroup().addChild(test);*/
                                  Alpha upRamp = new Alpha( );
                                  upRamp.setIncreasingAlphaDuration( 10000 );
                                  upRamp.setLoopCount( -1 ); // loop forever
                                  RotationInterpolator mySpinner = new RotationInterpolator( upRamp, (TransformGroup)namedObjects.get("Flagge"));
                                  mySpinner.setAxisOfRotation( new Transform3D());
                                  mySpinner.setMinimumAngle( 0.0f );
                                  mySpinner.setMaximumAngle( (float)(Math.PI * 2.0) );
                                  mySpinner.setSchedulingBounds(bounds);
                                  //Transform3D t3d = objAnsicht.getTransform();
                                  // objAnsicht.addChild(mySpinner); Fehler: only a branchGroup node may be added
                                  BranchGroup test = new BranchGroup();
                                  TransformGroup transFormtest = new TransformGroup();
                                  Transform3D tScale = new Transform3D();
                                    tScale.setTranslation(new Vector3d(verschiebungXachse,verschiebungYachse,0));
                                    transFormtest.setTransform(tScale);
                                    transFormtest.addChild(mySpinner);
                                  test.addChild(transFormtest);
                                  s.getSceneGroup().addChild(test);
              }

    Here is what I`ve done:
    Pointer + Red Circle is a movieclip called Watch
    inside Watch is the situation exemplified on the image above.
    As you can see the anchor (I mean the white ball being pointed to) is in the center from the circle. If i rotate the the watch pointer on flash editin mode, it does turn around it. But when testing my video, which increments the rotation property of the watch pointer, it is turning around a center located somewhere  up in the left side.
    I really have no idea to why this is happening.
    Thanks again,

  • Local rotation problem

    I am programming a spaceship moving around in Java3D.
    My problem is that I want the ship to be able to rotate around its z-axis(roll) and along its x-axis(nose up or down), when I am doing this however only one of the axis will follow the ships local coordinates.
    The scene looks like this.
    BG - TG1 - TG2 - Model
    TG2 is the z-axis rotation, and that works fine since it will rotate when T1, the x-axis rotation rotates. T1 however will be fixed to the world and not be affected by TG2s rotation...
    How do I make both rotations move along the axis of the local coordinates of the ship, instead of the world axis (BG axis).

    That does not matter, one rotation will cone first and that will mess up the other one. It seems like the first rotation is always locked to the world coordinate axis.
    This is my behavior code (after combining both transform groups into one):
    class FighterRotate extends Behavior
         double angleX;
         double angleZ;
         TransformGroup targetTG;
         Transform3D rotationX;
         Transform3D rotationZ;
         KeyEvent evt;
         WakeupOnAWTEvent awaken;
         FighterRotate(TransformGroup TG)
              angleX = 0;
              angleZ = 0;
              targetTG = TG;
              rotationX = new Transform3D();
              rotationZ = new Transform3D();
              awaken = new WakeupOnAWTEvent(KeyEvent.KEY_PRESSED);
         public void initialize()
              this.wakeupOn(awaken);
         public void processStimulus(Enumeration criteria)
              evt = (KeyEvent)awaken.getAWTEvent()[0];
              if (evt.getKeyCode() == KeyEvent.VK_UP)
                   angleX += 0.1;
              if (evt.getKeyCode() == KeyEvent.VK_DOWN)
                   angleX -= 0.1;
              if (evt.getKeyCode() == KeyEvent.VK_RIGHT)
                   angleZ += 0.1;
              if (evt.getKeyCode() == KeyEvent.VK_LEFT)
                   angleZ -= 0.1;
                   rotationX.rotX(angleX);
                   rotationZ.rotZ(angleZ);
                   rotationX.mul(rotationZ);
                   targetTG.setTransform(rotationX);
              this.wakeupOn(awaken);
    How can I change this to make my model move as it should?

  • JFrames and Java3D simple problem

    Hi ive created a program using jframes in Java and im wanting to move it over to java 3d but im having problems. Ive litterally just looked at java 3d so my knowledge is limited. All i want is to set up my canvas so that i have a Jframe panel on the right and a 3d ball on the left. Here's my failed attempt......
    import com.sun.j3d.utils.geometry.*;
    import com.sun.j3d.utils.universe.*;
    import com.sun.j3d.utils.image.*;//imports image functions
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import javax.swing.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.awt.*;
    public class Prog extends JFrame
        private Canvas3D canvas;
        private SimpleUniverse universe = new SimpleUniverse();  // Create the universe      
        private BranchGroup group = new BranchGroup(); // Create a structure to contain objects
        private Bounds bounds;
        public Prog()
            super("Program");
            GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
            canvas = new Canvas3D(config);
            //getContentPane().setLayout( new BorderLayout( ) );
            //getContentPane().add(canvas, "Center");
            Container c = getContentPane();
            setSize(600,400);
            c.setLayout(new BorderLayout( ));
            JPanel leftPanel = new JPanel( );
            leftPanel.setBackground(Color.BLACK);
            c.add(leftPanel, BorderLayout.CENTER);
            c.setLayout(new BorderLayout( ));
            JPanel rightPanel = new JPanel( );
            rightPanel.setBackground(Color.GRAY);
            c.add(rightPanel, BorderLayout.EAST);
            JButton goButton = new JButton("  Go  ");
            goButton.setBackground(Color.RED);
            rightPanel.add(goButton);
         Light();//Creates A Light Source
           // Create a ball and add it to the group of objects
           Sphere sphere = new Sphere(0.5f);
           group.addChild(sphere);
           // look towards the ball
           universe.getViewingPlatform().setNominalViewingTransform();
           // add the group of objects to the Universe
           universe.addBranchGraph(group);
        public void Light()
            // Create a white light that shines for 100m from the origin
            Color3f light1Color = new Color3f(1.8f, 1.8f, 1.8f);
           BoundingSphere bounds = new BoundingSphere(new Point3d(0.0,0.0,0.0), 100.0);
            Vector3f light1Direction = new Vector3f(4.0f, -7.0f, -12.0f);
           DirectionalLight light1 = new DirectionalLight(light1Color, light1Direction);
            light1.setInfluencingBounds(bounds);
           group.addChild(light1);
        public static void main(String[] args)
           Prog frame = new Prog();
         frame.setVisible(true);
    }It Compiles but the 3d ball and the Jframe gui are in different windows but i want them in the same window but i duno how ?

    Hi tesla66 I'm sorry if I didn't correct your code, but drop some new code trying to solve the problem. I've used the cube instead the sphere because it's easier to see is rotating but just change "new ColorCube(0.4f)" with " new Sphere( 0.4f )". I wrote even some coments tought they're helpful. Tell me if I solved the problem
    import java.awt.*;
    import javax.swing.*;
    import javax.media.j3d.*;
    import javax.vecmath.*;
    import com.sun.j3d.utils.universe.SimpleUniverse;
    import com.sun.j3d.utils.geometry.*;
    public class JFrameAndCanvas3D extends JFrame
         private Canvas3D canvas3D;
         public static void main(String[] args)
            new JFrameAndCanvas3D();
         public JFrameAndCanvas3D()
              initialize();
        public BranchGroup createSceneGraph()
            BranchGroup objRoot = new BranchGroup(); //root
            // Creates a bounds for lights and interpolator
            BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0);
            //Ambient light
            Color3f ambientColour = new Color3f(0.2f, 0.2f, 0.2f);
            AmbientLight ambientLight = new AmbientLight(ambientColour);
            ambientLight.setInfluencingBounds(bounds);
            objRoot.addChild(ambientLight);
            ///Creates a group for transforms
            TransformGroup objMove = new TransformGroup();
            //You must set the capability bit to allow to write transform on the object
            objMove.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
            //Adds a color cube
            objMove.addChild(new ColorCube(0.4));
            //Creates a timer
            Alpha rotationAlpha = new Alpha(-1, //-1 = infinite loop
                                            4000 // rotation time in ms
            //creates a transform 3D based on Y axis roation
            Transform3D t3d = new Transform3D();
            t3d.rotY(Math.PI/2);
            //Creates an rotation interpolator with an alpha and a TransformGroup
            RotationInterpolator rotator = new RotationInterpolator(rotationAlpha, objMove);
            rotator.setTransformAxis(t3d);//setta l'asse di rotazione
            //sets a bounding region. withouth this scheduling bounds the interpolator won't work
            rotator.setSchedulingBounds(bounds);
            //add the interpolator to the group
            objMove.addChild(rotator);
            //Adding the group to the root
            objRoot.addChild(objMove);
            objRoot.compile();//improve the performance
            return objRoot;
        public void initialize()
            setSize(800, 600);
            setLayout(new BorderLayout());
            GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();//default config
            canvas3D = new Canvas3D(config);
            canvas3D.setSize(400, 600);
            add(canvas3D, BorderLayout.WEST); //adding the canvas to the west side of the JFrame
            SimpleUniverse simpleU = new SimpleUniverse( canvas3D );
            JPanel controlPanel = new JPanel();
            controlPanel.setLayout(new BorderLayout());
            controlPanel.setSize(400, 600);
            JLabel label = new JLabel();
            label.setText("I'm the control Panel");
            controlPanel.add(label, BorderLayout.CENTER);
            add(controlPanel, BorderLayout.EAST);
            //Positioning the view
            TransformGroup viewingPlatformGroup = simpleU.getViewingPlatform().getViewPlatformTransform();
            Transform3D t3d = new Transform3D();
            t3d.setTranslation(new Vector3f(0, 0, 3)); //moving back from the cube--> +z
            viewingPlatformGroup.setTransform(t3d);
            canvas3D.getView().setBackClipDistance(300.0d); //sets the visible distance
            canvas3D.getView().setFrontClipDistance(0.1d);
            canvas3D.getView().setMinimumFrameCycleTime(20); //minimum time refresh
            canvas3D.getView().setTransparencySortingPolicy(View.TRANSPARENCY_SORT_GEOMETRY); //rendering order
            BranchGroup scene = createSceneGraph();
            simpleU.addBranchGraph(scene);
            setVisible(true);
    }-->Davil

  • Image Orientation/Rotation Problem in Lightroom 3.2 Final

    This is a continuation of my previous post regarding this same problem in 3.2RC. It's still happening in the Final version of Lightroom 3.2.
    THE PROBLEM
    Image orientation is not working properly in Lightroom 3.2. This affects newly imported images and images that were already in my Lightroom database -  and which have been in the database since Version 1.
    Here's a screen capture showing the strange displays I'm seeing in  Lightroom's grid mode:
    Notice the odd angle of the image. When I use the Rotate Photo Left tool, the display looks like this sometimes. After a second or so, it will snap to either a vertical or horizontal orientation by itself but rarely gives me the 90-degree rotation this tool should give. The image may flip 90-degrees or 180-degrees, there's no way to tell.
    When I view the image in Loupe view or on my second monitor, the orientation shown in Grid view does not match that displayed in Loupe Vew. For this particular image, Grid view currently shows it as correctly orientated as a horizontal while Loupe view shows it rotated 90-degrees to the right. Shouldn't they match?
    BACKGROUND
    I never had a problem with image orientation in any preveious version of Lightroom prior to Lightroom 3.2RC and 3.2 Final. So, it seems to be a bug in 3.2. I'm still using the same computer and video card I used with previous versions. My operating system is Windows 7 Home Premium. Both Windows and Lightroom are 64-bit.
    HELP!
    Is anyone else having this problem? How can I solve it?
    Alan
    PhtooCitizen.com

    The size of the catalogue is almost certainly not at play here.
    FWIW, I recall seeing something like this once a long time ago on a Mac, possibly with Lr 3 beta, or Lr 2.x.  It went away with a restart. It almost looks like a threading issue, where a thread is suspended or preempted and then is lost or disconnected from the main UI thread.
    I recall you can just rotate the image again and it will right itself.
    Adobe fist-line support seem to want to use the number of images in the catalogue as some sort of catch-all.  The problem with this is that most of us can demonstrate that there is little correspondence with the number of image IDs in the database and many reported UI artefacts.
    I'd keep raising this with them, and suggesting that the size of the catalogue is probably not at play here. As a tactic, you can ask what the maximum size of a catalogue should be, and if it is raw images or the number of changes to the images and virtual copies that is the problem, and if this can be verified by second- or third-line support.

  • Character rotation problem in tiled map

    Hi I am trying to rotate the character in a tiled map. Its is successful but theres problem with moving diagonally. When i pressed for example up and right keypressed, when its moving it will rotate as i wanted but when i released the buttons, it either rotate to the up or right. I want the image to rotate diagonally and stay as it is when i released the buttons.
    Here are my source code...I noe its very long but really need someone help...There are 3 java files. (Sorry for dis long and ridiculous codes...)
    1) Game.java
    import javax.swing.*;
    import java.awt.*;
    import java.awt.image.BufferStrategy;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    public class Game extends Canvas implements KeyListener
         private BufferStrategy strategy;
         private GameMap map=new GameMap();
         private Player player;
         private boolean left,right,up,down;
         Image ship = Toolkit.getDefaultToolkit().getImage("res/up1.PNG");
         public Game()
              Frame frame = new Frame("Pirate Game");
              frame.setLayout(null);
              setBounds(0,30,480,510);
              frame.add(this);
              frame.setSize(480,510);
              frame.setResizable(false);
              // exit the game
              frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              frame.addKeyListener(this);
              addKeyListener(this);
              frame.setVisible(true);
              createBufferStrategy(2);
              strategy = getBufferStrategy();
              player = new Player(ship, map, 1.5f, 1.5f);
              // start the game loop
              gameLoop();
    public void gameLoop()
              boolean gameRunning = true;
              long last = System.nanoTime();     
              // keep looking while the game is running
              while (gameRunning)
                   Graphics2D g = (Graphics2D) strategy.getDrawGraphics();
                   // clear the screen
                   g.setColor(Color.black);
                   g.fillRect(0,0,480,480);
                   // render our game objects
                   g.translate(0,0); //placing the map to desired location on the frame
                  map.paint(g);
                   player.paint(g);
                   // flip the buffer so we can see the rendering
                   g.dispose();
                   strategy.show();
                   // pause a bit so that we don't choke the system
                   try { Thread.sleep(4); } catch (Exception e) {};
                   long delta = (System.nanoTime() - last) / 1000000;
                   last = System.nanoTime();
                   for (int i=0;i<delta / 5;i++)
                        logic(5);
                   if ((delta % 5) != 0)
                        logic(delta % 5);
         public void logic(long delta) {
              // check the keyboard and record which way the player
              // is trying to move this loop
              float dx = 0;
              float dy = 0;
              if (left)
                   dx -= 1;
              if (right)
                   dx += 1;
              if (up)
                   dy -= 1;
              if (down)
                   dy += 1;
              // if the player needs to move attempt to move the entity
              // based on the keys multiplied by the amount of time thats
              // passed
              if ((dx != 0) | (dy != 0))
                   player.move(dx * delta * 0.0015f,dy * delta * 0.0015f);
         public void keyTyped(KeyEvent e) {}
         public void keyPressed(KeyEvent e)
              if (e.getKeyCode() == KeyEvent.VK_LEFT)
                   left = true;
              if (e.getKeyCode() == KeyEvent.VK_RIGHT)
                   right = true;
              if (e.getKeyCode() == KeyEvent.VK_DOWN)
                   down = true;
              if (e.getKeyCode() == KeyEvent.VK_UP)
                   up = true;
         public void keyReleased(KeyEvent e)
              if (e.getKeyCode() == KeyEvent.VK_LEFT)
                   left = false;
              if (e.getKeyCode() == KeyEvent.VK_RIGHT)
                   right = false;
              if (e.getKeyCode() == KeyEvent.VK_DOWN)
                   down = false;
              if (e.getKeyCode() == KeyEvent.VK_UP)
                   up = false;
         public static void main(String args[])
          new Game();
    2) GameMap.java
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class GameMap
         int width = 15;
        int height =15;
        static final int TILE_SIZE = 32;
             int[][]  A  =  {{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,3,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,2,2,2,2,2,2,2,2,2,2,2,2,2,1},
                                 {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1},
        Image sea = Toolkit.getDefaultToolkit().getImage("res/sea.PNG");
        Image rock = Toolkit.getDefaultToolkit().getImage("res/rock.PNG");
         public void paint(Graphics g)
            for(int across = 0; across < width ; across++)
                for(int vert = 0; vert < height ; vert++)
                    if (A[across][vert] == 1)
                    g.drawImage(rock,across*TILE_SIZE,vert*TILE_SIZE,null);
                         else
                         g.drawImage(sea,across*TILE_SIZE,vert*TILE_SIZE,null);
        public boolean blocked(float x, float y)
              return A[(int) x][(int) y] == 1;
    3) Player.java
    import java.awt.Graphics2D;
    import java.awt.Image;
    public class Player {
         private float x;
         private float y;
         private Image image;
         private GameMap map;
         private float ang;
         private float size=0.3f;
         public Player(Image image, GameMap map, float x, float y)
              this.image = image;
              this.map = map;
              this.x = x;
              this.y = y;
         public boolean move(float dx, float dy)
              // new position
              float nx = x + dx;
              float ny = y + dy;
              //check collision
              if (validLocation(nx, ny)) {
                   x = nx;
                   y = ny;
                   // and calculate the angle we're facing based on our last move
                   ang = (float) (Math.atan2(dy, dx) + (Math.PI / 2));
                   return true;
              // if it wasn't a valid move don't do anything apart from tell the caller
              return false;
         public boolean validLocation(float nx, float ny)
              if (map.blocked(nx - size, ny - size))
                   return false;
              if (map.blocked(nx + size, ny - size))
                   return false;
              if (map.blocked(nx - size, ny + size))
                   return false;
              if (map.blocked(nx + size, ny + size))
                   return false;
              return true;
         public void paint(Graphics2D g) {
              int xp = (int) (map.TILE_SIZE * x);
              int yp = (int) (map.TILE_SIZE * y);
              // rotate the sprite based on the current angle and then
              // draw it
              g.rotate(ang, xp, yp);
              g.drawImage(image, (int) (xp - 16), (int) (yp - 16), null);
              g.rotate(-ang, xp, yp);
    }

    rotate() should always be accompanied with appropriate translate().
    See:
    http://java.sun.com/docs/books/tutorial/2d/TOC.html
    http://www.adtmag.com/java/articleold.aspx?id=1241
    http://www.apl.jhu.edu/~hall/java/Java2D-Tutorial.html
    And, never mix AWT components with Swing ones.
    Use JPanel instead of Canvas.
    Use also standard drawing/painting technique shown above URSs.

  • After Effects Puppet Tool "Warping Upon Rotation"problem

    Hi Everyone,
    I am having a big issue with my newly puppeted after-effects character. I have rigged up a character I made originally in illustrator. I placed puppet pins, expressed to null objects I use as controllers, then parented to each other. I have done this many times before, with no problem. However, this time, when I rotated the "Parent" Null, the child nulls follow as usual, but in this case, the object is warped through the rotation (attached pictures below). I have been using the "Puppettools 3" Plug-in, and when the bug showed up using that, I tried using this expression (upon the pins themselves):
    A=thisComp.layer("NULL_OBJECT");
    fromWorld(A.toWorld(A.anchorPoint));
    which accomplishes the same thing, just through a longer, manual process. In both cases, the object warps. Before expressing to nulls, the rotation works fine. Anyone know why it would be behaving like this? Perhaps there is something I overlooked in the process? Not sure. Any help appreciated. Thanks
    First image: starting point.
    Second image: rotation only on the "Parent" null and pin. no other pins moved, it simply warps to that form without my action.

    Hi Rick,
    Thank you for this detailed and exemplified response, everything you are saying makes sense, and the examples seem to be exactly what I am dealing with. I tested out this troubleshooting option, but unfortunately, my mesh is still not working. I tried different values of triangles - 200, 350, 370, 600, 900, and even 1500 (the max), and it still warps. My best number was 1024, but that also seems ridiculously high. Could it be because my pin placements are not linear enough? Or there are too many in such a small area? My triangles don't seem to distribute as well as yours. Here are pictures of my mesh:

  • Image Rotation Problem in LR 3.2RC

    Anyone else having an issue with image rotation in Lightroom 3.2C?
    Here's what happens:
    I import images from my card. There are a combination of images taken horizontally and vertically. The vertical images come in sideways (horizontally). This is no big deal: maybe the cameras I was using in this case (Olympus E-PL1 and Panasonic GF1) don't properly mark the orientation.
    So, in Grid view,  I select one of the improperly orientated images and click the "Rotate Photo Left" arrow in the toolbar. Here's where it gets weird. Instead of rotating the image 90-degrees counter clockwise, the thumbnail rotates about 45-degrees, so now it's crooked in Grid view. However, on my second monitor, the image now looks properly orientated.
    I've tried rotating using the menu (Photo menu / Rotate Left) and got the same result. If I repeatedly rotate, it ends up in all sorts of odd positions in grid mode.
    What's up with this? Is it just me?
    Alan
    PhotoCitizen.com

    Restarted Lightroom and all looks good now. I'll be interested to see if the problem returns next time I import images.
    UPDATE: I spoke too soon. Closed LR3 and opened it again. No, the cockeyed thumbnails are not saved at their odd angles. But they still don't match the image shown on my 2nd monitor (or on my main monitor either if I go to Loupe View). The Grid view image might show the vertical image lying on its side (horizontal), even though the 2nd monitor shows it in the correct orientation.
    This happens with horizontal images too if I try to rotate them - something I tried just now but wouldn't normally need to do.
    Trying to rotate the thumbnail again results in the cockeyed thumbnail. If I then CLICK on that thumbnail, it straightens out, but never in the correct orientation. Here's a screen grab:
    Something seriously wrong here. Something that NEVER happend in Lightroom 3 until I installed version 3.2RC. So, I doubt that it's a video card problem - looks like a bug to me.
    Alan
    PhotoCitizen.com

  • Camera Rotation Problem

    Hello
    I have a problem with my camera rotation. I would like to have a button which allows me to rotate a camera in my scene using only x and y axe and with z axe blocked. My javascript is :
    var c = getAnnots3D(0)[0].context3D;
    var camera = c.scene.cameras.getByIndex(0);
    var camdir = camera.position.subtract(camera.targetPosition);
    camera.position.set(-Math.sin(3.14/6)*camdir.y+Math.cos(3.14/6)*camdir.x,Math.cos(3.14/6) *camdir.y+Math.sin(3.14/6)*camdir.x,camdir.z);
    Script works good for x and y axe , but unfortunatelly z axe moves too(kind of a wave, starts low goes up and ends down after Pi/2) . Even if I block it using a constant instead of camdir.z, it moves but javascripy debugger shows z value blocked.
    Any idea what I'm doing wrong ?
    Help appreciated
    Bartek

    Your math really doesn't make any sense to me.
    All those math.cos(..) calls are constant because you are only passing constants. i.e. Math.cos(3.14/6) will always be 0.866158094. So you are doing this:
    position.set(-.9y + .5x, .9x + .5y, z);
    I'm not really sure what this "button" is supposed to do. if you want it to prevent the camera from tilting up and down, you have to repeatedly prevent the camera from tilting using a TimerEventHandler.
    Also, you are taking the camera direction and using it to set it's position, this will keep moving the camera near the origin and will probably be unpredictable.
    So really, I'm not sure what you are trying to do. Let the camera rotate freely in only 2 of it's own axis? only 2 of the world axis? or orbit an object only on 2 axis? only let it move left and right, but prevent it from tilting up or down? ...
    I can help, but you need to be more specific.

  • Rotation problem...

    Hi, I have a problem with rotation, landscape mode. When I turn device more, it turns to portrait mode (upside down). Please fix this problem for me and for users who read when they lie
    thanks

    Thank you for the photos. I think I finally understand the problem.
    So you do not want Adobe Reader to support the Upside Down device orientation.
    Actually, there are four device orientation options that are available for iPhone and iPad respectively in Xcode.
    It is not wrong to support the Upside Down device orientation.  But most iPhone apps do not.  In contrast, most iPad apps do.
    Since we do not have any particular reason to support the Upside Down device orientation for iPhone, we can disable it so that Adobe Reader for iOS will behave like most other iPhone apps.
    The change will be included in a future release of Adobe Reader for iOS.   (Sorry, I am not able to speculate on the next release date.)
    Thank you for the feedback!

Maybe you are looking for