TextField3D/Shape3D placement

19 views
Skip to first unread message

G.

unread,
Jan 12, 2009, 7:42:44 PM1/12/09
to away3d.dev
Hi there,

Still on the same project, based mostly on typo, I'm trying to get
some words from the same text in another font. (more precisely:
highlighting some words with a bold font) The first thing that came to
my mind was to have the main text on a first TextField3D object with
the regular font and then find the index of each word I want in a bold
font and create as TextField3D as there are words and then place those
words at the coordinate of the word in regular font. The thing is
Shape3D doesn't implement x, y and z so I cant get a single char
position in the object. I've tryied using the TextField3D.letters and
get each char's first vertex' coordinates but the result is not really
precise.

The only thing that works well is to remove the chars from one
TextField3D to add them in the new TextField3D, but with this solution
I can't chose the font. So I tried to outline the chars in the new
TextField to get a bold effect but I could'nt succeed making the
outline property of either the Shape3D or the TextField3D work (I also
tried the basic way using a WireFrame Material, but that doesn"'t give
the result I need, I also tried mixing the WireFrame Material with a
ColorMaterial in a Composite Material but Composite Material doesn't
accept WireFrame Materials)

So here's my question:what is the appropriate way to place some chars/
a TextField3D depending on chars in another TextField3D's position??

Li

unread,
Jan 12, 2009, 9:15:42 PM1/12/09
to away3...@googlegroups.com
Mmmmm... that is interesting.

TextField3D definitely doesn't support that =(
So far it's designed to use a single font per TextField3D object. It would also be pretty difficult (and not very precise from a typography point of view) to remove shapes from a word and replace them with another word using a different font. The TextField3D uses a penPosition object for paragraph construction and it takes into consideration the dimensions of the space character in the typo. The way I would do it would be to create some sort of array or dictionary object in TextField3D to hold references to different fonts and word index positions in the field. Then alter the generateText() method to swap fonts having reached the indexes.

You can have a go, I'll give it a try when I have time. I've just got too many things to do now... I'd be nice to have a little help too :D

If you want to try the word swapping thing, the TextField3D object now has a word getter which returns a bunch of shapes corresponding to that word. If you read the first vertex of the first word of that you can get the coordinates of the word inside the textfield, remove the shape and use this point to place your new word. Also, you would have to use a dummy textfield as a source of the injected words.

Anyway, this just made me think of doing a wishlist for the textfields branch so I can go tackling points while I have some free time. What do you think would be the best way to use a wishlist? All I can think of is using a post in this group... There must be something better.

Nice to see you using the branch in such depth cheers!

G.

unread,
Jan 13, 2009, 8:24:32 AM1/13/09
to away3d.dev
Hi Li,

I know swapping fonts would be too difficult, it's cool that you can
figure a way to do so because I didn't at all...

Concerning the word swapping, that's exactly what I tried: getting the
word's index, get the Shape3D corresponding in the words getter for
the first letter and get its vertex's coordinates, but the result is
not precise (the word in the new TextField is not at the same
position), I think it's because the coordinates given by the words
getters are the coordinates inside the TextField, so the matter is to
move the letters in the new textfield inside this textfield and I
still can't figure how :s as I couldn't find something like the
localToGlobal property (but maybe the function is not so tough, I will
make some researches)

What would you think about instead of drawing the shapes directly
inside the TextField3D object wrapping it inside a Sprite3D (which
will be added to the TextField)? I know it's totally different from
the philosophy of the textField3D as it is now but it could let us use
the x, y and z coordinates for instance.

Concerning the use of bold, I think the easyest way would be to do as
in other softwares: use false bold, and so add some outlines on the
characters. This is what I'm trying to do actually but I can't make
the outline property work and I can't find why, as I'm following the
documentation.

Anyway I would be glad to help you out though I'm not sure my level
with away3d is good enough...

