object3d as Mesh problem

14 views
Skip to first unread message

desgraci

unread,
Jul 18, 2009, 12:10:18 PM7/18/09
to away3d.dev
getting a null error when i try this:


model1 = Collada.parse(Charmesh, {scaling:1,
material:manaC});
model1.mouseEnabled=false;

mesha = model1.getChildByName("model") as Mesh;
mesha.rotationY+=180;
mesha.rotationZ+=180;
mesha.ownCanvas=true;
mesha.pushfront=true;
mesha.name="Mesh Alpha";
var rx:Number= new Number(Math.round(Math.random() * (10000))
-5000);
var ry:Number= new Number(Math.round(Math.random() * (10000))
-5000);
var rz:Number= new Number(Math.round(Math.random() * (10000))
-5000);
mesha.x=rx;
mesha.y=ry;
mesha.z=rz;
scene.addChild(mesha);

meshc = model1.getChildByName("lpmodel") as Mesh;
meshc.rotationY+=180;
meshc.rotationZ+=180;
meshc.ownCanvas=true;
meshc.pushfront=true;
meshc.name="Mesh Charlie";
scene.addChild(meshc);

if i only add mesha works, if i add meshc, sucks

why? btw im using global vars

desgraci

unread,
Jul 18, 2009, 1:52:14 PM7/18/09
to away3d.dev
or at least thers a way to imlemetn mesha=meshb, and have them in
different postions?

ben

unread,
Jul 18, 2009, 4:45:57 PM7/18/09
to away3d.dev
HI,
I took a fast look it's always better to handle your parse and get
your meshes when your file (geometry and material is completely
loaded),
something like :
model1 = Collada.load(Charmesh, {scaling:1,
material:manaC}); //load is diffrent from parse , it retrun an
Object3DLoader instead of an ObjectContainer3D,
then you can had it a success event to make sure your geometry and
materials from your collada are welle loaded and parsed:

model1.addOnSuccess(getObject);

function getObject(e:LoaderEvent):void
{
now you are getting a
ObjectContainer3D(e.loader.handle).children are the array of
object3D contained in your loader (usefull to trace)
if you have only one object
var mesha:Mesh = (ObjectCOntainer3D(e.loader.handle).children[0] as
Mesh;//or cast as Object3D
or
var mesha:Mesh = ObjectCOntainer3D(e.loader.handle).getChildByName
("lpmodel") as Mesh;
then your stuff...
};

desgraci

unread,
Jul 19, 2009, 11:13:41 AM7/19/09
to away3d.dev
i dint considered the loader, due to the fact that it was calling the
first model, so there wouldnt be problem calling a second one, but ill
try it out, i think that may be the reason of the null object, i think
im was too satured of code :p

Also it can help me to have model/loader by separate so i can use some
properties of meshes that arent in containers (hope so XD)

anyway il try and let u know tx ben.

desgraci

unread,
Jul 19, 2009, 11:48:24 AM7/19/09
to away3d.dev

modelaL = Collada.load("assets/model.dae", {scaling:
1,material:manaC});
modelaL.addOnSuccess(llamo);
function llamo(e:LoaderEvent):void{
mesha = (ObjectContainer3D(e.loader.handle).getChildByName
("lpmodel") as Mesh);
meshb = (ObjectContainer3D(e.loader.handle).getChildByName
("lpmodel") as Mesh);
meshc = (ObjectContainer3D(e.loader.handle).getChildByName
("lpmodel") as Mesh);
scene.addChild(mesha);
scene.addChild(meshb);
scene.addChild(meshc);

}
no luck.

ben

unread,
Jul 19, 2009, 3:18:54 PM7/19/09
to away3d.dev
ok, here is the mistake :
you are giving 3 reference to a same object (your mesh ) but this
doesn't duplicate it at all !
the fact is that when you're addin your mesha object it's a kind of
empty reference as the lpmodel is now associated to meshc =
mesha and meshb are null !


>                         mesha = (ObjectContainer3D(e.loader.handle).getChildByName
> ("lpmodel") as Mesh);
>                         meshb = (ObjectContainer3D(e.loader.handle).getChildByName
> ("lpmodel") as Mesh);
>                         meshc = (ObjectContainer3D(e.loader.handle).getChildByName
> ("lpmodel") as Mesh);
>                         scene.addChild(mesha);
>                         scene.addChild(meshb);
>                         scene.addChild(meshc);
>
>                 }


if you want to duplicate :

