Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Vertex position and calculation... little help please

Author
Message
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 5th Nov 2010 15:36
This code is jumpy so I am sorry... no need to smack it around... I'll fix it later. The pick commands are off - another fix later... What I am trying to do is make a larger plane by putting several together. Then (since a vertexdata command in a huge set of vertices for 100 planes with 60 x and z segments each would kill you lol) gather the pick object and several objects around it and enter them into a "for-next" loop and edit them. Here's the code. All that it does (for now) is gathers the objects you're going to edit. As long as your pick objects (displayed on screen) are greater then 1, click some where on the object and it will in return color the objects. I need to find out or figure out how to keep certain things from happening... take a look and you'll fully understand.



Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Nov 2010 15:38
Which part are you having a problem with exactly? It's kind of hard to tell from your post.

Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 5th Nov 2010 16:24
I am sorry lol. Without running it my explaination will be crappy lol.

You know how pixels are drawn? How when you reach the end of an X row or Y row, you start at the top again... well if you move to far on one side of the planes and click, planes in the next row are selected. How do I keep this from happening?

123456789
123456789
123456789
123456789
123456789
123456789
123456789
123456789
123456789

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 5th Nov 2010 16:31
I'm afraid you lost me at "You know how pixels are drawn?", the rest is beyond my knowledge. Sorry!

Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 5th Nov 2010 17:20
I think your starting to loose us Daryn!

Your worried about vertex positioning, then worrying about how pixels are drawn. We confused!

Anyhoo, this bit here:

