clatterrr / ProjectSoyo

ProjectSoyo
0 stars 0 forks source link

Close And Far #1

Open clatterrr opened 3 months ago

clatterrr commented 3 months ago
void CameraSharpMovement(int startFrame, int endFrame, GameObject lookat)
{
    float startDegree = Random.Range(0.0f, 360.0f);
    float nextDegree = Random.Range(-30.0f, 30.0f);
    float finalDegree = Random.Range(0.5f, 2.0f) * nextDegree;
    nextDegree = startDegree + nextDegree;
    finalDegree = nextDegree - startDegree;

    float firstDistance = Random.Range(2, 5f);
    float secondDistance = Random.Range(2, 5f);

    Vector3 pos0 = new Vector3(lookat.transform.position.x + Mathf.Cos(startDegree) * firstDistance, lookat.transform.position.y, lookat.transform.position.z + Mathf.Sin(startDegree) * firstDistance);
    Vector3 pos1 = new Vector3(lookat.transform.position.x + Mathf.Cos(nextDegree) * secondDistance, lookat.transform.position.y, lookat.transform.position.z + Mathf.Sin(nextDegree) * secondDistance);
    Vector3 pos2 = new Vector3(lookat.transform.position.x + Mathf.Cos(finalDegree) * firstDistance, lookat.transform.position.y, lookat.transform.position.z + Mathf.Sin(finalDegree) * firstDistance);

    int oneTwo = (startFrame - endFrame) / 2;

    cameraSettings.Add(addCameraMove(startFrame, startFrame + oneTwo, pos0, pos1, lookat));
    cameraSettings.Add(addCameraMove(startFrame + oneTwo, endFrame, pos1, pos2, lookat));

}
clatterrr commented 3 months ago

Farest Point

    Vector3 FindFarthestVertex(Vector3 center, Vector3 size)
    {
        // 半边长
        size = size * 0.5f;

        // 计算立方体的8个顶点
        Vector3[] vertices = new Vector3[8];
        vertices[0] = center + new Vector3(-size.x, -size.y, -size.z);
        vertices[1] = center + new Vector3(size.x, -size.y, -size.z);
        vertices[2] = center + new Vector3(-size.x, size.y, -size.z);
        vertices[3] = center + new Vector3(size.x, size.y, -size.z);
        vertices[4] = center + new Vector3(-size.x, -size.y, size.z);
        vertices[5] = center + new Vector3(size.x, -size.y, size.z);
        vertices[6] = center + new Vector3(-size.x, size.y, size.z);
        vertices[7] = center + new Vector3(size.x, size.y, size.z);

        // 初始化最大距离和最远顶点
        float maxDistance = float.MinValue;
        Vector3 farthestVertex = Vector3.zero;

        // 遍历顶点,找到距离最大的那个
        foreach (var vertex in vertices)
        {
            float distance = vertex.magnitude; // 计算到原点的距离
            if (distance > maxDistance)
            {
                maxDistance = distance;
                farthestVertex = vertex;
            }
        }

        return farthestVertex;
    }
clatterrr commented 2 months ago
  1. when camera, support compute camera distance via to part bounds size
clatterrr commented 2 months ago

subtitles.Add(AddSub2(desc_env, replacer)); //从远处较远的地方,一直走到生物附近,有人 subtitles.Add(AddSub2(desc_nice, replacer)); // 附近放大看,无人生 subtitles.Add(AddSub2(desc_cute, replacer)); // 附近,自拍 subtitles.Add(AddSub2(desc_character, replacer)); // 附近看着,有人手 subtitles.Add(AddSub2(desc_attack, replacer)); // 附近,绕着走,自拍 subtitles.Add(AddSub2(desc_attack_time, replacer)); // 附近拍,无手 subtitles.Add(AddSub2(desc_grade, replacer)); // 附近自拍

