Depth buffering; getting the Z position of a point on a 3D triangle

Greetings.
I'm creating a 3D library (if that's what you call them) on my own, and this is all about:
Defining the triangles with three Vector3D instances.
Transforming them with the transform.matrix3D property of a Sprite instance.
Calculating and assigning the w property of each Vector3D instance and project().
Draw the triangles out with the Graphics instance, according to the x, y properties of the projected Vector3D instances.
There they go, and I'm trying to use the depth buffering (or z buffering) to my library. According to the information I read and as I comprehend (including Wikipedia, results from Google search), depth buffering can solve the problems of intersecting polygons and triangles. And the algorithm works like this:
For each polygon, calculate the Z position of each pixel it occupies after being rendered.
Compare the current Z position of the pixel with the already existing one in the depth buffer.If the one in the buffer is larger than the current one (that is, the current one being nearer to the viewer) then replace the pixel (color) of that in the depth buffer with the current pixel.
Draw the pixels out.
Please point out any mistake I made in the my-way-of understanding how the depth buffering works, thank you.
I'm now having problem about the "calculating the Z position" of each pixel.
As three points define a plane, I tried using this algorithm by Paul Brouke and then get the Z position with X and Y positions, along with a, b, c, and d parameters previously calculated with the three Vector3D instances that define a triangle, by this simple calculation:
z = (-ax-by-d) / c
But it did not work. Instead, the triangles were distorted.
Is there any other rather simple way to get depth buffering working? If yes, I appreciate usages of simple words to explain simple codes. If not, then... I hope you can help me in some way.
Thanks again.
greekfellows

click the getting started link:  http://www.adobe.com/devnet/flashplayer/articles/hello-triangle.html
you can skip the first part about flash builder if you're using flash cs6.
from there you can google:  flash stage3d
or if you want to get into the nitty-gritty:  http://www.adobe.com/devnet/flashplayer/articles/what-is-agal.html

