How to make a perspective matrix work

I'm trying to get my head around some 3D graphics, but ran into trouble.
I have a number of points that make up a cube. Very simple.
I use an orthographic projection matrix to display it.
But when I try to apply a perspective projection matrix it looks like anything but a cube. I've tried multiple ways to get it to work but it still doesn't.
You can download the source code here: http://www.bastardindustries.com/temp/example.zip
It is written in ActionScript 3.0. But the code is very basic and straight forward so I don't think it's will be a problem even if you are not familiar with ActionScript.
By commenting an uncommenting the following lines (in 3DGraphics.as) you can switch between the orthographic projection and perspective projection matrix. As you can see when just using the orthographic projection matrix it works fine. But with the perspective it doesn't.
// Ortographic and perspective
// mP = mPers.multiplyMatrix(mOrto);
// Just ortographic
mP = mOrto;
Any help on why my perspective matrix isn't working is appreciated.
The perspective matrix looks like this. In a column major order:
n is the near plane and f the far plane.
mA[0] = n;
mA[5] = n;
mA[10] = n+f;
mA[11] = 1;
mA[14] = -(f*n);
mA[15] = 0;
Thanks!
this thread was writting in another website since it was left unanswered
/ Magnus

you can save object to a file using an ObjectOutputStream
I hope, the code below makes things clear...
     Object anObject = new Object();
     Object aPanel = new Panel();
     Button saveButton = addButton("Save",aPanel);
     private Button addButton(String naam, Panel tPanel)
          Button tButton = new Button(naam);
          tButton.addActionListener(this);
          tPanel.add(tButton);
          return tButton;
     public void actionPerformed(ActionEvent e){
          if (e.getSource().equals(saveButton))
               saveObjectToFile();
     public void saveObjectToFile(){
          try
               FileOutputStream fStream = new FileOutputStream("file.dat");
               ObjectOutputStream oStream = new ObjectOutputStream(fStream);
               oStream.writeObject(anObject);
               oStream.close();
          catch (NotSerializableException e)
               System.out.println(e.getMessage());
          catch (IOException e)
               System.out.println(e.getMessage());
     }I hope this helps you out...
Goodluck
Leon van der Ree

Similar Messages

  • How to make a Button to work Actively even if there is a mandatory field..?

    Hi All..
    How to make a Button to work Actively even if there is a mandatory field to be fulfilled..???
    I am badly in need of this logic, as i have to incorporate in my code..
    Points will be rewarded without fail..

    Hi Pavan,
    I also faced the same requirement. U can do one thing like remove the obligatory keyword of that parameter/select-option. U can handle the same using the program in at selection-screen event. See this sample of code,
    SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-001.
    SELECT-OPTIONS:  s_land1 for T005-LAND1 <b>[Needs to be mandatory]</b>                 no intervals no-extension.
    SELECT-OPTIONS:  s_panid FOR zoindex_val-zopanid.
    SELECT-OPTIONS:  s_effdat FOR zoexchrate-zedate.
    SELECTION-SCREEN END OF BLOCK b2.
    *-- AT SELECTION-SCREEN
    AT SELECTION-SCREEN.
      CASE sscrfields-ucomm.
    *-- Obligatory Country Code
      IF s_land1[] IS INITIAL.
        MESSAGE e050 WITH text-050.
                     "Please select the Country Code
      ENDIF.
    So whenever u do F8/Enter other than that push button, it will prompt u to enter the country code first then only u can proceed.
    Hope this would help u in some way. Please do reward the helpful answers.

  • How to make third party cables work on iphone?

    I have been using the original Apple charger cable that came with my phone (iPhone 5C) for a good year, but then it broke. So I bought this non-Apple cable because I didn't really wanna spend a lot of money for an original one. I have already charged my phone with third-party cables before, so I thought it would work. The first time I used the non-Apple cord, there were minor difficulties because I had to plug and un-plug it several times before it actually charged. 2 days later, I plugged an original cable (which was my sister's) to charge my iPhone. Obviously, it worked. But later on, when I went to charge my iPhone with the non-Apple cable, a message popped up (This accessory may not be supported). I dismissed it, thinking it would still charge. No such luck. I tried to unplug and plug it, but still, it won't charge. Now, I have to charge through my laptop. Can anyone tell me how to make third-party cables work? I don't really wanna bring my laptop everytime I charge. I'm planning to only use this cable until I get my hands on an original one. Please help.

    Are you seeing the EE (or T-Mobile) network name and network bars in the top right hand corner of the screen?  Turn off WiFi (Settings>WiFi - turn this off).  Is there anything next to the network name in the top right hand corner (3G, E or o)?  E is Edge and o = GPRS.
    If there's nothing next to the network name, turn off the iPhone and then turn it back on.  To do this, press and hold down the button on the top until you see the 'Slide to Power Off' message.  Slide and then wait for the iPhone to shut down.  To turn it back on again, press and hold the top button again unti lkthe Apple logo shows on the screen.
    EE and signal bars top left = Yes
    Turned off Wifi and next to the EE is 'o' which you say is GPRS? What does that mean please??
    Got this reply from another forum but still no success???

  • How to make material availability check work during Work Order creation

    Hi Experts,
    Kindly advice about these matters:
    1. How to make material availability check work during Work Order creation?
    My requirement is Work Order can not be created when it has missing parts. I have set the config to '3' can not created when is has missing parts, but it still does not work.
    I have implemented SAP Notes 1148139 on my system (SAP ECC 6 Ehp 5) also, but still does not have any effect.
    I must not set the config Res./Purch Doc creation to 'immediately', because it does not fit to my user requirement. Is there anyone knows how to solve this requirement?
    2. How to make information message/ Availability check screen appear when sparepart is missing, without clicking Availability Check button? for example: appear when clicking Save button.
    Thank you
    -amoonra-

    Hi Maheswaran,
    I have implement the prerequisite notes. (Notes 790219 and 1034962). Do you know why it is still does not work?
    Thanks
    -amoonra-

  • How to make the mobile application work with firewall and anti-virus ON

    Hi,
    I keep on receiving internal processing error when i try to login sap mobile solution 1.3.0 on my ipad and i was provided a solution, that is to turn off my firewall and antivirus. I works by turn off both of it but i cant possible turn of the firewall and antivirus on the server.
    Can anyone guide me how to make the mobile application work with firewall and anti-virus ON
    Thank you

    Dear Rajesh,
    Create a policy in your fire wall to allow the port to send and receive data.
    I believe the port for the mobile should be port 8080 and 8443.
    And your license server port 30000 and 30001
    nd.Q

  • How to make the Smooth Scrolling work even H Swipe is tick?

    In my article, if I tick the H Swipe only and the Smooth Scrolling is Both direction, Why is it in previewing it in my iPad the Scrolling seems Off because it's snapping into the pages.
    Smooth scrolling is not working if H Swipe only is tick.
    How to make the Smooth Scrolling work even H Swipe is tick?

    Horizontal scrolling is only for 1024x768 or 768x1024 pages. That’s it.
    You cannot combine horizontal only with smooth scrolling.
    Bob

  • How to make "visa find resource" working with Agilent device

    I am trying to use Agilent 82357B GPIB device with LabVIEW for instrument control.
    I have checked:
    1.       NI-VISA (ver 5.1.1) is the primary visa by checking visa.dll properties under windows\system32 folder
    2.       Enable NIVISATulip.dll in NI Max Explorer
    3.       Enable the Agilent libraries to work with NI 488.2 in Agilent IO library (ver 16).
    I am able to communicate with the instrument in Max Explorer and talk to the instrument in LabVIEW with VISA write for almost all commands.
    But I can NOT make one particular visa function (Visa find resource) working with Agilent 82357B GPIB.
    With NI USB GPIB device, the same code above can find attached instruments as below, where GPIB1 is the Agilent device and GPIB0 is the NI device.
    I have no clue on how to make “visa find resource” working with Agilent device.
    Please help.
    Solved!
    Go to Solution.

    Quick question.  Did you also enable 488 support in Agilent? 
    If that does'not work try this.  and well see if you found a bug
    Jeff

  • How to make Adobe Media Player work online?

    Hello,
    I have Adobe Media Player. When I launched before, I was able to see the content. Nowadays, it showing just blank screen saying "You must be online to view this content" Although JavaScripts already enabled on my safari web browser and my personal firewall is On.
    p.s firewall was always On When I was able to see adobe media player content!
    I would like to know if anyone tell me how to make it online?
    Thank you.

    The flash add-on is not available for Safari on iOS. Never has been and in fact Adobe has ceased support for flash for mobile devices in general. Your options, depending on the specific sites:
    See if the site or sites in question have their own apps availabel in teh app store
    Look into some browsers such as Puffin adn iSwifter (there are others, I beleive). These browsers use a third server site to translate the flsh content into a form that the iPAd can use and restreams them to you. They may not work with all content.
    Use a computer capable of running flash.
    Seek a source of the conent that is designed for non flash use.

  • How to make a perspective fixed???

    hi,
    i am trying to make my perspective fixed using the setfixed="true" method in Eclipse but its not working for me.i m using eclipse 3.1 version. is their any other method of making a perspective fixed.plz reply soon.

    Not sure why you decided to ask this question in a Sun forum, much less in a "Java Event Handling" forum. This seems to be some issue regarding layout in SWT, which is the toolkit eclipse uses. Your chances of getting an answer will improve if you post this in an SWT forum. I know there is one on javaranch.

  • Eclipse - how to make a perspective fixed???

    hi,
    i am trying to make my perspective fixed using the setfixed="true" method in Eclipse but its not working for me.i m using eclipse 3.1 version. is their any other method of making a perspective fixed.plz reply soon.

    Not sure why you decided to ask this question in a Sun forum, much less in a "Java Event Handling" forum. This seems to be some issue regarding layout in SWT, which is the toolkit eclipse uses. Your chances of getting an answer will improve if you post this in an SWT forum. I know there is one on javaranch.

  • Why can't Apple and HP get Mountain Lion 10.8.4 to work with the HP OfficeJet 7610?  Does anyone know how to make the wireless scanning work?

    Does anyone know how to make the HP OfficeJet 7610 (latest version) and iMac 3.4 GHz i7 running 10.8.4 work together correctly?  Print function seems to work ok.  Just can't find the scanner in any setup.

    In System Preferences/Print & Scan is there a scan option?

  • How to make the default param work?

    Hi experts,
    When I define a default value for a parameter in a procedure or function, such as (p in     varchar2 default null), and when I call it without providing the parameter value, I am getting the "PLS-00306: wrong number or types of arguments in call to procname" error. How is the default supposed to work?
    Thank you.
    Ben

    Here is what I have,
    create or replace procedure CJIINGetBookingList (     
         p_LastName          in     varchar2,
         p_FirstName          in     varchar2,
         p_MiddleName          in     varchar2,     
         p_DOB               in     varchar2 default null,
         p_OLN               in     varchar2 default null,     --- DLN
         p_AddressCity          in     varchar2 default null,
         p_AddressZip          in     varchar2 default null,
         p_InCustody          in     varchar2 default null,
         p_Race               in     varchar2 default null,
         p_Gender          in     varchar2 default null,
         p_JailDateStart          in     varchar2 default null,
         p_JailDateEnd          in     varchar2 default null,
         p_ReleaseDateStart     in     varchar2 default null,
         p_ReleaseDateEnd     in     varchar2 default null,
         p_BkSearchResults     out     sys_refcursor
    Thanks.
    Ben

  • How to make the knowledgebase search work?

    This is not a FF problem; it is a problem with making the database search work properly. Example: trying to find the question "How do I install Addons for all users?" <http://support.mozilla.com/en-US/questions/745665>, I searched on "all users" with various combinations of "Add-ons" or "Addons" - coming up with many irrelevant hits (apparently not even corresponding to the search terms), but never with the page wanted. In fact, searching on the '''exact''' wording of the question "How do I install Addons for all users?" - with or without quotation marks - does not return the right page!! How is the search supposed to work?

    @the-edmeister:
    Ed, thanks for your reply, but in fact it is a reply to a different question - in fact, the question which, as I said, I was ''originally'' searching ("How do I install Addons for all users?"). That leaves two things to do:
    1) Since 50 users have already requested an answer to that question <http://support.mozilla.com/en-US/questions/745665>, would you please post your answer there? If you don't want to do that, may I do so? [It would be better if you do it, as you clearly know a lot more about the issue (and might be able to answer follow-up questions, of which I have at least one already).]
    2) We still need an answer to either:
    a) what is wrong with the KB search here or
    b) what is wrong with my search procedure?
    Thanks,
    John

  • An Idea: How to make the Magic Timeline work with Tracks

    i have thought about this for a title and i think i have found a solution. the magic timeline is pretty cool but with it we lost tracks. for broadcast (not only for that but mostly for it) you need tracks that are assignt in a special way and there is no way around it. so i came up with the following idea…
    to make the magic timeline work with tracks it will be a like an audio compound clip, that will give you full access to the magic time. but it can be outputted to proper tracks assignment.
    current audio compound clips don't show you the video if there is one. this one will. also audio can be tagged to a track so it will automatically drop into the right track. you can of course move the audio from one track to another. moving the clip to another track will auto change the tag to new track. if you copy an audio clip from one track to another, the original clip will keep its tag but the copied one gets the new tag.
    example…
    you do a voice over with all your edits and stuff. then you collapse it to a track (new name to get rid of any sort of confusion). you can tag/name the track to "voice over" or whatever you want and color label it.
    you need to edit, adjust it? no problem! double click it and it will open up and you'll see the magic timeline. edit till you done and click on arrow to return to track view.
    export your movie with proper tracks for broadcast right out of final cut pro x
    in the end your output timeline looks like a timeline from fcp7 before you output it on tape.
    could this work? i believe it could and it would help to make fcpx ready for broadcast.
    i hope this makes some sort of sense to you
    anyway, i hope apple will include this or something like this in an update for fcpx.

    You may be able to get by with just running MDT 2010 for now. *However* you *must* ensure that you are running WinPE 3.1 or greater, If you are unsure, open up a command prompt in WinPE (PRess F8), and run "ver" it should say build 7601 or greater, 7600
    and less is not compatible.
    When done, Run the Dell Advanced Format tool in the Full OS on a deployed machine to verify:  http://del.ly/afhdd  Although it is possible to install an OS on an Advanced Format Drive
    with WInPE 3.0 or earlier, and it may *appear* to work, performance may suffer. The Dell AF tool should tell you if the sectors are aligned properly.
    Additionally, it is also possible that the storage driver you have installed in your image is incompatible with AF drives. Check the Make/Model and check with the Hardware Mfg to see if they have driver that supports AF drives.
    Keith Garner - keithga.wordpress.com

  • How to make the bt hub work with GreenBee?

    I have some old BT hub (hub 2,3,4) can I make any of them work with another ISP like greenbee I heard changing the user name and password works? But I don't know what to change them to

    There are some options on this web page.
    Wireless connection problems
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