clatterrr commented 2 months ago
void CameraFarToCloseMovement(int startFrame, int endFrame, GameObject lookat)
{
    float degree0 = Random.Range(0f, 3.14f);
    float degree1 = Random.Range(-1.0f, 1.0f);
    float degree2 = degree0 + degree1;
    degree1 = degree0 - degree1;

    float distance0 = Random.Range(10, 20f);
    float distance1 = Random.Range(5, 10f);
    float distance2 = Random.Range(3, 5f);

    Vector3 pos0 = new Vector3(Mathf.Cos(degree0) * distance0, 1, Mathf.Sin(degree0) * distance0);
    Vector3 pos1 = new Vector3(Mathf.Cos(degree1) * distance1, 1, Mathf.Sin(degree1) * distance1);
    Vector3 pos2 = new Vector3(Mathf.Cos(degree2) * distance2, 1, Mathf.Sin(degree2) * distance2);
    int oneTwo = (endFrame - startFrame) / 2;

    cameraSettings.Add(addCameraMove(startFrame, startFrame + oneTwo, pos0, pos1, lookat, headOffset));
    cameraSettings.Add(addCameraMove(startFrame + oneTwo, endFrame, pos1, pos2, lookat, headOffset));

}
clatterrr commented 2 months ago

public struct ActorSettings { public int frameStart; public int frameEnd; public GameObject actor; public MinecraftAnimation.Animation animation; public Vector3 posStart; public Vector3 posEnd; public Quaternion rotationStart; public Quaternion rotationEnd; public bool active; public ActorSettings(int frameStart, int frameEnd, GameObject actor, MinecraftFighter.Animation animation, Vector3 pos, Quaternion rotation) { this.frameStart = frameStart; this.frameEnd = frameEnd; this.actor = actor; this.animation = MinecraftAnimation.Animation.Wait; this.posStart = pos; this.posEnd = pos; this.rotationStart = rotation; this.rotationEnd = rotation; this.active = true; }

public ActorSettings(int frameStart, int frameEnd, GameObject actor, MinecraftAnimation.Animation animation,
    Vector3 posStart, Vector3 posEnd, Quaternion rotationStart, Quaternion rotationEnd)
{
    this.frameStart = frameStart;
    this.frameEnd = frameEnd;
    this.actor = actor;
    this.animation = animation;
    this.posStart = posStart;
    this.posEnd = posEnd;
    this.rotationStart = rotationStart;
    this.rotationEnd = rotationEnd;
    this.active = true;
}

public ActorSettings(int frameStart, int frameEnd, GameObject actor, bool active)
{
    this.frameStart = frameStart;
    this.frameEnd = frameEnd;
    this.actor = actor;
    this.animation = MinecraftAnimation.Wait;
    this.posStart = Vector3.zero;
    this.posEnd = Vector3.zero;
    this.rotationStart = Quaternion.identity;
    this.rotationEnd = Quaternion.identity;
    this.active = active;
}

public bool Run(int frameCount)
{
    if (frameCount >= this.frameStart && frameCount < this.frameEnd)
    {

        if (!this.active)
        {
            actor.gameObject.SetActive(false);
            return true;
        }
        else if(!actor.gameObject.active) {
        {
            actor.gameObject.SetActive(true);
        }
        actor.GetComponent<MinecraftAnimation>().SetAnimation(animation);
        float ratio = (frameCount - this.frameStart) * 1.0f / (this.frameEnd - this.frameStart);
        Vector3 pos = Vector3.Lerp(posStart, posEnd, ratio);
        Quaternion rot = Quaternion.Lerp(rotationStart, rotationEnd, ratio);
        actor.GetComponent<MinecraftAnimation>().SetTransform(pos, rot);

        return true;
    }
    return false;
}

}

clatterrr commented 2 months ago

using UnityEngine;

public class Edit : MonoBehaviour { public struct Uint2 { public uint x; public uint y;

    public Uint2(uint x, uint y)
    {
        this.x = x;
        this.y = y;
    }

    // 重写 ToString 方法,便于调试时输出
    public override string ToString()
    {
        return $"Uint2({x}, {y})";
    }

    // 重载 + 运算符
    public static Uint2 operator +(Uint2 a, Uint2 b)
    {
        return new Uint2(a.x + b.x, a.y + b.y);
    }

    // 可选: 重载 - 运算符
    public static Uint2 operator -(Uint2 a, Uint2 b)
    {
        return new Uint2(a.x - b.x, a.y - b.y);
    }

    // 可选: 重载 * 运算符
    public static Uint2 operator *(Uint2 a, uint scalar)
    {
        return new Uint2(a.x * scalar, a.y * scalar);
    }
}
public struct Uint3
{
    public uint x;
    public uint y;
    public uint z;

    public Uint3(uint x, uint y, uint z)
    {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    // 重写 ToString 方法,便于调试时输出
    public override string ToString()
    {
        return $"Uint3({x}, {y}, {z})";
    }
}

public struct Uint4
{
    public uint x;
    public uint y;
    public uint z;
    public uint w;