For Ob=1 to (NumObjects+10)
PSX#= OBJECT SCREEN X(Ob)
PSY#= OBJECT SCREEN Y(Ob)
PDist#=GET PICK DISTANCE()
`PICK SCREEN MouseX(), mouseY(), PDist#
NEXT OB

You realise that GET PICK DISTANCE is for use with a PICK OBJECT or PICK SCREEN? - it's not doing anything in there. But it brings me onto my point - why not just use PICK OBJECT?

Then, just pass the mouse location and range of objects, and it will return the object number that you are clicking on - isn't that what your trying to do?

Health, Ammo, and bacon and eggs!
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 5th Nov 2010 18:13 Edited at: 5th Nov 2010 23:02
Woa woa woa... Nothing to do with pixels... use how pixels are drawn as a reference... Whole X column then move over 1 Y row... bare that in mind and use planes instead of pixels in 3D...

(I'll fix the pick commands later - was trying other things and left commands there)

Planes are laid out in the same manner as 2d pixels... row then column for example...

plane 1 then 2 then 3 - 4 - 5 - 6 - 7 - 8 - 9

I'm selecting a 3X3 plane sections based upon the center (2, 16) pick object...

1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10
11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20
21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30

If the central object moves to 2, 20 then the objects in front of it move to the next row. (7 would become 11, 17 to 21, 27 to none) What I want to stop from happening!

(Forgive the pixel reference. Just purely visual to grasp what I'm trying to prevent)

The reason I need to stop select edges on the next row/column... entering these objects into lock vertexdata, add mesh, convert, and move vertex positions... ah.

EDIT:
I cannot for the life of me align the 3D cursor objects with the mouse - I think I need to do this before I try and adjust objects since they're being called by the cursor. Anyone able to gather what's wrong.



Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 5th Nov 2010 19:38
Actually... The pixel reference might be good. If you've ever dealt with the memblock and make image from memblock commands, you probably have made a command so that given a pixel x and a pixel y value, you can find the index on the memblock where that data should be stored. Basically:

index=y*width+x

where x and y start from (0,0).

If you wanted to move an object up a row, you would just add "width" to index. down a row, you would just have to subtract "width" from index. To move right or left one, you would just have to check if the object would move to the next row, and react accordingly.

Alternatively, you could always refer to your vertices at point (x,y), and then just increase x or y by 1, making sure that they stay within a certain bound.

Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 5th Nov 2010 19:46
Funny - I have. But the more pressing matter at the moment is in 3D. If you have Ian's Matrix Utilities Plugin which is free and highly recommended , run the code in the second post. Thats 10 plains, each with 32 columns and rows.

If I could get the damn pick commands to positioning ratio correct, you would see which objects are going to (were it coded...) enter vertex editing.

The first post actually colors the plains in question if you click the mouse. You'll need Ian's plugin though.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Nov 2010 20:40
Did you intend to create an 11x11 array of plains? Your comments elsewhere seem to suggest you intended to create a 10x10 array of plains.

Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 5th Nov 2010 22:03 Edited at: 6th Nov 2010 19:07
oopsie - ironing this out

EDIT:
Okay I figured it out. Based on the scale size, I can gather how many objects are on each side and their corresponding object numbers.



I got it and it was so simple. Sometimes there are things that just make you laugh at yourself and this was hilarious! The "..." is the 'don't select me' code. ha ha. It's already in the strip of code above this post and added to the top.

Now for the pick commands. I removed Pick Screen and distance, but I can't get the 3D cursor (lines) to snap to each row/column segment. Can any one point out this problem?

EDIT 2:

HEY if anyone could help with the pick commands I'd appreciate it greatly. For some reason the scaling is always off. Bothersome thing. Please

Updated code:


Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 6th Nov 2010 19:08
Not to be pushy... but, um... da-da-da da-da DA! "bump"

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 6th Nov 2010 20:29
I don't understand your code. Why do you use this in one place:



and this in another:



???

I don't know how find free object() works - but are you sure the object numbers of the adjacent objects are those you've used? Why not use your own numbering system for objects? Alternatively, if you must use find free object() have a lookup array for the object numbers returned by that function.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 6th Nov 2010 21:06 Edited at: 7th Nov 2010 00:05
Here is what I've learned from this tool - and thank you for helping me to gather this bit of info. That command is called multiple times in a for-next loop. It is auto-incrementing each loop.

With each line of your code (1 - command, 2 - command...) that command checks for objects that are nonexistent, Starting from 1 to ... or if you specified a range, then from the start of the range to the end of it.

If you enter a for-next loop, it will return the same number if you don't create any objects within said loop. However, if you do create an object in said for-next loop, the next time the command is called, it increments until it returns an object number not in use, after which you would then repeat the process.

- I am using my own number system and still having issues


when I call pick object later in the code, the scale still remains off. Not sure what I'm doing wrong - but it only pisses you off when you're close to right but still wrong! CLOSE - but no cigar.

EDIT- I think it's somethin' to do with the camera.

EDIT II: Here's a closer look top down wireframe w/ correct snap, in correct mouse to pick ratio



Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Nov 2010 01:05
this is stupid and frustrating - like a small sibling

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Nov 2010 01:34
This line may be your problem:



A near value of zero is not a good idea.

Positive values (as stated in the Help file) seem to give better results - but there is still an annoying lag.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Nov 2010 09:01
That's native to your machine. But the problem is fixed - show up again to this post in a day or so and see something really cool - I swear on the coding gods!

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Nov 2010 11:08
Quote: "That's native to your machine."


What do you mean? Removing that line makes your code work on both my machines, different processors, different GFX cards, etc, etc.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Nov 2010 13:50
Well the point was I got it thanks to you bud mer-na-mer.

So now we have a cursor moving around correctly YAY... so, all I have to do is select an 3X3 group of objects around the center pick object and enter them into vertexdata commands... hooray!

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Nov 2010 15:35
Here is what I'm doing. I think we've gathered that it's messy and yes I intend to clean things up... but again... here's what I'm doing.

What you're looking at when running the code is 100 planes, each with 50X50 segments (If I remember correctly that's a lot of vertices ) As you move the mouse around, you'll see which of these planes will enter vertexdata editing. I will update this strip of code as I complete it

Here is a simple example of selecting objects...



Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Nov 2010 18:44
Forgive my triple post lord god, but how do I enter more than one object into vertexdata? I've tried adding mesh and converting. I want to adjust their positions. That's it. Run the strip above and I'm sure you'll grasp what it is I am doing.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Nov 2010 19:36
Quote: "but how do I enter more than one object into vertexdata"


As far as I know you can only process one limb at a time which can be annoying if you need to combine information from several limbs or objects. I usually copy the information I need into arrays, make the changes there and then copy back the changed stuff one limb at a time. There may be a simpler way that I've overlooked. Memblocks might be faster than arrays () but I doubt they'd be easier.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 7th Nov 2010 20:33
Okay so say I edit one plane object, how would I keep the edges of each plane always equal to the ones around them? (Seaming)

If you know of any posts or techniques for doing this it would help greatly!

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 7th Nov 2010 21:26
It's a case of just getting down to the coding yourself I'm afraid. As it happens I'm doing something similar at the moment for fixing the normals along Advanced Terrain seams. But I haven't decided on the simplest and most elegant solution yet.

Depending on what you're doing you could just store the values of the adjacent edges in two arrays and then calculate the averages and store those in a new array and finally copy those values back into the original vertex data for each object/limb. That's more or less what I intend to do for the AT normals (but they will need to be renormalized after averaging).

If you need specific code I can't help you - yet.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 8th Nov 2010 02:08 Edited at: 8th Nov 2010 02:34
No, no code... but to read the dos and donts would be useful.
How about this then, in what manner are vertices drawn... if it were as simple as 1-2-3-4-5-6 I'd be happy to just have a go at this... but is there a certain way that dbpro handles vertex positioning in accordance to face placement? IE - is the first vertex the upper right or upper left corner of each face, and where are the other two, is the second across or on the diagonal? Do segmented planes draw left to right or top to bottom or vise-versa?

On that note... why is it that we can't edit to or more objects in vertexdata? Is there a way to combine objects and then separate them? If not, why isn't there a way to do so... I mean what's the technical answer?

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Nov 2010 11:41
Quote: "How about this then, in what manner are vertices drawn... if it were as simple as 1-2-3-4-5-6 I'd be happy to just have a go at this... but is there a certain way that dbpro handles vertex positioning in accordance to face placement? IE - is the first vertex the upper right or upper left corner of each face, and where are the other two, is the second across or on the diagonal? Do segmented planes draw left to right or top to bottom or vise-versa? "


The simplest thing to do is to check for yourself by printing a few vertices to the screen. That's what I do anyway.

Quote: "On that note... why is it that we can't edit to or more objects in vertexdata? Is there a way to combine objects and then separate them? If not, why isn't there a way to do so... I mean what's the technical answer?"


I guess the necessary commands haven't been added to the language yet. I don't know of any other reason - but there might be some sort of DirectX limitation behind the scenes.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 8th Nov 2010 21:56 Edited at: 9th Nov 2010 00:05
Well I gather how to make two arrays, but how do I call them? I mean, looking at what I've posted (though lacking in ways ) Do I lock the center pick object and edit it in a for-next and while within the for-next adjust the other objects? - I understand that this is going to be one of those things I do without something to go on, but some of this is beyond my comprehension.

EDIT:
Here's another question, why can't I seem to do a for-next loop, call the heights of one object by locking for a limb, then unlock and continue doing the same again but with another object? Why can't I gather the correct distance to and from the mouse (3D) to each vertex...

Here is what I did. While the mouse was clicked, the objects (9 of them) were entered into vertexdata... that's one for-next loop for each of them. I then measured the distance from each vertex to the 3d mouse object and if it was within a certain distance from it, the vertice's Y position was incremented... however, when I tried this, the command just duplicated the same 'adjustments' to all 9 planes... if the distance is measured to and from an object, shouldn't each vertex position be different from another? (What happened one one plane was mirrored on the other 8, even though their positions and distance from the mouse were further/nearer. Why did this occur?)

In case you're wondering, I transformed the vertex positions by adding them to a vector3 and TRANSFORM VECTOR3 TO COORD.

I don't know.

EDIT 2:
Boy that is frustrating. I'll have to mess around with arrays a while - I can tell, and that's alright I guess... so long as in the end it works :*

My trouble is I'll have to calculate the positions of each vertex on the edges of each object, rather than check them as part of one array and another. Reason being, da da-da da! - the array size is to large with both the X,Y and Z coords.

Alas, if I don't take a break from this computer I think I might break it instead.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Nov 2010 01:19 Edited at: 9th Nov 2010 01:20
Sometimes it helps to plan it on paper first - after a prolonged coffee break in your case.

Here's a simple diagram outlining the steps needed if you want the vertices along the right hand edge of object A to coincide with the left hand edge of object B:



If that doesn't help then we need to see some code, short and simple preferably.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 9th Nov 2010 15:50
Okay I'm trying this now. I think I'll make 8 arrays for the objects around the pick object. These make up the 3X3 square in the coding above, then just average their heights with the pick object in vertexdata. I'll post it later

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 25th Nov 2010 02:22 Edited at: 27th Nov 2010 00:31
Okay now I need some real help. Here's the full bit of code. My pick commands and the raising of the terrain is confusing me now since the code is getting pretty heavy. I'm trying to incorporate the values in the arrays to the corresponding areas but I don't know what I am doing wrong, nor do I know what I am doing right. You need Ian's Matrix Utility plugin to run this, but please - if anyone can give an example or some example code just so I have something to go on. Here is the titan of confusion:


Quote: "short and simple preferably. "


-Sorry it's long and difficult, but to simplify would mean using more time than I have to spare at the moment. Don't eat me.

-There are some variables not doing anything - they have a use further on. Just a note that I am aware of it HELP!

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 25th Nov 2010 22:12
Your code will be so much more readable if you indent.

Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 27th Nov 2010 08:11
There u go

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 27th Nov 2010 10:38
Thank you.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 28th Nov 2010 09:00 Edited at: 30th Nov 2010 22:59
Any pointers?

EDIT: I havent gotten this to work right yet - can someone help a fellow out

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 2nd Dec 2010 06:38
Oh my - um... da-da-da da-da DA! "bump"

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 2nd Dec 2010 21:49
Quote: "Sorry it's long and difficult, but to simplify would mean using more time than I have to spare at the moment."


And we have lots of time to spare I suppose.

This sort of thing is just plain lazy - and hard to follow:



Why on earth don't you do the tests once and put all the relevant consequences together? Something like this at least:



If you haven't the time to organize your code sensibly what makes you think we have time to struggle to understand it?

Help us to help you.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 3rd Dec 2010 10:14
At the moment that strip of code has absolutly nothing to do with the arrays or vertexdata - it simply relays what objects are around the pick object if any. So in a way, without this strip of code you can't really gather what object number is in front, top, left, right, corner right top, bottom, corner left top, bottom around the pick object - and therefore wouldn't know what object(s) to apply the arrays to... if you have an easier way of keeping each vertex aligned and aren't using this method - then explain - The check object you referred to as "lazy" actually catches the objects in the 'many planes's corner... IE if you have four objects that can be edited then you must be in either the right, left, bottom, top, corners of the group of planes... and it relays whether the object off the map should be displayed... if you look further on down in the code... he he - I did exactly what you did above... the "lazy" code you're scanning is not for the intention you think its for.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 3rd Dec 2010 11:50
Quote: "The check object you referred to as "lazy""


I didn't. What I described as lazy was the fact that you used the same if test several times quite unnecessarily and makes your code both hard to read and unnecessarily long. Just do each test once in an organised fashion as I suggested in my snippet.

You've obviously completely missed the point.

Quote: "the "lazy" code you're scanning is not for the intention you think its for"


I have no idea what you mean.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 8th Jan 2011 00:27 Edited at: 8th Jan 2011 00:38
Okay... so here's what I've come up with... I don't understand why the pick commands return the locations they do but removing them from the distance code reports the correct location... I think its a vector problem... if You must know, the shader is based on one of your shaders GG... don't kill me for fooling around with it I'm looking for help with the arrays. On a side note I didn't indent... but for the most part I am only looking for help with the arrays (as you pointed me in the direction)

Oh... I realize there was some confusion as to the 'lazy bit of code' above... If the pick object equals 0 than all objects around the pick object = 0 - that was what you meant... but if you're working with 9 planes (8 around the pick object) than there is extra calculation for the other eight planes. That is why there is also the "lazy" bit of code... because in some cases, not all of the 9 planes are rendered... and in such cases, the pick object isn't the center of the 9 planes, but either the left or right of the remaining planes. (So again... thats top-left, top-center, top-right then center-left, center-center (the pick object), center-right, lastly bottom-left, bottom-center and bottom-right. All making up a 3X3 plane grid that is able to be terraformed at once. Take a look and run the exe)

-Daryn

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2011 19:54
Quote: "If the pick object equals 0 than all objects around the pick object = 0 - that was what you meant... but if you're working with 9 planes (8 around the pick object) than there is extra calculation for the other eight planes. That is why there is also the "lazy" bit of code... because in some cases, not all of the 9 planes are rendered... and in such cases, the pick object isn't the center of the 9 planes, but either the left or right of the remaining planes. (So again... thats top-left, top-center, top-right then center-left, center-center (the pick object), center-"


That has nothing to do with my main point which is quite simply: why test for the same condition more than once per loop in the same block of code. Just organize your code more efficiently.

Anyway, let's put that to one side for now.

I've tested your demo (from 25th/26th Novemver!) and I don't know what the problem is precisely.

You say:

Quote: "I don't understand why the pick commands return the locations they do but removing them from the distance code reports the correct location"


Could you be specific? What values do you see and what do you expect?

Also, what are lines like this supposed to be doing?



It may be what you intend but I'm not sure.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 8th Jan 2011 20:22
It moves the cursor along the segments (snapped to)

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2011 20:42
And? What is the problem exactly?
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 8th Jan 2011 21:06
OKAY! figured it out.

I removed all the extra objects around the pick object. What happens is 1) When a new pick object is edited by the vertexdata and pick commands... the position of the mouse(3d) isn't relative to the new pick object. (So when I move the mouse from one terrain plane to another, the x, y and z position returned by pick object are still relative to the pick object first clicked or drawn - frankly I'm not sure... but I am 100% sure it is a coordinate issue with the returned pick object.

Now my question is... (it's attached) how do I return the right coordinates for vertex positioning in relation to the current pick object?

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2011 22:11
Quote: "OKAY! figured it out."


Good. But I still don't know what the problem was/is.

I can't see anything wrong with the values returned by your 25th/26th November code. Care to enlighten us?

By the way, I've changed your original code from



to



I'm sure similar optimisations are possible elsewhere in your code.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2011 22:20
I've just tested your new download and you seem to have reintroduced the earlier problem you had at the beginning of this thread - the cursor object no longer aligns with the mouse. You had that problem solved (apart from the annoying lag) in your 25/26th November code.

I suspect the lag has something to do with the low FPS - I get about 6 on my laptop and 16 on my PC. Something is really slowing up your code. Not sure what the critical feature is yet.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 8th Jan 2011 22:22 Edited at: 8th Jan 2011 22:25
I'm sure there are optimizations as well... If you run the code I provided its 274 lines long with a large function rem'd out. If you run it, the center object will terraform, if you move to the right, left, up or down of the center pick object... the last location terraformed on the first plane is the same location on the second... so if you're terraforming on object 1 near the lower left... when you move to the upper left of object 2 you're terraforming the lower left of object 2 rather than the upper right. How do I fix this?

EDIT:
If there's a pick object near the "for-next" loop try moving it... I might have put it in there when shortening the code. I have no idea why you're experiencing lag.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2011 22:25
Just noticed a potential problem. In your code you have things like



Vertices are numbered from 0 to GET VERTEXDATA VERTEX COUNT()
- 1 so your code will be returning incorrect values.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 8th Jan 2011 22:27
Which code are you running. I corrected that in the latter of the posts

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2011 22:30
Quote: "If you run the code I provided its 274 lines long with a large function rem'd out. If you run it, the center object will terraform,"


I'll come back to this in a minute (meal's ready ). I'm afraid you included an exe file that is quite different from what I get when I compile your code.
Daryn Alsup
18
Years of Service
User Offline
Joined: 5th Jul 2008
Location: In your head... dun dun DUN!!!!!!!!
Posted: 8th Jan 2011 22:34
Oooh... food, k I think I'll make something too. I don't understand why I'm compiling something that runs so smoothly on my comp... oh wait... that's right... game-making.

Jack and Jill went up a hill to fetch a pale of water... but Jill got tired of his s#%& so she shot him.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jan 2011 22:37
Quote: "Which code are you running."


The vertex count problem is in your 25/26th November code. I haven't looked at your new code yet.

[Supper IS ready now - it was a "false alarm" before. ]

Login to post a reply

Server time is: 2026-07-10 20:57:58
Your offset time is: 2026-07-10 20:57:58