Similar Messages

  • How to get the Useru2019s position when the user doesnu2019t have CP relation

    We have a custom program which will add / delete attributes (In transaction PPOSA_BBP). It is working fine for users which were assigned with CP relation But it fails for users which doesnu2019t have CP relation (since we are getting the position of users form HRP1001 then we are retrieving the existing attributes based on the position after that updating the attributes) as we are getting the position from HRP1001 it fails for users were no CP relation.
    Help us how to get the Useru2019s position when the user doesnu2019t have CP relation. Suggest us any function module or how to query the HRP1001 or some other table if exists
    Regards
    Paul

    Hi Paul,
    Have a look at these tables.
    Using table BUT000 the central business partner data are stored, f.e. partner type, partner names, partner number, partner guid, person number, etc. In table BUTBKK the bank data to a business partner are stored.
    Central business partner address data
    The table ADRC is used for the address of a business partner. Table BUT020 links the business partner number with the address number. Using table BUT021 several addresses to a business partner with different usages (modes), f.e. correspondence or delivery address, can be stored. The personal data of a business partner person are stored with key person number in table ADRP. The person number is assignd to a business partner person in table BUT000. Communication data of business partners as e-mail, telephone, fax, etc. are stored in the tables ADDR1 u2013 ADDR12. The business address of a contact person or an employee consists of the organization address (company resp. org.-unit) and of an address addition, which describes f.e. a building, a room number, etc. The address addition is stored in table ADCP and is identified by the keys address number of the organization address and person number.
    Relationships between business partners
    Table BUT050 contains the relationships between a business partner organization and a business partner person using relation types. The relation types are defined in table TBZ9, f.e. the relation type u2018has employeeu2019 corresponds to identifier u2018BUR010u2019, the relation type u2018has contact personu2019 corresponds to identifier u2018BUR001u2019. Table BUT051 stores communication data of a contact person relationship (compare to table ADCP). Table BUT052 stores several address numbers to one business partner relationship (including a standard flag).
    Hope this helps,
    Kind Regards,
    Matthew

  • How to get the cursor position in the text edit box?

    Hi, all.
    I want to get the cursor position in the text edit box
    to insert some data.
    But I don't know how to get.
    Can someone give me some advice?
    BestRegard.
    Miya.

    Hi Miya,
    Write your own textSelectionSuite for this.
    and use ITextTarget->GetRange() function.
    Thanks and Regards,
    Yopangjo.

  • How to get the baselinegrid position for a line?

    Hi All,
    How to get the baselinegrid position for a line in a paragraph?

    Hi,
    2nd line baseline grid for yourPara paragraph is:
    yourPara.lines[1].baseline;
    last line baseline is:
    yourPara.endBaseline;
    Jarek

  • Get the current position within the PBEL Prozess

    Hi,
    In the BPELConsole I can see the the flow of every PBEL process
    instance and thus I see the current position within the process.
    How would you get the current position programatically, via SOAP e.g.?
    Kind regards,
    Martin

    Hi,
    there is a JAVA API provided by Oracle
    http://download-uk.oracle.com/docs/cd/B31017_01/integrate.1013/b28986/toc.htm
    If you really need SOAP, you can build your own Java webservices with this API

  • How to get the caret position of component embedded in JTextPane?

    Hi great java developers ;-)
    I want to get the caret position of component which is embedded in StyledDocument / JTextPane.
    How has it to be done?
    Thank you very much!!!

    The Document doesn't know which textPane it belongs to. (It could even be shared by mulitple textPanes).
    You get the caret position of a any text component by using:
    textComponent.getCaretPosition();

  • How to get the frame position after being moved.

    I created a frame, after I moved it by my mouse, how can I get the new position?

    you could use getLocation() of a JFrame, maybe call it with a mouselistener or windowlistner.

  • Getting the text position (inside or outside a box?)

    Hi all,
    I'm using plain Ruby to access the content of an PDF file. This by using yob's PDF Reader from GitHub.
    Now I've come a long way, but still have one question remaining! How to get the position of a text object (the box of this object)?
    I've read the PDF reference, it tells me all sorts of stuff about Text Space, Glyph space and User Space... As English is not my native language it's a lot to take in... I currently do have a CTM, a Text Matrix and a Text Render Matrix. I also have all the boxes on the page (media, trim, crop etc.)
    For a Image object, I use the CTM e and f values as x and y. This works perfectly, but when it comes to text, I seem to miss something..
    Example:
    CTM: Matrix[
      [1, 0, 0],
      [0, -1, 0],
      [-0.0, 640.346, 1]
    Text matrix => Matrix[
      [10.0, 0.0, 0],
      [0.0, 10.0, 0],
      [2062769.1732, 42.6732, 1]
    ] == Needed to convert from text space to User/device space!
    Trm: Matrix[
       [1000.0, 0.0, 0.0],
       [0.0, -10.0, 0.0],
       [2062769.1732, 597.6728, 1.0]
    I can count lines, and calc a displacement by multipling this number by the Font size (12pt per example) but how do I get the the box of te text_object? If I've the box, I can make sure it fits in a box or not....
    Please help with anything I might be doing wrong, or even better if you can help me find the text position!

    So if I understand correctly:
    the CTM x and y are the starting point of my textbox (lower left corner)
    What does the text matrix do then?
    Example 2:
    CTM: Matrix[
    [1, 0, 0],
    [0, -1, 0],
    [-0.0, 640.346, 1]
    The last of each col (0,0,1) is ignored, I know :-)
    text matrix:
    Matrix text: Matrix[
    [24, 0, 0],
    [0, 24, 0],
    [50.7401, 572.1733, 1]
    So my x for the lower left here is 50.7401 and my y is 572.1733, right?
    And then we need to move the x position the number of char widths in a text, right?
    And when we move the cursor to the next line, we must use the text line matrix?

  • Get the mouse position

    If I have a frame and some panels on the frame, it seems I should not add the mouselisteners to the frame, but the panels. Now I can receive the mouse events. But when I try to get the mouse's position, they are the position's related to each panel. How can I get the positions associated with the frame?
    Thanks!

    public class MyFrame exyends JFrame implements MouseListener
    implement all the methods of Interface MouseListener
    e.g.
    public void mouseClicked (MouseEvent e)
    System.out.println("CLICKED AT " + e.getX() + "," + e,getY());

  • How to get the cursor position from screen in module pool program

    Hi,
    I am doing the module pool program, I have one table control in one screen.
    I have to give functionality to the user that when the user enters first record in the table control and after filling the last field
    when he presses enter the cursor will have to come in the starting field of the second record.
    I know the logic , but i m bit confused.
    Can any body help me to solve this....
    thanks

    Hi,
    Check this code,
    Write it in the PBO
    MODULE SET_CURSOR_WERTKONTRAKT.
    MODULE SET_CURSOR_WERTKONTRAKT OUTPUT.
      PERFORM SET_CURSOR USING 'VBAP-ZWERT'.
    ENDMODULE.                 " SET_CURSOR_WERTKONTRAKT  OUTPUT
    FORM SET_CURSOR USING US_FELDNAME.
      DATA: DA_TFILL LIKE SY-TFILL.
      DESCRIBE TABLE IVBAP LINES DA_TFILL.
    FCODE 'Create Position':
    ==> Cursor to the first free line set to make the new position
    Can be created directly
        IF DA_TFILL EQ 0.
          SET CURSOR FIELD US_FELDNAME LINE 1.   -> set cursor position
        ELSE.
          SET CURSOR FIELD US_FELDNAME LINE 2.
        ENDIF.
    Product proposal actively
    Set ==> cursor in the first row
      IF DPP_ACTIVE   EQ CHARX AND
         XVBAP_UMFANG_OPV IS INITIAL.
    in the 'target volume' if available
        IF KOPGR_MIT_ZMENG CS TVAK-KOPGR.
            SET CURSOR FIELD 'VBAP-ZMENG' LINE 1.
            EXIT.
        ELSE.
    Else in the field 'Order quantity'
          SET CURSOR FIELD 'RV45A-KWMENG' LINE 1.
          EXIT.
        ENDIF.
      ENDIF.
    Hope it helps you,
    Regards,
    Abhijit G. Borkar

  • How to get the cursor position on a picture?

    I'd like to show the cursor position on a picture
    which is 400 by 400 pixel size and located at
    (0, 0, 400, 400) on a panel. So suppose that the
    cursor is at (50, 50), how can the java code know?
    Thank you.

    I am thinking about this, and use something like
    JPanel.setFocusable(true). Thank you.

  • Is there a way to get the cursor position index of html text field

    I'm trying to work on a text pad like MC with "insert text at
    position X" and "find and replace" can anyone tell me how to find
    the cursor index of an html text field. Selection.getBeginIndex() ,
    Selection.getEndIndex(), Selection.getCaretIndex() as far as I know
    these methods only work with text and not htmltext.
    What I'm trying to do is assign different parts of the string
    to variables so that I can combine them to reconstitute my html
    string.

    enfantterrible:
    If I understand correctly, you want the corresponding
    position in the
    htmlText propery of the caret index (which as you point out
    is only the
    position in the plain text version of the textfield content).
    Below is how I would do it. Maybe there's an easier or more
    efficient
    way (using XML objects etc), but I don't know it. You could
    conduct all
    your string searches in the plain text and then convert the
    result to
    the html positions. I didn't build this to accept negative
    parameters
    for the pos parameter (e.g. from end of string backwards) but
    the
    function could be adapted to do this too if necessary. The
    test data is
    not proper html from a text field, but it doesn't really
    matter what it
    is so long as its formatted correctly. It just separates the
    tags from
    the content to enable apples with apples comparison.
    //some test data
    var testStringXML = "<format>Hel<b>lo i can't
    t<i>ell you h</i>ow hap</b>py I
    am.</format>";
    var undecoratedString = "Hello i can't tell you how happy I
    am.";
    //the conversion function
    function findDecoratedPosition(pos:Number, xmlString:String,
    test:Boolean):Number {
    //anything between '<' and '>' should be excluded from
    plain text search.
    //create an array of array elements (n=2) consisting of tag
    then plain text
    //requires correctly formatted xml/html
    var tempArr:Array = xmlString.split("<");
    for (var aa = 0; aa<tempArr.length; aa++) {
    tempArr[aa] = tempArr[aa].split(">");
    //remove the first and last elements of the new array (these
    are empty)
    tempArr.pop();
    tempArr.shift();
    //find the corresponding plaintext location and calculate
    the "decorated" position
    var retPos:Number = 0;
    var posCount:Number = 0;
    for (var aa = 0; aa<tempArr.length; aa++) {
    retPos += tempArr[aa][0].length+2+tempArr[aa][1].length;
    //+2 allows for missing < and >
    posCount += tempArr[aa][1].length;
    if (posCount>pos) {
    return (retPos+(pos-posCount));
    //out of range
    return -1;
    //test code:
    for (var aa = 0; aa<undecoratedString.length; aa++) {
    var altPos = findDecoratedPosition(aa, testStringXML);
    trace(undecoratedString.charAt(aa)+" in position "+aa+"
    plainText equates to position "+altPos+" in the decorated version
    ["+testStringXML.charAt(altPos)+"]");
    }

  • Get the y position by sending x to LineSeries

    hi,
    i created a LineChart from simple x,y points. now i would
    like to get the y coordinate by sending some x to the specific
    line. but i didn't find the function that do so!! how come flex
    interpolate between point and uncover the function that draw the
    whole line? is there a why to get the y value of the line from
    cretin x?
    please help me...

    BLUP :0
    PLEASE....

  • When I turn on my computer I get the message APPLESyncNotifer.exe   Entry Point not found.

    Have a 5th generation nano and when I connect to my computer I get a message APPLESyncNotifer.exe  Entry Point Not Found. Not a computer geek so I am stumped. Anyone out there who could help? I have reinstalled ITunes and restarted my computer to not avail.

    Copying & pasting SQLIte3.dll worked out well for your computer?
    Just read your trouble with your iPod nano 5th generation & Windows PC, how about trying the one I found on this community before?
    Click the start button and type in 'msconfig' in search, and, in system structure utitily, click on the tab of 'startup' and check off the box of 'AppleSyncnotifier.exe' and reboost your system.(You have to follow down till the end of the place of the file.) That'll solve your trouble.
    I don't know you connect iPad or iPhone at all, that may change the solution? Hoping this suggestion also work out for you & your PC.

  • To get the user exits and modification points

    Hi Experts,
    I am able to find all user exits for a particular transaction,but is there a way to find it for some specific actions alone.
    Need to find the user exits and enhancement points that are called while clicking a specific button in a standard transaction.
    Your help is highly appreciated.
    Regards,
    Sridevi

    Hi
    To find out the userexits at position where you need you should see the description of the USER EXIT.If you find that it is close to the point where you want then put up a break point inside it and re - run the transaction.
    Also you can check SDN post to find out your user exit.
    FOR BADI -
    1 )You can put breakpoints at method GET_INSTANCE of class CL_EXITHANDLER and  CALL FUNCTION statements.
    2) You can run through SPRO transaction for the particular Functional area and understand the available exits or BADIs .
    Regards
    Gaurav

Maybe you are looking for

  • Using a shared networked  drive

    We have been trying to use a NAS drive to store project files in a central location that can be accessed by all systems in a shared RAID environment. (This way all editors can read and write to the same volume, as opposed to the problems that happen

  • HT201269 Restoring my phone after using find my phone on icloud

    I lost my phone and turned on find my phone in icloud I never got my phone back but now I have just got a new phone and want to restore it using my icloud but on my itunes is saying I need to turn off find my phone but after going to icloud turning i

  • Use of Field "Note" (WT_WARNTXT, Tabke name-ACWT_ITEM) in Wht button-MIRO

    Dear Experts, What is the role of Use of Field "Note" (WT_WARNTXT, Tabke name-ACWT_ITEM) in Wht button in MIRO/FB60 Transaction. For what purpose it is used. This is field is allowing for any thing to be enter. How can we make it enable so that the g

  • Reader extensions and 2d bardcode

    Hi, If I´m not wrong, even with the licence for 2d barcoded forms, one will always need reader extensions, right? I believe one can purchase only the part of reader extensions needed, or this funcionality is bought when we pay for the 2D barcoded for

  • Online number in Brazil not working

    For weeks my friends have been reporting it was working intermitently. Now none of them can place a call, they always get a busy signal. I have a friend who has an online number and he's reporting the same problem.