    public Uint4(uint x, uint y, uint z, uint w)
    {
        this.x = x;
        this.y = y;
        this.z = z;
        this.w = w;
    }

    // 重写 ToString 方法,便于调试时输出
    public override string ToString()
    {
        return $"Uint4({x}, {y}, {z}, {w})";
    }
}
public struct WholeFigure
{
    public UVSettings head;
    public UVSettings body;
    public UVSettings leftLeg;
    public UVSettings rightLeg;
    public UVSettings leftArm;
    public UVSettings rightArm;

    public WholeFigure(UVSettings head, UVSettings body, UVSettings leftLeg, UVSettings rightLeg, UVSettings leftArm, UVSettings rightArm)
    {
        this.head = head;
        this.body = body;
        this.leftLeg = leftLeg;
        this.rightLeg = rightLeg;
        this.leftArm = leftArm;
        this.rightArm = rightArm;
    }

}

Vector3 FindChildBounds(GameObject go, string target_name)
{
    // 如果当前 GameObject 名称匹配目标名称
    if (go.name == target_name)
    {
        Bounds combinedBounds = new Bounds();
        bool hasBounds = false;

        // 遍历所有直接子物体
        foreach (Transform child in go.transform)
        {
            Renderer renderer = child.GetComponent<Renderer>();
            if (renderer != null)
            {
                // 如果是第一个子物体,初始化 combinedBounds
                if (!hasBounds)
                {
                    combinedBounds = renderer.bounds;
                    hasBounds = true;
                }
                else
                {
                    // 扩展 combinedBounds 以包含当前子物体的 bounds
                    combinedBounds.Encapsulate(renderer.bounds);
                }
            }
        }

        // 返回所有子物体的 bounds.size
        if (hasBounds)
        {
            return combinedBounds.size;
        }
        return Vector3.zero;
    }

    // 如果名字不匹配,递归查找子物体
    foreach (Transform child in go.transform)
    {
        Vector3 boundsSize = FindChildBounds(child.gameObject, target_name);
        // 如果找到匹配的子物体,返回它的 bounds.size
        if (boundsSize != Vector3.zero)
        {
            return boundsSize;
        }
    }

    // 如果没有找到目标名称的物体,返回 Vector3.zero
    return Vector3.zero;
}

Vector2 FindChildUVStart(GameObject go, string target_name)
{
    // 如果当前 GameObject 名称匹配目标名称
    if (go.name == target_name)
    {
        Mesh mesh = go.GetComponent<MeshFilter>().sharedMesh;
        float uvxmin = float.MaxValue;
        float uvymin = float.MaxValue;
        for (int i = 0; i < mesh.uv.Length; i++)
        {
            if(uvxmin > mesh.uv[i].x)
            {
                uvxmin = mesh.uv[i].x;
            }
            if(uvymin > mesh.uv[i].y)
            {
                uvymin = mesh.uv[i].y;
            }
        }
        return new Vector2(uvxmin, uvymin);
    }

    // 如果名字不匹配,递归查找子物体
    foreach (Transform child in go.transform)
    {
        return FindChildUVStart(child.gameObject, target_name);
    }
    return Vector2.zero;
}
void ComputeFeatureAndResize(Texture texture0, Texture texture1, Uint2 start0, Uint2 start1, Uint2 size0, Uint2 size1)
{
    // find feature
    ComputeFeature(texture0, start0, size0);
    // get colors
    ResizeTexture(sourceTexture, targetTexture, sourceUVs, targetUvs);
}

public Texture2D sourceTexture;
Texture2D createResizedTexture(UVSettings sourceUVs, UVSettings targetUVs)
{
    Uint3 size = targetUVs.xyz;
    Texture2D newTexture = new Texture2D((int)(size.x * 2 + size.z * 2), (int)(size.y + size.z));

    // for each face
    ComputeFeatureAndResize(sourceTexture, newTexture, sourceUVs.front, targetUVs.front);
    ComputeFeatureAndResize(sourceTexture, newTexture, sourceUVs.back, targetUVs.back);
    ComputeFeatureAndResize(sourceTexture, newTexture, sourceUVs.left, targetUVs.left);
    ComputeFeatureAndResize(sourceTexture, newTexture, sourceUVs.right, targetUVs.right);
    ComputeFeatureAndResize(sourceTexture, newTexture, sourceUVs.up, targetUVs.up);
    ComputeFeatureAndResize(sourceTexture, newTexture, sourceUVs.down, targetUVs.down);

    return newTexture;
}

Uint2 CheckUv(int textureWidth, int textureHeight, GameObject go, string targetName)
{
    Vector2 uvs = FindChildUVStart(gameObject, "body");
    return new Uint2((uint)(uvs.x * textureWidth), (uint)(uvs.y * textureHeight));
}
void Editor()
{
    int textureWidth = 0;
    int textureHeight = 0;
    Uint2 body_uv_start = CheckUv(textureWidth, textureHeight, gameObject, "Body");
    Uint2 head_uv_start = CheckUv(textureWidth, textureHeight, gameObject, "Head");
    Uint2 rightLeg_uv_start = CheckUv(textureWidth, textureHeight, gameObject, "LeftArm");
    Uint2 leftLeg_uv_start = CheckUv(textureWidth, textureHeight, gameObject, "RightArm");
    Uint2 rightArm_uv_start = CheckUv(textureWidth, textureHeight, gameObject, "LeftLeg");
    Uint2 leftArm_uv_start = CheckUv(textureWidth, textureHeight, gameObject, "RightLeg");

    UVSettings bodyUV = new UVSettings(body_uv_start, FindChildBounds(gameObject, "Body"));
    UVSettings headUV = new UVSettings(head_uv_start, FindChildBounds(gameObject, "Head"));
    UVSettings leftArmUV = new UVSettings(leftArm_uv_start, FindChildBounds(gameObject, "LeftArm"));
    UVSettings rightArmUV = new UVSettings(rightArm_uv_start, FindChildBounds(gameObject, "RightArm"));
    UVSettings leftLegUV = new UVSettings(leftLeg_uv_start, FindChildBounds(gameObject, "LeftLeg"));
    UVSettings rightLegUV = new UVSettings(rightLeg_uv_start, FindChildBounds(gameObject, "RightLeg"));

    WholeFigure sourceFigure = new WholeFigure(bodyUV, headUV, leftArmUV, rightArmUV, leftLegUV, rightLegUV);

    WholeFigure targetFigure = new WholeFigure(bodyUV, headUV, leftArmUV, rightArmUV, leftLegUV, rightLegUV);

    Texture2D bodyTexture = createResizedTexture(sourceFigure.body, targetFigure.body);
    Material material;
   // material.mainTexture = bodyTexture;
    GameObject body;
   // body.GetComponent<MeshRenderer>().material = material;

    /*
           _____ __x__
          |     |     |
          |     z     |
          |     |     |
     _z___ __x__ ____ __x__
    |     |     |    |     |
    |     y     y    y     |
    |     |     |    |     |
     _____ _____ __z_ _____

     */
}

public struct UVSettings
{
    // x y global start z w height weight
    public Uint4 front;
    public Uint4 back;
    public Uint4 left;
    public Uint4 right;
    public Uint4 up;
    public Uint4 down;
    public Uint3 xyz;

