我是As和Flash的新手,我需要通过Actionscript中的代码镜像一半的汽车。有人可以帮我编码吗?我在网上看过,但对我来说似乎没什么好看的。
我在Flash Professional CS6的main.as文件中有很多'CarParts'.as文件,其中一些文件要镜像以保存数据,例如:carPaintLeft.as,wheelsLeft.as,rimsLeft.as, windowsLeft.as,carLeft.as,...所有这一切都必须在我的X轴中从我的绘图中心(x0,y0,z0)进行镜像。
例如,这里是PaintInstance.as,一个包含9个不同网格的数据文件(在这种情况下,它们都具有相同的材质:car Paint,例如红色)。我在Main.as文件中导入它,我需要镜像所有它(9个网格)。我怎样才能在Main.as中对此进行编码,在哪里编码,或者我应该在PaintInstance.as中进行编码?这是我的PaintInstance.as:
package
{
import ASBase;
import away3d.containers.ObjectContainer3D;
import away3d.entities.Mesh;
import away3d.core.base.Geometry;
import away3d.materials.MaterialBase;
import away3d.core.base.Geometry;
import away3d.materials.ColorMaterial;
import data.Hood_coverData;
import flash.display.Bitmap;
import data.Sideclosures_mainbodytopData;
import data.Extmirror_bodypart_iData;
import data.Fender_bodypartData;
import data.Frontdoor_bodyData;
import data.Sidemoldingpart_iData;
import data.Sidemoldingpart_iiData;
import data.Frontdoor_doorhandlepart_iData;
import data.Frontdoor_doorhandlepart_iiData;
public class PaintInstance extends ASBase
{
function PaintInstance ():void
{
super();
buildMaterials();
generate();
}
private function generate():void
{
var cont_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var cont:ObjectContainer3D = buildContainer( cont_rd, "cont", null);
var hood_coverData:Hood_coverData = new Hood_coverData();
var geomhood_cover:Geometry = hood_coverData.geometryData;
var hood_cover_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var hood_cover:Mesh = buildMesh(geomhood_cover, hood_cover_rd, "hood_cover", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
hood_cover.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
var sideclosures_mainbodytopData:Sideclosures_mainbodytopData = new Sideclosures_mainbodytopData();
var geomsideclosures_mainbodytop:Geometry = sideclosures_mainbodytopData.geometryData;
var sideclosures_mainbodytop_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var sideclosures_mainbodytop:Mesh = buildMesh(geomsideclosures_mainbodytop, sideclosures_mainbodytop_rd, "sideclosures_mainbodytop", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
sideclosures_mainbodytop.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
var extmirror_bodypart_iData:Extmirror_bodypart_iData = new Extmirror_bodypart_iData();
var geomextmirror_bodypart_i:Geometry = extmirror_bodypart_iData.geometryData;
var extmirror_bodypart_i_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var extmirror_bodypart_i:Mesh = buildMesh(geomextmirror_bodypart_i, extmirror_bodypart_i_rd, "extmirror_bodypart_i", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
extmirror_bodypart_i.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
var fender_bodypartData:Fender_bodypartData = new Fender_bodypartData();
var geomfender_bodypart:Geometry = fender_bodypartData.geometryData;
var fender_bodypart_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var fender_bodypart:Mesh = buildMesh(geomfender_bodypart, fender_bodypart_rd, "fender_bodypart", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
fender_bodypart.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
var frontdoor_bodyData:Frontdoor_bodyData = new Frontdoor_bodyData();
var geomfrontdoor_body:Geometry = frontdoor_bodyData.geometryData;
var frontdoor_body_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var frontdoor_body:Mesh = buildMesh(geomfrontdoor_body, frontdoor_body_rd, "frontdoor_body", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
frontdoor_body.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
var sidemoldingpart_iData:Sidemoldingpart_iData = new Sidemoldingpart_iData();
var geomsidemoldingpart_i:Geometry = sidemoldingpart_iData.geometryData;
var sidemoldingpart_i_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var sidemoldingpart_i:Mesh = buildMesh(geomsidemoldingpart_i, sidemoldingpart_i_rd, "sidemoldingpart_i", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
sidemoldingpart_i.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
var sidemoldingpart_iiData:Sidemoldingpart_iiData = new Sidemoldingpart_iiData();
var geomsidemoldingpart_ii:Geometry = sidemoldingpart_iiData.geometryData;
var sidemoldingpart_ii_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var sidemoldingpart_ii:Mesh = buildMesh(geomsidemoldingpart_ii, sidemoldingpart_ii_rd, "sidemoldingpart_ii", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
sidemoldingpart_ii.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
var frontdoor_doorhandlepart_iData:Frontdoor_doorhandlepart_iData = new Frontdoor_doorhandlepart_iData();
var geomfrontdoor_doorhandlepart_i:Geometry = frontdoor_doorhandlepart_iData.geometryData;
var frontdoor_doorhandlepart_i_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var frontdoor_doorhandlepart_i:Mesh = buildMesh(geomfrontdoor_doorhandlepart_i, frontdoor_doorhandlepart_i_rd, "frontdoor_doorhandlepart_i", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
frontdoor_doorhandlepart_i.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
var frontdoor_doorhandlepart_iiData:Frontdoor_doorhandlepart_iiData = new Frontdoor_doorhandlepart_iiData();
var geomfrontdoor_doorhandlepart_ii:Geometry = frontdoor_doorhandlepart_iiData.geometryData;
var frontdoor_doorhandlepart_ii_rd:Vector.<Number> = Vector.<Number>([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);
var frontdoor_doorhandlepart_ii:Mesh = buildMesh(geomfrontdoor_doorhandlepart_ii, frontdoor_doorhandlepart_ii_rd, "frontdoor_doorhandlepart_ii", getMaterialFromID("FrontDoor_DoorHandlePart_II0"), cont);
frontdoor_doorhandlepart_ii.subMeshes[0].material = getMaterialFromID("FrontDoor_DoorHandlePart_II0");
}
private function buildMaterials():void
{
var material:MaterialBase;
material = generateMaterial("FrontDoor_DoorHandlePart_II0", 0xFF0000);
ColorMaterial(material).alpha = 1;
ColorMaterial(material).ambientColor = 0x0;
ColorMaterial(material).specularColor = 0x0;
ColorMaterial(material).specular = 0;
}
}
}
这就是我所拥有的一切,但我真的不明白,有人可以帮助我吗?在speudo代码中 循环遍历yourPrefabClass.meshes if(yourPrefabClass.meshes [indexloop] .name ==“theNameOfTheWheelMeshThaTIWantToMirror”)
var myWheel:Mesh = yourPrefabClass.meshes[indexloop];
var mirror:Mirror = new Mirror();
mirror.apply(myWheel, Mirror.X_AXIS, Mirror.CENTER, 0);
那么,例如对我来说就是?:
private function Mirror(): void
{
for (PaintInstance.meshes)
{
if (PaintInstance.meshes["Hood_Cover","sideclosures_mainbodytop","extmirror_bodypart_i","fender_bodypart","frontdoor_body","sidemoldingpart_i","sidemoldingpart_ii","frontdoor_doorhandlepart_i","frontdoor_doorhandlepart_ii"].name == “Hood_Cover”)
{
var Hood_Cover:Mesh = PaintInstance.meshes["Hood_Cover","sideclosures_mainbodytop","extmirror_bodypart_i","fender_bodypart","frontdoor_body","sidemoldingpart_i","sidemoldingpart_ii","frontdoor_doorhandlepart_i","frontdoor_doorhandlepart_ii"];
var mirror:Mirror = new Mirror ();
mirror.apply(Hood_Cover, Mirror.X_AXIS, Mirror.CENTER, 0);
}
}
}
他们告诉我:对于很多网格我必须在class.meshes循环中插入一个switch语句,并在switch case中有一个专用的镜像函数,你可以在这里推送一堆镜像命令
像
开关(mesh.name){ 案例“myWheel”: doMirror(mesh,[xmax,zmin]);
我知道对你们中的一些人来说可能很清楚,但我基本上都不知道动作脚本和lil编程,现在我需要这样做......有人可以告诉我我要替换什么吗? / p>
提前多多感谢