Previous Thread
Next Thread
Print Thread
Joined: Feb 2014
Posts: 1,225
Likes: 224
G
Very Senior Member
Very Senior Member
G Offline
Joined: Feb 2014
Posts: 1,225
Likes: 224
Robotadv is the coolest thing I've seen lately.


I've been trying to study robotadv, and specifically how the position outputs works to display the arm.


I look at the layout and it doesn't quite make sense to me:


Code
	<element name="mpos" defstate="0">
		<rect>
			<bounds x="0" y="0" width="4096" height="6.25" />
			<color alpha="0" />
		</rect>
		<disk>
			<bounds state="0" x="0" y="0" width="6.25" height="6.25" />
			<bounds state="3600" x="3600" y="0" width="6.25" height="6.25" />
			<color red="1.0" green="0.2" blue="0.8" />
		</disk>
	</element>

So I see it refers to pos_x, with an interior animate tag that uses pos_y.

I don't quite understand how that works, because I always thought of the state values as a single dimensional value, not a 2d position.




Code
	<!-- optional claw position overlay -->
		<collection name="Claw Position">
			<element name="pos_x" ref="mpos">
				<animate name="pos_y" />
				<bounds state="0" x="-106.625" y="-168.625" width="819.2" height="1.25" />
				<bounds state="1500" x="-106.625" y="131.375" width="819.2" height="1.25" />
				<color alpha="0.4" />
			</element>
			<element name="pos_x" ref="mpos">
				<animate name="pos_y" />
				<bounds state="0" x="-516.225" y="-168.625" width="819.2" height="1.25" />
				<bounds state="1500" x="-516.225" y="131.375" width="819.2" height="1.25" />
				<color alpha="0.9" />
			</element>

			<element ref="blackb"><bounds x="-516.225" y="-200" width="409.6" height="400" /></element>
			<element ref="blackb"><bounds x="302.975" y="-200" width="409.6" height="400" /></element>
		</collection>


Code
	// output claw position
	const int open = (m_limits & 1) ? 0x800 : 0; // put open state on x bit 11
	m_out_pos[0] = int((x + 15.0) * 50.0 + 0.5) | open;
	m_out_pos[1] = int((y + 15.0) * 50.0 + 0.5);

And when the claw is engaged, it gets ored with 2048?


From the documentation:

Quote
Each component may have a bounds child element specifying its position and size (see Coordinates). If no such element is present, the bounds default to a unit square (width and height of 1.0) with the top left corner at (0,0).

A component’s position and/or size may be animated according to the element’s state by supplying multiple bounds child elements with state attributes. The state attribute of each bounds child element must be a non-negative integer. The state attributes must not be equal for any two bounds elements within a component.

If the element’s state is lower than the state value of any bounds child element, the position/size specified by the bounds child element with the lowest state value will be used. If the element’s state is higher than the state value of any bounds child element, the position/size specified by the bounds child element with the highest state value will be used. If the element’s state is between the state values of two bounds child elements, the position/size will be interpolated linearly.


I was amazed that all of this was done without using any kind of layout scripting where setting bounds is quite easy.



My cunning plan is to have an animated line display like this:



Last edited by Golden Child; 06/04/25 09:00 PM.
Joined: Feb 2014
Posts: 1,225
Likes: 224
G
Very Senior Member
Very Senior Member
G Offline
Joined: Feb 2014
Posts: 1,225
Likes: 224
Okay, I looked at it and looked at it and I think I may understand a little better?


the mpos element has a disk that has bound coordinates that go from 0,0 to 3600,0 where the state goes from 0 to 3600 controlling the x coordinate which gives you movement in the horizontal direction.

Code
state = 0        x,y = 0,    0
state = 3600     x,y = 3600, 0

then you have that element as part of the view, connected to name="pos_x".

Inside, the animate tag is connected to name="pos_y"

and it goes from

Code
state = 0          x,y = -106.625, -168.625       width,height =  819.2, 1.25
state = 1500       x,y = -106.625, -131.375       width,height =  819.2, 1.25


where the x coordinate is fixed, and the y coordinate varies

so because it's inside the element, the bounds are relative to the outer bounds? and that's how you get the movement in the vertical direction?

Last edited by Golden Child; 06/05/25 01:41 PM.
Joined: Mar 2002
Posts: 1,385
Likes: 145
H
hap Offline
Very Senior Member
Very Senior Member
H Offline
Joined: Mar 2002
Posts: 1,385
Likes: 145
There's a long horizontal bar that's moved vertically with animate pos_y. Inside the horizontal bar, I draw a small circle whose horizontal position is moved by element state pos_x. I draw 2 of these horizontal bars next to eachother. Claw open/close state is on x += 2048. So, one small circle is on screen, the other is off-screen and I draw a black rectangle over it to erase it.

Like that, it's possible to have a sprite moving in 2D without lua script. I do the same thing in:
fidel_phantom.lay
fidel_cphantom.lay
excal_mirage.lay

When the driver was in development, I drew one dot at each 'joint' to see the whole arm movement, eg. after each step in update_clawpos().
If you do that then yes, it should be possible to draw lines between the joints with lua. Sounds like it'd be distracting.

Last edited by hap; 06/05/25 03:07 PM.
1 member likes this: Golden Child
Joined: Feb 2014
Posts: 1,225
Likes: 224
G
Very Senior Member
Very Senior Member
G Offline
Joined: Feb 2014
Posts: 1,225
Likes: 224
Thanks for the pointer, Hap.

Just as an experiment, I took the second circle out and I didn't notice any difference in the display.

I did the drawing the joints, basically copying the pos_x and pos_y and the view elements for each vertex.

It's probably distracting but I just can't get over how cool it is!


Link Copied to Clipboard
Who's Online Now
3 members (AJR, Kale, 1 invisible), 232 guests, and 3 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,381
Posts122,712
Members5,085
Most Online1,529
Jun 7th, 2025
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Powered by UBB.threads™ PHP Forum Software 8.0.0