about the wishilist it's a great idea, you could post it on your blog
maybe and I'm sure you'll get some good results (and I could help for
a wishlist too, I'm good for wishlists =))

Li

unread,
Jan 13, 2009, 9:15:07 AM1/13/09
to away3...@googlegroups.com
What you're saying about containing the letters as individual Sprite3D's instead of Shape3D's is really interesting. This would turn TextField3D into a container of Sprite3D more than a container of Shape3D's and probably give the class more options for this kind of stuff... I'd have to analyze that. Another possibility would be giving Shape3D's x and y properties, though I'm not sure if this would make sense. I'd have to analyze that too!!

Regarding the bold issue, you could use a quick solution while this stuff is decided: I can Imagine the process of identifying the word you want to bold, then for each shape in it calculate the mean x, y and z values (of the vertices) and use some kind of vector difference to augment the outlines of the glyfs. Check it out, I can give you a hand if you don't succeed.

And finally, about the help and your level and all that, I find that once you played around enough with something you begin to understand how it works. Once you've reached this point you find yourself modifying it freely and creating some interesting enhancements that could -and usually should- be incorporated into the official version of what you are using. So, if you want to help, my advice would be to keep doing whatever you want to your code at home even if you mess it up -you can always sync with the repo again- until you reach this point I was talking about...

I'll try to make a poll on my blog for the wishlist!!
cheers

G.

unread,
Jan 13, 2009, 12:44:22 PM1/13/09
to away3d.dev
Cool that my idea seems interesting.

About the help, I'm agree with you, so I will start experimenting some
ideas and some modifications and if something good comes out of it I
will show you so you can check and validate. I will try the container
idea for a start and maybe some other stuff if I have time.

about the quick fix for my outline issue, I see how to get the word's
index, how to get the corresponding shapes but i can't see how to
augment the outlines with vector differences. I also tried getting the
first shape's vertex to get it's position but I can't find a way to
adapt this position to the new textfield as this position is related
to the original textfield's coordinates and the new textfield
coordinates are related to the view's coordinates and I can't find a
way to make something like a localToGlobal :s

G.

unread,
Jan 13, 2009, 8:03:43 PM1/13/09
to away3d.dev
Hi again,

did some tests tonight, and gone into the path I wrote about lately,
so here's what I've done:

- made a class Char3D which extends Sprite3D and creates a single
character.
- modified TextField3D (actually I made another class so I can keep
the original safe ^_^ ) which now extends ObjectContainer3D (not sure
it's a good choice) and which basically creates the text by creating
single characters and then placing them (with some sort of native
wordWrapping).
- I kept mostly all the original getters (font, textSize,
paragraphWidth etc), and added a numLines one, maybe useful though i'm
not really sure. Also added the extrude methods.
- I renamed the words array in glyfs (don't know why actually but I'm
too tired to guess), and it now inexates the single chars (so it's
possible to get their x,y,z coordinates)
- I added a method to highlight some words with different font and/or
color. So it's possible to choose any expression inside the text and
make it in another font and/or color.
I also wanted to try to add some TextAlign features (center, right,
left) and/or make the texte centered natively, but you tell me if it's
really useful.
It's not totally optimized yet, though I think I have gained some
milliseconds in the text's creation (but it's only relevant on big
texts I guess)

tell me what you think about it (i'm trying to send the stuff via
yousendit, hope it will work this time)

cheers
G.

G.

unread,
Jan 13, 2009, 9:15:36 PM1/13/09
to away3d.dev
I'm sorry I might have been too tired, but in the TextField3DG class,
in the initVars method, you have to change the conditions with that
one:

if (init && init.textSize) _textSize = init.textSize;
else _textSize = 20;

if (init && init.letterSpacing) _letterSpacing =
init.letterSpacing;
else _letterSpacing = 0;

if (init && init.lineSpacing) _lineSpacing = init.lineSpacing;
else _lineSpacing = 0;

if (init && init.paragraphWidth) _paragraphWidth =
init.paragraphWidth;
else _paragraphWidth = 1000;

I forgot the case where init would be null

cheers
G

G.

unread,
Jan 14, 2009, 6:30:45 AM1/14/09
to away3d.dev
well, seems that I still can't send things to your email ...

G.

unread,
Jan 14, 2009, 7:52:43 AM1/14/09
to away3d.dev
ok I just discovered the place to upload files on the group ... I
really should sleep more ... anyway you can find the rar in the files
section.
keep me in touch
G

Li

unread,
Jan 14, 2009, 8:04:26 AM1/14/09
to away3...@googlegroups.com
Hey G,

Awesome work!! Can you upload or send a working demo of this with source? I've got my own battle here with other topics in the branch... I'll let the wishlist mature for a few days and take priorities from there while I solve my current problem. Once I get to text handling be sure I will consider these suggestions.

Please send a demo =)