function llamo(e:LoaderEvent):void{
var temporaryRef:Object3D = (ObjectContainer3D
(e.loader.handle).getChildByName("lpmodel") as Obejct3D;
Object3D(mesha) = temporaryRef.clone();
Object3D(meshb) = temporaryRef.clone();
Object3D(meshc) = temporaryRef.clone();
scene.addChild(mesha);
scene.addChild(meshb);
scene.addChild(meshc);
}

that should work

desgraci

unread,
Jul 20, 2009, 10:42:30 AM7/20/09
to away3d.dev
im using v10 branch, ths is using flex SDK 4, and is telling me:

1105: Target of assignment must be a reference value.

This error means you are trying to assign a value to a value, and not
a value to a variable.

and well, Object3D(mesha) i think is not a variable.

anyway, im interested in reading more about that info u put, do u have
a blog or a place where i can research about how to use the references
in away3d components to see how do they work.

I cant google anything good on this so im kinda lost, and to be honest
is not my style to be asking so much, but i have a personal record of
post in the group asking this month :''(

anyway, i tried to make an Object:

private var objeto3D:Object3D=new Object3D();

and use it as
objeto3D(mesha) = temporaryRef.clone();

objeto3D.Object3D(mesha)= temporaryRef.clone();

mesha.Object3D()= temporaryRef.clone();

the last ones they are properties i think they dont get the value, so
where to shoot at now?
but got the same mistake

ben

unread,
Jul 20, 2009, 11:09:50 AM7/20/09
to away3d.dev
the lines :
private var objeto3D:Object3D=new Object3D();
objeto3D(mesha) = temporaryRef.clone();

when I do :
Object3D(mesha) this is not yourobject(mesha)
this is simple casting (that means that we pass mesha as a Object3D
instead of a mesh to the compiller (but it's still a mesh), that way
we access to properties and method inehrited
from Object3D (a parent class of Mesh).

It says to teh compiller my mesh is an Object3D: " believe me and do
what I want, there is no error !"
It's like when a silly guy want to enter in a very hip nightClub he
cast itself with a beautifull car, but he's still an assHole, and he
fluently prove it later...

Google for casting as3

the method :
aMesh.clone() return an Object3D,
so if you say aMesh = anObject3D you get an error
so you cast, in pseudocode :
itIsAnObject3D(aMesh) = Object3D

I hope you understand, this is very simple.
you just have to declare your mesha meshb, etc...
then do this:

Object3D(mesha) = temporaryRef.clone();

desgraci

unread,
Jul 20, 2009, 11:19:48 AM7/20/09
to away3d.dev
"im using v10 branch, ths is using flex SDK 4, and is telling me:

1105: Target of assignment must be a reference value.

This error means you are trying to assign a value to a value, and not
a value to a variable.

and well, Object3D(mesha) i think is not a variable. "

what i meaned is that this as what i was getting when i copy paste

desgraci

unread,
Jul 20, 2009, 11:22:56 AM7/20/09
to away3d.dev
to be more exact:

my function looks like this now:

function llamo(e:LoaderEvent):void{
var temporaryRef:Object3D = (ObjectContainer3D
(e.loader.handle).getChildByName("lpmodel") as Obejct3D;
Object3D(mesha) = temporaryRef.clone();
Object3D(meshb) = temporaryRef.clone();
Object3D(meshc) = temporaryRef.clone();
scene.addChild(mesha);
scene.addChild(meshb);
scene.addChild(meshc);

}

what i was trying to say is that i also trying to acces any other way
to cast it as an Object3D, or to add it, or to acces it or do
something ( i was little desesperado in that moment i admit it :p)

thanks in advance man, but this is the error that keeps throwing me now

ben

unread,
Jul 20, 2009, 11:29:11 AM7/20/09
to away3d.dev
without typing mistake: without parenthesis before ObjectContainer3D ,
and with Object3D and not Obejct3D,
that should work, I use it that way everytime (even when I sleep !)

do you have the same error ??
1105: Target of assignment must be a reference value.



desgraci

unread,
Jul 20, 2009, 11:34:05 AM7/20/09
to away3d.dev
AAHHH!!! YOU MEAN LIKE THIS

http://www.ierafaelperez.co.cc/ohmy.JPG

yes i do XD

no seriously, wheres else could be the problem, maybe libraries?

desgraci

unread,
Jul 20, 2009, 11:53:40 AM7/20/09
to away3d.dev
btw the mistakes u mentioned was cause i copied-pasted the previous
text from this post, sry if there was a confusion. I alwasy rewrite
the code, and make sure its clean without mistakes. It's not working,
i ask about libraries cause (and dont laugh if is nothing to do like
that) maybe theres something ur calling that i dont, that allows u do
that, thats why i gave the version of SDK im using, here are my
libraries:

import away3d.animators.PathAnimator;
import away3d.animators.SkinAnimation;
import away3d.animators.data.Path;
import away3d.cameras.Camera3D;
import away3d.containers.ObjectContainer3D;
import away3d.containers.Scene3D;
import away3d.containers.View3D;
import away3d.core.base.Mesh;
import away3d.core.base.Object3D;
import away3d.core.clip.Clipping;
import away3d.core.clip.NearfieldClipping;
import away3d.core.clip.FrustumClipping;
import away3d.core.clip.RectangleClipping;
import away3d.core.math.Number3D;
import away3d.core.render.Renderer;
import away3d.core.utils.Cast;
import away3d.lights.DirectionalLight3D;
import away3d.loaders.Collada;
import away3d.loaders.Object3DLoader;
import away3d.materials.BitmapMaterial;
import away3d.materials.CompositeMaterial;
import away3d.materials.Dot3BitmapMaterial;
import away3d.materials.MovieMaterial;
import away3d.overlays.LensFlare;
import away3d.primitives.Cube;
import away3d.primitives.Plane;
import away3d.primitives.Sphere;
import away3d.events.MouseEvent3D;
import away3d.events.LoaderEvent;

//import away3d.primitives.SeaTurtle;

import caurina.transitions.Tweener;

import com.as3dmod.ModifierStack;
import com.as3dmod.modifiers.Bend;
import com.as3dmod.modifiers.Perlin;
import com.as3dmod.plugins.away3d.LibraryAway3d;
import com.as3dmod.util.ModConstant;
import com.as3dmod.util.Phase;
import com.as3dmod.util.XMath;

import flash.display.Sprite;
import flash.display.StageQuality;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.filters.BlurFilter;
import flash.filters.DropShadowFilter;
import flash.filters.GlowFilter;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Keyboard;
import flash.utils.getTimer;

as you see, i take care even of not importing librarie.* i.e.

I apreciate ur help but also give me a little credit, i have been with
this problem about 3 days ago.

anyway im googlin again to see if i find a relation between this error
and the casting, but i dont find the documentation.

If someone find why, or have faced this before let me know.

desgraci

unread,
Jul 20, 2009, 12:07:48 PM7/20/09
to away3d.dev
btw:
ClassName(ObjectToCast)

i also imported:

import away3d.core.base.Object3D;

no luck, that was i meaned with the libraries.

Any idea?

desgraci

unread,
Jul 20, 2009, 12:09:27 PM7/20/09
to away3d.dev
sry language:
" i dint add the library"

is :

i checked that there was that library

desgraci

unread,
Jul 20, 2009, 12:26:29 PM7/20/09
to away3d.dev
a last thing ben

function llamo(e:LoaderEvent):void{
var temporaryRef:Object3D = (ObjectContainer3D
(e.loader.handle).getChildByName("lpmodel") as Obejct3D;
Object3D(mesha) = temporaryRef.clone();
Object3D(meshb) = temporaryRef.clone();
Object3D(meshc) = temporaryRef.clone();
scene.addChild(mesha);
scene.addChild(meshb);
scene.addChild(meshc);

}

i never used that code, maybe i wasnt clear before, but i check every
code i use, and i corrected since the first time, and was getting the
same mistake since the firt time, i just dont want you to think that
im wasting ur time here, or im totally clueless, i want to amke this
clear cause ure the one that has been helping me.

ben

unread,
Jul 20, 2009, 1:33:30 PM7/20/09
to away3d.dev
You're not wasting my time, but I don't why this just can't work for
you...

so ...
try just to clone the loader.handle we'll have one telmporary value
less...

mesha=(e.loader.handle).clone();
and also try
mesha = Object3D(ObjectContainer3D(e.loader.handle).getChildByName
("lpmodel")).clone(); /// not very pretty but that will help fix the
bug...
tell me what's hapenin'.

"i never used that code"
so what's yours right now ???

ben

unread,
Jul 20, 2009, 1:38:47 PM7/20/09
to away3d.dev
Looking at your other trhead you are using Collada.parse() ?

desgraci

unread,
Jul 20, 2009, 1:40:56 PM7/20/09
to away3d.dev
nope i also changed that from the start, loading with,, errr uhhm,
loader :p, here:

ben

unread,
Jul 20, 2009, 1:45:00 PM7/20/09
to away3d.dev
Wow strange it doesn't work...
ok would you gimme your code and model so that I try compil, and have
a closer look. Here is my mail :
benjamin(at)agence-anonyme.com

i'll have a look later now is barbecue time !!!! sorry !
;-)

desgraci

unread,
Jul 20, 2009, 1:49:08 PM7/20/09
to away3d.dev
baout :"i never used that code"

i meaned "i never used the code u posted cause it had spells mistakes
(ortographic mistake, not sure how to write that)"

this is my code:

var temporaryRef:Object3D = ObjectContainer3D
(e.loader.handle).getChildByName("lpmodel") as Object3D;
Object3D(mesha) = temporaryRef.clone();
Object3D(meshb) = temporaryRef.clone();
Object3D(meshc) = temporaryRef.clone();
scene.addChild(mesha);
scene.addChild(meshb);
scene.addChild(meshc);

and always has been since u sugest it me from the first time

ben

unread,
Jul 20, 2009, 1:55:27 PM7/20/09
to away3d.dev
I told you in the other topic, send me your source..

desgraci

unread,
Jul 20, 2009, 1:57:45 PM7/20/09
to away3d.dev
btw ben i tried both methods same mistake :''(, i mean 8'''C

im going to try with others models on internet, if not working sending
them to you

desgraci

unread,
Jul 20, 2009, 2:01:01 PM7/20/09
to away3d.dev
a last thing i know u dont work for me, i havent said u have to, or is
your obligation, or even so, rewrite my code, give me the entire code
working, i have never asked for that to anyone, ever, dont get mad, in
fact i knwo u sacrificae time u could be drinking a beer, or going to
beach to help a looser like me, is just that im not a native english,
so maybe im not very good making clear what i think, or want to say.

And good look with the barbecue :D, see ya later.

desgraci

unread,
Jul 20, 2009, 2:30:51 PM7/20/09
to away3d.dev
ahhh, sorry about that XD

You're not wasting my time, but I don't why this just can't work for
you.

in (the now for me evil) google language tool, came something like, "i
dont know, i juas cant be doing the work for you"

when u really meaned "i dont know why this solution isnt working for
you in your code."

an international problem :D.

we should do a promo:

away3d, breaking the language barriers...


ben

unread,
Jul 21, 2009, 4:51:12 AM7/21/09
to away3d.dev
You're welcome ;-)

desgraci

unread,
Jul 21, 2009, 10:26:34 AM7/21/09
to away3d.dev
ok ben heres the code, i dint uploaded the big thing, but it has the
same problem.

http://www.ierafaelperez.co.cc/testforben.as

thanks for the patiente dude, i will send it to ur mail also.

ben

unread,
Jul 21, 2009, 11:00:10 AM7/21/09
to away3d.dev
try this:

first declare mesha, meshb and meshc as Object3D not Mesh in your
private var

then:

function llamo(e:LoaderEvent):void{
var temporaryRef:Object3D = ObjectContainer3D
(e.loader.handle).getChildByName("polySurface1") as Object3D;
trace(temporaryRef)///hope your sure to have a polySurface1 in your
scene
/// 1 - now we are cloning the geometry and materials of the object as
Mesh:
mesha = Mesh(temporaryRef).clone();
meshb = Mesh(temporaryRef).clone();
meshc = Mesh(temporaryRef).clone();
//2 - and here the other variable of the object as Object3D
(transform, position, canvas, session, etc...), you probably don't
need it
temporaryRef.clone(mesha);
temporaryRef.clone(meshb);
temporaryRef.clone(meshc);
///
scene.addChild(mesha);
scene.addChild(meshb);
scene.addChild(meshc);
}

and try also to add;
mesha = new Object3D;
then call cloning...
meshb = new Object3D;
then call cloning...

tell me...I don't see anything else (but I'm workin in the meanTime
so, I could skip one error...)

desgraci

unread,
Jul 21, 2009, 11:31:17 AM7/21/09
to away3d.dev
black screen.

btw did u get the same mistakes i did?

ben

unread,
Jul 21, 2009, 11:40:09 AM7/21/09
to away3d.dev
what black screen !!!! ARRGGHH ! !!

well no error were returned ??

desgraci

unread,
Jul 21, 2009, 11:46:38 AM7/21/09
to away3d.dev
nope

desgraci

unread,
Jul 21, 2009, 11:47:23 AM7/21/09
to away3d.dev
man a diferent question, my balls r going blue with this to be honest,
theres a way to export the bone animation and just use a .3ds?
Reply all
Reply to author
Forward
0 new messages