Adding mesh from 3DS doesn’t work

Software: Away3D 4.x

christiancillo, Newbie
Posted: 17 January 2013 01:21 PM   Total Posts: 8

Hello!

I’m trying to add a mesh from 3DS to Away3D, and i made it work before in another project. But i surely have forgotten something, since i’m trying again in another and i keep getting this Error:

AARun3\src\away3d\animators\states\AnimationClipState.as, Line 172 1067: Implicit coercion of a value of type away3d.animators.states:AnimationClipState to an unrelated type away3d.animators:IAnimationState.

I looked lots of times and I cant find a difference with the other code or anything different. I’ll show you the code, i appreciate your time.

package  {
 
 import flash
.display.MovieClip;
 
import away3d.containers.Scene3D;
 
import away3d.cameras.Camera3D;
 
import away3d.containers.View3D;
 
import flash.media.Camera;
 
import flash.geom.Vector3D;
 
import flash.events.Event;
 
import away3d.entities.Mesh;
 
import away3d.primitives.CubeGeometry;
 
import away3d.materials.ColorMaterial;
 
import away3d.textures.BitmapTexture;
 
import away3d.materials.TextureMaterial;
 
import away3d.lights.DirectionalLight;
 
import away3d.lights.PointLight;
 
import away3d.materials.lightpickers.StaticLightPicker;
 
import away3d.materials.methods.FilteredShadowMapMethod;
 
import away3d.primitives.PlaneGeometry;
 
import away3d.primitives.SphereGeometry;
 
import away3d.containers.ObjectContainer3D;
 
import away3d.loaders.Loader3D;
 
import away3d.loaders.misc.AssetLoaderContext;
 
import flash.display.Loader;
 
import away3d.events.AssetEvent;
 
import flash.net.URLRequest;
 
import away3d.loaders.parsers.*;
 
import away3d.library.assets.*;
 
import jiglib.physics.RigidBody;
 
import jiglib.plugin.away3d4.Away3D4Physics;
 
import jiglib.plugin.away3d4.*;
 
import flash.events.*;
 
import flash.utils.Timer;
 
import away3d.controllers.HoverController;
 
 
 
 public class 
Run3 extends MovieClip 
 {
  
  
//Embeds
  
[Embed(source="txt/road.jpg")]
     
private var roadT:Class;
  
  
//Engine Variables
  
public var view:View3D;
  public var 
cam:Camera3D;
  public var 
scene:Scene3D;
  
  
//Camera Controllers
  
public var camCnt:HoverController;
  
  
//3D Loaders
  
public var meshLd:Loader3D;
  
  public var 
suelo:Mesh;
  public var 
suelo2:Mesh;
  
  public var 
sueloM:TextureMaterial;
  
  
  public var 
car:Mesh;
  
  public var 
i:int;
  
  
//navigation variables
  
private var move:Boolean false;
  private var 
lastPanAngle:Number;
  private var 
lastTiltAngle:Number;
  private var 
lastMouseX:Number;
  private var 
lastMouseY:Number;
  
  
  
  public function 
Run3() 
  
{
   addEngine
();
   
addElements();
   
addLights();
   
addListeners();
   
addGUI();
  
}
  
  
public function addEngine():void
  {
   scene 
= new Scene3D();
   
   
cam = new Camera3D();
   
   
view = new View3D();
   
view.antiAlias 4;
   
view.scene scene;
   
view.camera cam;
   
   
stage.addChild(view);
   
   
//setup camera Controller
   
camCnt = new HoverController(cam);
   
camCnt.distance 500;
   
camCnt.minTiltAngle 0;
   
camCnt.maxTiltAngle 90;
   
camCnt.panAngle 0;//45
   
camCnt.tiltAngle 20;
   
  
}
  
  
public function addElements():void
  {
   
   sueloM 
= new TextureMaterial(Cast.bitmapTexture(roadT));
   
sueloM.repeat true;
   
sueloM.mipmap false;
   
   
suelo = new Mesh(new PlaneGeometry(200,200), sueloM);
   
suelo.geometry.scaleUV(2,2);
   
suelo.0;
   
   
scene.addChild(suelo);
   
   
suelo2 = new Mesh(new PlaneGeometry(200,200), sueloM);
   
suelo2.geometry.scaleUV(2,2);
   
suelo2.0;
   
suelo2.200;
   
   
scene.addChild(suelo2);
   
   
loading3DMesh();
   
   
  

  
//addElements related funcs
  
  
public function loading3DMesh():void
  {
   Parsers
.enableAllBundled();
   var 
parseador:AssetLoaderContext = new AssetLoaderContext();
   
Loader3D.enableParser(Max3DSParser);
   
   
meshLd = new Loader3D();
   
meshLd.addEventListener(LoadEvent.RESOURCE_COMPLETEloaderHandler);
   
meshLd.load( new URLRequest("audi/a4_a.3DS"), parseador);
   
   
   
   
   
  
}
  
  
  
public function loaderHandler(e:AssetEvent):void
  {
   
if(e.asset.assetType == AssetType.MESH)
   
{
    car 
e.asset as Mesh;
    
car.position = new Vector3D(100,0,100);
    
    
scene.addChild(car);
   
}
   
  }
  
  
public function addLights():void
  {
   
  }
  
  
public function addListeners()
  
{
   stage
.addEventListener(Event.ENTER_FRAME,onEnterFrame);
   
stage.addEventListener(MouseEvent.MOUSE_DOWNonMouseDown);
   
stage.addEventListener(MouseEvent.MOUSE_UPonMouseUp);
   
  
}
  
//Listener Handlers
  
public function onEnterFrame(e:Event):void
  {
   
if (move{
    camCnt
.panAngle 0.3*(stage.mouseX lastMouseX) + lastPanAngle;
    
camCnt.tiltAngle 0.3*(stage.mouseY lastMouseY) + lastTiltAngle;
   
}
   view
.render();
  
}
  
  
private function onMouseDown(event:MouseEvent):void
  {
   lastPanAngle 
camCnt.panAngle;
   
lastTiltAngle camCnt.tiltAngle;
   
lastMouseX stage.mouseX;
   
lastMouseY stage.mouseY;
   
move true;
   
stage.addEventListener(Event.MOUSE_LEAVEonStageMouseLeave);
  
}

  
/**
   * Mouse up listener for navigation
   */
  
private function onMouseUp(event:MouseEvent):void
  {
   move 
false;
   
stage.removeEventListener(Event.MOUSE_LEAVEonStageMouseLeave);
  
}

  
/**
   * Mouse stage leave listener for navigation
   */
  
private function onStageMouseLeave(event:Event):void
  {
   move 
false;
   
stage.removeEventListener(Event.MOUSE_LEAVEonStageMouseLeave);
  
}

  
  
  
  
//Fin Listener Handlers
  
public function addGUI():void
  {
   
  }
 }
 
   

Qbrain, Member
Posted: 17 January 2013 10:28 PM   Total Posts: 92   [ # 1 ]

you forgot to:

import away3d.animators.*;
import away3d.animators.states.*; 

but, thinking about that right now… that “could” not solve the problem.
Do you use the most updated version of away3D? Seems like an integration issue if an .as file from away3d doesn’t have an import ready…

-Q

   

christiancillo, Newbie
Posted: 18 January 2013 03:07 AM   Total Posts: 8   [ # 2 ]

Thanks for answering, Q. I do use the latest version of Away3D. What bothers me most is that i have a really close example of this working on another project, loading the same file.3DS. And i can’t make it work since i have changed some stuff, and i can’t figure out what.

I’m using Flash Professional, just in case anyone was wondering. I’m very very frustrated right now!!

Thanks!

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X