    public UVSettings(Uint2 start, Vector3 xyz)
    {
        uint x = (uint)(xyz.x * 16.01);
        uint y = (uint)(xyz.y * 16.01);
        uint z = (uint)(xyz.z * 16.01);
        Uint2 frontStart = start + new Uint2(z, 0);
        Uint2 backStart = start + new Uint2(z + x + x, 0);
        Uint2 leftStart = start + new Uint2(0, 0);
        Uint2 rightStart = start + new Uint2(z + x, 0);
        Uint2 upStart = start + new Uint2(z, y);
        Uint2 downStart = start + new Uint2(z + x, y);
        front = new Uint4(frontStart.x, frontStart.y, x, y);
        back = new Uint4(backStart.x, backStart.y, x, y);
        left = new Uint4(leftStart.x, leftStart.y, z, y);
        right = new Uint4(rightStart.x, rightStart.y, z, y);
        up = new Uint4(upStart.x, upStart.y, x, z);
        down = new Uint4(downStart.x, downStart.y, x, z);
        this.xyz = new Uint3(x,y,z);
    }
}

Material ExpectMaterial(Texture sourceTexture, GameObject sourceModel, string bodyPartName, Uint3 size)
{
    Material material = new Material(Shader.Find("standard"));
    Texture2D texture = new Texture2D((int)(size.x * 2 + size.z * 2), (int)(size.y + size.z));
    texture.filterMode = FilterMode.Point;

    Vector2 sourceStartFloat = FindChildUVStart(gameObject, bodyPartName);
    Uint2 sourceStart = new Uint2((uint)(sourceStartFloat.x * sourceTexture.width), (uint)(sourceStartFloat.y * sourceTexture.height));
    Vector3 sourceSizeFloat = FindChildBounds(gameObject, bodyPartName);
    Uint3 sourceSize = new Uint3((uint)(sourceSizeFloat.x * 16.01), (uint)(sourceSizeFloat.y * 16.01), (uint)(sourceSizeFloat.z * 16.01));

    Uint2 start0;
    Uint2 start1;
    Uint2 size0;
    Uint2 size1;

    //front
    start0 = sourceStart + new Uint2(sourceSize.z, 0);
    start1 = new Uint2(size.z, 0);
    size0 = new Uint2(sourceSize.x, sourceSize.y);
    size1 = new Uint2(size.x, size.y);
    ComputeFeatureAndResize(sourceTexture, texture, start0, start1, size0, size1);

    //back
    start0 = sourceStart + new Uint2(sourceSize.z + sourceSize.x, 0);
    start1 = new Uint2(size.z, 0);
    size0 = new Uint2(sourceSize.x, sourceSize.y);
    size1 = new Uint2(size.x, size.y);
    ComputeFeatureAndResize(sourceTexture, texture, start0, start1, size0, size1);

    //left
    start0 = sourceStart;
    start1 = new Uint2(0, 0);
    size0 = new Uint2(sourceSize.z, sourceSize.y);
    size1 = new Uint2(size.z, size.y);
    ComputeFeatureAndResize(sourceTexture, texture, start0, start1, size0, size1);

    //back
    start0 = sourceStart + new Uint2(sourceSize.z + sourceSize.x, 0);
    start1 = new Uint2(size.z, 0);
    size0 = new Uint2(sourceSize.z, sourceSize.y);
    size1 = new Uint2(size.z, size.y);
    ComputeFeatureAndResize(sourceTexture, texture, start0, start1, size0, size1);

    //up
    start0 = sourceStart + new Uint2(sourceSize.z, sourceSize.y);
    start1 = new Uint2(size.z, size.y);
    size0 = new Uint2(sourceSize.x, sourceSize.z);
    size1 = new Uint2(size.x, size.z);
    ComputeFeatureAndResize(sourceTexture, texture, start0, start1, size0, size1);

    //down
    start0 = sourceStart + new Uint2(sourceSize.z, 0);
    start1 = new Uint2(size.z, 0);
    size0 = new Uint2(sourceSize.x, sourceSize.z);
    size1 = new Uint2(size.x, size.z);
    ComputeFeatureAndResize(sourceTexture, texture, start0, start1, size0, size1);

    material.mainTexture = texture;
    return material;
}

}

clatterrr commented 2 months ago

import openai import numpy as np import json

替换为你的 OpenAI API 密钥

openai.api_key = 'sk-zk2c32199828957c14f6dd4a13a37d6412366dfeebda836c' openai.api_base = 'https://api.zhizengzeng.com/v1'

resp = openai.Embedding.create( model="text-embedding-ada-002", input="i eat a orange")

将 JSON 字符串解析为 Python 对象

parsed_resp = json.loads(json.dumps(resp))

提取 embedding 字段的值

embedding_array0 = parsed_resp['data'][0]['embedding']

resp = openai.Embedding.create( model="text-embedding-ada-002", input="orange is good")

将 JSON 字符串解析为 Python 对象

parsed_resp = json.loads(json.dumps(resp))

提取 embedding 字段的值

embedding_array1 = parsed_resp['data'][0]['embedding']

resp = openai.Embedding.create( model="text-embedding-ada-002", input="i eat a apple")

将 JSON 字符串解析为 Python 对象

parsed_resp = json.loads(json.dumps(resp))

提取 embedding 字段的值

embedding_array2 = parsed_resp['data'][0]['embedding']

import numpy as np

def cosine_similarity(vec1, vec2):

计算两个向量的点积

dot_product = np.dot(vec1, vec2)
# 计算两个向量的欧几里得范数
norm_vec1 = np.linalg.norm(vec1)
norm_vec2 = np.linalg.norm(vec2)
# 计算余弦相似性
cosine_sim = dot_product / (norm_vec1 * norm_vec2)
return cosine_sim

a = cosine_similarity(embedding_array0, embedding_array1) b = cosine_similarity(embedding_array0, embedding_array2)

clatterrr commented 2 months ago

using UnityEngine; // random item collect (item, animal, plants) -> special kinds (scary, machinery) // step 1. generate name: "map" // step 2. generate desc: "with powerful muscles: yes", "hand segments: 3", "with ears: no" // step 3. generate skeletion prefab, mesh ,texture, material (no save) // step 4. generate model //

// pre build, compute all scale and segments and relative positions, per segment has it`s uv

// todo: ears, mouth, body desc sentences, // more fit show time camera and desc // head -> eye -> mouth -> ear -> hat, head -> ear -> eye -> mouth -> hat, head -> eye -> ear -> mouth -> hat // shoulder -> arm -> forearm -> toe // leg -> foreleg -> toe // head -> body - > left arm - > right arm -> left leg -> right leg -> tail

// build, monster school, show time is part of days 100

// build -> random bone length (only support simple voxel animation) // -> fix bone lenght (select from model, support all animation, build model from existing cubes) // -> read select bone, if meet cube, rescale 10 %,

// animations system, support simple stretch, voxel and full public class CubeScaler : MonoBehaviour {

struct ShapeDesc
{
    Uint3 minScaleRange;
    Uint3 maxScaleRange;
    ShapeName shapeName;
    int segmenst; // only for arms, legs and body, plus means enlarge, minus means desent
    string desc_str;