Maybe you are looking for

  • Downloading soap message attachement

    Hi experts, In my scenario, ABAP Proxy is sending an attachement. I could see that attachement in MONI, now i need to download that attachement to an ftp server. Can someone help me what are the various parameters i need to configure in FILE receiver

  • All SSIDs are not broadcasting...

    I have a  serious issue with my Cisco 4404 WLC. In from WLC, only some SSIDs are broadcasting the others are not broadcasting.... If I make a new WLAN and select it as broadcasting, but its not broadcasting correctly. I cannot see this in my device.

  • How do I display call out accessories with different images?

    I need some help with an app I'm developing.  I'm displaying a map with an array of annotations. I have managed to display the map & annotations successfully. What I want to do next is have call out accessories that display different images everytime

  • [HELP]How to make .swc file if there are several C++ classes imported?

    When I run the project in flash Builder, it'll be a error report: Undefined sym: __ZN3MapC1Eii     at Function/<anonymous>()     at Function/<anonymous>()     at findingPath::Map2D/createMap()[F:\astestfield\AStarPathing2\src\findingPath\Map2D.as:17]

  • I can't event photos from my iphone 4s

    I have a photo event stored on my phone with pictures from an old pone that I don't want anymore. I can't delete them directly from the phone, however they've also been deleted off my computer (macbook pro) so I can't go under photos when my iphone i