Point (0,0) in LD3DView image mapping - Printable Version +- Small Basic Forum (https://litdev.uk/mybb) +-- Forum: Small Basic (https://litdev.uk/mybb/forumdisplay.php?fid=1) +--- Forum: Extensions (https://litdev.uk/mybb/forumdisplay.php?fid=3) +--- Thread: Point (0,0) in LD3DView image mapping (/showthread.php?tid=31) Pages:
1
2
|
RE: Point (0,0) in LD3DView image mapping - jrmrhrb00 - 02-22-2024 LitDev, How are the values of 0 and 1 derived in the following line? I still don't understand this. LD3DView.AddImage(view3D,square,"0 1:1 1:1 0:1 0:0 0:0 1",image,"D") is 0 1 representing x and y? is : just a separator for the nodes is there 6 nodes? why 11 for the second node? JR RE: Point (0,0) in LD3DView image mapping - litdev - 02-23-2024 Hi, The textxtures parameter help info is: A space or colon deliminated list of the texture coordinates for each node. Each node has 2 values between 0 and 1 indicating the x,y image mapping to the node. The may be defaulted to "" if the texture has previously been set. So the space and colon are deliminators and I used : to separate between x y pairs to make it easier to read. The are 2 triangles on this 3D object (square). Although 2 nodes could be shared they were specified separately so there are 6 nodes. There are are also 6 x y pairs of textiure cordinates, one for each triangle node. So the purpose of the each texture node is to say what coorcinates ont the image the node corresponds to. The first is 0 0 which is bottom left of the image mapped to the first node. The second is 1 0 which is bottom right of the image mapped to the second node tec. The mapping coordinates do not have to be whole numbers, see the effect using just the left half of the image for example "0 1:0.5 1:0.5 0:0.5 0:0 0:0 1". RE: Point (0,0) in LD3DView image mapping - jrmrhrb00 - 02-23-2024 LitDev, So the purpose of each texture node is to say what coordinates on the image the node corresponds to. The first is 0 0 which is bottom left of the image mapped to the first node. The second is 1 0 which is bottom right of the image mapped to the second node. 0 1:1 1:1 0:1 0:0 0:0 1 Still confused! The above 2 lines aren't making any sense to me which is what you wrote. You said the first node 0 0 is bottom left of the image. Isn't 01 the value for first node? 11 the second node value. 10 the third node value. 10 the 4th node value. 00 the 5th node value and 01 the 6th node value? Since I am only doing a square which is 2 triangles put together. The first node is down in the left hand corner. Where is the second, third and 4th nodes? Do they just go around the square counter clockwise? I understand why you use 6 because of the 2 triangles which has 6 vertex's. Thanks for helping! JR RE: Point (0,0) in LD3DView image mapping - stevantosic - 02-24-2024 JR Maybe you should start with single triangle: triangle = LD3DView.AddGeometry(view3D,"-0.5 -0.5 0.5:0.5 -0.5 0.5:0.5 0.5 0.5","0 1 2","" , "Red","D") 'LD3DView.AddImage(view3D,triangle, "0 0:1 0:1 1",image,"D") ' LD3DView.AddImage(view3D,triangle, "0 1:1 1:1 0",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y or triangle2 = LD3DView.AddGeometry(view3D,"-0.5 -0.5 0.5:0.5 -0.5 0.5:0 0.5 0.5","0 1 2","" , "Red","D") 'LD3DView.AddImage(view3D,triangle2, "0 0:1 0:0.5 1",image,"D") ' LD3DView.AddImage(view3D,triangle2, "0 1:1 1:0.5 0",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y st RE: Point (0,0) in LD3DView image mapping - jrmrhrb00 - 02-24-2024 st, That helps a lot. Make it simple. Now, I understand that you flip all of the y values. How would you set this up to show only the left triangle? I have been trying this, but haven't succeded yet. RE: Point (0,0) in LD3DView image mapping - stevantosic - 02-25-2024 Code: triangleL = LD3DView.AddGeometry(view3D,"0.5 0.5 0.5:-0.5 0.5 0.5:-0.5 -0.5 0.5","0 1 2","" , "Red","D") Changing parameters slowly one by one is a good way to see what is happening on the scene. st RE: Point (0,0) in LD3DView image mapping - jrmrhrb00 - 02-25-2024 st, Thanks a lot. Now, I cam figure out how it works! JR RE: Point (0,0) in LD3DView image mapping - stevantosic - 03-01-2024 Maintain aspect ratio: LDNetwork.SetSSL() flickr = LDUtilities.FixFlickr() imageURL = Flickr.GetRandomPicture("word") tmpFile = File.GetTemporaryFilePath() LDNetwork.DownloadFile(tmpFile,imageURL) image = ImageList.LoadImage(tmpFile) File.DeleteFile(tmpFile) view3D = LD3DView.AddView(GraphicsWindow.Width,GraphicsWindow.Height,"True") LD3DView.AutoControl("True","True",2,1) LD3DView.AddAmbientLight(view3D,"White") a = ImageList.GetWidthOfImage(image) b = ImageList.GetHeightOfImage(image) k = LDMath.FixDecimal(a/b, 2) TextWindow.WriteLine(k) pointsR = "-x -0.5 0.5:x -0.5 0.5:x 0.5 0.5" pointsL = "x 0.5 0.5:-x 0.5 0.5:-x -0.5 0.5" pointsR = LDText.Replace(pointsR, "x", 0.5 * k) TextWindow.WriteLine(pointsR) pointsL = LDText.Replace(pointsL, "x", 0.5 * k) TextWindow.WriteLine(pointsL) triangleR = LD3DView.AddGeometry(view3D, pointsR,"0 1 2","" , "Red","D") 'LD3DView.AddImage(view3D,triangleR, "0 0:1 0:1 1",image,"D") ' LD3DView.AddImage(view3D,triangleR, "0 1:1 1:1 0",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y triangleL = LD3DView.AddGeometry(view3D,pointsL,"0 1 2","" , "Red","D") 'LD3DView.AddImage(view3D,triangleL, "1 1:0 1:0 0",image,"D") ' LD3DView.AddImage(view3D,triangleL, "1 0:0 0:0 1",image,"D") ' Y: 0 <-> 1 or Y = 1 - Y LD3DView.TranslateGeometry(view3D,triangleR,0,0,8) LD3DView.TranslateGeometry(view3D,triangleL,0,0,8) RE: Point (0,0) in LD3DView image mapping - jrmrhrb00 - 03-02-2024 st, I would have never thought of maintaining the ratio. Good program! JR |