    public ShapeDesc(ShapeName shapeName, Vector3 minScaleRange, Vector3 maxScaleRange)
    {
        this.shapeName = shapeName;
        this.minScaleRange = minScaleRange;
        this.maxScaleRange = maxScaleRange;
        this.desc_str = generate_desc(shapeName);
    }

}

List<GameObject> generateM(ShapeDesc shapeDesc, Uint3 size)
{

}

void adjustPos(theParts, List<GameObject> myParts, ShapeName hisName, Framework hisWork, Framework myWork)
{

}

public static string generate_desc(ShapeName name)
{
    string[] shape_desc_str = new string[] { "ear_top", "ear_side" };
    string real_name = "ear";
    List<string> possible_name = new List<string>();
    for (int i = 0; i < shape_desc_str.Length; i++)
    {
        if (shape_desc_str[i].Contains(real_name))
        {
            possible_name.Add(shape_desc_str[i]);
        }
    }
    int r = Random.Range(0, possible_name.Count);
    string final_str = possible_name[r];
}

public GameObject cube;
void Start()
{

    TraverseAndScale(cube.transform);
}

void TraverseAndScale(Transform parent)
{
    foreach (Transform child in parent)
    {
        // Check if the object's name contains "cube"
        if (child.name.ToLower().Contains("cube"))
        {
            // Print the parent name
            Debug.Log("Parent name: " + child.parent.name);

            // Randomly scale the cube between 0.9 and 1.1 times
            float randomScale = Random.Range(0.9f, 1.1f);
            child.localScale *= randomScale;
            Debug.Log("Scaled " + child.name + " by " + randomScale);
        }

        // Recursively traverse the children
        if (child.childCount > 0)
        {
            TraverseAndScale(child);
        }
    }
}

}

clatterrr commented 2 months ago

Hedging Your Bets: Optimizing Accuracy-Specificity Trade-offs in Large Scale Visual Recognition YouTube2Text: Recognizing and Describing Arbitrary Activities Using Semantic Aligned Scene Modeling of a Robot’s Vista Space – An Evaluation Video In Sentences Out Describing Videos by Exploiting Temporal Structure Grounding Action Descriptions in Videos A large scale dataset for 3d human activity analysis WHEN AND WHY VISION-LANGUAGE MODELS TMR: Text-to-Motion Retrieval Using Contrastive 3D Human Motion Synthesis Articulated Part-based Model for Joint Object Detection and Pose Estimation 似乎有啥不得了的东西 A survey on procedural modelling for virtual worlds

List<int> GetCircle(int start, int radius)
{
    List<int> result = new List<int>();
    for (int circlex = start; circlex < radius; circlex++) {
        int pDis = 0;
        for (int circlez = 0; circlez < radius; circlez++)
        {
            float dis = (float)((circlex + 0.5) * (circlex + 0.5) + (circlez + 0.5) * (circlez + 0.5));
            if (dis < radius * radius) { pDis = circlez; }
        }
        int startX = circlex;
        while (true)
        {
            float dis = (float)((circlex + 1.5) * (circlex + 1.5) + (pDis + 0.5) * (pDis + 0.5));
            if (dis < radius * radius) { circlex += 1; };
            else {
                Vector3 basePos = new Vector3((circlex + 1 + startX) * 0.05f, 0f, 0f);
                Vector3 baseSize = new Vector3((circlex + 1 - startX) * 0.1f, 0.1f, 0.1f);
                break;
            }
        }
        result.AddRange(new int[3] { startX, circlex - startX, pDis });
    }
    return result;
}
clatterrr commented 2 months ago

using System.Collections; using System.Collections.Generic; public class Class1 { enum ShuffleRuleOrder {

    MustPreOne,
    MustPostOne,
    Pre,
    Post,
}
struct ShuffleRule
{
    int index0;
    int index1;
    ShuffleRuleOrder order;

    bool Compare(List<int> tempList)
    {
        ShuffleRule rule = rules[k];
        int index0Pos = -1;
        int index1Pos = -1;
        for (int w = 0; w < tempList.Count; w++)
        {
            if (tempList[w] == rule.index0) index0Pos = w;
            if (tempList[w] == rule.index1) index1Pos = w;
        }
        if (index0Pos == -1 || index1Pos == -1) return true;
        switch (rule.order)
        {
            case ShuffleRuleOrder.Pre: return index0Pos < index1Pos;
            case ShuffleRuleOrder.Post: return index0Pos > index1Pos;
            case ShuffleRuleOrder.MustPreOne: return index0Pos == index1Pos - 1;
            case ShuffleRuleOrder.MustPostOne: return index0Pos == index1Pos + 1;
        }
    }
}

List<int> Shuffle(List<int> list, List<ShuffleRule> rules)
{
    for (int i = 0; i < list.Count; i++)
    {
        // while(true)
        for (int j = 0; j < list.Count; j++)
        {
            int rindex = Random.Range(0, list.Count);
            List<int> tempList = list;
            int temp = i;
            tempList[rindex] = i;
            tempList[i] = rindex;

            bool MatchRules = true;

            for(int k =0 ; k < rules.Count; k++)
            {
                if (!rules[k].Compare(tempList))
                {
                    MatchRules = false;
                    break;
                }
            }
            if (MatchRules)
            {
                list = tempList;
                break;
            }
        }
    }

void StartShuffle()
{
    List<GameObject> upperPart = new List<GameObject>();
    List<GameObject> downPart = new List<GameObject>();

    List<ShuffleRule> shuffleRules = new List<ShuffleRule>();

}
    // TODO DEBUG SPHERE LENGHT
    // TODO REVERSE GET FRAME WORK
    // TODO GENERATE MESH
    // TODO MORE SHOW PLANTS
    // TODO MORE CURVE FOR STEM
    // TODO MORE WIDTH FOR ROOT LEAVES
    // TODO IDLE ANIAMTION FOR PLANTS

enum CameraFocus
{
    None,
    Hero,
    Enemy,
}
enum CameraFollow
{
    None,
    Hero,
    Enemy,
}

}

clatterrr commented 2 months ago

using System.Collections; using System.Collections.Generic; using UnityEngine;

public class RotateCube : MonoBehaviour { public Transform cube; // 立方体的Transform

List<int> GetCirlceFull(int baseX, int radius)
{
    List<int> result = new List<int>();
    for (int px = baseX; px <= radius; px++)
    {
        int pz = Mathf.FloorToInt(Mathf.Sqrt(radius * radius - px * px));
        result.Add(pz);
    }
    return result;

}

struct XZvalues
{
    public float x;
    public float z;
    public XZvalues(float x, float z)
    {
        this.x = x;
        this.z = z;
    }

}
void Start()
{
    List<XZvalues> list = new List<XZvalues>();
    list.Add(new XZvalues(2.5f, 1.0f));
    int[] angles = new int[14] { 36, 30, 24, 20, 18, 16, 15, 12, 10, 9, 8, 6, 5, 4 };
    for (int xzi = 0; xzi < list.Count; xzi++)
    {
        float zPos = list[xzi].z;
        float xHalfLength = list[xzi].x;

        float minDelta = float.MaxValue;
        int minDeltaIndex = -1;
        for (int i = 0; i < angles.Length; i++)
        {
            float rads = Mathf.Deg2Rad * (360.0f / angles[i]) * 0.5f;
            float rx = Mathf.Tan(rads) * (zPos + 0.5f);
            Debug.Log("rx = " + rx);
            if (minDelta > Mathf.Abs(rx - xHalfLength))
            {
                minDelta = Mathf.Abs(rx - xHalfLength);
                minDeltaIndex = i;
                if (rx > 1.0f) break;
            }
        }

        for (int i = 0; i < angles[minDeltaIndex]; i++)
        {
            GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
            cube.transform.position = new Vector3(0, 0, zPos);
            cube.transform.localScale = new Vector3(2, 4, 1);
            float angle = 360.0f / (angles[minDeltaIndex]) * i;
            Quaternion rotation = Quaternion.Euler(0, angle, 0); // 创建绕Y轴的旋转

            Vector3 direction = cube.transform.position - Vector3.zero; // 从原点指向立方体的方向
            Vector3 rotatedPosition = rotation * direction; // 应用旋转

            // 更新立方体的位置
            cube.transform.position = rotatedPosition;
            cube.transform.rotation = rotation;
        }
    }

}

}

clatterrr commented 2 weeks ago

import cv2 import numpy as np

读取图片

image_path = 'input_image.jpg' # 请将此路径替换为你的图片路径 image = cv2.imread(image_path) output_image = image.copy()

存储点击的点坐标

points = []

点击事件回调函数

def draw_circle(event, x, y, flags, param): global points

if event == cv2.EVENT_LBUTTONDOWN:
    # 记录点击的坐标
    points.append((x, y))

    # 画一个20x20的红色圆形
    cv2.circle(output_image, (x, y), 10, (0, 0, 255), -1)

    # 如果有两个或以上的点,使用绿色线条连接它们
    if len(points) > 1:
        cv2.line(output_image, points[-2], points[-1], (0, 255, 0), 5)

    # 显示更新后的图片
    cv2.imshow('Image', output_image)

创建窗口并绑定鼠标点击事件

cv2.namedWindow('Image') cv2.setMouseCallback('Image', draw_circle)

显示图片

while True: cv2.imshow('Image', output_image) if cv2.waitKey(1) & 0xFF == 27: # 按下 ESC 键退出 break

保存新图片

output_path = 'output_image.jpg' cv2.imwrite(output_path, output_image) print(f'图片已保存为: {output_path}')

cv2.destroyAllWindows()

clatterrr commented 2 weeks ago

o2.txt

clatterrr commented 2 weeks ago

h3.txt

clatterrr commented 2 weeks ago
    enum KShape
    {
        RiseFall,
        FallRise,
        RiseTestFall,
        FallTestRise
    }

    KShape Test()
    {

        List<Vector2> pos = new List<Vector2>();

        if (pos.Count == 3)
        {
            if (isEqual(pos[0].y, pos[2].y) && isHigh(pos[1].y, pos[0].y) && isHigh(pos[1].y, pos[2].y)) return KShape.RiseFall
            else if (isEqual(pos[0].y, pos[2].y) && isLow(pos[1].y, pos[0].y) && isLow(pos[1].y, pos[2].y)) return KShape.FallRise;
        }else if (pos.Count == 4)
        {
            if (isEqual(pos[0].y, pos[3].y) && isEqual(pos[1].y, pos[2].y) && isHigh(pos[1].y, pos[0].y), && isHigh(pos[2].y, pos[3].y)) return KShape.RiseTestFall
            else if (isEqual(pos[0].y, pos[3].y) && isEqual(pos[1].y, pos[2].y) && isLow(pos[1].y, pos[0].y), && isLow(pos[2].y, pos[3].y)) return KShape.FallTestRise
        }

        return currentNormal;
    }

    bool isEqual(float a, float b)
    {
        return Mathf.Abs(a - b) < 1;
    }

    bool isHigh(float a, float b)
    {
        return a - b > 1;
    }

    bool isLow(float a, float b)
    {
        return a - b < -1;
    }
clatterrr commented 18 hours ago
    // 1. Channel Intro
    // Find Section in Paddy Galloway, AI Guy,
    // Add Section (Every Day Task)
    // Q & G: How to split Big Section to Small Section (Createive)

    // 2. Model Create
    // Q: Better Modeling (Creative)
    // Body Part Library (Every Day Task)

    // 3. Story
    // Q: Standard Story

    // 4. Eco