Cheers

G.

unread,
Jan 14, 2009, 8:18:28 AM1/14/09
to away3d.dev
ok i prepare something for today
cheers

G.

unread,
Jan 14, 2009, 5:58:27 PM1/14/09
to away3d.dev
I uploaded a rar in the files section called TextElementSrc.rar

keep me in touch and bon courage ;)
cheers

G

Li

unread,
Jan 15, 2009, 6:26:24 AM1/15/09
to away3...@googlegroups.com
Cool, I'll take a look as soon as I can!
Thanks!!

G.

unread,
Jan 15, 2009, 12:47:46 PM1/15/09
to away3d.dev
ok then,

meanwhile I will continue my developements as I will use these classes
for my actual project, so I might add some new features etc but I'll
keep you in touch when the time comes.

bests
G
> ...
>
> plus de détails »

Li

unread,
Jan 15, 2009, 3:40:57 PM1/15/09
to away3...@googlegroups.com
Cool G!

I'm busy at the time developing more graphics stuff related to primitive shape rendering, like shading materials, backface culling, fixing sorting bugs, etc: http://www.lidev.com.ar/demos/textfieldsmaterials18/

I trust you will develop cool stuff on your end. So yey! Double development speed for the textfields branch!

cheers

G.

unread,
Jan 16, 2009, 1:11:30 PM1/16/09
to away3d.dev
hey there,

that's pretty neat what you're doing with the shading material.
and yep the textfield branch is going to be really cool ;)

peace
> ...
>
> plus de détails »

Li

unread,
Jan 16, 2009, 4:12:55 PM1/16/09
to away3...@googlegroups.com
yeaaaah
;D thanks

G.

unread,
Jan 17, 2009, 1:19:18 PM1/17/09
to away3d.dev
Hey,

I was wondering if there was a way to make Sprite3D able to add other
Sprite3D as children (in additon to the ability to add Shapes3D)? I've
seen on a parent class that there is an addElement() method, but it's
no more reachable at Sprite3D's level

Second thought: maybe it would be interesting that Shape3D would have
x,y and z coordinates (it would permit for example to build words from
single chars by only doing some addChild instead of redrawing
everything)
> ...
>
> plus de détails »

Li

unread,
Jan 17, 2009, 1:52:57 PM1/17/09
to away3...@googlegroups.com
G,

When I started designing the textfields branch, I tried to reproduce the Shape, Sprite, etc chain in the Actionscript API, but in 3D. Of course, I started by making it functional as simple as possible with the idea of extending it in the future so that it behaves just as that chain does. I was inspired to do this by Mathieu Badimon's Five3D engine. It functions just as the AS3 graphics chain... simple and beautiful =)

So currently we have a few things designed that sort of work that way, but not exactly.  A lot of functionality is missing in regard of this chain such as the ability of Sprite3D's to contain other Sprite3D's, etc. But before actually extending the branch to support these missing features, we are currently re-evaluating the core of the shape primitive in the branch: We're currently thinking about 2 options:

1) Extend the branch by making more classes so that the graphics chain is reproduced more precisely or

2) Remove this chain and make the shape primitive be inherent in other Away3D classes. Away3D already has a chain for this with classes like Object3D, ObjectContainer3D, etc so it could be redundant to design a whole new chain for elements that are based on shape primitives instead of face primitives...

As you see, the branch is currently near the end of it's first experimental stage. It is a good point to reframe it entirely and think about how it will oficially merge with the main branch. There are however more expriments to do... We are just begginning to understand the shape primitive, so a little more experimentation before the official framework is built wouldn't be bad.

So, the points you make are very good G, and all this will have to be considered upon deciding the future of the branch... What are your thought about all this?

Cheers,
Li

G.

unread,
Jan 17, 2009, 3:37:20 PM1/17/09
to away3d.dev
Well,

I started using 3D with Five3D, and I spent some times on the
different classes. I think Mathieu Badimon's philosophy on his
framework is actually the best and that it would have to be the
starting point of the developement of the branch, as you did.

concerning the options, I think that the best solution would be to mix
the two : from one point keeping the Away3D chain and create/redesign
classes so the branch would be the closest possible to the
ActionScript API.

Basically, and in regard to my experiments, and from a user's point of
view, I would see something like this:

- making the actual Shape3D class become a Graphics3D class, I mean
giving it the same functionalities as the Graphics class.
- making a Shape3D class which would basically be a wrapper for vector
shapes, with x, y and z coordinates (and maybe rotationX, rotationY,
rotationZ, though it's not really important for a start unlike x, y
and z coordinates)
- making a Sprite3D class a part of the actual chain, but with the
ability to add Shapes and other Sprites as children, and maybe have
something like the actual Sprite class in the API: a graphics getter/
setter (and Sprite being a mesh and not only a container would be the
best)

with that i think that the branch would have a solid basis and the
maximum flexibility. I've seen during my experiments with the
TextField3D primitive that designing the text letter by letter first
opens to more possibilities (such as spotting an expression, or
changing some words' font, isolating some words/expressions and being
able to act on it as a group, like changing its z property or make
some rotations) and is also faster with less code (and drawing the
text content word by word is even faster but it reduces the
possibilities).

what are you thinking about it?


Peace
G
> ...
>
> plus de détails »

Li

unread,
Jan 17, 2009, 6:02:20 PM1/17/09
to away3...@googlegroups.com
Well, all this makes sense. But...

As I said before, we need to experiment with shape primitives a bit more before deciding which is the best way to incorporate them in the framework. A shape primitive is different from a face primitive in that it can have much more than 3 vertices, besides from containing different ways to concatenate them. Given that the engine is designed to work with tri-faces, this makes shape primitives come into conflict at particular situations. With this, I'm reconsidering a complete re-structuring of the branch right now. Perhaps an extension of the core face element that supports curved sides, I dont know... There is a lot to experiment before advancing, but the inflection point is close. An implementation like that would indeed be very powerful.

G.

unread,
Jan 17, 2009, 8:10:02 PM1/17/09
to away3d.dev
I see... and that's also why there were some angles where the extrude
materials become transparents I guess...
anyway don't forget to keep me aware of the evolutions
> ...
>
> plus de détails »

Li

unread,
Jan 17, 2009, 8:15:30 PM1/17/09
to away3...@googlegroups.com
Sure!

Let me know if you want to participate in the core of the development.

G.

unread,
Jan 17, 2009, 8:47:51 PM1/17/09
to away3d.dev
well I'm always ok to help but it depends of the level of knowledge
needed ^_^'

oups seems that the calculateOrientationXY() method has something
wront when the character is a space :s
> ...
>
> plus de détails »

G.

unread,
Jan 17, 2009, 8:49:17 PM1/17/09
to away3d.dev
I'm always up to give a hand, but as long as I'm helpul, so if I can,
it will be with pleasure :)

seems that there is a problem with the calculateOrientationXY method
when the character is a space :s

On 18 jan, 02:15, Li <paleblue...@gmail.com> wrote:
> ...
>
> plus de détails »

G.

unread,
Jan 17, 2009, 8:47:51 PM1/17/09
to away3d.dev
well I'm always ok to help but it depends of the level of knowledge
needed ^_^'

oups seems that the calculateOrientationXY() method has something
wront when the character is a space :s

On 18 jan, 02:15, Li <paleblue...@gmail.com> wrote:
> ...
>
> plus de détails »

Li

unread,
Jan 17, 2009, 9:00:19 PM1/17/09
to away3...@googlegroups.com
Thanks G, fixed.

Li

unread,
Jan 17, 2009, 9:17:36 PM1/17/09
to away3...@googlegroups.com
About the help, contact me paleb...@gmail.com and we can discuss it. I really could use some help!

G.

unread,
Jan 17, 2009, 9:58:30 PM1/17/09
to away3d.dev
do you have another email adress? for some obscur reason each time I
try to contact you i'm redirected to pale...@gmail.com (without the
dots), the person who receive the email is very gentle but I don't
like bothering her like that :s
mine is 090...@gmail.com

On 18 jan, 03:17, Li <paleblue...@gmail.com> wrote:
> About the help, contact me paleblue...@gmail.com and we can discuss it. I
> really could use some help!
>
>
>
> On Sun, Jan 18, 2009 at 12:00 AM, Li <paleblue...@gmail.com> wrote:
> > Thanks G, fixed.
>
> ...
>
> plus de détails »
Reply all
Reply to author
Forward
0 new messages